Commit 0ab50c51 authored by Myriam Delaruelle's avatar Myriam Delaruelle
Browse files

fix selector my groups

parent bc69c4d7
......@@ -93,14 +93,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
function changeGroup(){
completeUrl=getCompleteUrl();
loadMessage("loading");
console.log(completeUrl);
$.ajax({ url: completeUrl,
data: {action: 'test'},
type: 'post',
success: function(request) {
console.log("wat");
console.log(JSON.parse(request));
data=calcPercentage(JSON.parse(request));
changeCompletion();
//changeCompletion();
changeSection();
//reloadTable(JSON.parse(request));
}
});
......
......@@ -56,23 +56,26 @@ function init_page($course){
function get_groups($context, $active_group_id, $progress, $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). */
$groups_all=new StdClass();
// @TODO à supprimer si pas utilisé dans le JS (mettre dans la clause IF pour éviter un appel inutile si le GET existe)
$current_user_groups_ids=array();
$current_user_groups_ids = groups_get_user_groups($COURSE->id, $USER->id)[0];
$current_user_groups=[];
$other_groups=[];
/* Si pas de groupe dans le get ou groupe 0 (tous) mais pas le droit => premier groupe existant du user ou groupe 0 (tous) */
if ($active_group_id == NULL || ($active_group_id == 0 && !has_capability('course/iena:suivi_edit', $context, $USER->id)) ) {
if ( count($current_user_groups_ids) == 0 ) {
$active_group_id = 0;
} else {
$current_user_groups_ids = groups_get_user_groups($COURSE->id, $USER->id)[0];
$active_group_id = $current_user_groups_ids[0];
}
}
/* 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) */
$current_user_groups = [];
//$current_user_groups = [];
$active_group_name = "";
foreach ($groups as $group) {
......@@ -86,6 +89,9 @@ function get_groups($context, $active_group_id, $progress, $groups){
if ( $group->id == $ugi ) {
$current_user_groups[] = $group;
}
else{
$other_groups[]=$group;
}
}
}
......@@ -102,7 +108,9 @@ function get_groups($context, $active_group_id, $progress, $groups){
}
}
}*/
return $groups;
$groups_all->groups=$other_groups;
$groups_all->current_user_groups=$current_user_groups;
return $groups_all;
}
......@@ -157,6 +165,7 @@ function format_progress($progress, $modules, $groups, $active_group_id, $active
$students[]=$progress_student;
}
return $students;
}
......@@ -398,6 +407,7 @@ if ( $active_group_id == 0 ) {
echo $view->get_content($usersID);
} else */
if(isset($_POST['action']) && !empty($_POST['action'])) {
//Si on change les filtres
$data=[];
$modules=get_activities($completion, $active_section_id);
......@@ -414,16 +424,25 @@ else {
$data=[];
$modules=get_activities($completion, $active_section_id);
$groups=get_groups($context, $active_group_id, $progress, $groups);
$groups_all=get_groups($context, $active_group_id, $progress, $groups);
if(isset($groups_all->current_user_groups) && !empty($groups_all->current_user_groups)){
$current_user_groups=$groups_all->current_user_groups;
}
$groups=$groups_all->groups;
$sections=get_sections($active_section_id);
$data=set_filters($data, $filters, $symbols, $sections, $groups, $current_user_groups, $active_group_name, $active_section_id);
$data=set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id);
if(isset($_GET["msg_success"])){
$msg=$_GET["msg_success"];
$data["msg_success"]=$msg;
}
$renderer = $PAGE->get_renderer('format_iena');
$renderer->display_completion($data);
echo $OUTPUT->footer();
}
......
Supports Markdown
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