Skip to content
Snippets Groups Projects
Commit 3efc8022 authored by Lea's avatar Lea
Browse files

complete tracker features

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