From 80d9448c35c503708efe68b55ccb3a76b6139ca8 Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle
 <Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr>
Date: Tue, 23 Mar 2021 09:53:23 +0100
Subject: [PATCH] Template et ergonomie messages

---
 amd/build/suivi.js                        | 101 ++++-
 entity/course_format_iena_message.php     |  95 +++++
 format.js                                 |   2 +-
 lang/en/format_iena.php                   |   1 +
 lang/fr/format_iena.php                   |   2 +-
 renderer.php                              | 455 +---------------------
 send_message_post.php => send_message.php | 308 +++++++++------
 suivi_unit.php                            | 112 +++---
 templates/send-message.mustache           |  23 ++
 templates/suivi-table.mustache            |  44 ++-
 templates/suivi.mustache                  |  10 +-
 view/view_send_message.php                |   1 +
 12 files changed, 492 insertions(+), 662 deletions(-)
 create mode 100644 entity/course_format_iena_message.php
 rename send_message_post.php => send_message.php (50%)
 create mode 100644 templates/send-message.mustache

diff --git a/amd/build/suivi.js b/amd/build/suivi.js
index 7132217..3f66cf0 100644
--- a/amd/build/suivi.js
+++ b/amd/build/suivi.js
@@ -29,7 +29,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
        		registerFilters:function(){
        			
 	    		$("#group-select").on('change', function(e){
-	    			changeFilter(e, 'group');
+	    			changeGroup();
 	    		});
 	    		
        		},
@@ -42,8 +42,16 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 	    		$("#section-select").on('change', function(){
 	    			changeSection();
 	    		});
+	    		$("#filter-select").on('change', function(){
+	    			changeCompletion();
+	    		});
+	    		$("#symbol-select").on('change', function(){
+	    			changeCompletion();
+	    		});
 	    		
-	    		calcPercentage(data);
+	    		changeSection();
+	    		/*calcPercentage(data);
+	    		changeCompletion();*/
        		}
        		
 
@@ -57,6 +65,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     	courseid=urlParams.get('courseid');
     	groupid=$("#group-select").val();
     	sectionid=$("#section-select").val();
+    	filter=$("#symbol-select").val() + $("#filter-select").val();
     	completeUrl='suivi_unit.php?courseid='+courseid;
     	if(sectionid){
     		completeUrl+='&sectionid='+sectionid;
@@ -64,29 +73,69 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     	if(groupid){
     		completeUrl+="&groupid="+groupid;
     	}
+    	if(filter){
+    		completeUrl+="&filter="+filter;
+    	}
     	return completeUrl;
     }
 
-    function changeFilter(e, list){
+    function changeGroup(){
     	completeUrl=getCompleteUrl();
     	loadMessage("loading");
     	$.ajax({ url: completeUrl,
         	data: {action: 'test'},
         	type: 'post',
         	success: function(request) { 
-
-        		calcPercentage(JSON.parse(request));
-
+        		console.log(JSON.parse(request));
+        		
+        		data=calcPercentage(JSON.parse(request));
+        		changeCompletion();
          		//reloadTable(JSON.parse(request));	
 			}
 		});
     }
 
+  
     function changeCompletion(){
+    	console.log(data);
     	symbol=$("#symbol-select").val();
     	filter=$("#filter-select").val();
+    	data.count_results=0;
+    	for(var i=0; i<data.students.length; i++){
+    		if(symbol=="<"){
+    			if(data.students[i].percentage <= filter){
+    				data.count_results++;
+    				data.students[i].visible=true;
+    			}
+    			else{
+					data.students[i].visible=false;
+    			}
+    		}
+    		else if(symbol==">"){
+    			if(data.students[i].percentage >= filter){
+    				data.count_results++;
+    				data.students[i].visible=true;
+    			}
+    			else{
+					data.students[i].visible=false;
+    			}
+    		}
+    		else{
+    			if(data.students[i].percentage == filter){
+    				data.count_results++;
+    				data.students[i].visible=true;
+    			}
+    			else{
+					data.students[i].visible=false;
+    			}
+    		}
+    		
+    	}
+    	reloadTable(data);
     }
 
+    //on va devoir calculer le pourcentage, check la completion et reload la table à chaque fois
+
     function changeSection(){
     	loadMessage("loading");
     	sectionid=$("#section-select").val();
@@ -95,7 +144,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     		if(data.modules[i].section == sectionid || sectionid == 0){
     			data.modules[i].visible=true;
     			data.count_results++;
-    			console.log("on met les rés à true");
     			for(var j = 0; j<data.students.length; j++){
     				var prog=data.students[j].progress.find(progress => progress.idmodule === data.modules[i].id);
 					prog.visible=true;
@@ -110,11 +158,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     	}
     	
     	if(data.count_results==0){
-    		console.log("pas de résultats");
     		reloadTable(data);
     	}
     	else{
-    		calcPercentage(data);
+    		data=calcPercentage(data);
+    		changeCompletion();
+    		//reloadTable(data);
     	}
 
     	
@@ -138,6 +187,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     }
 
     function reloadTable(params){
+    	console.log(params);
     	url=getCompleteUrl();
     	templates.render('format_iena/suivi-table', params)
      	.done(function(html, js){
@@ -166,12 +216,31 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 
 	}
 
-
+	//Si on veut envoyer un message à tout le monde on ajoute deux champs cachés :
+	//La liste des étudiants (array d'id)
+	//L'url de retour pour revenir sur le tableau de suivi
 	function triggerAction(e){
 		value=$("#select-actions-suivi-iena").val();
 		
 		if(value=="msg"){
-			console.log("on va envoyer un message");
+			url=window.location.search;
+    		urlParams = new URLSearchParams(url);
+    		courseid=urlParams.get('courseid');
+			students=getSelectedStudents();
+			var form=$("#form_send_message_iena");
+			form.attr("action", "send_message.php?courseid="+courseid);
+			var field=$("<input></input>");
+			field.attr("type", "hidden");
+        	field.attr("name", "students");
+        	field.attr("value", students.toString());
+        	form.append(field);
+        	var fieldUrl=$("<input></input>");
+			fieldUrl.attr("type", "hidden");
+        	fieldUrl.attr("name", "back_url");
+        	fieldUrl.attr("value", url);
+        	form.append(fieldUrl);
+        	$(document.body).append(form);
+    		form.submit();
 		}
 		else if(value=="download"){
 			table_download(data);
@@ -197,6 +266,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 
 
 	function table_download() {
+		
 		var students=getSelectedStudents();
 		var csvContent = "data:text/csv;charset=utf-8,";
 		var head = ['Moodle_id', 'Prénom', 'Nom', 'Groupe', 'Complétion (en %)'];
@@ -215,7 +285,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 		/* Pour chaque étudiant */
 		
 		for ( var s = 0; s < data.students.length; s++ ) {
-			
 			if(students.includes(data.students[s].id)){
 				var arr_cpl = [];
 
@@ -230,8 +299,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 					if ( data.active_section_id != data.modules[mod].section && data.active_section_id != 0 ) {
 						continue;
 					}
-					
-
 					var stud_progress = data.students[s].progress
 					/* Si l'étudiant n'a pas de progres*/
 					if ( stud_progress.length == 0 ) {
@@ -308,6 +375,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 
 	//Pour chaque module non caché, on va regarder pour chaque étudiant 
 	function calcPercentage(data){
+		console.log(data);
 		for (var i = 0; i < data.students.length; i++) {
 			data.students[i].percentage=0;
 			var done=0;
@@ -318,13 +386,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 					if(data.students[i].progress[j].completionstate == 1 || data.students[i].progress[j].completionstate ==2){
 						done++;
 					}
-					
 				}
 			}
-			
 			data.students[i].percentage=Math.floor(100 * done / nb_modules);
 		}
-		reloadTable(data);
+		return data;
+		//reloadTable(data);
 	}
 
 
diff --git a/entity/course_format_iena_message.php b/entity/course_format_iena_message.php
new file mode 100644
index 0000000..9ad8fe7
--- /dev/null
+++ b/entity/course_format_iena_message.php
@@ -0,0 +1,95 @@
+<?php
+	/**
+	 * Created by PhpStorm.
+	 * User: softia
+	 * Date: 13/03/18
+	 * Time: 11:26
+	 */
+
+// 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
+	 * @category   format
+	 * @copyright  2021 Softia/Université lorraine
+	 * @author     Delaruelle Myriam
+	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+	 */
+
+	require_once("{$CFG->libdir}/formslib.php");
+
+
+	class course_format_iena_message extends moodleform
+	{
+		public function definition()
+		{
+			// TODO: Implement definition() method.
+		
+			$mform = $this->_form; // Don't forget the underscore!
+
+			$description = "";
+			
+			$mform->addElement('editor', 'summary', get_string('summary', 'format_iena'));
+			$mform->setType('summary', PARAM_RAW);
+			$mform->addRule('summary', get_string('error'), 'required', null, null, false, false);
+			$mform->setDefault('summary', array('text' => $description));
+			$mform->addElement('hidden', 'back_url', '');
+			$mform->setType('back_url', PARAM_TEXT);
+			$mform->setDefault('back_url', $this->_customdata['back_url']);
+			$mform->addElement('hidden', 'students', '');
+			$mform->setType('students', PARAM_TEXT);
+			$mform->setDefault('students', $this->_customdata['students']);
+
+			$this->add_action_buttons(true, "Envoyer");
+			
+			
+		}
+		
+		public function get_content($usersID){
+
+			global $DB, $CFG, $COURSE;
+			$data=new stdClass();
+			$nb = $usersID != "" ? count( explode(",", $usersID) ) : 0;
+
+			if ( $nb == 0 ) {
+				$data->nb_results=0;
+				
+			} else {
+				
+				$data->nb_results=$nb;
+				$data->users_id=$usersID;
+				$courseID = required_param('courseid', PARAM_INT);
+				$data->link_cancel= $CFG->wwwroot . "/course/view.php?id=" . $courseID;;
+				$mform = $this->_form;
+				$description = "";
+				
+				$mform->addElement('editor', 'summary', get_string('summary', 'format_iena'));
+				$mform->setType('summary', PARAM_RAW);
+				$mform->addRule('summary', get_string('error'), 'required', null, null, false, false);
+				$mform->setDefault('summary', array('text' => $description));
+				$this->add_action_buttons(true, "Envoyer");
+				
+				$data->form=$this->render();
+
+			}
+			
+			return $data;
+			
+		}
+	}
\ No newline at end of file
diff --git a/format.js b/format.js
index 90f3764..ab865fc 100644
--- a/format.js
+++ b/format.js
@@ -76,7 +76,7 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
     $('.section').find('a[href="#"].voir-plus').on('click', function (e) {
         e.preventDefault();
         this.expand = !this.expand;
-        $(this).text(this.expand?"Réduire la description":"Voir la description compléte");
+        $(this).text(this.expand?"Réduire la description":"Voir la description complète");
         $(this).closest('.section').find('.small, .big').toggleClass('small big');
     });
 }(jQuery));
\ No newline at end of file
diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php
index f497669..e898204 100644
--- a/lang/en/format_iena.php
+++ b/lang/en/format_iena.php
@@ -89,5 +89,6 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$string['status1']="Activity completed";
 	$string['status2']="Activity completed and passed";
 	$string['status3']="Activity completed but not passed";
+	$string["send_message_title"]="Sending a message to {{nb_results}} people";
 
 
diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php
index 29d7439..8e69a21 100644
--- a/lang/fr/format_iena.php
+++ b/lang/fr/format_iena.php
@@ -89,5 +89,5 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$string['status1']="Activité complétée";
 	$string['status2']="Activité complétée au dessus de la note";
 	$string['status3']="Activité complétée en dessous de la note";
-
+	$string["send_message_title"]="Envoi d'un message à {{nb_results}} personnes";
 
diff --git a/renderer.php b/renderer.php
index 23fcb3c..f4bc8b8 100644
--- a/renderer.php
+++ b/renderer.php
@@ -134,6 +134,7 @@ class format_iena_renderer extends format_topics_renderer{
 	 * @param type $onsectionpage 
 	 * @param type|null $sectionreturn 
 	 * @param type|bool $iena 
+	 * @param type $groups
 	 * @return type
 	 */
 	protected function get_section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false, $groups=false){
@@ -294,8 +295,7 @@ class format_iena_renderer extends format_topics_renderer{
 		return $o;
 	}
 
-	public function get_completion_by_section($idSection)
-	{
+	public function get_completion_by_section($idSection){
 		global $COURSE, $USER;
 		$ressources_entity = new course_format_iena_section_ressources();
 		$section_entity = new course_format_iena_sections();
@@ -320,250 +320,11 @@ class format_iena_renderer extends format_topics_renderer{
 		return array($modules, $valueTotal);
 	}
 
-	public function is_student($userId) {
-		// do NOT trust this method
-		global $COURSE;
-		$course_ctx = context_course::instance($COURSE->id);
-		foreach (get_user_roles($course_ctx, $userId) as $role) {
-			if ($role->shortname == 'student') {
-				return true;
-			}
-		}
-	}
 
-	public function get_render_competences($diSection){
-		global $DB, $COURSE, $CFG, $USER;
-		$section_entity = new course_format_iena_section_ressources();
-		$modules = $section_entity->get_ressources_by_id_section($diSection);
-		$id_competence = array();
-		foreach ($modules as $module) {
-			$comp_module = $DB->get_records('competency_modulecomp', array('cmid' => $module->id));
-			if ($comp_module) {
-				foreach ($comp_module as $comp){
-					$id_competence[$comp->id] = $comp->competencyid;
-				}
-			}
-		}
-		$competences = array();
-		foreach ($id_competence as $val) {
-			$req = $DB->get_record('competency', array('id' => $val));
-			$competences[$val] = $req->shortname;
-		}
-		if (count($competences) == 0) {
-			return "";
-		}
-		$render = false;
-		$render .= "
-		<div class=\"dropdown d-inline\">
-		<a href=\"#\" class=\"dropdown-toggle\" id=\"dropdown-2\" title=\"Actions\" role=\"button\" data-toggle=\"dropdown\"
-		aria-haspopup=\"true\" aria-expanded=\"false\" style=\"color : white\">
-		<i class=\"fa fa-lightbulb-o\" aria-hidden=\"true\"></i>
-		</a>
-		<div class=\"dropdown-menu dropdown- dropdown-menu-right menu align-tr-br\" id=\"action-menu-2-menu\" data-rel=\"menu-content\"
-		aria-labelledby=\"action-menu-toggle-2\" role=\"menu\" data-align=\"tr-br\">
-		<div class=\"contenu\">
-		<div class='centered'>
-		<h3>Compétences</h3>
-
-		</div>
-		<ul class='bulle'>
-		";
-		foreach ($competences as $key => $competence) {
-			$render .= "<li><a href='" . $CFG->wwwroot . "/admin/tool/lp/user_competency_in_course.php?courseid=" . $COURSE->id .
-			"&competencyid=" . $key . "&userid=" . $USER->id . "'> $competence </a></li>";
-		}
-		$render .= "
-		</ul>
-		<div class='centered'>
-		<a href ='" . $CFG->wwwroot . "/admin/tool/lp/coursecompetencies.php?courseid=" . $COURSE->id . "'>
-		<button class='btn  btn-sm  btn_blue' >Compétence du cours</button></a>
-		</div>
-
-		</div>
-		</div>
-		</div>";
-
-		return $render;
-	}
-
-	public function get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection)
-	{
+	public function get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection){
 		global $CFG, $COURSE, $USER;
 		$section_entity = new course_format_iena_sections();
 
-		//recommenté
-		// $course_sections_instance = new course_format_iena_section_ressources();
-
-		// $course_sections = new course_format_iena_sections();
-		// $liste_sections = $course_sections->get_sections_by_id_course($COURSE->id);
-
-		// $course_format_iena_groups_instance = new course_format_iena_groups();
-		// $groups = $course_format_iena_groups_instance->get_groups_by_id_course($COURSE->id);
-		// fin recommenté
-
-		// $groups = [];
-
-		//$students_group = $course_format_iena_groups_instance->get_students_group($course->id);
-
-
-		// COUPE ICI
-
-
-
-		// $tab_group_indicateur = array();
-
-		// foreach($groups as $group)
-		// {
-		// 	$tab_student_completion = array();
-		// 	$tab_section_indicateur = array();
-		// 	foreach ($liste_sections as $section_ligne)
-		// 	{
-		// 		//get modules for one section
-		// 		$modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id);
-
-		// 		// if rows is empty in BDD => check count modules of student
-		// 		// hide => cm (course module (activity) is linked to a section indicator)
-		// 		// $nb_modules => numbre of activities linked to this section indicator
-		// 		$nb_modules = 0;
-		// 		foreach ($modules_states_section as $mod) {
-		// 			if ($mod->hide == 1) {
-		// 				$nb_modules++;
-		// 			}
-		// 		}
-
-		// 		// Count each student of group who as not all validate in section
-		// 		foreach ($group->list_userid as $student)
-		// 		{
-		// 			// si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître
-		// 			if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->userid)) {
-		// 				continue;
-		// 			}
-		// 			//retrieving the student's module completion chart for this course (then check if module in section)
-		// 			// $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->userid, $COURSE->id);
-		// 			$tab_student_completion = NULL;
-
-
-		// 			// if no info completion of student is not in BDD
-		// 			if (empty($tab_student_completion)) {
-		// 				$indicateur = 1;
-		// 			} else {
-		// 				$compteur = 0;
-		// 				foreach ($modules_states_section as $mod) {
-		// 					if ($mod->hide == 1) {
-		// 						$break_one = 0;
-		// 						foreach ($tab_student_completion as $module_completion) {
-		// 							if ($module_completion->coursemoduleid == $mod->cmid) {
-		// 								$compteur++;
-		// 								if ($module_completion->completionstate == 0) {
-		// 									$indicateur = 1;
-		// 									$break_one = 1;
-		// 									break;
-		// 								} else {
-		// 									$indicateur = 0;
-		// 								}
-		// 							}
-		// 						}
-		// 						if ($break_one == 1) {
-		// 							break;
-		// 						}
-		// 					}
-		// 				}
-		// 				if ($compteur < $nb_modules) {
-		// 					if ($indicateur == 0) {
-		// 						$indicateur = 1;
-		// 					}
-		// 				}
-		// 			}
-
-		// 			if ($this->is_student($student->userid) !== true) {
-		// 				$indicateur = 0;
-		// 			}
-
-		// 			$tab_section_indicateur[$section_ligne->id] += $indicateur;
-
-		// 		}
-
-		// 		if ($nb_modules == 0) {
-		// 			$tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id&sectionid=$section_ligne->id\">-</a>";
-		// 		} else if ($tab_section_indicateur[$section_ligne->id] == NULL) {
-		// 			$tab_section_indicateur[$section_ligne->id] = 0;
-		// 		}
-		// 	}
-		// 	$tab_group_indicateur[$group->idnumber] = $tab_section_indicateur;
-
-		// }
-
-		// $course_ctx = context_course::instance($COURSE->id);
-		// $students = get_enrolled_users($course_ctx, 'mod/assignment:submit', 0);
-		// $tab_student_completion = array();
-		// $tab_section_indicateur = array();
-		// foreach ($liste_sections as $section_ligne) {
-		// 	//retrieves modules for a section
-		// 	$modules_states_section = $course_sections->get_hidden_modules_by_section($section_ligne->id);
-
-		// 	// if empty lines in the DB => check student module counter
-		// 	$nb_modules = 0;
-		// 	foreach ($modules_states_section as $mod) {
-		// 		if ($mod->hide == 1) {
-		// 			$nb_modules++;
-		// 		}
-		// 	}
-
-		// 	// Count each student in the course who has not validated everything in the
-		// 	foreach ($students as $student) {
-		// 		// si le user peut consulter le suivi, il n'est pas étudiant et ne doit pas y apparaître
-		// 		if (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $student->id)) {
-		// 			continue;
-		// 		}
-		// 		//retrieving the student's module completion chart for this course (then check if module in section)
-		// 		// $tab_student_completion = $course_sections_instance->get_completions_by_userid($student->id, $COURSE->id);
-		// 		$tab_student_completion = NULL;
-
-		// 		// if no student completion information is in the database
-		// 		if (empty($tab_student_completion)) {
-		// 			$indicateur = 1;
-		// 		} else {
-		// 			$compteur = 0;
-		// 			foreach ($modules_states_section as $mod) {
-		// 				if ($mod->hide == 1) {
-		// 					$break_one = 0;
-		// 					foreach ($tab_student_completion as $module_completion) {
-		// 						if ($module_completion->coursemoduleid == $mod->cmid) {
-		// 							$compteur++;
-		// 							if ($module_completion->completionstate == 0) {
-		// 								$indicateur = 1;
-		// 								$break_one = 1;
-		// 								break;
-		// 							} else {
-		// 								$indicateur = 0;
-		// 							}
-		// 						}
-		// 					}
-		// 					if ($break_one == 1) {
-		// 						break;
-		// 					}
-		// 				}
-		// 			}
-		// 			if ($compteur < $nb_modules) {
-		// 				if ($indicateur == 0) {
-		// 					$indicateur = 1;
-		// 				}
-		// 			}
-		// 		}
-		// 		$tab_section_indicateur[$section_ligne->id] += $indicateur;
-		// 	}
-		// 	if ($nb_modules == 0) {
-		// 		$tab_section_indicateur[$section_ligne->id] = "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id&sectionid=$section_ligne->id\">-</a>";
-		// 	} else if ($tab_section_indicateur[$section_ligne->id] == NULL) {
-		// 		$tab_section_indicateur[$section_ligne->id] = 0;
-		// 	}
-		// }
-		// $tab_group_indicateur['id_groupe0']=$tab_section_indicateur;
-		// $view = "";
-
-
-
-		// COUPE ICI
 		
 
 		// nouvelle génération du header
@@ -704,22 +465,10 @@ class format_iena_renderer extends format_topics_renderer{
 			<div class=\"card card_block\">
 			<div class=\"heading-iena set_height\">";
 
-
-			//&& !has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) 
 			if ( $cpl != false && count($cpl->sections[$i]->modules) > 0 && !has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)) {
 				$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) . "%
-			// 	</div>";
-			// }
-
-
-			// 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) {
 			
 
@@ -731,33 +480,9 @@ class format_iena_renderer extends format_topics_renderer{
 				$view .="<div onclick='change_grouplink(this)' style='display:block' class='nb_pers set_height id_groupe0'>";
 				$view .= "Suivi étudiants";
 				$view .= "</div>";
-
-				/*foreach ($course_groups as $group) {
-					$view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height id_groupe".$group->id."\">";
-					$view .= "Suivi étudiants";
-					$view .= "</div>";
-				}*/
 				$view .="</a>";
 				
-				// if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) {
-				// 	$view .= "<a href=\"$CFG->wwwroot/course/format/iena/param_indicateur.php?courseid=$COURSE->id&sectionid=$idSection[$i]\" class=\"set_height\" style=\"color: white;float: left;line-height: 4rem;margin-left: 1rem;\">Editer suivi</a>";
-				// }
-
-
-				// id_groupeXXX
-
-
-				// foreach($tab_group_indicateur as $group_indicateur => $val) {
-				// 	$view .="<div onclick='change_grouplink(this)' style=\"display:none;\" class=\"nb_pers set_height ".$group_indicateur."\">";
-				// 	foreach ($val as $key => $value) {
-				// 		if ($idSection[$i] == $key) {
-				// 			$view .= $value;
-				// 		}
-				// 	}
-				// 	$view .= "</div>";
-				// }
-
-				// $view .="</a>";
+				
 			}
 
 
@@ -810,7 +535,7 @@ class format_iena_renderer extends format_topics_renderer{
 					</div>";
 				}
 			}
-			// $cpt = $this->get_render_competences($idSection[$i]);
+			
 			$cpt = "";
 			if ($cpt != "") {
 				$view .= "
@@ -836,18 +561,7 @@ class format_iena_renderer extends format_topics_renderer{
 			";
 			$view .= "<div class=\"wrapper section\">";
 			$view .= $sectionIntro;
-			// à présent géré au niveau de la génération du header de section par la méthode dédiée
-			// if (strpos($sectionIntro, "</p>")) {
-			// 	$view .= "<div class=\"iena-description\">";
-			// 	$view .= "
-			// 	<div class=\"small\">
-			// 	$sectionIntro
-			// 	</div>
-			// 	</div>
-			// 	<a href=\"#\">Voir la description complète</a>
-			// 	";
-			// 	$view .= "</div>";
-			// }
+			
 			$view .= "<div class=\"wrapper\">
 			$section
 			</div >
@@ -860,8 +574,8 @@ class format_iena_renderer extends format_topics_renderer{
 		return $view;
 	}
 
-	public function get_view_iena_new($course,$nameSection, $idSection)
-	{
+	//
+	public function get_view_iena_new($course,$nameSection, $idSection){
 		global $CFG, $COURSE, $USER;
 		$section_entity = new course_format_iena_sections();
 
@@ -880,96 +594,6 @@ 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;
-
-
-
-
-		$view .= "<!-- <script defer src=\"https://use.fontawesome.com/releases/v5.0.8/js/all.js\"></script>  -->
-		<style>
-
-		/*
-		style for clean page
-		*/
-
-		/* [BOOST] : course header */
-		#page-header .card {
-					border: none;
-				}
-		#page-header .card-body {
-				padding-left: 0;
-			}
-			/* [BOOST] : left nav */
-		#nav-drawer,
-			[data-region='drawer'] {
-				background-color: #fff;
-			}
-		#nav-drawer .list-group-item {
-			border: 1px solid #ffffff;
-		}
-		#nav-drawer .list-group-item:hover {
-		background-color: #e7e9ea;
-		}
-		#nav-drawer .list-group-item.active:hover {
-		color: #000000;
-		}
-
-		/* [BOOST] : blocks */
-		#block-region-side-pre section.block {
-		border: none;
-		}
-		#block-region-side-pre section.block .card-body {
-		padding-top: 0;
-		}
-
-		/* [BOOST] : margin for ul, because ul is used to list sections */
-
-		ul, ul ul {
-			padding-left: 2.5rem;
-			margin-bottom: 0.5rem !important;
-		}
-
-		/* style for ? */
-
-					#completionprogressid {
-		display: none;
-		}
-
-		#region-main > .card {
-		border: none;
-		overflow-x: visible !important;
-		overflow-y: visible;
-		}
-
-		#region-main > .card > .card-body {
-		border: none;
-		padding: 0;
-		}
-
-		.centered {
-			display:flex;justify-content:center;align-items:center;
-		}
-		.contenu {
-			min-width: 15rem;
-		}
-		ul.bulle {
-			list-style: none;
-			padding:5%;
-		}
-
-		.bulle {
-			list-style: none;
-		}
-
-		.bulle > li {
-			list-style: none;
-			font-weight: normal;
-			font-size: 0.8rem;
-			line-height: 1rem;
-			padding-top: 5%;
-		}
-		</style>";
 		
 	}
 
@@ -1195,67 +819,10 @@ class format_iena_renderer extends format_topics_renderer{
 		
 		echo $this->get_view_iena_new($course, $nameSections, $idSections);
 		echo $this->render_from_template('format_iena/sections', $sections);
-		//On récupère toutes les infos des sections
-		/*foreach ($modinfo->get_section_info_all() as $section => $thissection) {
-			$htmlsection[$section] = '';
-			
-			$numsections = course_get_format($course)->get_last_section_number();
-			if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', $context = context_course::instance($course->id), $USER->id))) {
-				if ($course->hiddensections && !(int)$thissection->visible) {
-					continue;
-				}
-				if (!$thissection->available && !empty($thissection->availableinfo)) {
-					$htmlsection[$section] .= $this->section_header($thissection, $course, false, 0);
-					continue;
-				}
-				if (!$thissection->uservisible || !$thissection->visible) {
-					$htmlsection[$section] .= $this->section_hidden($section, $course->id);
-					continue;
-				}
-			}
-
-
-			$idSection[$section] = $thissection->id;
-			
-			$nameSection[$section] = $this->section_title_without_link($thissection, $course);
-			if ($PAGE->user_is_editing()) {
-				$htmlsection[$section] .= $this->section_header($thissection, $course, false, 0);
-			}
-			$introSection[$section] = $this->section_header($thissection, $course, false, 0, true);
-			if ($thissection->uservisible) {
-				$htmlsection[$section] .= "<div class='content'>";
-				
-				$htmlsection[$section] .= $this->courserenderer->course_section_cm_list($course, $thissection, 0);
-				$htmlsection[$section] .= $this->courserenderer->course_section_add_cm_control($course, $section, 0);
-				$htmlsection[$section] .= "</div>";
-			}
-			
-			
-			
-		} 
-		
-		echo $this->output->heading($this->page_title(), 2, 'accesshide');
-		echo $this->course_activity_clipboard($course, 0);
-		echo $this->start_section_list();
-		
-		
-
-		if (!$PAGE->user_is_editing()) {
-			echo $this->get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection);
-		} else {
-			foreach ($htmlsection as $current) {
-				echo $current;
-			}
-		}
-		
-
-		
-		
-		echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }');
-		*/
 		
 	}
 
+	//If edit mode, we use the old code that generates HTML, else we use the templates
 	public function switch_mode($course){
 		global $PAGE, $CFG;
 		$context = context_course::instance($course->id);
@@ -1276,4 +843,8 @@ class format_iena_renderer extends format_topics_renderer{
 	public function display_table_completion($data){
 		echo $this->render_from_template('format_iena/suivi-table', $data);
 	}
+
+	public function display_message($data){
+		echo $this->render_from_template('format_iena/send-message', $data);
+	}
 }
diff --git a/send_message_post.php b/send_message.php
similarity index 50%
rename from send_message_post.php
rename to send_message.php
index 4d123af..05c6773 100644
--- a/send_message_post.php
+++ b/send_message.php
@@ -1,119 +1,189 @@
-<?php
-	/**
-	 * Created by PhpStorm.
-	 * User: softia
-	 * Date: 06/03/18
-	 * Time: 10:20
-	 */
-
-// 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/>.
-	
-	/**
-	 *
-	 * @package    format_iena
-	 * @category   format
-	 * @copyright  2018 Softia/Université lorraine
-	 * @author     vrignaud camille
-	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-	 */
-	
-	define('NO_OUTPUT_BUFFERING', true);
-	require_once('../../../config.php');
-	
-	global $COURSE, $DB, $USER, $CFG;
-	
-	$courseID = required_param('courseid', PARAM_INT);
-	$url = new moodle_url('/course/format/iena/send_message_post.php', array('courseid' => $courseID));
-	
-	$PAGE->set_pagelayout('course');
-	$PAGE->set_url($url);
-	
-	if (!has_capability('course/iena:suivi', $context = context_course::instance($courseID), $USER->id)) {
-		$link = $CFG->wwwroot . '/course/view.php?id=' . $courseID;
-		header("Location: {$link}");
-		exit;
-	}
-	
-	$course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
-	require_login($course, false, NULL);
-	
-	if ($_POST) {
-		$messageContent = $_POST['summary']['text'];
-		$usersid = explode(",", $_POST["usersid"]);
-		// $messageContent .= "<br>". get_string('course', 'format_iena') . " : " . $course->fullname;
-		$messageContent .= "<br>". get_string('course', 'format_iena') . " :  <a href='" . $CFG->wwwroot . "/course/view.php?id=" . $course->id . "'>" . $course->fullname . "</a>";
-		$messageContent .= "<br> ". get_string('prof', 'format_iena') . " : " . $USER->firstname . " " . $USER->lastname;
-		$brutMessageContent = $course->fullname . " " . $_POST['summary']['text'];
-		$course_ctx = context_course::instance($courseID);
-		$students = get_enrolled_users($course_ctx);
-		
-		// sending a notification to each students
-		foreach ($usersid as $userID) {
-			foreach ($students as $student) {
-				if ($student->id == $userID) {
-					$message = new \core\message\message();
-					$message->courseid = $course->id;
-					$message->component = 'moodle';
-					$message->name = 'instantmessage';
-					$message->userfrom = $USER;
-					$message->notification = '0';
-					$message->fullmessageformat = FORMAT_HTML;
-					$message->subject = "Rappel : " . $course->fullname;
-					$message->smallmessage = $messageContent;
-					$message->fullmessage = $brutMessageContent;
-					$message->fullmessagehtml = $messageContent;
-					$message->userto = $student;
-					$messageid = message_send($message);
-					break;
-				}
-			}
-		}
-		$link = $CFG->wwwroot . '/course/view.php?id=' . $courseID;
-		header("Location: {$link}");
-		exit;
-
-
-
-// $message = new \core\message\message();
-// $message->component = 'moodle';
-// $message->name = 'instantmessage';
-// $message->userfrom = $USER;
-// $message->userto = $USER;
-// $message->subject = 'message subject 1';
-// $message->fullmessage = 'message body';
-// $message->fullmessageformat = FORMAT_MARKDOWN;
-// $message->fullmessagehtml = '<p>message body</p>';
-// $message->smallmessage = 'small message';
-// $message->notification = '0';
-// $message->contexturl = 'http://GalaxyFarFarAway.com';
-// $message->contexturlname = 'Context name';
-// $message->replyto = "random@example.com";
-// $content = array('*' => array('header' => ' test ', 'footer' => ' test ')); // Extra content for specific processor
-// $message->set_additional_content('email', $content);
-// $message->courseid = $COURSE->id; // This is required in recent versions, use it from 3.2 on https://tracker.moodle.org/browse/MDL-47162
-// $messageid = message_send($message);
-
-
-
-	}
-	
-	$dataSection = $DB->get_record('format_iena', array('id_section' => $sectionId), '*');
-	$course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
-	// require_login($course, false, NULL);
-	echo $OUTPUT->header();
-	
-	
-	echo $OUTPUT->footer();
\ No newline at end of file
+<?php
+	/**
+	 * Created by PhpStorm.
+	 * User: softia
+	 * Date: 06/03/18
+	 * Time: 10:20
+	 */
+
+// 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/>.
+	
+	/**
+	 *
+	 * @package    format_iena
+	 * @category   format
+	 * @copyright  2018 Softia/Université lorraine
+	 * @author     vrignaud camille
+	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+	 */
+	
+	define('NO_OUTPUT_BUFFERING', true);
+	require_once('../../../config.php');
+	
+	global $COURSE, $DB, $USER, $CFG;
+	
+	$courseID = required_param('courseid', PARAM_INT);
+	$url = new moodle_url('/course/format/iena/send_message.php', array('courseid' => $courseID));
+	
+	$PAGE->set_pagelayout('course');
+	$PAGE->set_url($url);
+	
+	if (!has_capability('course/iena:suivi', $context = context_course::instance($courseID), $USER->id)) {
+		$link = $CFG->wwwroot . '/course/view.php?id=' . $courseID;
+		header("Location: {$link}");
+		exit;
+	}
+	
+	$course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
+	require_login($course, false, NULL);
+	
+	/*if (isset($_POST['action'])) {
+		$messageContent = $_POST['summary']['text'];
+		$usersid = explode(",", $_POST["usersid"]);
+		// $messageContent .= "<br>". get_string('course', 'format_iena') . " : " . $course->fullname;
+		$messageContent .= "<br>". get_string('course', 'format_iena') . " :  <a href='" . $CFG->wwwroot . "/course/view.php?id=" . $course->id . "'>" . $course->fullname . "</a>";
+		$messageContent .= "<br> ". get_string('prof', 'format_iena') . " : " . $USER->firstname . " " . $USER->lastname;
+		$brutMessageContent = $course->fullname . " " . $_POST['summary']['text'];
+		$course_ctx = context_course::instance($courseID);
+		$students = get_enrolled_users($course_ctx);
+		
+		// sending a notification to each students
+		foreach ($usersid as $userID) {
+			foreach ($students as $student) {
+				if ($student->id == $userID) {
+					$message = new \core\message\message();
+					$message->courseid = $course->id;
+					$message->component = 'moodle';
+					$message->name = 'instantmessage';
+					$message->userfrom = $USER;
+					$message->notification = '0';
+					$message->fullmessageformat = FORMAT_HTML;
+					$message->subject = "Rappel : " . $course->fullname;
+					$message->smallmessage = $messageContent;
+					$message->fullmessage = $brutMessageContent;
+					$message->fullmessagehtml = $messageContent;
+					$message->userto = $student;
+					$messageid = message_send($message);
+					break;
+				}
+			}
+		}
+		$link = $CFG->wwwroot . '/course/view.php?id=' . $courseID;
+		header("Location: {$link}");
+		exit;
+	}*/
+	
+	//$dataSection = $DB->get_record('format_iena', array('id_section' => $sectionId), '*');
+	//$course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
+	// require_login($course, false, NULL);
+
+	$students="";
+	$back_url=$CFG->wwwroot . '/course/view.php?id=' . $courseID;
+	
+	if(isset($_POST["students"])){
+		$students=$_POST["students"];
+	}
+	if(isset($_POST["back_url"])){
+		$back_url=$_POST["back_url"];
+		
+	}
+
+
+	$data=new stdClass();
+	$nb = $students != "" ? count( explode(",", $students) ) : 0;
+	require_once('entity/course_format_iena_message.php');
+	$send_message = new course_format_iena_message(null, array('back_url'=>$back_url, 'students'=>$students));
+	
+	if ( $nb == 0 ) {
+		$data->nb_results=0;
+		
+	} else {
+		$data->nb_results=$nb;
+		$data->users_id=$students;
+		$courseID = required_param('courseid', PARAM_INT);
+		$data->link_cancel= $CFG->wwwroot . "/course/view.php?id=" . $courseID;;
+		
+		$data->form=$send_message->render();
+
+	}
+
+	
+
+	
+
+	if($send_message->is_cancelled()){
+		$back_url=$CFG->wwwroot . '/course/format/iena/suivi_unit.php'.$back_url;
+		
+		header("Location: {$back_url}");
+	}
+	else if ($fromform = $send_message->get_data()) {
+		$back_url=$CFG->wwwroot . '/course/format/iena/suivi_unit.php'.$back_url;
+		
+		try{
+			$messageContent = $fromform->summary['text'];
+			
+			$usersid = explode(",", $fromform->students);
+			
+			$messageContent .= "<br>". get_string('course', 'format_iena') . " :  <a href='" . $CFG->wwwroot . "/course/view.php?id=" . $course->id . "'>" . $course->fullname . "</a>";
+			$messageContent .= "<br> ". get_string('prof', 'format_iena') . " : " . $USER->firstname . " " . $USER->lastname;
+			$brutMessageContent = $course->fullname . " " . $_POST['summary']['text'];
+			$course_ctx = context_course::instance($courseID);
+			$students = get_enrolled_users($course_ctx);
+			
+			// sending a notification to each students
+			foreach ($usersid as $userID) {
+				foreach ($students as $student) {
+					if ($student->id == $userID) {
+						$message = new \core\message\message();
+						$message->courseid = $course->id;
+						$message->component = 'moodle';
+						$message->name = 'instantmessage';
+						$message->userfrom = $USER;
+						$message->notification = '0';
+						$message->fullmessageformat = FORMAT_HTML;
+						$message->subject = "Rappel : " . $course->fullname;
+						$message->smallmessage = $messageContent;
+						$message->fullmessage = $brutMessageContent;
+						$message->fullmessagehtml = $messageContent;
+						$message->userto = $student;
+						$messageid = message_send($message);
+						break;
+					}
+				}
+			}
+			$back_url.="&msg_success=true";
+		}
+		catch(Exception $e){
+			$back_url.="&msg_failure=true";
+		}
+		
+    	header("Location: {$back_url}");
+	}
+	else{
+		echo $OUTPUT->header();
+		$renderer = $PAGE->get_renderer('format_iena');
+		$renderer->display_message($data);
+		echo $OUTPUT->footer();
+	}
+
+
+
+	//echo $view_param_section->get_content($course, $dataSection);
+	
+	
+	
+	
+
diff --git a/suivi_unit.php b/suivi_unit.php
index eb4eac1..7e5fe51 100644
--- a/suivi_unit.php
+++ b/suivi_unit.php
@@ -141,12 +141,12 @@ function format_progress($progress, $modules, $groups, $active_group_id, $active
 			else{
 				$module_progress->completionstate=$prog_info->progress[$module->id]->completionstate;
 			}
-			if($module->section == $active_section_id || $active_section_id == 0){
+			/*if($module->section == $active_section_id || $active_section_id == 0){
 				$module_progress->visible=true;
 			}
 			else{
 				$module_progress->visible=false;
-			}
+			}*/
 			$module_progress->namemodule=$module->name;
 			$module_progress->idmodule=$module->id;
 			
@@ -208,20 +208,21 @@ function get_sections($active_section_id){
 
 
 
-//useless ?
-function set_filter(){
-	// Filtre actif si il existe (si la page est rechargée pour un filtre de groupe p.ex.)
+
+function set_filters($data, $filters, $symbols, $sections, $groups, $current_user_groups, $active_group_name, $active_section_id){
+	
 	if (isset($_GET['filter'])) {
-		$filter = $_GET['filter'];
+		$filterComplete = $_GET['filter'];
+		$symbols[substr($filterComplete, 0, 1)]->selected="selected";
+		$filters[substr($filterComplete, 1)]->selected="selected";
 	} else {
-		$filter = 'all';
+		$filters["0"]->selected="selected";
+		$symbols[">"]->selected="selected";
 	}
-	return $filter;
-}
 
-function set_filters($data, $filters, $sections, $groups, $current_user_groups, $active_group_name, $active_section_id){
-	
-	$data['filters']=$filters;
+
+	$data['filters']=array_values($filters);
+	$data['symbols']=array_values($symbols);
 	$data["sections"]=$sections;
 	$data["groups"]=array_values($groups);
 	$data['current_user_groups']=$current_user_groups;
@@ -283,54 +284,43 @@ function set_data($data, $modules, $progress, $groups, $active_group_id, $active
 }
 
 $filters=[
-	"0"=>array(
-		"value"=>"all",
-		"name"=>"Tous",
-	),
-	"1"=>array(
-		"value"=>"=100%",
-		"name"=>"100%",
-	),
-	"2"=>array(
-		"value"=>"=0",
-		"name"=>"0",
-	),
-	"3"=>array(
-		"value"=>"<100",
-		"name"=>"<100%",
-	),
-	"4"=>array(
-		"value"=>"<50",
-		"name"=>"<50%",
-	),
-	"5"=>array(
-		"value"=>"<25",
-		"name"=>"<25%",
-	),
-	"6"=>array(
-		"value"=>">50",
-		"name"=>">=50%",
-	),
-	"7"=>array(
-		"value"=>">25",
-		"name"=>">=25%",
-	),
-	"8"=>array(
+	"0"=>(object)[
 		"value"=>"0",
-		"name"=>">0%",
-	),
+		"name"=>"0",
+	],
+	"25"=>(object)[
+		"value"=>"25",
+		"name"=>"25%",
+	],
+	"50"=>(object)[
+		"value"=>"50",
+		"name"=>"50%",
+	],
+	"75"=>(object)[
+		"value"=>"75",
+		"name"=>"75%",
+	],
+	"100"=>(object)[
+		"value"=>"100",
+		"name"=>"100%",
+	]
+	,
+	
 ];
 
 $symbols=[
-	"0"=>array(
+	"="=>(object)[
 		"value"=>"=",
-	),
-	"1"=>array(
+		"name"=>"=",
+	],
+	"<"=>(object)[
 		"value"=>"<",
-	),
-	"2"=>array(
+		"name"=>"<",
+	],
+	">"=>(object)[
 		"value"=>">",
-	)
+		"name"=>">",
+	]
 ];
 
 
@@ -398,23 +388,20 @@ if ( $active_group_id == 0 ) {
 
 
 // If a post is sent trought the page
-if ($_POST && !isset($_POST["action"])) {
+/*if ($_POST && !isset($_POST["action"])) {
 	require_once("$CFG->libdir/formslib.php");
 	require_once('view/view_send_message.php');
 	$usersID = $_POST["api_url"];
 	$view = new view_send_message();
 	echo $view->get_content($usersID);
-} else if(isset($_POST['action']) && !empty($_POST['action'])) {
+} else */
+if(isset($_POST['action']) && !empty($_POST['action'])) {
 	//Si on change les filtres
 	$data=[];
 	$modules=get_activities($completion, $active_section_id);
 
 	$data=set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id);
 	echo json_encode($data);
-	//$renderer = $PAGE->get_renderer('format_iena');
-
-	//$renderer->display_table_completion($data);
-   	//echo json_encode($data);
 }
 else {
 
@@ -427,8 +414,13 @@ else {
 	$modules=get_activities($completion, $active_section_id);
 	$groups=get_groups($context, $active_group_id, $progress, $groups);
 	$sections=get_sections($active_section_id);
-	$data=set_filters($data, $filters, $sections, $groups, $current_user_groups, $active_group_name, $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();
diff --git a/templates/send-message.mustache b/templates/send-message.mustache
new file mode 100644
index 0000000..da29ba1
--- /dev/null
+++ b/templates/send-message.mustache
@@ -0,0 +1,23 @@
+<div>
+	{{#nb_results}}
+		<h2>{{# str }} send_message_title, format_iena {{/ str}}</h2>
+		
+		<p>Envoi d'un message à tous les étudiants précédemment sélectionnés. Les informations suivantes seront automatiquement ajoutées au message&nbsp;: nom du cours, lien vers le cours, nom du l'enseignant émetteur du message (vous). </p>
+		<p>L'étudiant recevra le message dans le chat et pourra être notifié par mail s'il n'est pas connecté au moment où le message est envoyé.</p>
+		<form class="m-t-1"  method="post">
+			<fieldset>
+				<div class="form-group">
+					{{{form}}}
+				</div>
+			</fieldset>
+		</form>
+	{{/nb_results}}
+	{{^nb_results}}
+	
+		<div class='alert alert-warning'>Vous n'avez sélectionné aucun destinataire pour votre message.</div>
+		<a class='btn btn-secondary' href='javascript:history.go(-1)'>Retour</a>
+	
+
+
+	{{/nb_results}}
+</div>
\ No newline at end of file
diff --git a/templates/suivi-table.mustache b/templates/suivi-table.mustache
index 171787c..a95429b 100644
--- a/templates/suivi-table.mustache
+++ b/templates/suivi-table.mustache
@@ -24,28 +24,30 @@
 	</thead>
 	<tbody id="table-body">
 		{{#students}}
-			<tr data-userid="{{id}}" data-percent={{percentage}}>
-				<th class="first-column-iena">
-					<input type="checkbox" name="checkstudent" value="{{id}}">
-				</th>
-				<th class="second-column-iena">
-					<span class="stud_perc">{{percentage}} %</span>
-				</th>
-				<th class="actions-column-iena">
-					<a href="{{report_link}}" target="_blank"><i class="icon fa fa-graduation-cap fa-fw"></i></a>
-					<a href="{{message_link}}" target="_blank"><i class="icon fa fa-envelope fa-fw"></i></a>
-				</th>
-				<th class="third-column-iena">
-					{{firstname}} {{lastname}}
-					
-				</th>
+			{{#visible}}
+				<tr data-userid="{{id}}" data-percent={{percentage}}>
+					<th class="first-column-iena">
+						<input type="checkbox" name="checkstudent" value="{{id}}">
+					</th>
+					<th class="second-column-iena">
+						<span class="stud_perc">{{percentage}} %</span>
+					</th>
+					<th class="actions-column-iena">
+						<a href="{{report_link}}" target="_blank"><i class="icon fa fa-graduation-cap fa-fw"></i></a>
+						<a href="{{message_link}}" target="_blank"><i class="icon fa fa-envelope fa-fw"></i></a>
+					</th>
+					<th class="third-column-iena">
+						{{firstname}} {{lastname}}
+						
+					</th>
 
-				{{#progress}}
-					{{#visible}}
-						<td title="{{namemodule}}" data-section="{{id}}" class="pointer-help state-{{completionstate}}"><span class="icon-progress"></span></td>
-					{{/visible}}
-				{{/progress}}
-			</tr>
+					{{#progress}}
+						{{#visible}}
+							<td title="{{namemodule}}" data-section="{{id}}" class="pointer-help state-{{completionstate}}"><span class="icon-progress"></span></td>
+						{{/visible}}
+					{{/progress}}
+				</tr>
+			{{/visible}}
 		{{/students}}
 	</tbody>
 </table>
diff --git a/templates/suivi.mustache b/templates/suivi.mustache
index 47118b4..6fc1c6f 100644
--- a/templates/suivi.mustache
+++ b/templates/suivi.mustache
@@ -98,7 +98,7 @@
 		<select class="custom-select mr-sm-2" id="symbol-select" name="filter">
 			
 			{{#symbols}}
-				<option {{selected}} value='{{value}}'>{{value}}</option>
+				<option {{selected}} value='{{value}}'>{{name}}</option>
 			{{/symbols}}
 			
 		</select>
@@ -114,6 +114,12 @@
 
 
 </form>
+{{#msg_success}}
+	<div class="alert alert-success">Message(s) envoyé(s)</div>
+{{/msg_success}}
+{{#msg_failure}}
+	<div class="alert alert-danger">Messages non envoyés</div>
+{{/msg_failure}}
 <div id="caption-iena"><h5>{{# str }} caption, format_iena {{/ str}}</h5>
 		<div class="">
 			<div class="caption-status"><div class="pointer-help state-0"><span class="icon-progress"></span></div> <span class="caption-title"> {{# str }} status0, format_iena {{/ str}}</span></div>
@@ -140,6 +146,7 @@ require(['format_iena/suivi', 'core/templates'], function(module) {
 			<div class="col-form-label d-inline">Avec la sélection : </div>
 		</div>
 		<div class="col-md-9">
+		<form method="POST" id="form_send_message_iena">
 			<select class="custom-select mr-sm-2" id="select-actions-suivi-iena" name="actions">
 				
 					<option  value='msg'>Envoyer un message</option>
@@ -147,6 +154,7 @@ require(['format_iena/suivi', 'core/templates'], function(module) {
 				
 			</select>
 			<input type="submit" class="btn btn-primary" name="submit" id="id_submit_iena" value="Valider">
+		</form>
 		</div>
 	</div>
 </div>
\ No newline at end of file
diff --git a/view/view_send_message.php b/view/view_send_message.php
index 5aff912..950cb06 100644
--- a/view/view_send_message.php
+++ b/view/view_send_message.php
@@ -48,6 +48,7 @@
 			$nb = $usersID != "" ? count( explode(",", $usersID) ) : 0;
 
 			if ( $nb == 0 ) {
+				
 				$content = "<div class='alert alert-warning'><h2>Attention</h2><p>Vous n'avez sélectionné aucun destinataire pour votre message.</p><a class='btn btn-secondary' href='". $_SERVER['HTTP_REFERER'] ."'>Retour</a></div>";
 			} else {
 
-- 
GitLab