Commit 708205d9 authored by Thomas Fradet's avatar Thomas Fradet
Browse files

cpt x users get data

parent 7155fb79
...@@ -114,6 +114,8 @@ Ne pas utiliser de méthodes root, quitte à abandonner des fonctionnalités. Tr ...@@ -114,6 +114,8 @@ Ne pas utiliser de méthodes root, quitte à abandonner des fonctionnalités. Tr
[ ] Liste d'étudiants selon des filtres sur le grade, la proficiency et la demande d'évaluation avec sélection de filtre multiples cumulatifs. [ ] Liste d'étudiants selon des filtres sur le grade, la proficiency et la demande d'évaluation avec sélection de filtre multiples cumulatifs.
[ ] Repasser les données au crible des compétences actuellement liées dans le cours dans le cas où une cpt ait été liée par le passé puis supprimée. Voir si c'est nécessaire dans l'autre liste. Pour tableau de bord et liste.
[x] Traiter le cas où il n'y a pas de compétences dans le cours (renvoyer vers la matrice) [x] Traiter le cas où il n'y a pas de compétences dans le cours (renvoyer vers la matrice)
[x] Pouvoir changer de compétence via un champ de recherche dynamique [x] Pouvoir changer de compétence via un champ de recherche dynamique
......
...@@ -62,17 +62,27 @@ if (count($course_cpts) === 0) { ...@@ -62,17 +62,27 @@ if (count($course_cpts) === 0) {
$count_students = count($students); $count_students = count($students);
$student_ids = array(); $student_ids = array();
foreach ($students as $stud) { foreach ($students as $stud) {
$student_ids[] = $stud->id; $student_ids[] = intval($stud->id);
} }
echo "<div class='container-fluid'>"; echo "<div class='container-fluid'>";
/* ===== CHANGE COMPETENCY ===== */ /* ===== CHANGE COMPETENCY ===== */
/* There is 2 forms witch use data from each other while submitting. */
echo "<div class='alert row' style='padding: 0;'>"; /* Début change competency. */ echo "<div class='alert row' style='padding: 0;'>"; /* Début change competency. */
echo "<div class='col-12' style='padding-left: 0;'>"; echo "<div class='col-12' style='padding-left: 0;'>";
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competency_students_2.php' id='change_cpt_form' class='form-inline'>"; echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competency_students_2.php' id='change_cpt_form' class='form-inline'>";
echo "<input type='text' hidden name='courseid' value='{$COURSE->id}'>"; echo "<input type='text' hidden name='courseid' value='{$COURSE->id}'>";
if ( isset($_GET['grade']) ) {
echo "<input type='text' hidden name='grade' value='{$_GET['grade']}'>";
}
if ( isset($_GET['proficiency']) ) {
echo "<input type='text' hidden name='proficiency' value='{$_GET['proficiency']}'>";
}
if ( isset($_GET['review']) ) {
echo "<input type='text' hidden name='review' value='{$_GET['review']}'>";
}
echo "<span hidden id='competencyid'>{$current_cpt->id}</span>"; echo "<span hidden id='competencyid'>{$current_cpt->id}</span>";
echo "<label class='m-r-1' for='competencyid_sel' style=''>Changer de compétence</label>"; 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 "<input type='text' name='competencyid' id='competencyid_sel' value='' list='competency_list' class='form-control'>";
...@@ -101,7 +111,7 @@ if (count($course_cpts) === 0) { ...@@ -101,7 +111,7 @@ if (count($course_cpts) === 0) {
'competencyid' => $current_cpt->id 'competencyid' => $current_cpt->id
]); ]);
echo "<h2 class='h4'>Validé dans ce cours</h2>"; echo "<h2 class='h4'>Compétences validées</h2>";
$chart = new \core\chart_pie(); $chart = new \core\chart_pie();
$proficiency_serie = new core\chart_series('', [$count_proficients, $count_students - $count_proficients]); $proficiency_serie = new core\chart_series('', [$count_proficients, $count_students - $count_proficients]);
...@@ -147,12 +157,16 @@ if (count($course_cpts) === 0) { ...@@ -147,12 +157,16 @@ if (count($course_cpts) === 0) {
/* <<< TO REVIEW SECTION >>> */ /* <<< TO REVIEW SECTION >>> */
echo "<div class='col-12'>"; echo "<div class='col-12'>";
$student_ids_implode = implode(",", $student_ids);
$reviews_count = $DB->count_records_select( list($in_sql_stud_ids, $params_stud_ids) = $DB->get_in_or_equal($student_ids);
'competency_usercomp', $sql = "SELECT * FROM {competency_usercomp}
"userid IN ({$student_ids_implode}) AND competencyid = {$current_cpt->id} AND status = 1", WHERE userid {$in_sql_stud_ids} AND competencyid = ? AND status = ?";
null, $params_rev = array();
"COUNT('status')"); $params_rev = array_merge($params_rev, $params_stud_ids);
$params_rev[] = $current_cpt->id;
$params_rev[] = 1;
$reviews_data = $DB->get_records_sql($sql, $params_rev);
$reviews_count = count($reviews_data);
echo "<h2 class='h4'>Demandes d'évaluations <span class='badge badge-pill badge-primary' style=' border-radius: 0.15rem;'>$reviews_count</span></h2>"; echo "<h2 class='h4'>Demandes d'évaluations <span class='badge badge-pill badge-primary' style=' border-radius: 0.15rem;'>$reviews_count</span></h2>";
echo "</div>"; /* to review section end */ echo "</div>"; /* to review section end */
...@@ -160,14 +174,54 @@ if (count($course_cpts) === 0) { ...@@ -160,14 +174,54 @@ if (count($course_cpts) === 0) {
echo "</div>"; /* Fin tableau de bord. */ echo "</div>"; /* Fin tableau de bord. */
/* ===== FILTERS ===== */ /* ===== FILTERS ===== */
/* There is 2 forms witch use data from each other while submitting. */
echo "<div class='alert alert-secondary row'>"; /* Début filtres. */ echo "<div class='alert alert-secondary row' id='stud_filters'>"; /* Début filtres. */
echo "<div class='col-12'>"; echo "<div class='col-12'>";
echo "<form class='form-inline'>"; echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competency_students_2.php#stud_filters' class='form-inline'>";
echo "<label>Évaluation</label><select name='grade' class='custom-select mr-3'><option value='all'>Tous</option><option value='no'>Pas encore évalué</option><option value='0'>Not yet competent</option><option value='1'>Competent</option></select>"; echo "<input type='text' hidden name='courseid' value='{$COURSE->id}'>";
echo "<label>Validé</label><select name='proficiency' class='custom-select mr-3'><option value='all'>Tous</option><option value='0'>Non</option><option value='1'>Oui</option></select>"; echo "<input type='text' hidden name='competencyid' value='{$current_cpt->id}'>";
echo "<label>Évaluation demandée</label><select name='review' class='custom-select mr-3'><option value='all'>Tous</option><option value='0'>Non</option><option value='1'>Oui</option></select>";
echo "<label>Évaluation</label><select name='grade' class='custom-select mr-3'>";
$form_grade = isset($_GET['grade']) ? $_GET['grade'] : 'all';
if ( $form_grade == 'all' ) { echo "<option value='all' selected>Tous</option>"; } else { echo "<option value='all'>Tous</option>"; }
if ( $form_grade == 'no' ) { echo "<option value='no' selected>Non évalués</option>"; } else { echo "<option value='no'>Non évalués</option>"; }
foreach ($current_cpt->scale as $key => $scale_item) {
$strkey = strval($key + 1);
echo "<option value='{$strkey}'";
if ( $form_grade == $strkey ) { echo "selected"; }
echo ">{$scale_item}</option>";
}
echo "</select>";
$form_proficiency = isset($_GET['proficiency']) ? $_GET['proficiency'] : 'all';
echo "<label>Validé</label><select name='proficiency' class='custom-select mr-3'>
<option value='all'";
if ( $form_proficiency == 'all' ) { echo 'selected'; }
echo ">Tous</option>
<option value='no'";
if ( $form_proficiency == 'no' ) { echo 'selected'; }
echo ">Non</option>
<option value='yes'";
if ( $form_proficiency == 'yes' ) { echo 'selected'; }
echo ">Oui</option>
</select>";
$form_review = isset($_GET['review']) ? $_GET['review'] : 'all';
echo "<label>Évaluation demandée</label><select name='review' class='custom-select mr-3'><option value='all'";
if ( $form_review == 'all' ) { echo 'selected'; }
echo ">Tous</option>
<option value='0'";
if ( $form_review == '0' ) { echo 'selected'; }
echo ">Non</option>
<option value='1'";
if ( $form_review == '1' ) { echo 'selected'; }
echo ">Oui</option>
</select>";
echo "<button type='submit' class='btn btn-primary'>Chercher</button>"; echo "<button type='submit' class='btn btn-primary'>Chercher</button>";
echo "</form>"; echo "</form>";
...@@ -176,13 +230,134 @@ if (count($course_cpts) === 0) { ...@@ -176,13 +230,134 @@ if (count($course_cpts) === 0) {
/* ===== STUDENT LIST ===== */ /* ===== STUDENT LIST ===== */
echo "<div class='row'>"; /* Début student list. */ /* NB : un étudiant n'existe pas en base competency_usercompcourse tant que personne n'a accédé à une page de compétence le concernant. Donc pour afficher des données, il faut boucler sur les utilisateurs et pour chaque utilisateur sur les données en base : si correspondance, on peut afficher de "vraies" données (p.ex. "Compétent"), sinon, afficher des données vides car de toutes façon elles n'existent pas (p.ex. "Non évalué"). */
echo "<div class='col-12'>";
/* IF all params are NULL => do not search students, just display dashboard. */
if ( isset($_GET['grade']) || isset($_GET['proficiency']) || isset($_GET['review']) ) {
if ( !isset($_GET['grade']) || $_GET['grade'] == 'all' ) {
$sql_grade = "";
} elseif ( $_GET['grade'] == 'no' ) {
$sql_grade = " AND grade IS NULL";
} else {
$sql_grade = " AND grade = ?";
}
if ( !isset($_GET['proficiency']) || $_GET['proficiency'] == 'all' ) {
$sql_proficiency = "";
} elseif ($_GET['proficiency'] == 'no') {
/* not proficient is "= 0" => "NULL && 0" */
$sql_proficiency = " AND (proficiency = ? OR proficiency IS NULL)";
} else {
$sql_proficiency = " AND proficiency = ?";
}
echo "<div class='row'>"; /* Début student list. */
echo "<div class='col-12'>";
/* $course_cpts_ids IN sql (idem pour studs) */
$course_cpts_ids = array();
foreach ($course_cpts as $key => $cpt) {
$course_cpts_ids[] = intval($cpt->get('id'));
}
/* $in_sql => string "IN (?, ?, etc.) // $params array(1, 2, etc.) */
/* already defined list($in_sql_stud_ids, $params_stud_ids) = $DB->get_in_or_equal($student_ids);*/
list($in_sql_cpts_ids, $params_cpts_ids) = $DB->get_in_or_equal($course_cpts_ids);
$sql = "SELECT * FROM {competency_usercompcourse}
WHERE courseid = ?
AND userid {$in_sql_stud_ids} AND competencyid = ?{$sql_grade}{$sql_proficiency}";
$params = array();
$params[] = $courseid;
$params = array_merge($params, $params_stud_ids);
$params[] = $current_cpt->id;
if ( isset($_GET['grade']) && $_GET['grade'] !== 'all' && $_GET['grade'] !== 'no' ) {
$params[] = $_GET['grade'];
}
if ( isset($_GET['proficiency']) && $_GET['proficiency'] !== 'all' ) {
$params[] = $_GET['proficiency'] == 'no' ? 0 : 1;
}
$course_cpts = $DB->get_records_sql($sql, $params);
/* LIST PRINT */
$include_all_studs = false;
if ( isset($_GET['grade']) && isset($_GET['proficiency']) ) {
if ( $_GET['grade'] == 'all' && $_GET['proficiency'] == 'all' ) {
$include_all_studs = true;
}
if ( $_GET['grade'] == 'all' && $_GET['proficiency'] == 'no' ) {
$include_all_studs = true;
}
if ( $_GET['grade'] == 'no' && $_GET['proficiency'] == 'all' ) {
$include_all_studs = true;
}
if ( $_GET['grade'] == 'no' && $_GET['proficiency'] == 'no' ) {
$include_all_studs = true;
}
}
$list_count = 0;
foreach ($students as $student) {
$grade_d = "-";
$proficiency_d = "Non";
$display = false;
foreach ($course_cpts as $course_cpt) {
if ( $course_cpt->userid == $student->id ) {
$display = true;
$grade_d = $course_cpt->grade == NULL ? "-" : $current_cpt->scale[$course_cpt->grade - 1];
$proficiency_d = $course_cpt->proficiency == 1 ? "Oui" : "Non";
echo "<p>$grade_d</p>";
echo "<p>$proficiency_d</p>";
break;
}
}
if ( $display || $include_all_studs ) {
$list_count++;
$color = $proficiency_d == "Oui" ? "success" : "secondary";
echo "<div class='alert alert-{$color}'>";
echo "<h4>{$student->firstname} {$student->lastname} ({$student->id})</h4>";
echo "<p>Évaluation : {$grade_d}</p>";
echo "<p>Acquis : {$proficiency_d}</p>";
echo "<p>Demande d'évaluation : {OUI/NON}</p>";
echo "</div>";
}
}
echo "$list_count";
echo "<pre>";
// echo "<h1>review data</h1>";
// var_dump($reviews_data);
// echo "<h1>course user comp list</h1>";
// foreach ($course_cpts as $key => $course_cpt) {
// var_dump($course_cpt);
// echo "<hr>";
// }
// echo "<h1>students</h1>";
// var_dump($students);
echo "</pre>";
/* AFFICHER */
/* Pour chaque étudiant du cours */
/* Pour chaque étudiant résultat de la requête */
/* Si l'étudiant correspond */
/* Afficher données */
/* Sinon */
/* Afficher ligne standard vide car étu pas en base car jamais accédé à la page cpt */
echo "</div>";
echo "</div>"; /* Fin student list. */
} else {
/* if all filters are not set ( ! isset GET... ) dont display the stud list */
}
echo "prout";
echo "</div>";
echo "</div>"; /* Fin student list. */
echo "</div>"; /* Fin du container bootstrap. */ echo "</div>"; /* Fin du container bootstrap. */
......
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