Commit 6da2f746 authored by Thomas Fradet's avatar Thomas Fradet

text history

parent 60736b19
......@@ -57,7 +57,7 @@ $review_asked = count($reviews_data) > 0 ? true : false;
/* POST EVALUATION */
if ( isset($_POST['grade']) ) {
$note = "Évaluation donnée pour le cours {$COURSE->fullname} par {$USER->firstname} {$USER->lastname}. " . $_POST['note'];
$note = $_POST['note'];
\core_competency\api::grade_competency_in_course($courseid, $studentid, $competencyid, $_POST['grade'], $note);
if ( $review_asked ) {
\core_competency\api::user_competency_start_review($studentid, $competencyid);
......@@ -261,7 +261,7 @@ echo "</div>"; /* END review and grade ASK and ACTION - col */
echo "</div>"; /* END review and grade ASK and ACTION - alert */
echo "</div>"; /* END evaluation info and actions row */
/* GRADES HISTORY CHART */
/* GRADES AND EVIDENCES HISTORY CHART AND LIST */
// quelle différence
// read_user_evidence($id)
......@@ -283,30 +283,176 @@ echo "</div>"; /* END evaluation info and actions row */
// OKOK
/* Utilisation des renderer du /admin/tool/lp/class/output pour obtenir toutes les données d'historique construites et organisées */
/* Dabord dans le cours, puis dans l'absolu pour les différencier / filtrer */
$tool_lp_renderer = $PAGE->get_renderer('tool_lp');
$user_cpt_course_data = new \tool_lp\output\user_competency_summary_in_course($studentid, $competencyid, $courseid);
$user_cpt_course_data = $user_cpt_course_data->export_for_template($tool_lp_renderer);
$course_evidences = $user_cpt_course_data->usercompetencysummary->evidence;
$course_evidences_ids = array();
foreach ($course_evidences as $course_evidence) {
$course_evidences_ids[] = $course_evidence->id;
}
$user_competency = \core_competency\api::get_user_competency($studentid, $competencyid);
$user_cpt_all_data = new \tool_lp\output\user_competency_summary($user_competency);
$user_cpt_all_data = $user_cpt_all_data->export_for_template($tool_lp_renderer);
$all_evidences = $user_cpt_all_data->evidence;
echo "<div class='row'>";
echo "<div class='col-12 col-lg-6'>";
echo "<h2 class='h3'>Historique</h2><ul class='nav nav-tabs' id='hist-tabs'>
<li class='nav-item'>
<a class='nav-link active' href='#' id='all_history_tab'>Complet</a>
</li>
<li class='nav-item'>
<a class='nav-link' href='#' id='course_history_tab'>Dans ce cours</a>
</li>
<li class='nav-item'>
<a class='nav-link' href='#' id='other_history_tab'>Hors de ce cours</a>
</li>
</ul>";
echo "<ul class='list-group' style='height: 50vh; min-height: 300px; overflow: scroll;'>";
/* proficient or not depending of rating in scale (set in framework by creator) */
foreach ($all_evidences as $key => $ev) {
/* mark difference between this course evidences in html for JS filter with tabs */
if ( in_array($ev->id, $course_evidences_ids) ) {
$is_course_evidence = " data-evidenceorigin='course'";
} else {
$is_course_evidence = " data-evidenceorigin='other'";
}
if ( $ev->action === "0" ) {
$grade_make_proficient = ' list-group-item-light';
} else {
$scale_rules = json_decode($user_cpt_all_data->competency->scaleconfiguration);
foreach ($scale_rules as $scale_rule) {
if ( isset($scale_rule->proficient) && $scale_rule->id == $ev->grade && $scale_rule->proficient == 1 ) {
$grade_make_proficient = ' list-group-item-success';
} else {
$grade_make_proficient = '';
}
}
}
$date = date("d/m/y – H:i", $ev->timemodified);
echo "<li class='list-group-item{$grade_make_proficient}'{$is_course_evidence}>
<div class='d-flex w-100 justify-content-between'>";
if ( isset($ev->gradename) ) {
echo "<h5 class='mb-1' style='font-weight: 600;'>$ev->gradename</h5>";
}
echo "<small>{$date}</small>
</div>
<p class='mb-1 font-weight-light'><em>{$ev->description}</em></p>";
if ( isset($ev->note) && $ev->note != "" ) {
echo "<p class='mb-1' style='font-weight: 500;'>{$ev->note}</p>";
}
if ( isset($ev->actionuser) ) {
echo "<small>Évalué par : <a target='_blank' href='{$ev->actionuser->profileurl}'>{$ev->actionuser->fullname}</a></small>";
}
echo "</li>";
}
echo "</ul>";
echo "</div>";
echo "<script>
(function() {
function active_tabs(active_tab) {
var tabs = document.querySelectorAll('#hist-tabs .nav-link');
for ( var i=0; i < tabs.length; i++ ) {
tabs[i].setAttribute('class', 'nav-link');
}
active_tab.setAttribute('class', 'nav-link active');
}
function filter(type) {
var list_items = document.querySelectorAll('[data-evidenceorigin]');
for ( var j = 0; j < list_items.length; j++ ) {
if ( list_items[j].dataset.evidenceorigin != type ) {
list_items[j].style.display = 'none';
} else {
list_items[j].style.display = '';
}
}
}
document.getElementById('all_history_tab').addEventListener('click', function (e) { e.preventDefault(); active_tabs(e.target); filter('course'); });
document.getElementById('course_history_tab').addEventListener('click', function (e) { e.preventDefault(); active_tabs(e.target); filter('course'); });
document.getElementById('other_history_tab').addEventListener('click', function (e) { e.preventDefault(); active_tabs(e.target); filter('other'); });
})();
</script>;";
echo "</div>";
echo "<pre>";
var_dump($course_evidences_ids);
print_r($all_evidences);
echo "</pre>";
/*
TODO :
Remonter ces données en haut et commenter les données préalablement récupérées d'une autre manière devenues superflues avec celles-ci. Ca réduira l'impact du chargement de la page. Et ça sera plus propre et plus concis. Quand-même garder les éléments en commentaire au cas où les exporteurs sautent dans les prochaines versions de MOODLE.
*/
// echo $output_lp->render($cpt_base_page);
/* Data */
$course_evidencies = \core_competency\api::list_evidence_in_course($studentid, $courseid, $competencyid, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0);
$all_evidencies = \core_competency\api::list_evidence($studentid, $competencyid, $planid = 0, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0);
$evidences = array();
foreach ($course_evidencies as $course_ev) {
$ev = new stdClass();
// echo "<pre>";
// var_dump($course_ev);
// echo "</pre>";
$ev->id = $course_ev->get('id');
$ev->usercompetencyid = $course_ev->get('usercompetencyid');
$ev->contextid = $course_ev->get('contextid');
$ev->actionuserid = $course_ev->get('actionuserid');
$ev->descidentifier = $course_ev->get('descidentifier'); /* nature de l'événement */
// $course_ev->get('actionuserid')
$ev->out = $course_ev->get_description()->out();
$evidences[] = $ev;
}
foreach ($evidences as $ev) {
// echo "<p>{$ev->out}</p>";
}
// $user_competency_summary_in_course = new \tool_lp\output\user_competency_summary_in_course($studentid, $competencyid, $courseid);
// $dataSumCourse = $user_competency_summary_in_course->export_for_template(new renderer_base(new moodle_page(), 'autre'));
// var_dump($dataSumCourse);
$labels = array();
$series_data = array();
$series_data_all = array();
foreach ($all_evidencies as $evidence) {
echo "<ul>";
// echo "<ul>";
echo "<li>{$evidence->get('id')}</li>";
// echo "<li>{$evidence->get('id')}</li>";
echo "<li>Action : {$evidence->get('action')} (0 : log, 2 ou 3 : rating)</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>";
// echo "<li>{$grade_label}</li>";
if ( $evidence->get('contextid') == $context->__get('id') ) {
$series_data[] = $grade;
$series_data_all[] = 0;
$series_data_all[] = end($series_data_all);
} else {
$series_data[] = 0;
$series_data[] = end($series_data);
$series_data_all[] = $grade;
}
$labels[] = userdate($evidence->get('timecreated'), "%d/%m/%y");
......@@ -319,24 +465,24 @@ foreach ($all_evidencies as $evidence) {
$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>";
// echo "<li>{$emitter->firstname} {$emitter->lastname}</li>";
} elseif ( $evidence_type == 'evidence_coursemodulecompleted' ) {
echo "<li>{$evidence->get('desca')}</li>";
// echo "<li>{$evidence->get('desca')}</li>";
}
var_dump($evidence->get_description()->out());
// var_dump($evidence->get_description()->out());
echo "</ul>";
// echo "</ul>";
}
echo "<pre>";
// echo "<pre>";
// var_dump($context->__get('id'));
// var_dump($all_evidencies);
// var_dump($series_data);
// var_dump($series_data_all);
// var_dump($labels);
echo "</pre>";
// echo "</pre>";
// OK OK END
......@@ -345,15 +491,24 @@ echo "</pre>";
echo "<div class='alert alert-secondary'>";
_html('h2', "Historique d'évaluation", "h3");
$chart = new core\chart_bar();
// $chart->get_yaxis(0, true)->set_label("I'm the label for Y");
$chart->get_yaxis(0, true)->set_labels(["Non évaluant", "Non compétent", "Compétent"]);
$series = new core\chart_series('Donnée dans ce cours', array_reverse($series_data));
$series_all = new core\chart_series("Donnée dans d'autres cours", array_reverse($series_data_all));
$chart->add_series($series);
$chart->add_series($series_all);
$chart->set_labels(array_reverse($labels));
echo $OUTPUT->render($chart);
// $chart = new core\chart_line();
// $chart->get_yaxis(0, true)->set_labels(["Non évaluant", "Non compétent", "Compétent"]);
// $series = new core\chart_series('Donnée dans ce cours', array_reverse($series_data));
// $series_all = new core\chart_series("Donnée dans d'autres cours", array_reverse($series_data_all));
// $chart->add_series($series);
// $chart->add_series($series_all);
// $chart->set_labels(array_reverse($labels));
// echo $OUTPUT->render($chart);
// echo "<hr>";
// $chart = new core\chart_bar();
// $chart->get_yaxis(0, true)->set_labels(["Non évaluant", "Non compétent", "Compétent"]);
// $series = new core\chart_series('Donnée dans ce cours', array_reverse($series_data));
// $series_all = new core\chart_series("Donnée dans d'autres cours", array_reverse($series_data_all));
// $chart->add_series($series);
// $chart->add_series($series_all);
// $chart->set_labels(array_reverse($labels));
// echo $OUTPUT->render($chart);
echo "</div>";
/* LINKED MODULES */
......
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