From a861a46505b2a0123c32408430be2d805562378c Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle
<Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr>
Date: Mon, 20 Sep 2021 09:56:34 +0200
Subject: [PATCH] template student dashboard
---
competency_iena_competencies_2.php | 176 ++++++++--------------
lang/en/block_competency_iena.php | 1 +
lang/fr/block_competency_iena.php | 1 +
renderer.php | 4 +
templates/dashboard_competencies.mustache | 1 +
templates/dashboard_students.mustache | 55 +++++++
6 files changed, 129 insertions(+), 109 deletions(-)
create mode 100644 templates/dashboard_competencies.mustache
create mode 100644 templates/dashboard_students.mustache
diff --git a/competency_iena_competencies_2.php b/competency_iena_competencies_2.php
index b883f81..6e27e44 100644
--- a/competency_iena_competencies_2.php
+++ b/competency_iena_competencies_2.php
@@ -19,6 +19,7 @@ $is_student = false;
if (!has_capability('moodle/course:update', $context = context_course::instance($course->id), $USER->id)) {
$is_student = true;
if ( $studentid != $USER->id ) {
+ //Si on est un étudiant on ne peux consulter que son propre dashboard ?
$link = $CFG->wwwroot . '/blocks/competency_iena/competency_iena_competencies_2.php?courseid=' . $courseid . '&studentid=' . $USER->id;
header("Location: {$link}");
exit;
@@ -27,30 +28,24 @@ if (!has_capability('moodle/course:update', $context = context_course::instance(
$course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
$count_course_cpts = count($course_cpts);
-if ($count_course_cpts === 0) {
- $PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
- echo $OUTPUT->header();
- echo "<p class='alert alert-warning'>Pour le moment, aucune compétence n'a été liée à ce cours. Pour lier des compétences au cours et les associer à des activités, rendez-vous dans la page <a href='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competencies_mgmt.php?courseid={$courseid}'>Gestion des compétences</a>. </p>";
- echo $OUTPUT->footer();
-} else {
-
- // L'état des compétences du cours pour un utilisateur
- $user_course_competencies = \core_competency\api::list_user_competencies_in_course($COURSE->id, $studentid);
-
- // Les étudiants.
- $student = new block_competency_iena_student();
- $students = $student->get_all_students_by_course($COURSE->id);
-
- // L'étudiant
- $student->get_student_by_id($studentid);
-
- $PAGE->set_heading($OUTPUT->heading($student->firstname . " " . $student->lastname, 2, 'headingblock header outline'));
- $PAGE->requires->js("/blocks/competency_iena/js/dropdown.js");
- echo $OUTPUT->header();
-
- /* Les demandes de validation de compétence (review) prises dans le cptuser car n'existent pas dans le contexte restreint à un cours. */
- /* TODO : préciser sur quelles compétences ? */
- $sql = "SELECT * FROM {competency_usercomp}
+$user_course_competencies = \core_competency\api::list_user_competencies_in_course($COURSE->id, $studentid);
+$student = new block_competency_iena_student();
+$students = $student->get_all_students_by_course($COURSE->id);
+
+// L'étudiant
+$student->get_student_by_id($studentid);
+
+//$PAGE->set_heading($OUTPUT->heading($student->firstname . " " . $student->lastname, 2, 'headingblock header outline'));
+$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
+
+$coursenode = $PAGE->navigation->find($course->id, navigation_node::TYPE_COURSE);
+$thingnode = $coursenode->add(get_string('dashboard_students', 'block_competency_iena'));
+$thingnode->make_active();
+
+$PAGE->requires->js("/blocks/competency_iena/js/dropdown.js");
+echo $OUTPUT->header();
+
+$sql = "SELECT * FROM {competency_usercomp}
WHERE userid = ? AND status = ?";
$params_rev = array();
$params_rev[] = $student->studentid;
@@ -67,97 +62,60 @@ if ($count_course_cpts === 0) {
}
}
- /* DEBUT CONTAINER */
- echo "<div class='container-fluid' id='dash-container'>";
-
- /* <<< DASHBOARD >>> */
-
- echo "<div class='alert alert-secondary row' style='padding-top: 1.5rem;'>"; /* Début tableau de bord. */
-
- /* Left col */
- echo "<div class='col-12 col-lg-6'>";
-
- echo "<h2 class='h3'>{$student->firstname} {$student->lastname}</h2>";
-
- if ( !$is_student ) {
- echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competencies_2.php' id='change_stud_form' class='form-inline' autocomplete='off' style='display: block;height: 1.5rem;'>";
- echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
- echo "<span hidden id='studentid'>{$studentid}</span>";
-
- echo "<div id='student_dropdown' class='iena-dropdown' style='z-index: 10;'>";
- echo "<input type='text' hidden name='studentid' id='studentid_sel' class='iena-drop-input-value' value=''>";
- echo "<input type='text' value='' class='form-control iena-drop-input' style='font-size: .7rem; line-height: 1; width: 300px;' placeholder='{$student->firstname} {$student->lastname}'><button class='btn btn-secondary' id='prevStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Précédent</button><button class='btn btn-secondary' id='nextStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Suivant</button>";
- echo "<div class='iena-droplist' id='student_list'>";
- foreach ($students as $stud) {
- echo "<a href='#' data-value='{$stud->id}' class='iena-drop-item' style='display: none;'>{$stud->firstname} {$stud->lastname}</a>";
- }
- echo "</div>";
- echo "</div>";
-
- echo "</form>";
+$chart = new \core\chart_pie();
+$proficiency_serie = new core\chart_series('', [$count_proficients, $count_course_cpts - $count_proficients]);
+$chart->set_doughnut(true);
+$chart->add_series($proficiency_serie);
+$chart->set_labels(["Validé", "Non validé"]);
+
+
+foreach ($user_course_competencies as $user_course_competency) {
+
+ // Crée un obj cpt à partir de l'ID. Attention, id de compétence et course_competency sont différents.
+ $cpt = new \core_competency\competency($user_course_competency->get('competencyid'));
+ /* Visuel indentation to reflect levels in cpt framework */
+ $cpt_level_in_framework = substr_count($cpt->get('path'), '/') - 1; /* start at 1 */
+ $user_course_competency->level_indentation = $cpt_level_in_framework * 1.5;
+ // Récupère les chaines de caractère de l'échelle d'évaluation
+ $cpt_scale = $cpt->get_scale()->scale_items;
+ $user_course_competency->eval = "-";
+ if ( $user_course_competency->get('grade') != null ) {
+ $user_course_competency->eval = $cpt_scale[$user_course_competency->get('grade') - 1];
}
-
- echo "<h2 class='h4 m-t-2'>Demandes d'évaluations <span class='badge badge-pill badge-primary' style='border-radius: 0.15rem;'>$reviews_count</span></h2>";
-
- echo "</div>"; /* Left col END */
-
- /* Right col */
- echo "<div class='col-12 col-lg-6'>";
- echo "<h2 class='h4'>Compétences validées</h2>";
- $chart = new \core\chart_pie();
- $proficiency_serie = new core\chart_series('', [$count_proficients, $count_course_cpts - $count_proficients]);
- $chart->set_doughnut(true);
- $chart->add_series($proficiency_serie);
- $chart->set_labels(["Validé", "Non validé"]);
- echo $OUTPUT->render($chart);
- echo "</div>"; /* Right col END */
-
- echo "</div>"; /* Fin tableau de bord */
-
- /* <<< COMPETENCY LIST >>> */
-
- echo "<div class='row'>";
-
- echo "<div class='col-12' style='padding: 0;'>";
-
- echo "<div class='list-group'>";
- foreach ($user_course_competencies as $user_course_competency) {
- // Crée un obj cpt à partir de l'ID. Attention, id de compétence et course_competency sont différents.
- $cpt = new \core_competency\competency($user_course_competency->get('competencyid'));
- /* Visuel indentation to reflect levels in cpt framework */
- $cpt_level_in_framework = substr_count($cpt->get('path'), '/') - 1; /* start at 1 */
- $level_indentation = $cpt_level_in_framework * 1.5;
- // Récupère les chaines de caractère de l'échelle d'évaluation
- $cpt_scale = $cpt->get_scale()->scale_items;
- $eval = "-";
- if ( $user_course_competency->get('grade') != null ) {
- $eval = $cpt_scale[$user_course_competency->get('grade') - 1];
+ $user_course_competency->proficient_class = $user_course_competency->get('proficiency') == 1 ? " list-group-item-success" : "";
+ $user_course_competency->proficient_str = $user_course_competency->get('proficiency') == 1 ? "Oui" : "Non";
+ $user_course_competency->shortname=$cpt->get('shortname');
+ $user_course_competency->link=$CFG->wwwroot."/blocks/competency_iena/course_competency.php?courseid=".$COURSE->id."&studentid=".$student->studentid."&competencyid=".$cpt->get('id');
+ foreach ($reviews_data as $review) {
+ if ( $review->competencyid == $cpt->get('id') ) {
+ error_log("Oui on a une demande");
+ $user_course_competency->review_asked=true;
+ break;
}
- $proficient_class = $user_course_competency->get('proficiency') == 1 ? " list-group-item-success" : "";
- $proficient_str = $user_course_competency->get('proficiency') == 1 ? "Oui" : "Non";
- echo "
- <a href='{$CFG->wwwroot}/blocks/competency_iena/course_competency.php?courseid={$courseid}&studentid={$studentid}&competencyid={$cpt->get('id')}' class='list-group-item list-group-item-action{$proficient_class}' style='padding-left: {$level_indentation}rem;'>
- <div class='d-flex w-100 justify-content-between'>
- <h3 class='mb-1 iena-cpt-action-title h5'>{$cpt->get('shortname')}</h3>";
- foreach ($reviews_data as $review) {
- if ( $review->competencyid == $cpt->get('id') ) {
- echo "<div><small class='review-badge'>Évaluation demandée</small></div>";
- break;
- }
- }
- echo "</div>
- <p class='small' style='margin-bottom: 0;'>Évaluation : {$eval} / Acquis : {$proficient_str}</p>
- </a>";
}
- echo "</div>";
+ //$user_course_competency->reviews_data=array_values($reviews_data);
+
+}
- echo "</div>";
+$data=array();
+$data['count_course_cpts']=$count_course_cpts;
+$data['is_not_student']=!$is_student;
+$data['courseid']=$COURSE->id;
+$data['chart']=$OUTPUT->render($chart);
+//$data['reviews_data']=array_values($reviews_data);
+$data['user_course_competencies']=array_values($user_course_competencies);
+$data['student']=$student;
+$data['students']=array_values($students);
+$data['reviews_count']=$reviews_count;
+$data['link_dashboard']=$CFG->wwwroot."/blocks/competency_iena/competency_iena_competencies_2.php";
- echo "</div>"; /* Fin de la liste. */
- echo "</div>"; /* FIN CONTAINER */
+$renderer = $PAGE->get_renderer('block_competency_iena');
- echo $OUTPUT->footer();
+$renderer->get_dashboard_students($data);
+
+
+echo $OUTPUT->footer();
-} /* Fin else condition qu'il y ait des cpt liées au cours. */
\ No newline at end of file
+?>
\ No newline at end of file
diff --git a/lang/en/block_competency_iena.php b/lang/en/block_competency_iena.php
index 0dec00c..a61db35 100644
--- a/lang/en/block_competency_iena.php
+++ b/lang/en/block_competency_iena.php
@@ -87,4 +87,5 @@
$string['manage_matrix_end'] = 'Exit edit mode';
$string['no_competency_description'] = 'This competency doesn\'t have a description' ;
$string['error_delete']="The activity/resource couldn't be deleted";
+ $string['dashboard_students']="Students dashboard";
?>
\ No newline at end of file
diff --git a/lang/fr/block_competency_iena.php b/lang/fr/block_competency_iena.php
index f3cad31..c4ab932 100644
--- a/lang/fr/block_competency_iena.php
+++ b/lang/fr/block_competency_iena.php
@@ -86,6 +86,7 @@
$string['manage_matrix_end'] = 'Quitter le mode édition';
$string['no_competency_description'] = 'Cette compétence n\'a pas de description.';
$string['error_delete']="L'activité/ressource n'a pas pu être supprimée";
+ $string['dashboard_students']="Tableau de bord étudiants";
diff --git a/renderer.php b/renderer.php
index d56f5af..ffc5574 100644
--- a/renderer.php
+++ b/renderer.php
@@ -75,4 +75,8 @@ class block_competency_iena_renderer extends plugin_renderer_base {
function get_competency_matrix($data){
echo $this->render_from_template('block_competency_iena/matrix_competencies', $data);
}
+
+ function get_dashboard_students($data){
+ echo $this->render_from_template('block_competency_iena/dashboard_students', $data);
+ }
}
diff --git a/templates/dashboard_competencies.mustache b/templates/dashboard_competencies.mustache
new file mode 100644
index 0000000..0ec5d8d
--- /dev/null
+++ b/templates/dashboard_competencies.mustache
@@ -0,0 +1 @@
+<h1></h1>
\ No newline at end of file
diff --git a/templates/dashboard_students.mustache b/templates/dashboard_students.mustache
new file mode 100644
index 0000000..b8dbfda
--- /dev/null
+++ b/templates/dashboard_students.mustache
@@ -0,0 +1,55 @@
+<h2>{{# str }} dashboard_students, block_competency_iena{{/ str }}</h2>
+{{#count_course_cpts}}
+ <div class='container-fluid' id='dash-container'>
+ <div class='alert alert-secondary row' style='padding-top: 1.5rem;'>
+ <div class='col-12 col-lg-6'>
+
+ <!--<h2 class='h3'>{{student.firstname}} {{student.lastname}}</h2>-->
+
+ {{#is_not_student}}
+ <form action='{{link_dashboard}}' id='change_stud_form' class='form-inline' autocomplete='off' style='display: block;height: 1.5rem;'>
+ <input type='text' hidden name='courseid' value='{{courseid}}'>
+ <span hidden id='studentid'>{{student.studentid}}</span>
+ <div id='student_dropdown' class='iena-dropdown' style='z-index: 10;'>
+ <input type='text' hidden name='studentid' id='studentid_sel' class='iena-drop-input-value' value=''>
+ <input type='text' value='' class='form-control iena-drop-input' style='font-size: .7rem; line-height: 1; width: 300px;' placeholder='{{student.firstname}} {{student.lastname}}'><button class='btn btn-secondary' id='prevStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Précédent</button><button class='btn btn-secondary' id='nextStud' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Suivant</button>
+ <div class='iena-droplist' id='student_list'>
+ {{#students}}
+ <a href='#' data-value='{{id}}' class='iena-drop-item' style='display: none;'>{{firstname}} {{lastname}}</a>
+ {{/students}}
+ </div>
+ </div>
+ </form>
+ {{/is_not_student}}
+ <h2 class='h4 m-t-2'>Demandes d'évaluations <span class='badge badge-pill badge-primary' style='border-radius: 0.15rem;'>{{reviews_count}}</span></h2>
+ </div>
+ <div class='col-12 col-lg-6'>
+ <h2 class='h4'>Compétences validées</h2>
+ {{{chart}}}
+ </div>
+ </div>
+ <div class='row'>
+ <div class='col-12' style='padding: 0;'>
+ <div class='list-group'>
+ {{#user_course_competencies}}
+ <a href='{{link}}' class='list-group-item list-group-item-action{{proficient_class}}' style='padding-left: {{level_indentation}}rem;'>
+ <div class='d-flex w-100 justify-content-between'>
+ <h3 class='mb-1 iena-cpt-action-title h5'>{{shortname}}</h3>
+
+
+ {{#review_asked}}
+ <div><small class='review-badge'>Évaluation demandée</small></div>
+ {{/review_asked}}
+
+ </div>
+ <p class='small' style='margin-bottom: 0;'>Évaluation : {{eval}} / Acquis : {{proficient_str}}</p>
+ </a>
+ {{/user_course_competencies}}
+ </div>
+ </div>
+ </div>
+ </div>
+{{/count_course_cpts}}
+{{^count_course_cpts}}
+ <p class='alert alert-warning'>Pour le moment, aucune compétence n'a été liée à ce cours. Pour lier des compétences au cours et les associer à des activités, rendez-vous dans la page <a href='/blocks/competency_iena/competency_iena_competencies_mgmt.php?courseid={{courseid}}'>Gestion des compétences</a>. </p>
+{{/count_course_cpts}}
\ No newline at end of file
--
GitLab