Commit 3efc8022 authored by Lea's avatar Lea
Browse files

complete tracker features

parent 42e2f138
......@@ -38,6 +38,9 @@ function changePath(){
type: 'post',
success: function(request) {
$("#tracker").html(request);
$("#path-select").on('change', function(e){
changePath();
});
}
});
}
......
......@@ -9,8 +9,8 @@ global $USER, $DB, $CFG;
require_once($CFG->libdir . '/adminlib.php');
$id_path = optional_param('pathid',NULL, PARAM_INT);
$display = required_param('display', PARAM_INT);
$id_course= required_param('courseid',PARAM_INT);
if(!empty($id_path)){
$url = new moodle_url('/blocks/career/career_tracker.php', array('courseid'=>$id_course,'pathid' => $id_path));
}else{
......@@ -18,11 +18,11 @@ if(!empty($id_path)){
}
//Check if the user has capability to update course
if (!has_capability('moodle/course:update', $context = context_course::instance($id_course), $USER->id)) {
/*if (!has_capability('moodle/course:update', $context = context_course::instance($id_course), $USER->id)) {
$link = $CFG->wwwroot . '/course/view.php?id=' . $id_course;
header("Location: {$link}");
exit;
}
}*/
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
......@@ -31,21 +31,32 @@ require_login($course, false, NULL);
$PAGE->set_title(get_string('title_plugin', 'block_career'));
$PAGE->set_heading($OUTPUT->heading($COURSE->fullname, 2, 'headingblock header outline'));
// echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">";
//$content = new view_career_list();
$renderer = $PAGE->get_renderer('block_career');
if(!empty($id_path)){
$renderer->get_tracker($id_path);
print_r($display);
if ($display=='solo') {
echo 'COUCOU';
echo $OUTPUT->header();
$renderer->get_tracker($id_path);
echo $OUTPUT->footer();
}else{
$renderer->get_tracker($id_path);
}
}
else{
//$PAGE->requires->js("/blocks/career/js/suivi_career.js");
//$id_path=getOption();
//print_r($_GET['pathfilter']);
//ici une valeur de parcours en brut pour pas avoir d'erreurs au chargement de la page
$sql="SELECT id
FROM {block_career}
WHERE course = ?";
$requete=$DB->get_records_sql($sql, array($id_course));
echo $OUTPUT->header();
$renderer->get_tracker(1);
if(empty($requete)){
echo "Aucun parcours à afficher";
}
else{
$renderer->get_tracker($requete[1]->id);
}
echo $OUTPUT->footer();
}
......@@ -19,4 +19,5 @@
$string['about_this_career']='About this path';
$string['edit_path']='Edit';
$string['track']='Tracking the path : {$a}';
$string['no_group']='There are no groups registered for this path';
?>
\ No newline at end of file
......@@ -21,14 +21,15 @@ class block_career_renderer extends plugin_renderer_base {
if (empty($request)) {
$emptycareer=get_string('any_carrer', 'block_career');
$careerlist=false;
$list=['list_title'=>$listtitle, 'heading_plugin'=>$headingplugin,'empty_career'=>$emptycareer,'add_path'=>$addpath, 'path'=>$path,'course_id'=>$courseid];
$empty=true;
$list=['list_title'=>$listtitle, 'heading_plugin'=>$headingplugin,'empty_career'=>$emptycareer,'add_path'=>$addpath, 'path'=>$path,'course_id'=>$courseid,'empty'=>$empty];
}
else {
foreach ($request as $value){
$careerpath=$CFG->wwwroot.'/blocks/career/career_setting.php?courseid='.$_GET["courseid"].'&pathid='.$value->id;
array_push($careerlist,array('name'=>$value->name,'description'=>$value->description));
}
$trackerpath=$CFG->wwwroot.'/blocks/career/career_tracker.php?courseid='.$_GET['courseid'];
$trackerpath=$CFG->wwwroot.'/blocks/career/career_tracker.php?courseid='.$_GET['courseid'].'&display=none';
$list=['list_title'=>$listtitle, 'heading_plugin'=>$headingplugin,'add_path'=>$addpath, 'path'=>$path,'career_path'=>$careerpath, 'course_id'=>$courseid,'career_list'=>$careerlist,'track_path'=>$trackerpath];
......@@ -41,7 +42,7 @@ class block_career_renderer extends plugin_renderer_base {
$aboutcareer=get_string('about_this_career','block_career');
$request = $DB->get_record('block_career',array('id' => $pathid));
$description=$request->description;
$trackerpath=$CFG->wwwroot.'/blocks/career/career_tracker.php?courseid='.$request->course.'&pathid='.$request->id;
$trackerpath=$CFG->wwwroot.'/blocks/career/career_tracker.php?courseid='.$request->course.'&pathid='.$request->id.'&display=solo';
$list=array('about_this_career'=>$aboutcareer,'description'=>$description,'tracker_path'=>$trackerpath);
echo $this->render_from_template('block_career/career_header', $list);
}
......@@ -103,17 +104,21 @@ class block_career_renderer extends plugin_renderer_base {
function get_tracker($path_id){
global $DB, $CFG, $COURSE, $USER,$SITE;
require_once($CFG->libdir . '/completionlib.php');
$no_group='';
$student=array();
$module=array();
$progress=0;
$path=array();
if(!isset($_GET['pathid'])){
$isset=false;
$requete=$DB->get_records('block_career',array('course'=>$COURSE->id));
foreach($requete as $value){
array_push($path,array('name'=>$value->name,'id'=>$value->id));
if($value->id==$path_id){
array_push($path,array('name'=>$value->name,'id'=>$value->id,'selected'=>'selected'));
}else{
array_push($path,array('name'=>$value->name,'id'=>$value->id));
}
}
}
else{
......@@ -123,49 +128,53 @@ class block_career_renderer extends plugin_renderer_base {
FROM {block_career_groups} JOIN {groups_members} JOIN {user}
WHERE groupid = group_id AND userid=mdl_user.id AND career=?";
$requete=$DB->get_records_sql($sql, array($path_id));
$request=$DB->get_record('block_career',array('id'=>$path_id));
$ressource=explode(',',$request->ressources);
$suivi=get_string('track','block_career',$request->name);
foreach($requete as $user){
$progress=array();
$reportlink=$CFG->wwwroot . "/report/outline/user.php?id=" . $user->id . "&course=" . $COURSE->id . "&mode=outline";
$messagelink=$CFG->wwwroot . "/message/index.php?id=" . $user->id;
$percentage=0;
$percentage=(int)$this->get_completion_by_resource_list($ressource,$user->id);
$suivi=get_string('track','block_career',$request->name);
if (empty($requete)) {
$empty=true;
$no_group=get_string('no_group','block_career');
}
else{
$empty=false;
$ressource=explode(',',$request->ressources);
foreach($requete as $user){
$progress=array();
$reportlink=$CFG->wwwroot . "/report/outline/user.php?id=" . $user->id . "&course=" . $COURSE->id . "&mode=outline";
$messagelink=$CFG->wwwroot . "/message/index.php?id=" . $user->id;
$percentage=0;
$percentage=(int)$this->get_completion_by_resource_list($ressource,$user->id);
foreach($ressource as $value){
$resource = new block_career_ressource();
$resource->get_ressource_by_id($value);
$resource_completion=0;
$resource_completion=$this->get_completion_by_resource($value,$user->id);
switch ($resource_completion) {
case 0:
$completionstate="state-0";
break;
case 1:
$completionstate="state-1";
break;
case 2:
$completionstate="state-2 ";
break;
case 2:
$completionstate="state-3";
break;
}
array_push($progress,array('namemodule'=>$resource->name,'id'=>$resource->id,'completionstate'=>$completionstate));
}
array_push($student,array('firstname'=>$user->firstname,'lastname'=>$user->lastname,'id'=>$user->id,'report_link'=>$reportlink,'message_link'=>$messagelink,'percentage'=>$percentage,'progress'=>$progress));
}
foreach($ressource as $value){
$resource = new block_career_ressource();
$resource->get_ressource_by_id($value);
$resource_completion=0;
$resource_completion=$this->get_completion_by_resource($value,$user->id);
switch ($resource_completion) {
case 0:
$completionstate="state-0";
break;
case 1:
$completionstate="state-1";
break;
case 2:
$completionstate="state-2 ";
break;
case 2:
$completionstate="state-3";
break;
}
array_push($progress,array('namemodule'=>$resource->name,'id'=>$resource->id,'completionstate'=>$completionstate));
array_push($module,array('name'=>$resource->name,'section'=>$resource->section->id));
}
array_push($student,array('firstname'=>$user->firstname,'lastname'=>$user->lastname,'id'=>$user->id,'report_link'=>$reportlink,'message_link'=>$messagelink,'percentage'=>$percentage,'progress'=>$progress));
}
foreach($ressource as $value){
$resource = new block_career_ressource();
$resource->get_ressource_by_id($value);
array_push($module,array('name'=>$resource->name,'section'=>$resource->section->id));
}
$list =['students'=>$student,'modules'=>$module,'progress'=>$progress,'track'=>$suivi,'path'=>$path,'isset'=>$isset];
$list =['students'=>$student,'modules'=>$module,'progress'=>$progress,'track'=>$suivi,'path'=>$path,'isset'=>$isset,'empty'=>$empty,'no_group'=>$no_group];
echo $this->render_from_template('block_career/career_table_tracker', $list);
}
}
<h2>{{list_title}}</h2>
<div class="alert alert-info">{{heading_plugin}}</div>
<a class="list-group-item list-group-item-action2" style='color: inherit' href='{{track_path}}'>
{{^empty}}<a class="list-group-item list-group-item-action2" style='color: inherit' href='{{track_path}}'>
<h2 class='' style='float: left'>Suivi des parcours</h2>
<div class='' style='clear: both'>
Vous trouverez ici le suivi des étudiants selon les différents parcours
</div>
</a><br>
</a><br>{{/empty}}
<div class="list-group">
{{#career_list}}
<a class="list-group-item list-group-item-action2" style='color: inherit' href='{{career_path}}''>
......
......@@ -12,14 +12,17 @@
</div>
<select class="custom-select mr-sm-2" id="path-select" name="pathfilter">
{{#path}}
<option value={{id}}>{{name}}</option>
<option {{selected}} value={{id}}>{{name}}</option>
{{/path}}
</select>
</div>
</form>
{{/isset}}
{{#empty}}
<br><div class="alert alert-info">{{no_group}}</div>
{{/empty}}
{{^empty}}
<table id="suivi">
<thead style ="height:100%;width:150%;overflow-x: hidden; ">
<tr id="modules">
......@@ -65,6 +68,8 @@
</tbody>
</table>
</div>
{{/empty}}
{{#js}}
require(['block_career/suivi'], function(module) {
module.registerFilters();
......
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