Skip to content
Snippets Groups Projects
Commit 39bc2da5 authored by DELARUELLE Myriam's avatar DELARUELLE Myriam
Browse files

helper class for tracking table

parent 25e2c9fc
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,6 @@ class content extends content_base {
$course_data['student']=true;
}
$summary = file_rewrite_pluginfile_urls($COURSE->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$course_data['summary']=$summary;
//$course_data['summary']=$COURSE->summary;
$course_data['enableclickicons']=$formatoptions['enableclickicons'];
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
* course_format_iena_sections
*
* @package format_iena
* @copyright 2018 Softia/Université lorraine
* @author Thomas Fradet
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_format_iena_helper {
/**
* @param $idcourse
* @return array
* @throws dml_exception
*/
public function get_activities($completion, $activesectionid) {
$activities = $completion->get_activities();
$modules = [];
foreach ($activities as $activity) {
$module = new StdClass();
$module->id = $activity->id;
$module->name = $activity->name;
$displayname = format_string($activity->name, true, array('context' => $activity->context));
$module->displayname = strlen($displayname) > 50 ? mb_substr($displayname, 0, 49, 'UTF-8').'…' : $displayname;
$module->section = $activity->section;
if($activity->get_url()){
$module->link=$activity->get_url()->out();
}
$modules[] = $module;
if ($activity->section == $activesectionid || $activesectionid == 0 ) {
$module->visible = true;
} else {
$module->visible = false;
}
}
return $modules;
}
public function get_groups($groups) {
global $USER, $COURSE;
// Groupe du GET provenant du sélecteur de la page du cours
// ou premier groupe de l'utilisateur, ou groupe 0 (tous les groupes).
$groupsall = new StdClass();
// TODO à supprimer si pas utilisé dans le JS (mettre dans la clause IF pour éviter un appel inutile si le GET existe).
$currentusergroupsids = groups_get_user_groups($COURSE->id, $USER->id)[0];
$currentusergroups = [];
$othergroups = [];
// Si pas de groupe dans le get ou groupe 0 (tous) mais pas le droit => premier groupe existant du user ou groupe 0 (tous).
// Groupes du cours avec id, nom et liste des id utilisateur de tous les
// membres (3 clefs d'un tableau de groupes : id, name, member).
$activegroupname = "";
foreach ($groups as $group) {
if (in_array($group->id, $currentusergroupsids)) {
$currentusergroups[] = $group;
} else {
$othergroups[] = $group;
}
}
$groupsall->othergroups = $othergroups;
$groupsall->current_user_groups = $currentusergroups;
return $groupsall;
}
public function get_sections($activesectionid){
global $COURSE;
// Liste des sections du cours.
$modinfo = get_fast_modinfo($COURSE->id);
$sectionsinfoall = $modinfo->get_section_info_all();
$sections = [];
foreach ($sectionsinfoall as $key => $sectioninfo) {
$section = new StdClass();
$section->id = $sectioninfo->id;
$section->name = $sectioninfo->name === null || $sectioninfo->name === '' ? 'Section ' . $key : $sectioninfo->name;
if ($section->id == $activesectionid) {
$section->selected = "selected";
}
$sections[] = $section;
}
return $sections;
}
public function set_data($data, $modules, $progress, $groups, $activegroupsids, $activesectionid, $listoptions) {
global $COURSE, $USER, $CFG;
$data["modules"] = $modules;;
$countmodules = count($data["modules"]);
$data["students"] = $this->format_progress($progress, $modules, $groups, $activegroupsids, $activesectionid);
$countstudents = count($data["students"]);
if ($countstudents > 0 && $countmodules > 0) {
$data['count_results'] = count($data["students"]);
}
if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id)) {
$data['link_bulkcompletion'] = $CFG->wwwroot . "/course/bulkcompletion.php?id=" . $COURSE->id;
}
$data['link_classicview'] = $CFG->wwwroot . "/report/progress/index.php?course=" . $COURSE->id;
$data['link_editview']=$CFG->wwwroot . "/course/format/iena/suivi_edit.php?courseid=" . $COURSE->id;
if($listoptions->listoptions['display_groups']["value"]){
$data["display_groups"]=1;
}
if($listoptions->listoptions['display_details']["value"]){
$data["display_details"]=1;
}
// Pour le téléchargement du tableau ?
/*if (!isset($data['data'])) {
$data['data'] = array();
}
$data['data'] = json_encode($data);*/
return $data;
}
public function format_progress($progress, $modules, $groups, $activegroupids, $activesectionid) {
global $CFG, $COURSE;
$students = array();
foreach ($progress as $proginfo) {
$progressstudent = new StdClass();
$progressstudent->firstname = $proginfo->firstname;
$progressstudent->lastname = $proginfo->lastname;
$progressstudent->id = $proginfo->id;
$progressstudent->email = $proginfo->email;
$progressstudent->progress = array();
$progressstudent->report_link = $CFG->wwwroot . "/report/outline/user.php?id=" .
$progressstudent->id . "&course=" . $COURSE->id . "&mode=outline";
$progressstudent->message_link = $CFG->wwwroot . "/message/index.php?id=" . $progressstudent->id;
//var_dump($progressstudent);
//if ($activegroupid == 0) {
$progressstudent->groups = "";
$progressstudent->groupsid=array();
foreach ($groups as $group) {
if (in_array($progressstudent->id, $group->members)) {
if(empty( $progressstudent->groups)){
$progressstudent->groups .= $group->name . "";
}
else{
$progressstudent->groups .= ", " .$group->name . " ";
}
array_push( $progressstudent->groupsid, $group->id);
}
}
//}
foreach ($modules as $key => $module) {
$moduleprogress = new StdClass();
if (!isset($proginfo->progress[$module->id])) {
$moduleprogress->completionstate = '0';
} else {
$moduleprogress->completionstate = $proginfo->progress[$module->id]->completionstate;
}
$moduleprogress->namemodule = $module->name;
$moduleprogress->idmodule = $module->id;
$progressstudent->progress[$key] = $moduleprogress;
}
//On a les données de tous les étudiants, c'est ici qu'on filtre selon le groupe actif - DEPRECATED
/*if ($activegroupid == 0 || ($activegroupid>0 && in_array($activegroupid, $progressstudent->groupsid))) {
$students[] = $progressstudent;
}*/
$students[] = $progressstudent;
}
return $students;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment