Commit 7813f941 authored by Thomas Fradet's avatar Thomas Fradet
Browse files

add template graphic and history

parent 72a4bd43
...@@ -20,6 +20,7 @@ $PAGE->requires->js("/blocks/competency_iena/js/datalist-polyfill.min.js"); ...@@ -20,6 +20,7 @@ $PAGE->requires->js("/blocks/competency_iena/js/datalist-polyfill.min.js");
$PAGE->requires->js("/blocks/competency_iena/js/stud-x-cpts.js"); $PAGE->requires->js("/blocks/competency_iena/js/stud-x-cpts.js");
$PAGE->requires->js("/blocks/competency_iena/js/cpt-x-studs.js"); $PAGE->requires->js("/blocks/competency_iena/js/cpt-x-studs.js");
/* <<< GESTION DROITS D'ACCÈS >>> */ /* <<< GESTION DROITS D'ACCÈS >>> */
$context = context_course::instance($courseid); $context = context_course::instance($courseid);
...@@ -42,15 +43,20 @@ if ( $is_teacher === false && $studentid != $USER->id ) { ...@@ -42,15 +43,20 @@ if ( $is_teacher === false && $studentid != $USER->id ) {
echo $OUTPUT->header(); echo $OUTPUT->header();
/* REVIEW DATA */
/* <<< REVIEW DATA >>> */
$sql_rev = "SELECT * FROM {competency_usercomp} $sql_rev = "SELECT * FROM {competency_usercomp}
WHERE userid = ? AND competencyid = ? AND status = ?"; WHERE userid = ? AND competencyid = ? AND status = ?";
$reviews_data = $DB->get_records_sql($sql_rev, [$studentid, $competencyid, 1]); $reviews_data = $DB->get_records_sql($sql_rev, [$studentid, $competencyid, 1]);
$review_asked = count($reviews_data) > 0 ? true : false; $review_asked = count($reviews_data) > 0 ? true : false;
/* <<< POST >>> */
/* POST EVALUATION */ /* POST EVALUATION */
if ( isset($_POST['competencyid']) ) { if ( isset($_POST['grade']) ) {
$note = "Évaluation donnée pour le cours {$COURSE->fullname} par {$USER->firstname} {$USER->lastname}. " . $_POST['note']; $note = "Évaluation donnée pour le cours {$COURSE->fullname} par {$USER->firstname} {$USER->lastname}. " . $_POST['note'];
\core_competency\api::grade_competency_in_course($courseid, $studentid, $competencyid, $_POST['grade'], $note); \core_competency\api::grade_competency_in_course($courseid, $studentid, $competencyid, $_POST['grade'], $note);
if ( $review_asked ) { if ( $review_asked ) {
...@@ -76,7 +82,8 @@ if ( isset($_POST['review']) ) { ...@@ -76,7 +82,8 @@ if ( isset($_POST['review']) ) {
} }
/* HELPERS */ /* <<< HELPERS >>> */
function _html($el, $str, $class = "") { function _html($el, $str, $class = "") {
$class = " class='" . $class . "'"; $class = " class='" . $class . "'";
echo "<" . $el . $class . ">" . $str . "</" . $el . ">"; echo "<" . $el . $class . ">" . $str . "</" . $el . ">";
...@@ -86,12 +93,14 @@ function _modal_builder($id, $title, $body) { ...@@ -86,12 +93,14 @@ function _modal_builder($id, $title, $body) {
return "<div class='modal fade' id='{$id}' tabindex='-1' role='dialog' aria-labelledby='exampleModalScrollableTitle' aria-hidden='true'><div class='modal-dialog modal-dialog-scrollable' role='document'><div class='modal-content'><div class='modal-header'><h5 class='modal-title' id='exampleModalScrollableTitle'>{$title}</h5><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div><div class='modal-body'>{$body}</div></div></div></div>"; return "<div class='modal fade' id='{$id}' tabindex='-1' role='dialog' aria-labelledby='exampleModalScrollableTitle' aria-hidden='true'><div class='modal-dialog modal-dialog-scrollable' role='document'><div class='modal-content'><div class='modal-header'><h5 class='modal-title' id='exampleModalScrollableTitle'>{$title}</h5><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div><div class='modal-body'>{$body}</div></div></div></div>";
} }
/* <<< GESTION ERREUR ACCÈS >>> */ /* <<< GESTION ERREUR ACCÈS >>> */
if ( $is_enrolled === false ) { if ( $is_enrolled === false ) {
_html("p", "L'étudiant demandé n'est pas inscrit dans ce cours.", "alert alert-warning"); _html("p", "L'étudiant demandé n'est pas inscrit dans ce cours.", "alert alert-warning");
} }
/* <<< DATA >>> */ /* <<< DATA >>> */
/* Student USER object */ /* Student USER object */
...@@ -116,84 +125,47 @@ if ( $u_c_cpt->get('grade') != null ) { ...@@ -116,84 +125,47 @@ if ( $u_c_cpt->get('grade') != null ) {
$eval = $cpt_scale[$u_c_cpt->get('grade') - 1]; $eval = $cpt_scale[$u_c_cpt->get('grade') - 1];
} }
$proficiency = $u_c_cpt->get('proficiency') == 1 ? "Oui" : "Non"; $proficiency = $u_c_cpt->get('proficiency') == 1 ? "Oui" : "Non";
$proficiency_class = $u_c_cpt->get('proficiency') == 1 ? "success" : "secondary";
/* All course competencies */ /* All course competencies */
$course_cpts = \core_competency\course_competency::list_competencies($COURSE->id); $course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
/* <<< PAGE >>> */
/*user_competency_request_review($userid, $competencyid)*/
echo "<pre>"; /* <<< PAGE >>> */
// var_dump($u_c_cpt->get('proficiency'));
// var_dump($course_cpts);
// var_dump($students);
// var_dump($reviews_data);
// var_dump($review_asked);
// var_dump($proficiency);
// var_dump($u_c_cpt->get('grade'));
// var_dump($eval);
// var_dump($cpt_scale);
// // var_dump($cpt);
// var_dump($cpt->get('competencyframeworkid'));
// var_dump($cpt->get('parentid'));
echo "</pre>"; // echo "<pre>";
// var_dump($_POST);
// echo "</pre>";
/* STUDENT NAME */ /* STUDENT NAME */
_html("h2", $student->firstname . " " . $student->lastname);
_html("h2", $student->firstname . " " . $student->lastname, "h3' style='margin-bottom: 0.3rem;'");
/* SWITCH STUDENT FORM */ /* SWITCH STUDENT FORM */
if ( $is_teacher && $students != NULL && count($students) != 0 ) { if ( $is_teacher && $students != NULL && count($students) != 0 ) {
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php' id='change_stud_form' class='form-inline'>"; echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php' id='change_stud_form' class='form-inline m-b-1'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>"; echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
echo "<input type='text' hidden name='competencyid' value='{$competencyid}'>"; echo "<input type='text' hidden name='competencyid' value='{$competencyid}'>";
echo "<span hidden id='studentid'>{$studentid}</span>"; echo "<span hidden id='studentid'>{$studentid}</span>";
echo "<label class='m-y-1 m-r-1' for='studentid_sel' style='color: black;'>Etudiant</label>"; /*echo "<label class='m-y-1 m-r-1' for='studentid_sel' style='color: black;'>Etudiant</label>";*/
echo "<input type='text' name='studentid' id='studentid_sel' value='' list='student_list' class='form-control m-r-1'>"; echo "<input type='text' name='studentid' id='studentid_sel' value='' list='student_list' class='form-control' style='font-size: .7rem; line-height: 1;'>";
echo "<datalist id='student_list' title='Select student'>"; echo "<datalist id='student_list' title='Select student'>";
foreach ($students as $stud) { foreach ($students as $stud) {
echo "<option value='{$stud->firstname} {$stud->lastname} ({$stud->id})' data-value='{$stud->id}'>{$stud->firstname} {$stud->lastname} ({$stud->id})</option>"; echo "<option value='{$stud->firstname} {$stud->lastname} ({$stud->id})' data-value='{$stud->id}'>{$stud->firstname} {$stud->lastname} ({$stud->id})</option>";
} }
echo "</datalist>"; echo "</datalist>";
echo "<div><button class='btn btn-secondary' id='prevStud'>Précédent</button>"; echo "<div><button class='btn btn-secondary' id='prevStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Précédent</button>";
echo "<button class='btn btn-secondary m-l-1' id='nextStud'>Suivant</button></div>"; echo "<button class='btn btn-secondary' id='nextStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Suivant</button></div>";
echo "</form>"; echo "</form>";
} }
/* SWITCH COMPETENCY FORM */ /* INFO ABOUT COMPETENCIES, FRAMEWORK AND CURRENT GRADE */
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php' id='change_cpt_form' class='form-inline'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
echo "<input type='text' hidden name='studentid' value='{$studentid}'>";
echo "<span hidden id='competencyid'>{$competencyid}</span>";
echo "<label class='m-r-1' for='competencyid_sel' style=''>Changer de compétence</label>";
echo "<input type='text' name='competencyid' id='competencyid_sel' value='' list='competency_list' class='form-control'>";
echo "<datalist id='competency_list' title='Select competency'>";
foreach ($course_cpts as $course_cpt) {
echo "<option value='{$course_cpt->get('shortname')} ({$course_cpt->get('id')})' data-value='{$course_cpt->get('id')}'>{$course_cpt->get('shortname')} ({$course_cpt->get('id')})</option>";
}
echo "</datalist>";
echo "<button class='btn btn-secondary m-l-1' id='prevCpt'>Précédent</button>";
echo "<button class='btn btn-secondary m-l-1' id='nextCpt'>Suivant</button>";
echo "</form>";
/* LINKED MODULES */ _html('h2', $cpt->get('shortname'), "h3' style='margin-bottom: 0.3rem;'");
if ( count($cm_ids) !== 0 ) {
$modinfo = get_fast_modinfo($courseid);
_html("h3", "Lié à cette compétence");
echo "<div class='list-group'>";
foreach ($cm_ids as $cm_id) {
echo "<a href='{$modinfo->cms[$cm_id]->url->out()}' target='_blank' class='list-group-item list-group-item-action'><img src='$CFG->wwwroot/theme/image.php/boost/{$modinfo->cms[$cm_id]->modname}/1/icon>' style='height: 1.3rem;'><span class='align-middle'> {$modinfo->cms[$cm_id]->name}</span></a>";
}
echo "</div>";
} else {
_html("p", "Aucune ressource ou activité n'est liée à cette compétence dans ce cours. ", "alert alert-secondary");
}
/* INFO ABOUT COMPETENCIES, FRAMEWORK AND CURRENT GRADE */ /* COMPETENCY TREE PATH */
echo "<div class='alert alert-secondary'>"; /* for competency info and grade info */
_html('h2', $cpt->get('shortname'));
/* Competency tree parents path from current to framework */ /* Competency tree parents path from current to framework */
$cptid = $competencyid; $cptid = $competencyid;
$parent_cpts = array(); $parent_cpts = array();
...@@ -210,16 +182,52 @@ foreach ($parent_cpts as $parent_cpt) { ...@@ -210,16 +182,52 @@ foreach ($parent_cpts as $parent_cpt) {
} }
echo "<div style='margin-bottom: 0.7rem;'>" . $cpt_path_link . "</div>"; echo "<div style='margin-bottom: 0.7rem;'>" . $cpt_path_link . "</div>";
/* Current grade */ /* SWITCH COMPETENCY FORM */
_html('p', "Validé : {$proficiency}<br>Évaluation : {$eval}");
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php' id='change_cpt_form' class='form-inline m-b-1'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
echo "<input type='text' hidden name='studentid' value='{$studentid}'>";
echo "<span hidden id='competencyid'>{$competencyid}</span>";
/*echo "<label class='m-r-1' for='competencyid_sel' style=''>Changer de compétence</label>";*/
echo "<input type='text' name='competencyid' id='competencyid_sel' value='' list='competency_list' class='form-control' style='font-size: .7rem; line-height: 1;'>";
echo "<datalist id='competency_list' title='Select competency'>";
foreach ($course_cpts as $course_cpt) {
echo "<option value='{$course_cpt->get('shortname')} ({$course_cpt->get('id')})' data-value='{$course_cpt->get('id')}'>{$course_cpt->get('shortname')} ({$course_cpt->get('id')})</option>";
}
echo "</datalist>";
echo "<button class='btn btn-secondary' id='prevCpt' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Précédent</button>";
echo "<button class='btn btn-secondary' id='nextCpt' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Suivant</button>";
echo "</form>";
/* END switch competency form */
/* EVALUATION INFOS AND ACTIONS */
/* Review */ echo "<div class='row'>";
/* Proficiency info */
echo "<div class='col-12 col-lg-3'>";
echo "<div class='alert alert-{$proficiency_class}'>";
echo "<h3 class='h4'>Validé</h3>";
echo "<p class='m-b-0 btn p-l-0'>{$proficiency}</p>";
echo "</div>";
echo "</div>";
/* Grade info */
echo "<div class='col-12 col-lg-3'>";
echo "<div class='alert alert-{$proficiency_class}'>";
echo "<h3 class='h4'>Évaluation</h3>";
echo "<p class='m-b-0 btn p-l-0'>{$eval}</p>";
echo "</div>";
echo "</div>";
/* Review and grade ASK and ACTION */
$review_class = $review_asked ? "info" : "secondary";
$review_msg = $review_asked ? "Évaluation demandée" : "Aucune évaluation demandée";
echo "<div class='col-12 col-lg-6'>";
echo "<div class='alert alert-{$review_class}'>";
echo "<h3 class='h4'>{$review_msg}</h3>";
if ( $review_asked ) { if ( $review_asked ) {
echo "<div class='alert alert-primary'>Évaluation demandée</div>"; /* Request review and cancel buttons */
/* Student can cancer his own request review */
if ( $USER->id == $studentid ) { if ( $USER->id == $studentid ) {
/* Student cancel review */ /* Student cancel his own review */
echo "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}'>"; echo "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}' style='display: inline; margin-right: 1rem;'>";
echo "<input hidden style='display: none;' type='text' name='review' value='cancel'>"; echo "<input hidden style='display: none;' type='text' name='review' value='cancel'>";
echo "<button type='submit' class='btn btn-secondary'>Annuler la demande</button>"; echo "<button type='submit' class='btn btn-secondary'>Annuler la demande</button>";
echo "</form>"; echo "</form>";
...@@ -227,55 +235,119 @@ if ( $review_asked ) { ...@@ -227,55 +235,119 @@ if ( $review_asked ) {
} else { } else {
if ( $USER->id == $studentid ) { if ( $USER->id == $studentid ) {
/* Student ask review */ /* Student ask review */
echo "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}'>"; echo "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}' style='display: inline; margin-right: 1rem;'>";
echo "<input hidden style='display: none;' type='text' name='review' value='request'>"; echo "<input hidden style='display: none;' type='text' name='review' value='request'>";
echo "<button type='submit' class='btn btn-primary'>Demande d'évaluation</button>"; echo "<button type='submit' class='btn btn-primary'>Demande d'évaluation</button>";
echo "</form>"; echo "</form>";
} }
} }
echo "</div>"; /* for competency info and grade info */ if ( $is_teacher ) {
/* Evaluation button and modal */
/* EVALUATION ACTION */ echo "<a href='#' data-toggle='modal' data-target='#modaleval' class='btn btn-primary'>Évaluer</a>";
$eval_modale_echo = "";
/* TODO : check if user is teacher */ $eval_modale_echo .= "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}'><div class='form-group'><div class='form-group'><label>Évaluation</label><select name='grade' class='form-control'>";
echo "<div class='alert alert-secondary'>"; foreach ($cpt_scale as $key => $item) {
echo "<form method='post' action='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$competencyid}'>"; $grade = $key + 1;
echo "<div class='form-group'>"; $selected = "";
echo "<label>Évaluation</label>"; if ( $item == $eval ) {
echo "<select name='grade' class='form-control'>"; $selected = " selected";
foreach ($cpt_scale as $key => $item) { }
$grade = $key + 1; $eval_modale_echo .= "<option value='{$grade}'{$selected}>{$item}</option>";
$selected = "";
if ( $item == $eval ) {
$selected = " selected";
} }
echo "<option value='{$grade}'{$selected}>{$item}</option>"; $eval_modale_echo .= "</select></div><div class='form-group'><textarea name='note' class='form-control' placeholder=\"Commentaire d'évaluation\"></textarea></div><button type='submit' class='btn btn-primary'>Évaluer</button></form></div>";
echo _modal_builder("modaleval", "Évaluation", $eval_modale_echo);
} }
echo "</select>"; echo "</div>"; /* END review and grade ASK and ACTION - col */
echo "</div>"; echo "</div>"; /* END review and grade ASK and ACTION - alert */
echo "<div class='form-group'>"; echo "</div>"; /* END evaluation info and actions row */
echo "<label>Commentaire d'évaluation</label>";
echo "<textarea name='note' class='form-control' placeholder=\"Commentaire d'évaluation\"></textarea>";
echo "</div>";
echo "<button type='submit' class='btn btn-primary'>Évaluer</button>";
echo "</form>";
echo "</div>";
/* GRADES HISTORY CHART */
// quelle différence
// read_user_evidence($id)
// read_evidence($evidenceid)
// delete_user_evidence($id)
echo "<pre>"; // pour toutes les cpt
// var_dump($cpt->get_framework()->get('shortname')); // list_user_evidence($userid)
// var_dump($cpt->get_framework()->get('description'));
echo "</pre>";
// lié à la compétence
// list_evidence($userid = 0, $competencyid = 0, $planid = 0, $sort = 'timecreated',
// $order = 'DESC', $skip = 0, $limit = 0)
// list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated',
// $order = 'DESC', $skip = 0, $limit = 0)
echo $OUTPUT->footer();
// OKOK
// $course_evidencies = \core_competency\api::list_evidence_in_course($studentid, $courseid, $competencyid, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0);
// foreach ($course_evidencies as $evidence) {
// echo "<ul>";
// echo "<li>{$evidence->get('id')}</li>";
// echo "<li>Action : {$evidence->get('action')} (0 : log, 2 ou 3 : rating)</li>";
// $grade = $evidence->get('grade');
// if ( $grade != NULL ) { /* liéer à descidentifier == evidence_manualoverrideincourse ??? */
// $grade_label = $cpt_scale[$grade - 1];
// echo "<li>{$grade_label}</li>";
// }
// // evidence_manualoverride
// // evidence_manualoverrideinplan
// // evidence_manualoverrideincourse
// $evidence_type = $evidence->get('descidentifier');
// if ( $evidence_type == 'evidence_manualoverrideincourse' ) {
// $emitter = user_get_users_by_id([$evidence->get('actionuserid')])[$evidence->get('actionuserid')];
// echo "<li>{$emitter->firstname} {$emitter->lastname}</li>";
// } elseif ( $evidence_type == 'evidence_coursemodulecompleted' ) {
// echo "<li>{$evidence->get('desca')}</li>";
// }
// var_dump($evidence->get_description()->out());
// echo "</ul>";
// }
// echo "<pre>";
// var_dump($course_evidencies);
// echo "</pre>";
// $student = user_get_users_by_id($studentid) // OK OK END
echo "<div class='alert alert-secondary'>";
$labels = ["Un", "Deux", "Trois"];
$series_data = [1, 2, 3];
$chart = new core\chart_bar();
$series = new core\chart_series('', $series_data);
$chart->add_series($series);
$chart->set_labels($labels);
echo $OUTPUT->render($chart);
echo "</div>";
/* LINKED MODULES */
if ( count($cm_ids) !== 0 ) {
$modinfo = get_fast_modinfo($courseid);
_html("h3", "Lié à cette compétence");
echo "<div class='list-group'>";
foreach ($cm_ids as $cm_id) {
echo "<a href='{$modinfo->cms[$cm_id]->url->out()}' target='_blank' class='list-group-item list-group-item-action'><img src='$CFG->wwwroot/theme/image.php/boost/{$modinfo->cms[$cm_id]->modname}/1/icon>' style='height: 1.3rem;'><span class='align-middle'> {$modinfo->cms[$cm_id]->name}</span></a>";
}
echo "</div>";
} else {
_html("p", "Aucune ressource ou activité n'est liée à cette compétence dans ce cours. ", "alert alert-secondary");
}
echo $OUTPUT->footer();
?> ?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment