competency_iena_competencies_2.php 3.63 KB
Newer Older
Thomas Fradet's avatar
Thomas Fradet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
<?php

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_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');


global $COURSE, $DB, $USER, $CFG;

$courseid = required_param('courseid', PARAM_INT);
$studentid = optional_param('studentid', $USER->id, PARAM_INT);
$url = new moodle_url('/blocks/competency_iena/competency_iena_competencies_2.php', array('courseid' => $courseid, 'studentid' => $studentid));
$PAGE->set_pagelayout('course');
$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");
echo $OUTPUT->header();



// Les étudiants. 
$student = new block_competency_iena_student();
$students = $student->get_all_students_by_course($COURSE->id);
// var_dump($students);

// L'étudiant
$student->get_student_by_id($studentid);

// Les compétences du cours. 
// $course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
$course_cpts = \core_competency\course_competency::list_competencies($COURSE->id);
// echo "<pre>";
// foreach ($course_cpts as $course_cpt) {
// 	var_dump($course_cpt);
// 	echo "<hr>";
// }
// echo "</pre>";

// L'état des compétences du cours pour un utilisateur
$user_course_competencies = \core_competency\api::list_user_competencies_in_course($COURSE->id, $studentid);
// echo "<pre>";
// foreach ($user_course_competencies as $user_course_competency) {
// 	var_dump($user_course_competency);
// 	echo "<hr>";
// 	$cpt = new \core_competency\competency($user_course_competency->get('id'));
// 	var_dump($cpt->get_scale());
// 	echo "<hr>";
// 	echo "<hr>";
// }
// echo "</pre>";

echo "<form action='{$CFG->wwwroot}/blocks/competency_iena/competency_iena_competencies_2.php'>";
echo "<input type='text' hidden name='courseid' value='{$courseid}'>";
// https://github.com/mfranzke/datalist-polyfill
echo "<input type='text' name='studentid' id='studentid_sel' value='' list='student_list' class='dtlst'>";

echo "<datalist id='student_list' title='Select student'>";

foreach ($students as $stud) {
	echo "<option value='{$stud->id}'>{$stud->firstname} {$stud->lastname}</option>";
}
echo "</datalist>";
echo "<button type='submit'>Rechercher</button>";
echo "</form>";

echo "<h2>{$student->firstname} {$student->lastname}</h2>";
foreach ($user_course_competencies as $user_course_competency) {
	echo "<div class='alert alert-secondary'>";
	$cpt = new \core_competency\competency($user_course_competency->get('id'));
	echo "<h3 id='{$cpt->get('id')}'>{$cpt->get('shortname')}</h3>";
	$cpt_scale = $cpt->get_scale()->scale_items;
	if ( $user_course_competency->get('grade') == null ) {
		$eval = "Non évalué";
	} else {
		$eval = $cpt_scale[$user_course_competency->get('grade') - 1];
	}
	echo "<p>Evaluation : {$eval}</p>";
	$proficient = $user_course_competency->get('proficiency') == 1 ? "Oui" : "Non";
	echo "<p>Validé : {$proficient}</p>";
	echo "</div>";
}







echo $OUTPUT->footer();