From 25fcd2d076b27c6ac9bbeefba8dd9a0dc6982af7 Mon Sep 17 00:00:00 2001 From: Myriam Delaruelle <Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr> Date: Fri, 15 Jan 2021 14:45:27 +0100 Subject: [PATCH] =?UTF-8?q?Bouton=20de=20suivi=20=C3=A9tudiant=20dans=20le?= =?UTF-8?q?=20header=20des=20sections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renderer.php | 76 +++++++++++++++++--------------------- styles.css | 8 ++-- templates/section.mustache | 19 ++++++++-- 3 files changed, 53 insertions(+), 50 deletions(-) diff --git a/renderer.php b/renderer.php index 138bcf6..c42167b 100644 --- a/renderer.php +++ b/renderer.php @@ -136,7 +136,7 @@ class format_iena_renderer extends format_topics_renderer{ * @param type|bool $iena * @return type */ - protected function get_section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false){ + protected function get_section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false, $groups=false){ global $PAGE, $CFG, $COURSE, $USER; $section_entity = new course_format_iena_sections(); @@ -170,8 +170,6 @@ class format_iena_renderer extends format_topics_renderer{ /* Paramètres */ $presence = ""; - - //$param_section = $section_entity->get_section_settings_by_id_section($section->id); $format = course_get_format($course); $param_section = (object)$format->get_format_options($section); @@ -188,12 +186,7 @@ class format_iena_renderer extends format_topics_renderer{ } if (isset($param_section->daterendu) && $param_section->daterendu != 0) { - //$section->dateUp = date_create($param_section->date_rendu); - $section->dateUp = new DateTime("@$param_section->daterendu"); - - //$section->dateUp = $unformattedDate; - $section->date = $section->dateUp->format("j/m H:i"); $section->date_jour = $section->dateUp->format("j/m"); $section->date_heure = $section->dateUp->format("H:i"); @@ -211,8 +204,22 @@ class format_iena_renderer extends format_topics_renderer{ $section->date = ""; } - if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id)) { - $section->link_param = $CFG->wwwroot . "/course/format/iena/param_section.php?courseid=" . $COURSE->id . "§ionid=" . $section->id; + //Bouton de suivi dans chaque section : si pas d'activités suivies on n'affiche pas le bouton + if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)) { + $ressources_entity = new course_format_iena_section_ressources(); + $modules = $ressources_entity->get_ressources_completion_on_by_id_section($section->id); + $nb_modules = count($modules); + if($nb_modules>0){ + //si trop d'étudiants on va afficher le premier groupe dans le suivi + if($this->count_students($context)>299 && count($groups)>0){ + $section->link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id . "§ionid=" . $section->id . "&groupid=".reset($groups)->id; + } + else{ + $section->link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id . "§ionid=" . $section->id . "&groupid=0"; + } + + } + } @@ -395,7 +402,7 @@ class format_iena_renderer extends format_topics_renderer{ // fin recommenté // $groups = []; - // var_dump($groups); + //$students_group = $course_format_iena_groups_instance->get_students_group($course->id); @@ -550,7 +557,6 @@ class format_iena_renderer extends format_topics_renderer{ // } else if ($tab_section_indicateur[$section_ligne->id] == NULL) { // $tab_section_indicateur[$section_ligne->id] = 0; // } - // // var_dump($tab_section_indicateur[$section_ligne->id]); // } // $tab_group_indicateur['id_groupe0']=$tab_section_indicateur; // $view = ""; @@ -704,11 +710,6 @@ class format_iena_renderer extends format_topics_renderer{ $view .= "<div class='iena-percent set_height'>" . $cpl->sections[$i]->completion . "%</div>"; } - - - - - // if ($compl_by_section != 999 && $completion->is_enabled()) { // $view .= "<div class=\"iena-percent set_height\"> // " . floor($compl_by_section) . "% @@ -716,25 +717,18 @@ class format_iena_renderer extends format_topics_renderer{ // } - - - - - - - - // if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { + + if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) { - + $course_groups = groups_get_all_groups($COURSE->id); - // var_dump($course_groups->id); $group_indicateur = 0; - $view .= "<a href='$link§ionid=".$idSection[$i]."' style=\"color : white\">"; - $view .="<div onclick='change_grouplink(this)' style=\"display:block;\" class=\"nb_pers set_height id_groupe0\">"; + $view .= "<a href='$link§ionid=".$idSection[$i]."style='color : white'>"; + $view .="<div onclick='change_grouplink(this)' style='display:block' class='nb_pers set_height id_groupe0'>"; $view .= "Suivi étudiants"; $view .= "</div>"; @@ -752,9 +746,6 @@ class format_iena_renderer extends format_topics_renderer{ // id_groupeXXX - // var_dump($course_groups); - - // var_dump($idSection[$i]); // foreach($tab_group_indicateur as $group_indicateur => $val) { // $view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height ".$group_indicateur."\">"; @@ -890,7 +881,7 @@ class format_iena_renderer extends format_topics_renderer{ echo $this->render_from_template('format_iena/course-header', $course_infos); $i = 0; - $link = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id; + //$link = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id; @@ -984,13 +975,14 @@ class format_iena_renderer extends format_topics_renderer{ - public function count_students(){ - $count = count_enrolled_users($COURSE->id); - echo "on compte les étudiants"; + public function count_students($context){ + $count = count_enrolled_users($context); return $count; } + + public function print_iena_section_pages($course){ global $PAGE, $USER; @@ -1026,7 +1018,6 @@ class format_iena_renderer extends format_topics_renderer{ $numsections = course_get_format($course)->get_last_section_number(); - // var_dump($numsections); // if ($section > $numsections) { // // if ($section > $course->numsections) { // // continue; @@ -1085,8 +1076,7 @@ class format_iena_renderer extends format_topics_renderer{ //A ce stade on à toutes les activité déja prête en HTML par contre il manque le nom des sections // Il se trouve dans : $thissection->name - //var_dump($htmlsection); - //var_dump($htmlsection0); + if ($PAGE->user_is_editing()) { // echo $completioninfo->display_help_icon(); echo $this->output->heading($this->page_title(), 2, 'accesshide'); @@ -1148,6 +1138,8 @@ class format_iena_renderer extends format_topics_renderer{ $context = context_course::instance($course->id); $course = course_get_format($course)->get_course(); $completion = new \completion_info($course); + $groups=groups_get_all_groups($course->id); + $modinfo = get_fast_modinfo($course); @@ -1170,7 +1162,6 @@ class format_iena_renderer extends format_topics_renderer{ - //var_dump($modinfo->get_section_info_all()); foreach($modinfo->get_section_info_all() as $section => $thissection){ if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', $context = context_course::instance($course->id), $USER->id))) { @@ -1178,8 +1169,7 @@ class format_iena_renderer extends format_topics_renderer{ continue; } if (!$thissection->available && !empty($thissection->availableinfo)) { - echo "par là"; - $thissection= $this->get_section_header($thissection, $course, false, 0); + $thissection= $this->get_section_header($thissection, $course, false, 0, $groups); continue; } @@ -1189,7 +1179,7 @@ class format_iena_renderer extends format_topics_renderer{ continue; } } - $thissection=$this->get_section_header($thissection, $course, false, 0, true); + $thissection=$this->get_section_header($thissection, $course, false, 0, true, $groups); if ($thissection->uservisible) { diff --git a/styles.css b/styles.css index 75ea60f..8ab2e49 100644 --- a/styles.css +++ b/styles.css @@ -178,10 +178,12 @@ ul.nav.navbar-nav.ml-auto { float: right; min-width: 4rem; padding: .6rem .6rem; - font-size: 1rem; + font-size: 14px ; border-radius: 5px; - margin-top: 0.4rem; - margin-right: 0.4rem; + margin-top: 0.35rem; + line-height: 0.5rem; + margin-right: .4rem; + margin-left: .4rem; } .nb_pers a { color: white; diff --git a/templates/section.mustache b/templates/section.mustache index ed51bec..e210fec 100644 --- a/templates/section.mustache +++ b/templates/section.mustache @@ -15,13 +15,24 @@ {{string_date}} </div> {{/string_date}} - {{#link_param}} - <div class="titre_section set_height"> + + {{#link_suivi}} + <a href='{{link_suivi}}' style='color : white'> + <div style="display:block;" class="nb_pers set_height id_groupe0">Suivi étudiant</div> + + </a> + {{/link_suivi}} + <!-- Not used anymore : c'était pour le formulaire avant--> + {{! #link_param}} + <!-- <div class="titre_section set_height"> <a href={{link_param}} style="color : white"> <i class="fa fa-cog " aria-hidden="true" ></i> </a> - </div> - {{/link_param}} + </div>--> + {{! /link_param}} + + + </div> </div> -- GitLab