Commit 4b6f19cf authored by Thomas Fradet's avatar Thomas Fradet

user x cpts msg if no cpt in course

parent 51bb2c0a
......@@ -3,15 +3,14 @@
require_once('../../config.php');
// ENLEVER SI NON NECESSAIRE :
require_once('entity/block_competency_iena_competency.php');
require_once('entity/block_competency_iena_module.php');
require_once('entity/block_competency_iena_ressource.php');
require_once('entity/block_competency_iena_section.php');
// require_once('entity/block_competency_iena_competency.php');
// require_once('entity/block_competency_iena_module.php');
// require_once('entity/block_competency_iena_ressource.php');
// require_once('entity/block_competency_iena_section.php');
require_once('entity/block_competency_iena_student.php');
require_once('entity/block_competency_iena_cron_roles.php');
require_once('entity/block_competency_iena_cron_competency.php');
require_once('view/view_competency_iena_competencies.php');
// require_once('entity/block_competency_iena_cron_roles.php');
// require_once('entity/block_competency_iena_cron_competency.php');
// require_once('view/view_competency_iena_competencies.php');
global $COURSE, $DB, $USER, $CFG;
......@@ -23,72 +22,80 @@ $PAGE->set_url($url);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_competency_iena'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
$PAGE->requires->js("/blocks/competency_iena/js/datalist-polyfill.min.js");
$PAGE->requires->js("/blocks/competency_iena/js/stud-x-cpts.js");
echo $OUTPUT->header();
// Les étudiants.
$student = new block_competency_iena_student();
$students = $student->get_all_students_by_course($COURSE->id);
$course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
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'étudiant
$student->get_student_by_id($studentid);
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
$PAGE->requires->js("/blocks/competency_iena/js/datalist-polyfill.min.js");
$PAGE->requires->js("/blocks/competency_iena/js/stud-x-cpts.js");
echo $OUTPUT->header();
// Les compétences du cours.
// $course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
// Les compétences du cours.
// $course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
// L'état des compétences du cours pour un utilisateur
$user_course_competencies = \core_competency\api::list_user_competencies_in_course($COURSE->id, $studentid);
// 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);
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competencies_2.php' id='change_stud_form' class='form-inline m-b-1 alert alert-secondary'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
echo "<span hidden id='studentid'>{$studentid}</span>";
// L'étudiant
$student->get_student_by_id($studentid);
// https://github.com/mfranzke/datalist-polyfill
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'>";
echo "<datalist id='student_list' title='Select student'>";
echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competencies_2.php' id='change_stud_form' class='form-inline m-b-1 alert alert-secondary'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
echo "<span hidden id='studentid'>{$studentid}</span>";
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 "</datalist>";
// https://github.com/mfranzke/datalist-polyfill
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'>";
echo "<button class='btn btn-secondary m-l-1' id='prevStud'>Précédent</button>";
echo "<button class='btn btn-secondary m-l-1' id='nextStud'>Suivant</button>";
echo "<datalist id='student_list' title='Select student'>";
echo "</form>";
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 "</datalist>";
echo "<button class='btn btn-secondary m-l-1' id='prevStud'>Précédent</button>";
echo "<button class='btn btn-secondary m-l-1' id='nextStud'>Suivant</button>";
echo "</form>";
echo "<h2>{$student->firstname} {$student->lastname}</h2>";
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'));
// 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];
}
$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='#?courseid={$courseid}&studentid={$studentid}&competencyid={$cpt->get('id')}' class='list-group-item list-group-item-action{$proficient_class}'>
<div class='d-flex w-100 justify-content-between'>
<h3 class='mb-1 iena-cpt-action-title'>{$cpt->get('shortname')}</h3>
<!--<small class='text-muted'>3 days ago</small>-->
<!--<span class='badge badge-primary badge-pill'>3 days ago</span>-->
</div>
<p class='' style='margin-bottom: 0;'>Évaluation : <em>{$eval}</em></p>
<small class=''>Acquis : {$proficient_str}</small>
</a>";
}
echo "</div>";
echo "<h2>{$student->firstname} {$student->lastname}</h2>";
echo $OUTPUT->footer();
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'));
// 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];
}
$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='#?courseid={$courseid}&studentid={$studentid}&competencyid={$cpt->get('id')}' class='list-group-item list-group-item-action{$proficient_class}'>
<div class='d-flex w-100 justify-content-between'>
<h3 class='mb-1 iena-cpt-action-title'>{$cpt->get('shortname')}</h3>
<!--<small class='text-muted'>3 days ago</small>-->
<!--<span class='badge badge-primary badge-pill'>3 days ago</span>-->
</div>
<p class='' style='margin-bottom: 0;'>Évaluation : <em>{$eval}</em></p>
<small class=''>Acquis : {$proficient_str}</small>
</a>";
}
echo "</div>";
echo $OUTPUT->footer();
} /* Fin else condition qu'il y ait des cpt liées au cours. */
\ 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