diff --git a/amd/build/header.js b/amd/build/header.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef5d2533217da6850d40f69c25a07d62888904da
--- /dev/null
+++ b/amd/build/header.js
@@ -0,0 +1,66 @@
+// 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/>.
+
+/**
+ * Handle add/remove competency links.
+ *
+ * @module     format_iena/suivi
+ * @package    format_iena
+ * @copyright  2021 Myriam Delaruelle
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['jquery', 'core/ajax', 'core/str'],
+       function($, ajax, str) {
+
+       	return{
+       		
+       		registerHeader:function(){
+	    		$("#button-collapse").click(function(){
+	    			if($("#summary-wrapper").hasClass('collapsed')){
+	    				$("#summary-wrapper").animate({ "max-height": '7rem' }, "slow" );
+	    				var message=str.get_string('displayInfos', 'format_iena');
+		    			$.when(message).done(function(localizedEditString) {
+						    $("#button-collapse").text(localizedEditString);
+						});	
+
+	    			}
+	    			else{
+	    				var height= $("#summary-collapse").css("height");
+		    			$("#summary-wrapper").animate({ "max-height": height }, "slow" );
+		    			var message=str.get_string('hideInfos', 'format_iena');
+		    			$.when(message).done(function(localizedEditString) {
+						    $("#button-collapse").text(localizedEditString);
+						});	
+		    			
+		    			
+	    			}
+	    			$("#summary-wrapper").toggleClass("collapsed");
+	    			
+	    			
+	    		})
+	    		
+       		}
+       		
+
+       		
+       		
+       	}
+
+   
+
+
+   
+  
+});
diff --git a/amd/build/suivi-table.js b/amd/build/suivi-table.js
new file mode 100644
index 0000000000000000000000000000000000000000..0dccd035ec7c8997382c2c218ebd42f15c94ff0e
--- /dev/null
+++ b/amd/build/suivi-table.js
@@ -0,0 +1,56 @@
+// 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/>.
+
+/**
+ * Handle add/remove competency links.
+ *
+ * @module     format_iena/suivi-table
+ * @package    format_iena
+ * @copyright  2021 Myriam Delaruelle
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['jquery'],
+       function($) {
+       	var all_selected=false;
+       	return{
+       		registerSelectAll:function(){
+       			all_selected=false;
+       			$('#iena-select-all').on('click', function(e){
+					select_all_studs(e);
+	    		});
+	    		
+	    		
+	    		
+       		}
+       	}
+
+   
+    function select_all_studs(e) {
+    	
+		all_selected=!all_selected;
+		var counter = 0;
+		var checks = document.querySelectorAll("#table-body tr");
+		for (var i = 0; i < checks.length; i++) {
+			if ( checks[i].style.display != "none" || all_selected ) {
+				var box = checks[i].querySelector("input[type='checkbox']");
+				box.checked = all_selected;
+				counter++;
+			}
+		}
+	}
+
+
+
+});
diff --git a/amd/build/suivi.js b/amd/build/suivi.js
new file mode 100644
index 0000000000000000000000000000000000000000..2a5a12c006fd03baf45c058a9fde1d90274244ec
--- /dev/null
+++ b/amd/build/suivi.js
@@ -0,0 +1,412 @@
+// 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/>.
+
+/**
+ * Handle add/remove competency links.
+ *
+ * @module     format_iena/suivi
+ * @package    format_iena
+ * @copyright  2021 Myriam Delaruelle
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
+       function($, ajax, templates, str) {
+       	var all_selected=false;
+       	var data=[];
+       	return{
+       		
+       		registerFilters:function(){
+       			
+	    		$("#group-select").on('change', function(e){
+	    			changeGroup();
+	    		});
+	    		
+       		},
+       		
+       		registerSubmit:function(infos){
+       			data=infos;
+       			$("#id_submit_iena").on('click', function(e){
+	    			triggerAction(e);
+	    		});
+	    		$("#section-select").on('change', function(){
+	    			changeSection();
+	    		});
+	    		$("#filter-select").on('change', function(){
+	    			changeCompletion();
+	    		});
+	    		$("#symbol-select").on('change', function(){
+	    			changeCompletion();
+	    		});
+	    		
+	    		changeSection();
+	    		/*calcPercentage(data);
+	    		changeCompletion();*/
+       		}
+       		
+
+       		
+       		
+       	}
+
+    function initHeaders(){
+
+    	var nb_counts=$(".th-rotate").length;
+
+		$(".th-rotate").each(function(index, element){
+
+			$( element ).css("zIndex",nb_counts-index);
+		})
+    }
+
+    function getCompleteUrl(){
+    	url=window.location.search;
+    	urlParams = new URLSearchParams(url);
+    	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;
+    	}
+    	if(groupid){
+    		completeUrl+="&groupid="+groupid;
+    	}
+    	if(filter){
+    		completeUrl+="&filter="+filter;
+    	}
+    	return completeUrl;
+    }
+
+    function changeGroup(){
+    	completeUrl=getCompleteUrl();
+    	loadMessage("loading");
+    	$.ajax({ url: completeUrl,
+        	data: {action: 'test'},
+        	type: 'post',
+        	success: function(request) { 
+        		console.log(JSON.parse(request));
+        		
+        		data=calcPercentage(JSON.parse(request));
+        		changeCompletion();
+         		//reloadTable(JSON.parse(request));	
+			}
+		});
+    }
+
+  
+    function changeCompletion(){
+    	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();
+    	data.count_results=0;
+    	for(var i = 0; i<data.modules.length; i++){
+    		if(data.modules[i].section == sectionid || sectionid == 0){
+    			data.modules[i].visible=true;
+    			data.count_results++;
+    			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;
+    			}
+    		}
+    		else{
+    			data.modules[i].visible=false;
+    			for(var j = 0; j<data.students.length; j++){
+    				data.students[j].progress.find(progress => progress.idmodule === data.modules[i].id).visible=false;
+    			}
+    		}
+    	}
+    	
+    	if(data.count_results==0){
+    		reloadTable(data);
+    	}
+    	else{
+    		data=calcPercentage(data);
+    		changeCompletion();
+    		//reloadTable(data);
+    	}
+
+    	
+    	
+    	//reloadTable(data);
+    }
+
+    function loadMessage(type){
+    	console.log("on load");
+    	if(type=="loading"){
+    		var message = str.get_string('loadingResults', 'format_iena');
+	    	
+    	}
+    	else if(type=="error"){
+			var message = str.get_string('errorLoadingResults', 'format_iena');
+    	}
+
+    	$.when(message).done(function(localizedEditString) {
+		    $("#partial-table").html("<div class='alert alert-primary' role='alert'>"+localizedEditString+"</div>");
+		});	
+    }
+
+    function reloadTable(params){
+    	console.log(params);
+    	url=getCompleteUrl();
+    	templates.render('format_iena/suivi-table', params)
+     	.done(function(html, js){
+     		console.log("done done");
+     		 $("#partial-table").html(html);
+     		 templates.runTemplateJS(js);
+     		 window.history.pushState('suivi',"", url);
+     		 initHeaders();
+     	})
+        .fail(function(){
+        	loadMessage("error");
+        });	
+    }
+
+
+
+
+	function getSelectedStudents(){
+		var selectedChecks=$("#table-body input:checked");
+		var students=[];
+		for(var i=0; i < selectedChecks.length; i++){
+			
+			students.push(selectedChecks[i].value);
+		}
+	
+		return students;
+
+	}
+
+	//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"){
+			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);
+		}
+	}
+
+
+	function slug_it(str) {
+		return str.toString().toLowerCase().trim()
+		.replace(/\s+/g, '-')           /* Replace spaces with - */
+		.replace(/&/g, '-and-')         /* Replace & with 'and' */
+		.replace(/[^\w\-]+/g, '')       /* Remove all non-word chars */
+		.replace(/\-\-+/g, '-');        /* Replace multiple - with single - */
+	}
+
+
+	function padLeft(date){
+		
+		return String(date).length > 1? date : '0'+date ;
+	}
+
+	
+
+
+	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 %)'];
+		data.active_section_id=$("#section-select").val();
+		for ( var m = 0; m < data.modules.length; m++ ) {
+			if ( data.active_section_id != data.modules[m].section && data.active_section_id != 0 ) {
+				continue;
+			}
+			head.push('"'+data.modules[m].displayname.replace(',', '')+'"');
+		}
+
+
+		csvContent += head.join(",");
+		csvContent += "\n";
+		
+		/* Pour chaque étudiant */
+		
+		for ( var s = 0; s < data.students.length; s++ ) {
+			if(students.includes(data.students[s].id)){
+				var arr_cpl = [];
+
+				/* Pour chaque activité du cours */
+				var activities_nbr = 0;
+				var done_activities_nbr = 0;
+				
+
+				for ( var mod = 0; mod < data.modules.length; mod++ ) {
+					/* Si le module n'est pas dans la section actuellement filtrée */
+					
+					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 ) {
+						arr_cpl.push(0);
+					} else {
+						// var prog = 0;
+						/* Pour chaque trace d'achèvement */
+						var cpl = 0;
+						for (var i =0; i<stud_progress.length; i++) {
+							
+							/* Quand l'index de progression correspond à l'id du module */
+							if ( data.modules[mod].id == stud_progress[i].idmodule ) {
+								cpl = stud_progress[i].completionstate;
+								if (cpl == 3) {
+									cpl = 0.5;
+									cpl = '"' + cpl.toLocaleString() + '"';
+								}
+							}
+						}
+						
+						if (cpl == 1 || cpl == 2) {
+							done_activities_nbr++;
+						}
+						arr_cpl.push(cpl);
+					}
+					activities_nbr++;
+				}
+				var perc = Math.round(100 * 100 * done_activities_nbr / activities_nbr) / 100;
+				var groups = '"';
+				active_group_id=$('#group-select').val();
+				data.active_group_name=$('#group-select').find('option:selected').html()
+
+				if ( data.active_group_name != "" && active_group_id != 0 ) {
+					groups += data.active_group_name.replace('"', '');
+				} else {
+					groups += data.students[s].groups.replace('"', '');
+				}
+				groups += '"';
+				var arr = [
+				data.students[s].id,
+				data.students[s].firstname,
+				data.students[s].lastname,
+				groups,
+				'"'+perc.toLocaleString()+'"',
+				arr_cpl
+				];
+				var dataString = arr.join(",");
+				csvContent += dataString + "\n";
+			}
+		}
+		
+		var encodedUri = encodeURI(csvContent);
+
+		var section_name = data.active_section_id;
+		if ( section_name == 0 ) {
+			section_name = "cours-complet";
+		} else {
+			section_name = slug_it($('#section-select').find('option:selected').html()).substring(0, 20);
+		}
+		var d = new Date;
+		month = d.getMonth()+1;
+
+
+		date = d.getFullYear() +"."+ padLeft(month) +"."+ padLeft(d.getDate()) +"-"+ padLeft(d.getHours()) +"."+ padLeft(d.getMinutes()) +"."+ padLeft(d.getSeconds());
+		
+		var link = document.createElement("a");
+		link.setAttribute("href", encodedUri);
+		link.setAttribute("download", "report-"+section_name+"-"+ date +".csv");
+		document.body.appendChild(link);
+		link.click();
+		document.body.removeChild(link); 
+	}
+
+
+	//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;
+			var nb_modules=0;
+			for(var j=0; j < data.students[i].progress.length;j++){
+				if(data.modules.find(module => module.id === data.students[i].progress[j].idmodule).visible){
+					nb_modules++;
+					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);
+		}
+		return data;
+		//reloadTable(data);
+	}
+
+
+
+   
+  
+});
diff --git a/classes/task/sync_task_iena_message.php b/classes/task/sync_task_iena_message.php
index d83414eac31e10c1ab6f090e8d33732aadaad14a..078e16697a3a21da56eb1a79b4a72d7e9a9ab8fa 100644
--- a/classes/task/sync_task_iena_message.php
+++ b/classes/task/sync_task_iena_message.php
@@ -51,10 +51,13 @@
 		public function execute()
 		{
 			global $CFG;
+			mtrace("IENA notifications task started");
+
 			require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_cron_action.php');
 			$cron_test = new \course_format_iena_cron_action();
 			// echo 'send message start';
 			$cron_test->cron_message();
+			mtrace("IENA notifications task completed");
 			// echo 'send message stop';
 		}
 		
diff --git a/course-header.css b/course-header.css
index 146852f40e2465e9cb71daf7fa527c451031455d..3f667a34c7a2b37a62c37cd1e39749570c0e3f7c 100644
--- a/course-header.css
+++ b/course-header.css
@@ -212,4 +212,3 @@
 
 
 
-
diff --git a/db/install.xml b/db/install.xml
index 1f5bd9cdb18530ead8de538e3fff2129175ca47e..8e5257d4d74dacfe791d338cdb8bbe74d220f8c8 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -3,7 +3,7 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
 >
-  <TABLES>
+  <!--<TABLES>
     <TABLE NAME="format_iena" COMMENT="Default comment for format_iena, please edit me">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
@@ -21,5 +21,5 @@
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-  </TABLES>
+  </TABLES>-->
 </XMLDB>
\ No newline at end of file
diff --git a/db/tasks.php b/db/tasks.php
index 9435163d05819a90af345753b6bab2864dd0a1eb..5d9bca3eb01e8fd77754d0d159033f1924bee1a5 100644
--- a/db/tasks.php
+++ b/db/tasks.php
@@ -37,15 +37,7 @@
 	
 	$tasks = array(
 		
-		// array(
-		// 	'classname' => 'format_iena\task\sync_task_iena_hide',
-		// 	'blocking' => 0,
-		// 	'minute' => '*/5',
-		// 	'hour' => '*',
-		// 	'day' => '*',
-		// 	'month' => '*',
-		// 	'dayofweek' => '*'
-		// ),
+
 		array(
 			'classname' => 'format_iena\task\sync_task_iena_message',
 			'blocking' => 0,
diff --git a/db/upgrade.php b/db/upgrade.php
new file mode 100644
index 0000000000000000000000000000000000000000..8616fe3696a4c8015ca53375842c64540f3ec375
--- /dev/null
+++ b/db/upgrade.php
@@ -0,0 +1,73 @@
+<?php
+
+	
+
+function xmldb_format_iena_upgrade($oldversion) {
+    global $CFG, $DB;
+ 	$dbman = $DB->get_manager();
+    $result = TRUE;
+ 
+      if ($oldversion < 2021220900) {
+
+       
+
+        //Support for old versions: we copy format options to the course_format_options table
+        try {
+            $sections= $DB->get_records_sql('select * FROM {format_iena}');
+        } 
+        catch (dml_exception $e) {
+            echo "Aucun cours avec le format hybride dans la base";
+        }
+        if(count($sections) > 0){
+            foreach ($sections as $section) {
+                try {
+
+                    $courseid = $DB->get_record_sql('select course FROM {course_sections} WHERE id=?', array($section->id_section));
+                    
+                    $section_data = new stdClass();
+                    $section_data->courseid = $courseid->course;
+                    $section_data->format = "iena";
+                    $section_data->sectionid = $section->id_section;
+                    //On va faire pour présence, daterendu et daysnotif
+                    $section_data->name = "presence";
+                    $section_data->value = $section->presence;
+                    
+                    $exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="presence"', array($section->id_section));
+                    
+                    if(!$exists){
+                       
+                        $resultat = $DB->insert_record('course_format_options', $section_data, true);
+                    }
+                    $exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="daterendu"', array($section->id_section));
+                    if(!$exists){
+                       
+                        if(isset($section->date_rendu)){
+                            $section_data->name = "daterendu";
+                            $section_data->value = strtotime($section->date_rendu);
+                            $resultat = $DB->insert_record('course_format_options', $section_data, true);
+                        }
+                    }
+                    $exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="daysnotif"', array($section->id_section));
+                    if(!$exists){
+                        
+                        if(!empty($section->day_before)){
+                            $section_data->name = "daysnotif";
+                          
+                            $section_data->value = $section->nb_days_before;
+                            $resultat = $DB->insert_record('course_format_options', $section_data, true);
+                        }
+                    }
+                } 
+                catch (dml_exception $e) {
+                }
+            }
+        }
+
+        // Format_iena savepoint reached.
+        upgrade_plugin_savepoint(true, 2021070600,'format', 'iena');
+    }
+ 
+    return $result;
+}
+
+?>
\ No newline at end of file
diff --git a/entity/course_format_iena_completion.php b/entity/course_format_iena_completion.php
index 5bc75086c10547ff8fc63c7229ce219d43f9ec54..b3880a37bb7b2f4ce84eb3d27b26682f31892fda 100644
--- a/entity/course_format_iena_completion.php
+++ b/entity/course_format_iena_completion.php
@@ -27,6 +27,12 @@
  */
 class course_format_iena_completion {
 
+	/**
+	 * Get completion by sections
+	 * @param type $section_names 
+	 * @param type $idSection 
+	 * @return type
+	 */
 	public static function get_completion_by_section($section_names, $idSection) {
 
 		global $COURSE, $USER, $DB, $CFG;
@@ -36,18 +42,6 @@ class course_format_iena_completion {
 			return false;
 		}
 
-		// $modules = $DB->get_records_sql('SELECT cmc.id, cmc.coursemoduleid, cmc.userid, cmc.completionstate, cm.section
-		// 	FROM  {course_modules_completion} as cmc
-		// 	inner join {course_modules} as cm on cm.id = cmc.coursemoduleid
-		// 	inner join {user} as u on u.id = cmc.userid
-		// 	inner join {modules} as m on m.id = cm.module
-		// 	where cm.course = ? and cm.deletioninprogress = 0
-		// 	and cmc.userid = ?
-		// 	order by section, coursemoduleid asc', array($course->id, $USER->id));
-
-		// echo "<pre>";
-		// var_dump($modules);
-		// echo "</pre>";
 
 		$sections = [];
 
@@ -59,7 +53,9 @@ class course_format_iena_completion {
 			$module = $completion->get_data($cm, true, $USER->id, $fast_modinfo);
 			$module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
 			$module->section = $cm->section;
-			if ( $cm->deletioninprogress == 0 && $cm->completion != 0 ) {
+			if ( $cm->deletioninprogress == 0 && $cm->completion != 0 && $cm->uservisible) {
+				$module->name = $cm->name;
+				$module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
 				$modules[] = $module;
 			}
 		}
@@ -75,19 +71,15 @@ class course_format_iena_completion {
 			$inner_modules = [];
 			$inner_completed = 0;
 			foreach ($modules as $module) {
-				if ( $module->section == $section_id ) {
+				if ( $module->section == $section_id) {
 					$mod = new StdClass();
 					$mod->coursemoduleid = $module->coursemoduleid;
 					$mod->completion = $module->completionstate;
+					$mod->name = $module->name;
+					$mod->url = $module->url;
 					if ( $mod->completion == 1 || $mod->completion == 2 ) {
 						$inner_completed++;
 					}
-					foreach ($modinfos_cms as $cm) {
-						if ( $cm->id == $mod->coursemoduleid ) {
-							$mod->name = $cm->name;
-							$mod->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
-						}
-					}
 					$inner_modules[] = $mod;
 				}
 			}
@@ -105,11 +97,6 @@ class course_format_iena_completion {
 		$progress = new StdClass();
 		$progress->total = number_format( 100 * $total_completed / $total_modules, 0);
 		$progress->sections = $sections;
-
-		// echo "<pre>";
-		// var_dump($progress);
-		// echo "</pre>";
-
 		return $progress;
 
 	}
diff --git a/entity/course_format_iena_cron_action.php b/entity/course_format_iena_cron_action.php
index de4e6af017b6c1c078fbc51c5495c036bd8eb72b..59e7c833c52e80399e8411b0cdf353bac519e17b 100644
--- a/entity/course_format_iena_cron_action.php
+++ b/entity/course_format_iena_cron_action.php
@@ -41,130 +41,42 @@
 	class course_format_iena_cron_action
 	{
 		
-		/**
-		 * @param $requete
-		 * @param $nbJours
-		 * @throws coding_exception
-		 */
-		private function hide_section($requete, $nbJours)
-		{
-			if ($nbJours < 0) {
-				set_section_visible($requete->course, $requete->section, 0);
-				//Log for task
-				echo get_string('hide_section', 'format_iena') . $requete->name;
-			} else {
-				set_section_visible($requete->course, $requete->section, 1);
-				//Log for task
-				echo get_string('show_section', 'format_iena') . $requete->name;
-			}
-		}
-		
-		/**
-		 * @param $date
-		 * @return float|int
-		 */
-		private function calcul_nb_jours($date)
-		{
-			$date_now = date_create(date("Y-m-d H:i:s"))->getTimestamp();
-			$nbJoursTimestamp = $date_now - $date;
-			// Calcul number of day
-			$nbJours = $nbJoursTimestamp / 86400;
-			return $nbJours;
-		}
-		
-		/**
-		 * @throws dml_exception
-		 */
-		public function cron_hide_section()
-		{
-			global $DB;
-			
-			$sections = $DB->get_records('format_iena');
-			
-			foreach ($sections as $section) {
-				$requete = $DB->get_record('course_sections', array('id' => $section->id_section));
-				
-				if ($section->hide == 1) {
-					set_section_visible($requete->course, $requete->section, 1);
-					echo get_string('show_section', 'format_iena') . $requete->name;
-				}
-				
-				if ($section->hide == 2) {
-					$date_rendu = date_create($section->date_rendu);
-					//We calcul date with timeStamp
-					$date_rendu = $date_rendu->getTimestamp();
-					$this->hide_section($requete, $this->calcul_nb_jours($date_rendu));
-					
-				} else if ($section->hide == 3) {
-					if ($section->day_before && $section->nb_days_before) {
-						$date_before = date('Y-m-d H:i:s', strtotime($section->date_rendu . " - " . $section->nb_days_before . " days"));
-						$date_before = date_create($date_before)->getTimestamp();
-						$this->hide_section($requete, $this->calcul_nb_jours($date_before));
-					} else if ($section->day_same) {
-						$date_rendu = date_create($section->date_rendu);
-						$date_rendu = $date_rendu->getTimestamp();
-						$this->hide_section($requete, $this->calcul_nb_jours($date_rendu));
-					} else if ($section->day_after && $section->nb_days_after) {
-						$date_after = date('Y-m-d H:i:s', strtotime($section->date_rendu . " + " . $section->nb_days_after . " days"));
-						$date_after = date_create($date_after)->getTimestamp();
-						$this->hide_section($requete, $this->calcul_nb_jours($date_after));
-					}
-				}
-				
-			}
-		}
 		
+
 		/**
-		 * @throws dml_exception
-		 * @throws coding_exception
+		 * Récupère le nombre de jours avant le rendu/présence pour envoyer une notification
+		 * @return type
 		 */
 		public function cron_message()
 		{
 			global $DB, $USER, $CFG;
-			$sections = $DB->get_records('format_iena');
+
+			$sections = $DB->get_records_sql("SELECT fo1.sectionid, fo1.value daysnotif, fo2.value daterendu, fo3.value presence FROM {course_format_options} fo1 LEFT JOIN {course_format_options} fo2 ON fo1.sectionid = fo2.sectionid LEFT JOIN {course_format_options} fo3 ON fo1.sectionid = fo3.sectionid WHERE fo1.format='iena' AND fo1.name ='daysnotif' AND (fo1.value IS NOT NULL) AND fo1.value != -1 AND fo2.name='daterendu' AND fo3.name='presence'");
 			foreach ($sections as $section) {
-				if ($section->day_before || $section->day_same || $section->day_after) {
-					$requete = $DB->get_record('course_sections', array('id' => $section->id_section));
-					$date_notif = $this->is_notif($section);
-					if ($date_notif == false) {
-						continue;
-					}
-					$this->iena_send_message($requete, $section);
-				} else {
+				$requete = $DB->get_record('course_sections', array('id' => $section->sectionid));
+				$date_notif = $this->is_notif($section);
+				if ($date_notif == false) {
 					continue;
 				}
+				$this->iena_send_message($requete, $section);
+	
 			}
 		}
 		
 		/**
+		 * Check if it's time to send a notif by comparing the date withe the numbers of days before sending one in the db
 		 * @param $section
-		 * @return bool
+		 * @return bool true if it's time to send a notif
 		 */
 		private function is_notif($section)
 		{
-			$date_notif = null;
-			$date_now = date_create(date("Y-m-d"));
-			if ($section->day_before && $section->nb_days_before) {
-				$date_notif = date('Y-m-d', strtotime($section->date_rendu . " - " . $section->nb_days_before . " days"));
-				$date_notif = date_create($date_notif);
-				if ($date_notif == $date_now) {
-					return true;
-				}
-			}
-			if ($section->day_same) {
-				$date_notif = date_create(date('Y-m-d', strtotime($section->date_rendu)));
-				if ($date_notif == $date_now) {
-					return true;
-				}
+			//On compare la date d'aujourd'hui avec le timestamp - daysnotifs
+			$date_now=date('Ymd');
+			$timenotif=strtotime('-'.$section->daysnotif.' days', $section->daterendu);
+			$date_notif=date('Ymd', $timenotif);
+			if($date_notif==$date_now){
+				return true;
 			}
-			if ($section->day_after && $section->nb_days_after) {
-				$date_notif = date('Y-m-d', strtotime($section->date_rendu . " + " . $section->nb_days_after . " days"));
-				$date_notif = date_create($date_notif);
-				if ($date_notif == $date_now) {
-					return true;
-				}
-			}
-			
 			return false;
 		}
 		
@@ -177,8 +89,12 @@
 		private function iena_send_message($requete, $section)
 		{
 			global $DB, $CFG, $USER;
-			
 			$course_ctx = context_course::instance($requete->course);
+
+			//À vérifier : on récupère tous les utilisateurs, même les invités
+			//2. $students = get_role_users(5 , $context) (the 5 represents the role-id with role.shortname = 'student')
+			//
+
 			$students = get_enrolled_users($course_ctx);
 			$course = $DB->get_record('course', array('id' => $requete->course), '*', MUST_EXIST);
 
@@ -187,8 +103,8 @@
 			$messageContent .= "<h1>Rappel</h1>";
 			$messageContent .= "<h2>$course->fullname</h2>";
 
-			$date_jour = date('d/m', strtotime($section->date_rendu));
-			$date_heure = date('H:i', strtotime($section->date_rendu));
+			$date_jour = date('d/m', $section->daterendu);
+			$date_heure = date('H:i', $section->daterendu);
 
 			// 0 : NC
 			// 1 : work in the classroom
diff --git a/entity/course_format_iena_message.php b/entity/course_format_iena_message.php
new file mode 100644
index 0000000000000000000000000000000000000000..c673ae56dd946d2cbf5479c499463dcfe6c12375
--- /dev/null
+++ b/entity/course_format_iena_message.php
@@ -0,0 +1,64 @@
+<?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");
+			
+			
+		}
+		
+	}
\ No newline at end of file
diff --git a/entity/course_format_iena_sections.php b/entity/course_format_iena_sections.php
index 1fa6c991d144da72862f842b248dcb113bd595cf..16432599bae9f5f190003a89510eade6947e02e8 100644
--- a/entity/course_format_iena_sections.php
+++ b/entity/course_format_iena_sections.php
@@ -33,8 +33,13 @@
 		public $name;
 		/** @var int id of course */
 		public $id_course;
-		/** @var block_career_ressources array<Ressource> ressources */
-		public $ressources;
+		/** @var block_career_resources array<Ressource> resources */
+		public $resources;
+		/** @var date */
+		public $date;
+		/** @var string availability */
+		public $availability;
+		public $visibility;
 		
 		
 		/**
@@ -125,4 +130,156 @@
 			return $requete;
 		}
 		
-	}
+	
+    /**
+     * @return mixed
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param mixed $id
+     *
+     * @return self
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * @param mixed $name
+     *
+     * @return self
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getIdCourse()
+    {
+        return $this->id_course;
+    }
+
+    /**
+     * @param mixed $id_course
+     *
+     * @return self
+     */
+    public function setIdCourse($id_course)
+    {
+        $this->id_course = $id_course;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getResources()
+    {
+        return $this->resources;
+    }
+
+    /**
+     * @param mixed $resources
+     *
+     * @return self
+     */
+    public function setResources($resources)
+    {
+        $this->resources = $resources;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getDate()
+    {
+        return $this->date;
+    }
+
+    /**
+     * @param mixed $date
+     *
+     * @return self
+     */
+    public function setDate($date)
+    {
+        $this->date = $date;
+
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getAvailability()
+    {
+        return $this->availability;
+    }
+
+    /**
+     * @param mixed $availability
+     *
+     * @return self
+     */
+    public function setAvailability($availability)
+    {
+        $this->availability = $availability;
+
+        return $this;
+    }
+
+
+
+    /**
+     * @return mixed
+     */
+    public function getVisibility()
+    {
+        return $this->visibility;
+    }
+
+    /**
+     * @param mixed $visibility
+     *
+     * @return self
+     */
+    public function setVisibility($visibility)
+    {
+        $this->visibility = $visibility;
+
+        return $this;
+    }
+
+
+    public function toArray(){
+    	$vars = [];
+	    foreach($this as $varName => $varValue) {
+	        $vars[$varName] = $varValue;
+	    }
+
+	    return $vars;
+    }
+}
diff --git a/format.js b/format.js
index 90f376417e6299dad4298101aa0a026fd41cf30b..ab865fc34f1c11bad8e231f9d0f7a534de428034 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/format.php b/format.php
index af89b14fd4ed8879b74242d3b4d96f838a0471a5..3b82b0591d3b1285d04e9e0dfc8045af5a5f1637 100644
--- a/format.php
+++ b/format.php
@@ -22,6 +22,8 @@
 	 * @copyright  2018 Softia/Université lorraine
 	 * @author     vrignaud camille
 	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+	 *
+	 * Point d'entrée du plugin
 	 */
 	
 	defined('MOODLE_INTERNAL') || die();
@@ -33,10 +35,7 @@
 	require_once('entity/course_format_iena_groups.php');
 	require_once('entity/course_format_iena_attendance.php');
 	
-	/*$cron_test = new course_format_iena_cron_action();
-	$cron_test->cron_hide_section();
-	$cron_test->cron_message();*/
-//use core_completion\progress;
+	
 	
 	require_once($CFG->dirroot . '/blocks/myoverview/lib.php');
 	require_once($CFG->dirroot . '/completion/classes/progress.php');
@@ -61,9 +60,14 @@
 	course_create_sections_if_missing($course, 0);
 	$renderer = $PAGE->get_renderer('format_iena');
 	if (!empty($displaysection)) {
+		
 		$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
 	} else {
-		$renderer->print_iena_section_pages($course);
+		
+		$renderer->switch_mode($course);
+		
+		
+		//$renderer->print_iena_section_pages($course);
 	}
 //	$PAGE->requires->js('/course/format/iena/js/jquery.min.js');
 //	$PAGE->requires->js('/course/format/iena/format.js');
diff --git a/js/groups.js b/js/groups.js
index 5ee6b6c96b67ca93bdb2af3bdd6090266f8440f4..91102594f8b6d29d61c40363a2bc2e44bb25e8aa 100644
--- a/js/groups.js
+++ b/js/groups.js
@@ -47,6 +47,7 @@
 	})
 
 	function set_indicateur_displays() {
+		console.log("display indicateur")
 		$('.nb_pers').hide();
 		$('.' + $('#select-group').val()).show();
 	}
diff --git a/js/param_section.js b/js/param_section.js
deleted file mode 100644
index dcb89787cc582657b3ddb1525195663ff63e69b4..0000000000000000000000000000000000000000
--- a/js/param_section.js
+++ /dev/null
@@ -1,5 +0,0 @@
-(function() {
-
-// inclus nul part. 
-
-})()
\ No newline at end of file
diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php
index 6fee5644453c70df9a353fc09069e18ddd96ba8f..1a7ce582aaea2fe9dbda760e3ae7cf9999a395a9 100644
--- a/lang/en/format_iena.php
+++ b/lang/en/format_iena.php
@@ -80,4 +80,20 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$string['section'] = 'Section';
 	$string['hide_section'] = 'HIDE section ';
 	$string['show_section'] = 'SHOW section ';
+	$string['aboutcourse'] = 'About this course';
+	$string['modalite_help'] = 'To get help on modalities';
+	$string['loadingResults'] = "Loading results...";
+	$string['errorLoadingResults'] = "Students could not be retrieved, please contact an administrator";
+	$string['caption']="Caption";
+	$string['status0']="Activity not completed";
+	$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";
+	$string['display_course_infos']="Show/hide course information";
+	$string['my_progress']="My progress in the course: ";
+	$string['table_progress']="Tracking";
+	$string['displayInfos']="Display course informations";
+	$string['hideInfos']="Hide course informations";
+
 
diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php
index 3d63789aad9133ae328f8428a6deb00a44beedd3..a4cf6401d66023f36e39c27f1bc6fec226181697 100644
--- a/lang/fr/format_iena.php
+++ b/lang/fr/format_iena.php
@@ -31,7 +31,7 @@
 	$string['editsection'] = 'Modifier section';
 	$string['deletesection'] = 'Supprimer section';
 	$string['sectionname'] = 'Section';
-	$string['section0name'] = 'General';
+	$string['section0name'] = 'Général';
 	$string['hidefromothers'] = 'Cacher section';
 	$string['showfromothers'] = 'Voir section';
 	$string['showdefaultsectionname'] = 'Show the default sections name';
@@ -47,7 +47,7 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$string['notif'] = 'Notification';
 	$string['notif_summary'] = 'Une notification peut être envoyée à l étudiant par mail. Elle lui rapplera de consulter la section et contiendra diverses informations (nom du cours, lien vers le cours, nom de la section, date le la section et modalité';
 	$string['in_presence'] = 'En présence';
-	$string['not_presence'] = 'A distance';
+	$string['not_presence'] = 'À distance';
 	$string['days_before'] = 'Un certain nombre de jours avant la séance';
 	$string['days_after'] = 'Un certain nombre de jours après la séance';
 	$string['days_same'] = 'Le jour même';
@@ -80,4 +80,20 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$string['section'] = 'Section';
 	$string['hide_section'] = 'CACHER la section ';
 	$string['show_section'] = 'MONTRER la section ';
+	$string['aboutcourse'] = 'À propos de ce cours';
+	$string['modalite_help'] = 'Pour avoir de l\'aide sur les modalités';
+	$string['loadingResults'] = "Chargement des résultats...";
+	$string['errorLoadingResults'] = "Les étudiants n'ont pas pu être chargés, veuillez contacter un administrateur.";
+	$string['caption']="Légende";
+	$string['status0']="Activité non complétée";
+	$string['status1']="Activité complétée";
+	$string['status2']="Activité complétée et validée";
+	$string['status3']="Activité complétée non validée";
+	$string["send_message_title"]="Envoi d'un message à {{nb_results}} personnes";
+	$string['display_course_infos']="Afficher/Masquer les informations du cours";
+	$string['my_progress']="Ma progression dans le cours : ";
+	$string['table_progress']="Suivi des étudiants";
+	$string['displayInfos']="Afficher les infos du cours";
+	$string['hideInfos']="Masquer les infos du cours";
+
 
diff --git a/lib.php b/lib.php
index ac15dea8d3c5672bf2a07a4ae124d4900fb0858d..70875887437b635ee47114fe97ece35b69a3c58a 100644
--- a/lib.php
+++ b/lib.php
@@ -51,20 +51,6 @@
 				);
 			}
 			if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
-				// $courseconfig = get_config('moodlecourse');
-				// $max = $courseconfig->maxsections;
-				// if (!isset($max) || !is_numeric($max)) {
-				// 	$max = 52;
-				// }
-				// $sectionmenu = array();
-				// for ($i = 0; $i <= $max; $i++) {
-				// 	$sectionmenu[$i] = "$i";
-				// }
-				// $courseformatoptionsedit['numsections'] = array(
-				// 	'label' => new lang_string('numberweeks'),
-				// 	'element_type' => 'select',
-				// 	'element_attributes' => array($sectionmenu),
-				// );
 				$choiceTab = array();
 				$choiceTab['1'] = get_string('yes', 'format_iena');
 				$choiceTab['0'] = get_string('no', 'format_iena');
@@ -82,6 +68,214 @@
 			}
 			return $courseformatoptions;
 		}
+
+			 /**
+     * Definitions of the additional options that this course format uses for section
+     *
+     * See {@link format_base::course_format_options()} for return array definition.
+     *
+     * Additionally section format options may have property 'cache' set to true
+     * if this option needs to be cached in {@link get_fast_modinfo()}. The 'cache' property
+     * is recommended to be set only for fields used in {@link format_base::get_section_name()},
+     * {@link format_base::extend_course_navigation()} and {@link format_base::get_view_url()}
+     *
+     * For better performance cached options are recommended to have 'cachedefault' property
+     * Unlike 'default', 'cachedefault' should be static and not access get_config().
+     *
+     * Regardless of value of 'cache' all options are accessed in the code as
+     * $sectioninfo->OPTIONNAME
+     * where $sectioninfo is instance of section_info, returned by
+     * get_fast_modinfo($course)->get_section_info($sectionnum)
+     * or get_fast_modinfo($course)->get_section_info_all()
+     *
+     * All format options for particular section are returned by calling:
+     * $this->get_format_options($section);
+     *
+     * @param bool $foreditform
+     * @return array
+     */
+    public function section_format_options($foreditform = false) {
+         global $CFG;
+        static $courseformatoptions = false;
+
+        if ($courseformatoptions === false) {
+            $courseformatoptions = array(
+           
+                'presence'=>array(
+                	'label'=>"Présence",
+                	'type'=>PARAM_INT
+                ),
+                'daterendu'=>array(
+                	'label'=>"Date rendu",
+                	'type'=>PARAM_INT
+            	),
+            	'daysnotif'=>array(
+            		'label'=>"Notification",
+            		'type'=>PARAM_INT
+            	)
+
+            );
+        }
+        
+        return $courseformatoptions;
+    }
+
+
+
+     /**
+     * Adds format options elements to the course/section edit form.
+     *
+     * This function is called from {@link course_edit_form::definition_after_data()}.
+     *
+     * @param MoodleQuickForm $mform form the elements are added to.
+     * @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
+     * @return array array of references to the added form elements.
+     */
+    public function create_edit_form_elements(&$mform, $forsection = false) {
+        global $COURSE;
+        global $PAGE;
+        $elements = parent::create_edit_form_elements($mform, $forsection);
+
+        if ($forsection) {
+           	$mform->removeElement('presence', false);
+           	$mform->removeElement('daterendu', false);
+           	$mform->removeElement('daysnotif', false);
+           	$sectionclass = new stdClass();
+           	$sectionclass->id=optional_param('id', 0, PARAM_INT);
+           
+          	$section_config=$this->get_format_options($sectionclass);
+          	
+			$mform->addElement('header', 'nameforyourheaderelement', 'Format hybride');
+          	$radioarray=array();
+	    	$radioarray[] = $mform->createElement('radio', 'presence', '', 'Distance', 2);
+			$radioarray[] = $mform->createElement('radio', 'presence', '', 'Présentiel', 1);
+			$radioarray[] = $mform->createElement('radio', 'presence', '', 'Aucune', 0);
+			$mform->addGroup($radioarray, 'modalite', 'Modalité', array(' '), false);
+
+			$mform->addHelpButton('modalite', 'modalite', 'format_iena');
+
+
+			$datearray=array();
+			$datearray[] = $mform->createElement('date_time_selector', 'daterendu', '');
+			$datearray[] = $mform->createElement('checkbox', 'daterenducheck', 'Activer');
+			$mform->addGroup($datearray, 'groupdate', 'Date d\'échéance', array(' '), false);
+			$mform->disabledIf('groupdate', 'daterenducheck');
+
+			//On montre le groupe seulement si à distance
+			$mform->hideIf('groupdate', 'presence', 'neq', 2);
+			//$mform->hideIf('groupdate', 'id_presence_2', 'notchecked');
+			
+
+			$datearray=array();
+			$datearray[] = $mform->createElement('date_time_selector', 'daterendu2', '');
+			$datearray[] = $mform->createElement('checkbox', 'daterenducheck2', 'Activer');
+			$mform->addGroup($datearray, 'groupdate2', 'Date du cours', array(' '), false);
+			$mform->disabledIf('groupdate2', 'daterenducheck2');
+			//On montre le groupe si pas distance
+			$mform->hideIf('groupdate2', 'presence', 'eq', 2);
+
+
+
+			$daysarray=array();
+			$days=array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
+			$daysarray[] = $mform->createElement('select', 'daysnotif', "jours avant la séance", $days);
+			$daysarray[]=$mform->createElement('html', ' <span id="days-text">jours avant la séance</span>');
+			$daysarray[] = $mform->createElement('checkbox', 'selectdayscheck', 'Activer');
+			$mform->addGroup($daysarray, 'groupdays', 'Notification', array(' '), false);
+			$mform->disabledIf('groupdays', 'selectdayscheck');
+			$mform->disabledIf('groupdays', 'daterenducheck');
+			$mform->hideIf('groupdays', 'presence', 'neq', 2);
+
+
+			$daysarray=array();
+			
+			$daysarray[] = $mform->createElement('select', 'daysnotif2', "jours avant le rendu", $days);
+			$daysarray[]=$mform->createElement('html', ' <span id="days-text">jours avant le rendu</span>');
+			$daysarray[] = $mform->createElement('checkbox', 'selectdayscheck2', 'Activer');
+			$mform->addGroup($daysarray, 'groupdays2', 'Notification', array(' '), false);
+			$mform->disabledIf('groupdays2', 'selectdayscheck2');
+			$mform->disabledIf('groupdays2', 'daterenducheck2');
+			$mform->hideIf('groupdays2', 'presence', 'eq', 2);
+
+			//on ne peut pas activer des notifs s'il n'y a pas de date de rendu/date de cours
+			
+
+          	if($section_config['presence']){
+          		$mform->setDefault('presence', $section_config['presence']);
+          	}
+          	if($section_config['daterendu']){
+
+          		if(isset($section_config['presence']) && $section_config['presence']==2){
+          			error_log("on passe là");
+          			$mform->setDefault('daterendu', $section_config['daterendu']);
+          			$mform->setDefault('daterenducheck', "1");
+          		}
+          		else if(isset($section_config['presence'])){
+          			error_log("non on passe là");
+          			$mform->setDefault('daterendu2', $section_config['daterendu']);
+          			$mform->setDefault('daterenducheck2', "1");
+          		}
+          		
+          	}
+          	if(isset($section_config['daysnotif']) && $section_config['daysnotif'] > -1){
+          		$mform->setDefault('selectdays', $section_config['daysnotif']);
+          		$mform->setDefault('selectdayscheck', "1");
+          	}
+
+        }
+
+        return $elements;
+    }
+
+    /**
+     * Updates format options for a course
+     *
+     * In case if course format was changed to 'periods', we try to copy options
+     * 'coursedisplay', 'numsections' and 'hiddensections' from the previous format.
+     * If previous course format did not have 'numsections' option, we populate it with the
+     * current number of sections
+     *
+     * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
+     * @param stdClass $oldcourse if this function is called from {@link update_course()}
+     *     this object contains information about the course before update
+     * @return bool whether there were any changes to the options values
+     */
+    public function update_section_format_options($data) {
+        global $DB;
+        
+       	$objectSection=new stdClass();
+       	$objectSection->id=$data["id"];
+        $section_config=$this->get_format_options($objectSection);
+        
+        //$data = (array)$data;
+        //if a date was set but we want to remove it
+        if(!isset($data['daterenducheck']) && !isset($data['daterenducheck2'])){
+        	if(array_key_exists('daterendu', $section_config) && !empty($section_config['daterendu'])){
+        		$data['daterendu']=NULL;
+        	}
+        	else{
+        		unset($data['daterendu']);
+        	}
+        }
+        else if(isset($data['daterenducheck2'])){
+        	$data['daterendu']=$data['daterendu2'];
+
+        }
+        if(!isset($data['selectdayscheck'])){
+        	if(isset($data['daysnotif2'])){
+    			$data['daysnotif']=$data["daysnotif2"];
+    		}
+        	if(array_key_exists('daysnotif', $section_config) && $section_config['daysnotif']>-1){
+        		$data['daysnotif']=-1;
+
+        	}
+        	else{
+        		unset($data['daysnotif']);
+        	}
+        }
+        return $this->update_format_options($data, $data['id']);
+    }
+
 		
 		/**
 		 * get_view_url
@@ -150,3 +344,24 @@
 			return course_get_format($section->course)->inplace_editable_update_section_name($section, $itemtype, $newvalue);
 		}
 	}
+
+	
+		/**
+	 * Extends the course administration navigation with the Badges page
+	 *
+	 * @param navigation_node $coursenode
+	 * @param object $course
+	 */
+	function iena_add_course_navigation(navigation_node $coursenode, stdClass $course) {
+		echo "<br><br>br>";
+		echo "ien add course";
+	}
+	function format_iena_add_course_navigation(navigation_node $coursenode, stdClass $course) {
+
+		echo "<br><br>br>";
+		echo "formatien add course";
+	}
+
+
+
+
diff --git a/renderer.php b/renderer.php
index f20219ad385b54f586ec16fd4f83fe7b1f102ef2..bc665d1da2d0964b907cbfa54a5249e3e856ed9b 100644
--- a/renderer.php
+++ b/renderer.php
@@ -14,887 +14,801 @@
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
+/**
+ * format_iena
+ *
+ * @package    format_iena
+ * @category   format
+ * @copyright  2018 Softia/Université lorraine
+ * @author     vrignaud camille/Thomas Fradet
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->dirroot . '/course/format/topics/renderer.php');
+require_once($CFG->dirroot . '/course/format/iena/view/view_course_header.php');
+
+/**
+ * format_iena_renderer
+ *
+ * @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
+ */
+class format_iena_renderer extends format_topics_renderer{
+
+
 	/**
-	 * format_iena
+	 * start_section_list
 	 *
-	 * @package    format_iena
-	 * @category   format
-	 * @copyright  2018 Softia/Université lorraine
-	 * @author     vrignaud camille/Thomas Fradet
-	 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+	 * @return string
 	 */
-	
-	defined('MOODLE_INTERNAL') || die();
-	
-	require_once($CFG->dirroot . '/course/format/topics/renderer.php');
-	require_once($CFG->dirroot . '/course/format/iena/view/view_course_header.php');
-	
+	//bientôt useless
+	protected function start_section_list()
+	{
+		return html_writer::start_tag('ul', ['class' => 'iena-editing']);
+	}
+
 	/**
-	 * format_iena_renderer
+	 * section_header
 	 *
-	 * @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
+	 * @param stdclass $section
+	 * @param stdclass $course
+	 * @param bool $onsectionpage
+	 * @param int $sectionreturn
+	 * @return string
 	 */
-	class format_iena_renderer extends format_topics_renderer
-	{
-
-
-		/**
-		 * start_section_list
-		 *
-		 * @return string
-		 */
-		protected function start_section_list()
-		{
-			return html_writer::start_tag('ul', ['class' => 'iena-editing']);
-		}
-
-		/**
-		 * section_header
-		 *
-		 * @param stdclass $section
-		 * @param stdclass $course
-		 * @param bool $onsectionpage
-		 * @param int $sectionreturn
-		 * @return string
-		 */
-		protected function section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false)
-		{
-			global $PAGE, $CFG;
-			$o = '';
-			$currenttext = '';
-			$sectionstyle = '';
-			if ($section->section != 0) {
-				if (!$section->visible) {
-					$sectionstyle = ' hidden';
-				} elseif (course_get_format($course)->is_section_current($section)) {
-					$sectionstyle = ' current';
-				}
-			}
-			if ($PAGE->user_is_editing()) {
-				$o .= html_writer::start_tag('li', ['id' => 'section-' . $section->section,
-					'class' => 'section main clearfix' . $sectionstyle,
-					'role' => 'region', 'aria-label' => get_section_name($course, $section)]);
+	//Bientôt useless
+	protected function section_header($section, $course, $onsectionpage, $sectionreturn = null, $iena = false){
+		global $PAGE, $CFG;
+		$o = '';
+		$currenttext = '';
+		$sectionstyle = '';
+		if ($section->section != 0) {
+			if (!$section->visible) {
+				$sectionstyle = ' hidden';
+			} elseif (course_get_format($course)->is_section_current($section)) {
+				$sectionstyle = ' current';
 			}
-			
-			$o .= html_writer::tag('span', $this->section_title($section, $course), ['class' => 'hidden sectionname']);
+		}
+		
+		if ($PAGE->user_is_editing()) {
+			$o .= html_writer::start_tag('li', ['id' => 'section-' . $section->section,
+				'class' => 'section main clearfix' . $sectionstyle,
+				'role' => 'region', 'aria-label' => get_section_name($course, $section)]);
+		}
+		
+		$o .= html_writer::tag('span', $this->section_title($section, $course), ['class' => 'hidden sectionname']);
+
+		//This is were the editing menu is generated
+		if ($PAGE->user_is_editing()) {
+			$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
+			$o .= html_writer::tag('div', $leftcontent, ['class' => 'left side']);
+			$rightcontent = $this->section_right_content($section, $course, $onsectionpage);
+			$o .= html_writer::tag('div', $rightcontent, ['class' => 'right side']);
+		}
 
-			if ($PAGE->user_is_editing()) {
-				$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
-				$o .= html_writer::tag('div', $leftcontent, ['class' => 'left side']);
-				$rightcontent = $this->section_right_content($section, $course, $onsectionpage);
-				$o .= html_writer::tag('div', $rightcontent, ['class' => 'right side']);
-			}
+		$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
+		$hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name)));
+		$classes = ' accesshide';
+		if ($hasnamenotsecpg || $hasnamesecpg) {
+			$classes = '';
+		}
+		$sectionname = html_writer::tag('span', $this->section_title($section, $course));
+		if ($PAGE->user_is_editing()) {
+			$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
+		}
+		// if ($course->showdefaultsectionname) {
+		// 	$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
+		// }
+		// if (!$iena) { $o .= $sectionname; }
 
-			$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
-			$hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name)));
-			$classes = ' accesshide';
-			if ($hasnamenotsecpg || $hasnamesecpg) {
-				$classes = '';
-			}
-			$sectionname = html_writer::tag('span', $this->section_title($section, $course));
-			if ($PAGE->user_is_editing()) {
-				$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
-			}
-			// if ($course->showdefaultsectionname) {
-			// 	$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
-			// }
-			// if (!$iena) { $o .= $sectionname; }
+		$context = context_course::instance($course->id);
+		
+		/* résumé de section */
+		if ( $section->summary != "" ) {
+			$o .= html_writer::start_tag('div', ['class' => 'iena-description']);
+			$o .= html_writer::start_tag('div', ['class' => 'small']);
+
+			$o .= html_writer::start_tag('div', ['class' => 'iena-summary']);
+			$o .= $this->format_summary_text($section);
+			$o .= html_writer::end_tag('div');
+
+			$o .= html_writer::end_tag('div');
+			$o .= html_writer::end_tag('div');
+			$o .= html_writer::tag('a', 'Voir la description complète', ['href' => '#', 'class' => 'voir-plus']);
+		}
+		
+		$o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context));
 
-			$context = context_course::instance($course->id);
-			
-			/* résumé de section */
-			if ( $section->summary != "" ) {
-				$o .= html_writer::start_tag('div', ['class' => 'iena-description']);
-				$o .= html_writer::start_tag('div', ['class' => 'small']);
-
-				$o .= html_writer::start_tag('div', ['class' => 'iena-summary']);
-				$o .= $this->format_summary_text($section);
-				$o .= html_writer::end_tag('div');
-
-				$o .= html_writer::end_tag('div');
-				$o .= html_writer::end_tag('div');
-				$o .= html_writer::tag('a', 'Voir la description complète', ['href' => '#', 'class' => 'voir-plus']);
-			}
-			
-			$o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context));
+		
 
-			if ($PAGE->user_is_editing()) {
-				// $o .= html_writer::end_tag('li');
-			}
+		return $o;
+	}
 
-			return $o;
+	/**
+	 * Add style attributes, classes (useless?), format section summary and add the hidden/restricted message 
+	 * @param type $section 
+	 * @param type $course 
+	 * @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){
+	
+		global $PAGE, $CFG, $COURSE, $USER;
+		$section_entity = new course_format_iena_sections();
+		$o = '';
+		$currenttext = '';
+		$sectionstyle = '';
+		if ($section->section != 0) {
+			if (!$section->visible) {
+				$section->sectionstyle = ' hidden';
+			} elseif (course_get_format($course)->is_section_current($section)) {
+				$section->sectionstyle = ' current';
+			}
 		}
+		
+		$section->edit=$this->section_title_without_link($section, $course);
 
-		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();
-			//$completions = $ressources_entity->get_completions_by_userid($USER->id, $COURSE->id);
+		$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
+		$hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name)));
+		$section->classes = ' accesshide';
+		if ($hasnamenotsecpg || $hasnamesecpg) {
+			$section->classes = '';
+		}
+		$section->sectionname = get_section_name($course, $section);
+		
+		$context = context_course::instance($course->id);
+		if($section->summary != ""){
+			$section->summary=$this->format_summary_text($section);
+		}
+		
+		$section->messageavailability= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context));
 
-			// list modules in a section
-			$modules = $ressources_entity->get_ressources_completion_on_by_id_section($idSection);
-			$nb_modules = count($modules);
-			if ($nb_modules == 0) {
-				return array($nb_modules, 999);
-			}
 
-			$valueI = 100 / $nb_modules;
-			$valueTotal = 0;
-			foreach ($modules as $module) {
-				$complet = $ressources_entity->get_completions_by_module($USER->id, $COURSE->id, $module->id);
-				if ($complet->completionstate != 0) {
-					$valueTotal += $valueI;
+		/* Paramètres */
+		$presence = "";
+		$format = course_get_format($course);
+		
+		$param_section = (object)$format->get_format_options($section);
+		if ($param_section !== false) {
+
+				if (isset($param_section->presence)) {
+					if ($param_section->presence == 1) {
+						$section->presence = true;
+						$section->distance =false;
+						$string_date_presence="Le ";
+					} else if ($param_section->presence == 2) {
+						$section->presence = false;
+						$section->distance =true;
+						$string_date_presence="Pour le ";
+					}
+					else{
+						$string_date_presence="Le ";
+						$section->presence = false;
+						$section->distance =false;
+					}
 				}
-			}
 
-			return array($modules, $valueTotal);
+				if (isset($param_section->daterendu) && $param_section->daterendu != 0) {
+					$section->date=date("j/m H:i", $param_section->daterendu);
+					$section->date_jour = date("j/m", $param_section->daterendu);
+					$section->date_heure =  date("H:i", $param_section->daterendu);
+
+					/*$section->dateUp = new DateTime("@$param_section->daterendu");
+					$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");
+					$section->dateUp = $section->dateUp->getTimestamp();*/
+					if($string_date_presence){
+						$section->string_date=$string_date_presence.$section->date_jour." à ".$section->date_heure;
+					}
+					else{
+						$section->string_date="Le ".$section->date_jour." à ".$section->date_heure;
+					}
+				} else {
+					$section->date = "";
+				}
+		} else {
+			$section->date = "";
 		}
 
-		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;
+		//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 . "&sectionid=" . $section->id . "&groupid=".reset($groups)->id;
+				}
+				else{
+					$section->link_suivi = $CFG->wwwroot . "/course/format/iena/suivi_unit.php?courseid=" . $COURSE->id . "&sectionid=" . $section->id . "&groupid=0";
 				}
+				
 			}
+			
+			
 		}
+		
 
-		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>
+		return $section;
+	}
 
-			</div>
-			</div>
-			</div>";
-
-			return $render;
-		}
-
-		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 = [];
-			// var_dump($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;
+	//useless
+	/*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();
+		$modules = $ressources_entity->get_ressources_completion_on_by_id_section($idSection);
+		$nb_modules = count($modules);
+		if ($nb_modules == 0) {
+			return array($nb_modules, 999);
+		}
 
-			// }
+		$valueI = 100 / $nb_modules;
+		$valueTotal = 0;
+		foreach ($modules as $module) {
+			$complet = $ressources_entity->get_completions_by_module($USER->id, $COURSE->id, $module->id);
+			if ($complet->completionstate != 0) {
+				$valueTotal += $valueI;
+			}
+		}
 
-			// $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;
-			// 	}
-			// 	// var_dump($tab_section_indicateur[$section_ligne->id]);
-			// }
-			// $tab_group_indicateur['id_groupe0']=$tab_section_indicateur;
-			// $view = "";
+		return array($modules, $valueTotal);
+	}*/
 
 
+	//Bientôt useless
+	public function get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection){
+		global $CFG, $COURSE, $USER;
+		$section_entity = new course_format_iena_sections();
 
-			// COUPE ICI
-			
+		
 
-			// nouvelle génération du header
+		// nouvelle génération du header
 
-			$view = "";
+		$view = "";
 
-			require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_completion.php');
-			// return false if completion disabled (site or course)
-			$cpl = course_format_iena_completion::get_completion_by_section($nameSection, $idSection);
+		require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_completion.php');
+		// return false if completion disabled (site or course)
+		$cpl = course_format_iena_completion::get_completion_by_section($nameSection, $idSection);
 
-			/* Passer le calcul de complétion de la classe course_format_iena_completion à part à la vue qui fait le header permet de ne pas récupérer deux fois les mêmes informations. */
-			$header = new view_course_header($nameSection, $idSection, $course, $cpl);
-			$view .= $header->get_content();
+		/* Passer le calcul de complétion de la classe course_format_iena_completion à part à la vue qui fait le header permet de ne pas récupérer deux fois les mêmes informations. */
+		$header = new view_course_header($nameSection, $idSection, $course, $cpl);
+		$view .= $header->get_content();
 
-			$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>
+		$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
-			*/
+		/*
+		style for clean page
+		*/
 
-			/* [BOOST] : course header */
-#page-header .card {
-			border: none;
+		/* [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;
 		}
-#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 ? */
+		/* [BOOST] : blocks */
+		#block-region-side-pre section.block {
+		border: none;
+		}
+		#block-region-side-pre section.block .card-body {
+		padding-top: 0;
+		}
 
-			#completionprogressid {
-display: none;
-}
+		/* [BOOST] : margin for ul, because ul is used to list sections */
 
-#region-main > .card {
-border: none;
-overflow-x: visible !important;
-overflow-y: visible;
-}
+		ul, ul ul {
+			padding-left: 2.5rem;
+			margin-bottom: 0.5rem !important;
+		}
 
-#region-main > .card > .card-body {
-border: none;
-padding: 0;
-}
+		/* style for ? */
 
-.centered {
-	display:flex;justify-content:center;align-items:center;
-}
-.contenu {
-	min-width: 15rem;
-}
-ul.bulle {
-	list-style: none;
-	padding:5%;
-}
+					#completionprogressid {
+		display: none;
+		}
 
-.bulle {
-	list-style: none;
-}
+		#region-main > .card {
+		border: none;
+		overflow-x: visible !important;
+		overflow-y: visible;
+		}
 
-.bulle > li {
-	list-style: none;
-	font-weight: normal;
-	font-size: 0.8rem;
-	line-height: 1rem;
-	padding-top: 5%;
-}
-</style>";
+		#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%;
+		}
 
-foreach ($htmlsection as $section) {
-	$presence = "";
-	if (!$section) {
-		continue;
-	}
-	$param_section = $section_entity->get_section_settings_by_id_section($idSection[$i]);
-	// dates, modality and notification section parameters : false if not set. 
-	if ($param_section !== false) {
-		if ($param_section->presence && $i != 0) {
-			if ($param_section->presence == 1) {
-				$presence = "En présence";
-			} else if ($param_section->presence == 2) {
-				$presence = "A distance";
-			}
+		.bulle {
+			list-style: none;
 		}
 
-		if ($param_section->date_rendu) {
-			$dateUp = date_create($param_section->date_rendu);
-			$date = $dateUp->format("j/m H:i");
-			$date_jour = $dateUp->format("j/m");
-			$date_heure = $dateUp->format("H:i");
-			$dateUp = $dateUp->getTimestamp();
-		} else {
-			$date = "";
+		.bulle > li {
+			list-style: none;
+			font-weight: normal;
+			font-size: 0.8rem;
+			line-height: 1rem;
+			padding-top: 5%;
 		}
-	} else {
-		$date = "";
-	}
+		</style>";
+		foreach ($htmlsection as $section) {
+			$presence = "";
+			if (!$section) {
+				continue;
+			}
+			$param_section = $section_entity->get_section_settings_by_id_section($idSection[$i]);
+			// dates, modality and notification section parameters : false if not set. 
+			if ($param_section !== false) {
+				if ($param_section->presence && $i != 0) {
+					if ($param_section->presence == 1) {
+						$presence = "En présence";
+					} else if ($param_section->presence == 2) {
+						$presence = "A distance";
+					}
+				}
 
-	$titre = $nameSection[$i];
-	$sectionIntro = $introSection[$i];
-				//If section is hidden continue
-	if ($titre == null && !(has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id))) {
-		$i++;
-		continue;
-	}
-	$view .= "<section class=\"section iena-section\" id=\"section-$i\">
-	<div class=\"card card_block\">
-	<div class=\"heading-iena set_height\">";
+				if ($param_section->date_rendu) {
+					$dateUp = date_create($param_section->date_rendu);
+					$date = $dateUp->format("j/m H:i");
+					$date_jour = $dateUp->format("j/m");
+					$date_heure = $dateUp->format("H:i");
+					$dateUp = $dateUp->getTimestamp();
+				} else {
+					$date = "";
+				}
+			} else {
+				$date = "";
+			}
 
-	if ( $cpl != false && count($cpl->sections[$i]->modules) > 0 ) {
-		$view .= "<div class='iena-percent set_height'>" . $cpl->sections[$i]->completion . "%</div>";
-	}
+			$titre = $nameSection[$i];
+			$sectionIntro = $introSection[$i];
+						//If section is hidden continue
+			if ($titre == null && !(has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id))) {
+				$i++;
+				continue;
+			}
+			$view .= "<section class=\"section iena-section\" id=\"section-$i\">
+			<div class=\"card card_block\">
+			<div class=\"heading-iena set_height\">";
 
+			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 (has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) {
+			
 
+				$course_groups = groups_get_all_groups($COURSE->id);
 
+				$group_indicateur = 0;
 
+				$view .= "<a href='$link&sectionid=".$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>";
+				$view .="</a>";
+				
+				
+			}
 
-	// if ($compl_by_section != 999 && $completion->is_enabled()) {
-	// 	$view .= "<div class=\"iena-percent set_height\">
-	// 	" . floor($compl_by_section) . "%
-	// 	</div>";
-	// }
 
 
+			$view .= "<div class=\"titre_section set_height\">
+			<p>$titre</p>
+			</div>
+			<div class=\"right_info\">
+			";
+						// if ($presence) {
+						// 	$view .= "
+						// 	<div class=\"label_item\">
+						// 	$presence
+						// 	</div>";
+						// }
+			if ($date) {
+				$link_date = $CFG->wwwroot . "/calendar/view.php?view=month&time=" . $dateUp . "&course=" . $COURSE->id;
+				if ($presence && $presence == "A distance") {
+					$view .= "
+					<div class=\"label_item sect-date\">
+					À distance
+					</div>
+					<div class=\"label_item sect-date\">
+					Pour le $date_jour à $date_heure
+					</div>";
+				} else if ($presence && $presence == "En présence") {	
+					$view .= "
+					<div class=\"label_item sect-date\">
+					En présence
+					</div>
+					<div class=\"label_item sect-date\">
+					Le $date_jour à $date_heure
+					</div>";
+				} else {
+					$view .= "
+					<div class=\"label_item sect-date\">
+					Le $date_jour à $date_heure
+					</div>";
+				}
+			} else {
+				if ($presence && $presence == "A distance") {
+					$view .= "
+					<div class=\"label_item sect-date\">
+					À distance
+					</div>";
+				} else if ($presence && $presence == "En présence") {	
+					$view .= "
+					<div class=\"label_item sect-date\">
+					En présence
+					</div>";
+				}
+			}
+			
+			$cpt = "";
+			if ($cpt != "") {
+				$view .= "
+				<div class=\"titre_section set_height\">
+
+				";
+				$view .= $cpt;
+				$view .= "</div>
+				";
+			}
 
+			$link_param = $CFG->wwwroot . "/course/format/iena/param_section.php?courseid=" . $COURSE->id . "&sectionid=" . $idSection[$i];
+			if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) {
+				$view .= "<div class=\"titre_section set_height\">
+				<a href='$link_param' style=\"color : white\">
+				<i class=\"fa fa-cog \" aria-hidden=\"true\" ></i>
+				</a>
+				</div>";
+			}
+			$view .= "</div>
+
+			</div>
+			";
+			$view .= "<div class=\"wrapper section\">";
+			$view .= $sectionIntro;
+			
+			$view .= "<div class=\"wrapper\">
+			$section
+			</div >
 
+			</div>
 
+			</section>";
+			$i++;
+		}
+		return $view;
+	}
 
+	/**
+	 * Render le template du header avec les infos nécessaires : le progrès
+	 * @param StdObject $course 
+	 * @param array<string> $nameSections
+	 * @param array<int> $idSections
+	 * @return type
+	 */
+	public function get_view_iena_new($course,$nameSections, $idSections){
+		global $CFG, $COURSE, $USER;
+		$section_entity = new course_format_iena_sections();
+		require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_completion.php');
+		// return false if completion disabled (site or course)
+		$cpl = course_format_iena_completion::get_completion_by_section($nameSections, $idSections);
 
+		/* Passer le calcul de complétion de la classe course_format_iena_completion à part à la vue qui fait le header permet de ne pas récupérer deux fois les mêmes informations. */
+		$header = new view_course_header($nameSections, $idSections, $course, $cpl);
+		$course_infos= $header->create_view($cpl);
+		//$course_infos=$header->get_data($cpl);
 
 
+		echo $this->render_from_template('format_iena/course-header', $course_infos);
 
-	// 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&sectionid=".$idSection[$i]."' style=\"color : white\">";
-		$view .="<div onclick='change_grouplink(this)' style=\"display:none;\" 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>";
-		// }
+	public function count_students($context){
+		$count = count_enrolled_users($context);
+		return $count;
+	}
 
 
-		// id_groupeXXX
 
-		// var_dump($course_groups);
+	//Seulement en mode édition - 
+	//bientôt useless
+	public function print_iena_section_pages($course){
+		global $PAGE, $USER;
 
-		// 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."\">";
-		// 	foreach ($val as $key => $value) {
-		// 		if ($idSection[$i] == $key) {
-		// 			$view .= $value;
-		// 		}
-		// 	}
-		// 	$view .= "</div>";
-		// }
+		$context = context_course::instance($course->id);
+		$course = course_get_format($course)->get_course();
+		$completion = new \completion_info($course);
 
-		// $view .="</a>";
-	}
 
-	$view .= "<div class=\"titre_section set_height\">
-	<p>$titre</p>
-	</div>
-	<div class=\"right_info\">
-	";
-				// if ($presence) {
-				// 	$view .= "
-				// 	<div class=\"label_item\">
-				// 	$presence
-				// 	</div>";
-				// }
-	if ($date) {
-		$link_date = $CFG->wwwroot . "/calendar/view.php?view=month&time=" . $dateUp . "&course=" . $COURSE->id;
-		if ($presence && $presence == "A distance") {
-			$view .= "
-			<div class=\"label_item sect-date\">
-			À distance
-			</div>
-			<div class=\"label_item sect-date\">
-			Pour le $date_jour à $date_heure
-			</div>";
-		} else if ($presence && $presence == "En présence") {	
-			$view .= "
-			<div class=\"label_item sect-date\">
-			En présence
-			</div>
-			<div class=\"label_item sect-date\">
-			Le $date_jour à $date_heure
-			</div>";
+		$modinfo = get_fast_modinfo($course);
+		// $course = course_get_format($course)->get_course();
+		
+		// $completioninfo = new completion_info($course);
+		if (isset($_COOKIE['sectionvisible_' . $course->id])) {
+			$sectionvisible = $_COOKIE['sectionvisible_' . $course->id];
+		} elseif ($course->marker > 0) {
+			$sectionvisible = $course->marker;
 		} else {
-			$view .= "
-			<div class=\"label_item sect-date\">
-			Le $date_jour à $date_heure
-			</div>";
-		}
-	} else {
-		if ($presence && $presence == "A distance") {
-			$view .= "
-			<div class=\"label_item sect-date\">
-			À distance
-			</div>";
-		} else if ($presence && $presence == "En présence") {	
-			$view .= "
-			<div class=\"label_item sect-date\">
-			En présence
-			</div>";
+			$sectionvisible = 1;
 		}
-	}
-	// $cpt = $this->get_render_competences($idSection[$i]);
-	$cpt = "";
-	if ($cpt != "") {
-		$view .= "
-		<div class=\"titre_section set_height\">
-
-		";
-		$view .= $cpt;
-		$view .= "</div>
-		";
-	}
-
-	$link_param = $CFG->wwwroot . "/course/format/iena/param_section.php?courseid=" . $COURSE->id . "&sectionid=" . $idSection[$i];
-	if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $USER->id) && $i != 0) {
-		$view .= "<div class=\"titre_section set_height\">
-		<a href='$link_param' style=\"color : white\">
-		<i class=\"fa fa-cog \" aria-hidden=\"true\" ></i>
-		</a>
-		</div>";
-	}
-	$view .= "</div>
-
-	</div>
-	";
-	$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 >
-
-	</div>
-
-	</section>";
-	$i++;
-}
-
-return $view;
-}
-
-
-public function print_iena_section_pages($course)
-{
-	global $PAGE, $USER;
+		$htmlsection = false;
+		$nameSection = [];
+		$idSection = false;
+		$introSection = false;
+		
+		//On récupère toutes les infos des sections
+		foreach ($modinfo->get_section_info_all() as $section => $thissection) {
 
-			//$courses = enrol_get_my_courses('*', 'fullname ASC');
-	// $coursesprogress = [];
+			//Nom de la section
 
-	$context = context_course::instance($course->id);
-	$course = course_get_format($course)->get_course();
+			$htmlsection[$section] = '';
+			
+			$numsections = course_get_format($course)->get_last_section_number();
 
-	$completion = new \completion_info($course);
+			// if ($section > $numsections) {
+			// // if ($section > $course->numsections) {
+			// 	// continue;
+			// }
+			/* if is not editing verify the rules to display the sections */
+			if (!$PAGE->user_is_editing() && (!has_capability('moodle/course:viewhiddensections', $context = context_course::instance($course->id), $USER->id))) {
 
-	// First, let's make sure completion is enabled.
-	// if (!$completion->is_enabled()) {
-	// 	continue;
-	// }
+				//si la section est cachée
+				if (isset($course->hiddensections) && !(int)$thissection->visible) {
+					continue;
+				}
 
-	// $proges = new \core_completion\progress();
-	// $percentage = $proges->get_course_progress_percentage($course);
+				//si la section n'est pas disponible
+				if (!$thissection->available && !empty($thissection->availableinfo)) {
+					$htmlsection[$section] .= $this->section_header($thissection, $course, false, 0);
+					continue;
+				}
 
-	// if (!is_null($percentage)) {
-	// 	$percentage = floor($percentage);
-	// }
-	// $coursesprogress[$course->id]['completed'] = $completion->is_course_complete($USER->id);
-	// $coursesprogress[$course->id]['progress'] = $percentage;
+				if (!$thissection->uservisible || !$thissection->visible) {
+					$htmlsection[$section] .= $this->section_hidden($section, $course->id);
+					continue;
+				}
+			}
 
-	// $completion_total = $coursesprogress[$course->id]["progress"];
 
+			//Affiche le nom de la section en mode propre sans lien
+			$idSection[$section] = $thissection->id;
+			// $nameSection[$section] .= $this->section_title_without_link($thissection, $course);
+			$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) {
+				/* Ne pas enlever sinon le activity chooser ne fonctionne pas en JS */
+				$htmlsection[$section] .= "<div class='content'>";
+				// Renvoie le lien du cours avec icone
+				$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>";
+			}
+	
+			/* pas de footer car on ne commence par la structure par une div non fermée et que ce footer ferme par une div */
+			// $htmlsection[$section] .= $this->section_footer();
+			
+			
+		} //ENDFOREACH
 
-	$modinfo = get_fast_modinfo($course);
-	// $course = course_get_format($course)->get_course();
-	$context = context_course::instance($course->id);
-	// $completioninfo = new completion_info($course);
-	if (isset($_COOKIE['sectionvisible_' . $course->id])) {
-		$sectionvisible = $_COOKIE['sectionvisible_' . $course->id];
-	} elseif ($course->marker > 0) {
-		$sectionvisible = $course->marker;
-	} else {
-		$sectionvisible = 1;
-	}
-	$htmlsection = false;
-	$nameSection = [];
-	$idSection = false;
-	$introSection = false;
-			//var_dump($modinfo->get_section_info_all());die;
-	foreach ($modinfo->get_section_info_all() as $section => $thissection) {
-
-		// var_dump($thissection);
-				//Nom de la section
-
-		$htmlsection[$section] = '';
-				/*if ($section == 0) {
-					//$section0 = $thissection;
-					//continue;
-					$nameSection[$section] = "Section 0";
-					$idSection[$section] =  $section;
-				}*/
-				$numsections = course_get_format($course)->get_last_section_number();
-
-				// var_dump($numsections);
-				// if ($section > $numsections) {
-				// // if ($section > $course->numsections) {
-				// 	// continue;
-				// }
-				/* if is not editing verify the rules to display the sections */
-				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;
-					}
-				}
-				
-				
-				//Affiche le nom de la section en mode propre sans lien
-				$idSection[$section] = $thissection->id;
-				// $nameSection[$section] .= $this->section_title_without_link($thissection, $course);
-				$nameSection[$section] = $this->section_title_without_link($thissection, $course);
-				if ($PAGE->user_is_editing()) {
-					$htmlsection[$section] .= $this->section_header($thissection, $course, false, 0);
-				}
-				//$htmlsection[$section] .= $this->section_title($thissection,$course);
-				//$introSection[$section] .= $this->section_header($thissection, $course, false, 0);
-				$introSection[$section] = $this->section_header($thissection, $course, false, 0, true);
-				if ($thissection->uservisible) {
-					/* Ne pas enlever sinon le activity chooser ne fonctionne pas en JS */
-					$htmlsection[$section] .= "<div class='content'>";
-					// Renvoie le lien du cours avec icone
-					$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>";
-				}
-				/* pas de footer car on ne commence par la structure par une div non fermée et que ce footer ferme par une div */
-				// $htmlsection[$section] .= $this->section_footer();
-				
-				
-			} //ENDFOREACH
+		// echo $completioninfo->display_help_icon();
+		
+		echo $this->output->heading($this->page_title(), 2, 'accesshide');
+		echo $this->course_activity_clipboard($course, 0);
+		echo $this->start_section_list();
+		
+		
+		//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
 
+		if ($PAGE->user_is_editing()) {
 			// echo $completioninfo->display_help_icon();
-			
 			echo $this->output->heading($this->page_title(), 2, 'accesshide');
 			echo $this->course_activity_clipboard($course, 0);
 			echo $this->start_section_list();
-			
-			//traitement section 0
-			/*if ($section0->summary || !empty($modinfo->sections[0]) || $PAGE->user_is_editing()) {
-				$htmlsection0 = $this->section_header($section0, $course, false, 0);
-				$htmlsection0 .= $this->courserenderer->course_section_cm_list($course, $section0, 0);
-				$htmlsection0 .= $this->courserenderer->course_section_add_cm_control($course, 0, 0);
-				$htmlsection0 .= $this->section_footer();
-			}*/
-			//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');
-				echo $this->course_activity_clipboard($course, 0);
-				echo $this->start_section_list();
-			}
+		}
+
+
+
 
-			// if ($course->sectionposition == 0 and isset($htmlsection0)) {
-			// 	if ($PAGE->user_is_editing()){
-			// 		echo html_writer::tag('span', $htmlsection0, ['class' => 'above']);
-			// 	}
-			// }
-			//echo $this->get_button_section($course, $sectionvisible);
 			//here all activities are displayed
 			//If we are in etition mode then we display the "BASE" page Otherwise our model
-			if (!$PAGE->user_is_editing()) {
-				echo $this->get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection);
-			} else {
-				foreach ($htmlsection as $current) {
-					echo $current;
-				}
+		if (!$PAGE->user_is_editing()) {
+			echo $this->get_view_iena($course, $htmlsection, $nameSection, $introSection, $idSection);
+		} else {
+			foreach ($htmlsection as $current) {
+				echo $current;
 			}
+		}
 			//At this stage nothing is yet displayed except the icon: Your progress
 			// if ($course->sectionposition == 1 and isset($htmlsection0)) {
 				// if ($PAGE->user_is_editing())
 				// 	echo html_writer::tag('span', $htmlsection0, ['class' => 'below']);
 			// }
-			
+
 			//Add the + and - at the end of the page to see which part of the code to really keep
-			if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
-				foreach ($modinfo->get_section_info_all() as $section => $thissection) {
-					if ($section <= $numsections or empty($modinfo->sections[$section])) {
-						continue;
-					}
-					echo $this->stealth_section_header($section);
-					echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
-					echo $this->stealth_section_footer();
+		if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
+			foreach ($modinfo->get_section_info_all() as $section => $thissection) {
+				if ($section <= $numsections or empty($modinfo->sections[$section])) {
+					continue;
 				}
-				echo $this->end_section_list();
-				echo html_writer::start_tag('div', ['id' => 'changenumsections', 'class' => 'mdl-right']);
-				$straddsection = get_string('addsections');
-				$url = $url = new moodle_url('/course/changenumsections.php', ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, 'sesskey' => sesskey(), 'sectionreturn' => 0]);
-				$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
-				echo html_writer::link($url, $icon . $straddsection, ['class' => 'increase-sections']);
-				// if ($course->numsections > 0) {
-					// $strremovesection = get_string('reducesections', 'moodle');
-					// $url = new moodle_url('/course/changenumsections.php', ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, 'sesskey' => sesskey(), 'sectionreturn' => 0]);
-					// // http://localhost:8888/moodle35/course/changenumsections.php?courseid=5&insertsection=0&sesskey=IYEFeaNxbo&sectionreturn=0
-					// $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
-					// echo html_writer::link(
-					// 	$url,
-					// 	$icon . get_accesshide($strremovesection),
-					// 	['class' => 'reduce-sections']
-					// );
-				// }
-				echo html_writer::end_tag('div');
-			} else {
-				echo $this->end_section_list();
+				echo $this->stealth_section_header($section);
+				echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
+				echo $this->stealth_section_footer();
 			}
-			echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }');
-			if (!$PAGE->user_is_editing()) {
+			echo $this->end_section_list();
+			echo html_writer::start_tag('div', ['id' => 'changenumsections', 'class' => 'mdl-right']);
+			$straddsection = get_string('addsections');
+			$url = $url = new moodle_url('/course/changenumsections.php', ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, 'sesskey' => sesskey(), 'sectionreturn' => 0]);
+			$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
+			echo html_writer::link($url, $icon . $straddsection, ['class' => 'increase-sections']);
+				
+			echo html_writer::end_tag('div');
+		} else {
+			echo $this->end_section_list();
+		}
+		echo html_writer::tag('style', '.course-content ul.iena #section-' . $sectionvisible . ' { display: block; }');
+		//if (!$PAGE->user_is_editing()) {
 				//$PAGE->requires->js_init_call('M.format_iena.init', [$course->numsections]);
+		//}
+
+	}
+
+	/**
+	 * Fetch the course sections with infos
+	 * @param StdObject $course 
+	 * @param bool $onsectionpage 
+	 * @return templates
+	 */
+	public function get_iena_sections($course, $editing, $onsectionpage=false){
+		global $PAGE, $USER;
+
+		$context = context_course::instance($course->id);
+		
+		$completion = new \completion_info($course);
+		$groups=groups_get_all_groups($course->id);
+		
+
+
+		$modinfo = get_fast_modinfo($course);
+		
+		if (isset($_COOKIE['sectionvisible_' . $course->id])) {
+			$sectionvisible = $_COOKIE['sectionvisible_' . $course->id];
+		} elseif ($course->marker > 0) {
+			$sectionvisible = $course->marker;
+		} else {
+			$sectionvisible = 1;
+		}
+		$htmlsection = false;
+		$nameSections = [];
+		$idSections = [];
+		$introSection = false;
+	
+
+
+		$sections=['sections'=>[]];
+
+
+		
+
+		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))) {
+				if (isset($course->hiddensections) && !(int)$thissection->visible) {
+					continue;
+				}
+				if (!$thissection->available && !empty($thissection->availableinfo)) {
+					$thissection= $this->get_section_header($thissection, $course, false, 0, $groups);
+					
+					continue;
+				}
+				if (!$thissection->uservisible || !$thissection->visible) {
+					$htmlsection = $this->section_hidden($section, $course->id);
+					
+					continue;
+				}
+			}
+			$thissection=$this->get_section_header($thissection, $course, false, 0, true, $groups);
+
+			if ($thissection->uservisible) {
+				$thissection->resources= $this->courserenderer->course_section_cm_list($course, $thissection, 0);
+				if ($editing) {
+
+					$thissection->addresources = $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0);
+					$thissection->leftcontent = $this->section_left_content($thissection, $course, $onsectionpage);
+					$thissection->rightcontent = $this->section_right_content($thissection, $course, $onsectionpage);
+
+				}
+		
 			}
+
+
+			array_push($sections['sections'], $thissection);
+			array_push($nameSections, $thissection->name);
+			array_push($idSections, $thissection->id);
+		}
+		if($editing){
+			$sections['link_add_sections']=new moodle_url('/course/changenumsections.php', ['courseid' => $course->id, 'insertsection' => 0, 'increase' => false, 'sesskey' => sesskey(), 'sectionreturn' => 0]);
+		}
+		echo $this->get_view_iena_new($course, $nameSections, $idSections);
+		echo $this->render_from_template('format_iena/sections', $sections);
+		
+	}
+
+
+
+	//If edit mode, we use the old code that generates HTML, else we use the templates - bientôt useless
+	public function switch_mode($course){
+		global $PAGE, $CFG;
+		$context = context_course::instance($course->id);
+		$course = course_get_format($course)->get_course();
+		if($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)){
+			//$this->print_iena_section_pages($course);
+			$this->get_iena_sections($course, true);
+		}
+		else{
 			
+			$this->get_iena_sections($course, false);
 		}
 	}
+
+	public function display_completion($data){
+		echo $this->render_from_template('format_iena/suivi', $data);
+	}
+
+	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/save_sync_task_iena_hide.php b/save_sync_task_iena_hide.php
deleted file mode 100644
index 4271d1801e5e805b568541aa88e0c948e4ebddbb..0000000000000000000000000000000000000000
--- a/save_sync_task_iena_hide.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-	/**
-	 * Created by PhpStorm.
-	 * User: softia
-	 * Date: 15/03/18
-	 * Time: 16:22
-	 */
-
-// 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/>.
-	
-	/**
-	 *
-	 * sync_task_iena_message lunch cron_hide_section()
-	 *
-	 * @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
-	 */
-	
-	namespace format_iena\task;
-	
-	class sync_task_iena_hide extends \core\task\scheduled_task
-	{
-		/**
-		 * Get a descriptive name for this task (shown to admins).
-		 *
-		 * @return string
-		 */
-		
-		public function get_name()
-		{
-			return "task_iena_hide_section";
-		}
-		
-		
-		public function execute()
-		{
-			global $CFG;
-			require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_cron_action.php');
-			$cron_test = new \course_format_iena_cron_action();
-			echo 'cron_hide_section start';
-			$cron_test->cron_hide_section();
-			echo 'cron_hide_section stop';
-		}
-		
-	}
\ No newline at end of file
diff --git a/send_message.php b/send_message.php
new file mode 100644
index 0000000000000000000000000000000000000000..f589f690fe55156c71019a4a87f7612ece00d616
--- /dev/null
+++ b/send_message.php
@@ -0,0 +1,187 @@
+<?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 form is cancelled, we go back to the table. Else, we send the message and then go back to the table, with a success or failure message.
+	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/send_message_post.php b/send_message_post.php
deleted file mode 100644
index 4d123af9aef07f4cb216a33773d2c947e8e7d2ff..0000000000000000000000000000000000000000
--- a/send_message_post.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?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
diff --git a/styles.css b/styles.css
index 7231081abf5dbc4af42edeb5dbd64d9fe689f17f..06d33e32f85b6966213b580c3871888eb8f23ded 100644
--- a/styles.css
+++ b/styles.css
@@ -60,7 +60,10 @@ ul.iena-editing .voir-plus {
 }
 
 .iena-editing h3.sectionname {
-	margin: 1rem 0;
+	/*margin: 1rem 0;*/
+	margin: 0;
+	padding:0 10px;
+	background: transparent;
 }
 
 /*
@@ -94,6 +97,7 @@ ul.nav.navbar-nav.ml-auto {
 	padding-bottom: 1.3rem;
 	padding-top: 1%;
 	clear: both;
+	border-bottom: none!important;
 }
 
 .iena-section > .card.card_block {
@@ -101,18 +105,24 @@ ul.nav.navbar-nav.ml-auto {
 }
 
 .set_height {
-	min-height: 3rem;
-	line-height: 1.7rem;
+	/*min-height: 3rem;*/
+	line-height: 2.4rem;
 }
 
 .heading-iena {
-	background: #666;
+	background: #D6D6D6;
 	padding: 0rem;
-	color: white;
+	
 	float: left;
 	width: 100%
 }
 
+.heading-iena .right.side{
+	margin-top: 0;
+	padding: 0 6px 0;
+    text-align: right;
+    width: auto;
+}
 .iena-heading_title {
 	background: #2d2d2d;
 	padding: 0rem;
@@ -152,20 +162,38 @@ ul.nav.navbar-nav.ml-auto {
 
 .titre_section {
 	float: left;
-	padding-top: 1rem;
-	padding-left: 0.8rem;
+	
+	/*padding-left: 0.8rem;*/
 	padding-right: 1rem;
 	font-size: 1.4rem;
+	color: #1a1a1a;
+    font-weight: 100;
 	/*font-weight: bold;*/
 }
 
+.titre_section p {
+	margin-bottom: 0;
+	display: inline-block;
+	padding-left: 0.5rem;
+}
+
+.titre_section .label_item.sect-date{
+	display: inline-block;
+	border-left: none;
+}
+
 .nb_pers {
 	text-align: center;
-	background: #d68d01;
-	float: left;
-	min-width: 4rem;
-	padding: 1rem 0.7rem;
-	font-size: 1rem;
+    background: #009186;
+    float: right;
+    min-width: 4rem;
+    padding: .6rem .6rem;
+    font-size: 14px	;
+    border-radius: 5px;
+    margin-top: 0.35rem;
+    line-height: 0.5rem;
+    margin-right: .4rem;
+    margin-left: .4rem;
 }
 .nb_pers a {
 	color: white;
@@ -180,17 +208,20 @@ ul.nav.navbar-nav.ml-auto {
 }
 
 .label_item.sect-date {
-	color: #fafafa;
-	border: 1px solid #fafafa;
-	border-radius: .15rem;
-	/* margin: 0.9rem; */
-	margin: 0.9rem 0.2rem 0.9rem 0.2rem;
-	/* margin-right: 0; */
-	padding: .05rem .6rem;
-	float: left;
-	font-weight: 700;
-	background-color: #666;
-	font-size: 0.85rem;
+    /* color: #fafafa; */
+    /* border: 1px solid #fafafa; */
+    border-right: 1px solid white;
+    border-left: 1px solid white;
+    border-radius: .15rem;
+    /* margin: .9rem .2rem .9rem .2rem; */
+    padding: .05rem .6rem;
+    float: left;
+    font-weight: 700;
+    /* background-color: #666; */
+    font-size: .85rem;
+    line-height: 2.4rem;
+    color: #666;
+    font-weight: 400;
 }
 
 .iena-description {
@@ -273,8 +304,10 @@ ul.nav.navbar-nav.ml-auto {
 
 /* Bottom header */
 
-.iena-course-header-bottom {
-	margin-bottom: 1.6rem;
+.iena-course-header > .iena-course-header-bottom {
+	margin-bottom: 40px;
+    background: #eaeaea;
+    padding: 15px;
 }
 
 /* Toggler */
@@ -296,6 +329,33 @@ ul.nav.navbar-nav.ml-auto {
 
 /* Progress detail */
 
+.iena-progress-header .iena-progress-label, .iena-progress-header .progress-wrapper{
+	display: inline-block;
+
+}
+
+.iena-progress-header .progress{
+	width: 200px;
+	background-color:white;
+}
+
+.iena-progress-header{
+	background-color: #eaeaea;
+    padding: 10px;
+    margin-bottom: 20px;
+}
+
+.progress-wrapper{
+	vertical-align: 8%;
+}
+
+.iena-h-prog-sect{
+	margin-left: 5px!important;
+    padding-left: 20px;
+    margin-top: 7px;
+    border-left: 1px solid lightgrey;
+}
+
 .iena-h-prog-sect h2 {
 	margin-bottom: 1rem;
 }
@@ -304,30 +364,62 @@ ul.nav.navbar-nav.ml-auto {
 	clear: both;
 }
 
+
+.iena-progress-legend #caption-iena{
+	margin-top: 10px;
+}
+
+.iena-progress-legend #caption-iena .caption-status{
+	margin-right: 0;
+	display: block;
+	margin-bottom: 5px;
+	cursor: default!important;
+}
+
+.iena-progress-legend #caption-iena .caption-status .pointer-help{
+	width: 1rem;
+    height: 1rem;
+    vertical-align: middle;
+    border-radius: 10px;
+}
+
+
+.iena-progress-legend #caption-iena .caption-status .pointer-help .icon-progress{
+	line-height: 17px;
+}
+
+
+
 /* Section progression block */
 
 /* Section progression name and % */
 .btn-outline-success.iena-h-prog-name {
 	color: #009085;
-	border-color: #009085;
-	border-radius: 0.15rem;
-	max-width: 300px;
-	overflow: hidden;
-	position: relative;
-	margin-bottom: 0.5rem;
-	float: left;
-	clear: left;
-	min-width: 300px;
-	text-align: left;
+    border-color: #009085;
+    border-radius: .15rem;
+    max-width: 300px;
+    display: block;
+    /* overflow: hidden; */
+    /* position: relative; */
+    /* margin-bottom: .5rem; */
+    /* float: left; */
+    /* clear: left; */
+    min-width: 300px;
+    text-align: left;
+}
+.iena-h-prog-name{
+	display: block;
+	font-size: initial;
 }
 .btn-outline-success.iena-h-prog-name:before {
-	content:'';
+	/*content:'';
 	width:100%;
 	height:100%;
 	position:absolute;
 	left:0;
 	top:0;
 	background:linear-gradient(90deg, rgba(255, 255, 255, 0) 245px, rgba(255, 255, 255, 1) 289px);
+	*/
 }
 .btn-outline-success.iena-h-prog-name:hover,
 .btn-outline-success.iena-h-prog-name:active {
@@ -345,16 +437,82 @@ ul.nav.navbar-nav.ml-auto {
 	border-color: #009085 !important;
 }
 
+.details-progress{
+	padding-left: 0!important;
+}
+
+.details-progress .section-progress{
+	margin-bottom: 0.5rem;
+}
+
+
+.details-progress .section-progress .progress-wrapper{
+	width: 300px;
+	display: inline-block;
+}
+
+.details-progress .section-progress .progress-wrapper .progress{
+	height: 0.5rem;
+}
+
+.details-progress .section-progress .progress-wrapper .iena-prog-label{
+	font-size: small;
+}
+
+
+.details-progress:target::before{
+	display: none!important;
+}
+.details-progress:before{
+	display: none!important;
+}
+
+
 /* Represent a course module link as a bullet */
 .iena-h-prog-mod-item {
 	border-radius: 1.5rem;
-	float: left;
-	min-width: 1.5rem;
-	min-height: 1.5rem;
-	position: relative;
-	margin-left: 0.25rem;
-	margin-top: 0.4rem;
+    display: inline-block;
+    line-height: 36px;
+    vertical-align: top;
+    /* float: left; */
+    min-width: 1.5rem;
+    display: inline-block;
+    /* height: 24px; */
+    /* width: 24px; */
+    height: 1.5rem;
+    position: relative;
+    margin-left: .25rem;
+    margin: auto;
+    text-align: center;
+    /* margin-top: .4rem;*/
+}
+
+.section-progress .iena-h-prog-mod-item{
+	height: 1rem;
+	width: 1rem;
+	min-width: 1rem;
+}
+
+.section-progress .iena-prog-bubble .icon-progress{
+	line-height: 17px;
 }
+
+.iena-prog-bubble .icon-progress{
+	line-height: 24px;
+
+}
+
+.iena-prog-link{
+	display: block;
+	display: block;
+    width: 100%;
+    height: 100%;
+    position: absolute;
+    /* float: right; */
+    top: 0;
+}
+
+
 /* .iena-h-prog-mod-item.iena-g-prog-done {
 	background-color: #009085;
 	border-color: 1px solid red;
@@ -380,26 +538,26 @@ ul.nav.navbar-nav.ml-auto {
 }
 
 /* Course module name in a bubble */
-.iena-h-prog-mod-item span {
+.iena-h-prog-mod-item span.popover-module {
 	display: none;
 	position: absolute;
 	top: -3rem;
 	left: -85px;
 	background-color: #333;
 	color: #fafafa;
-	padding: 0 15px;
+	padding: 0 5px;
 	width: 200px;
 	height: 2.5rem;
 	line-height: 2.5rem;
 	border-radius: 0.15rem;
-	font-size: 1rem;
+	font-size: 0.9rem;
 	text-align: center;
 	overflow: hidden;
 }
-.iena-h-prog-mod-item:hover span {
+.iena-h-prog-mod-item:hover span.popover-module {
 	display: inline;
 }
-.iena-h-prog-mod-item span:before {
+.iena-h-prog-mod-item span.popover-module:before {
 	content:'';
 	width:100%;
 	height:100%;
@@ -418,5 +576,303 @@ ul.nav.navbar-nav.ml-auto {
 }
 
 
+ #summary-wrapper{
+ 	padding-left: 1px;
+ 	display: block;
+	max-height: 7rem;
+	height: auto;
+	overflow: hidden;
+	margin-bottom: 5px;
+ }
+
+/*#title-summary-iena #summary-collapse.collapse:not(.show) {
+  display: block;
+  max-height: 7rem;
+  height: auto;
+  overflow: hidden;
+
+}
+
+#title-summary-iena #summary-collapse.collapsing {
+	height: auto;
+  max-height: 100rem;
+      -webkit-transition: max-height .35s ease;
+    -o-transition: max-height .35s ease;
+    transition: max-height .35s ease;
+    transition: max-height 1s ease;
+}*/;
+
+
+
+#days-text{
+	margin:0 20px 0 5px;
+}
+
+
+
+
+
+/*#################################   CSS TABLEAU DE SUIVI ##########################################*/
+/* Permet la rotation des entêtes du tableau */
+th.th-rotate {
+	/* Something you can count on */
+	height: 140px;
+	white-space: nowrap;
+	position: sticky;
+	top:0;
+	background: white;
+}
+
+th.th-rotate > div {
+	transform: 
+	/* Magic Numbers */
+	translate(18px, 53px)
+	/* 45 is really 360 - 45 */
+	rotate(315deg);
+	width: 30px;
+}
+th.th-rotate > div > span {
+	border-bottom: 1px solid #ccc;
+	padding: 5px 10px;
+	padding-bottom: 2px;
+    width: 180px;
+    display: block;
+
+}
+/* Change la couleur une ligne sur deux dans le tableau */
+#table-body tr:nth-child(even) { background: #fafafa; }
+#table-body tr:nth-child(odd) { background: #eee; }
+
+#table-body tr{
+	border-bottom: 1px solid white;
+}
+
+
+/* Colorie la cellule en fonction de l'achèvement */
+
+/*.state-0 { background-color: rgba(0, 143, 132, 0.23); }
+.state-1 { background-color: #009085; }
+.state-2 { background-color: #009085; }
+.state-3 { background-color: rgba(214, 141, 1, 0.4); }*/
+
+.state-0 { background-color: #CECECE; }
+.state-1 { background-color: #40ACA3; }
+.state-2 { background-color: #40ACA3; }
+.state-3 { background-color: #F3A41C}; 
+
+
+.state-0 span.icon-progress, .state-1 span.icon-progress, .state-2 span.icon-progress, .state-3 span.icon-progress{
+	content: "";
+	display: block;
+	color: white;
+}
+
+.state-1 span.icon-progress::after{
+	content: "\f1db";
+	font-family: FontAwesome; width: 100%; display: inline-block;text-align: center; 
+	color: white;
+	font-size: x-large;
+}
+
+.state-2 span.icon-progress::after{
+	content: "\f05d";
+	font-family: FontAwesome; width: 100%; display: inline-block; text-align: center;
+	color: white;
+	font-size: x-large;
+}
+.state-3 span.icon-progress::after{
+	content: "\f1db";
+	font-family: FontAwesome; width: 100%; display: inline-block; text-align: center;
+	color: white;
+	font-size: x-large;
+}	
+
+.section-progress span.icon-progress::after, .iena-progress-legend span.icon-progress::after{
+	font-size: small;
+}
+
+
+
+#first-column-head, #iena-select-all {
+	vertical-align: bottom;
+	padding-bottom: 0.5rem;
+}
+
+.pointer-help {
+	cursor: default!important;
+}
+
+.stud_perc {
+	min-width: 45px;
+	display: inline-block;
+}
+
+#table-body td { 
+	border-right: 1px solid #eee;
+
+	 }
+
+/* Scroll de la table */
+#table-body {
+	display: table-row-group; 
+	/*overflow-y:scroll;*/
+	/*overflow: auto; 
+	margin-right: 10rem;
+	height: 300px;
+	height: 50vh; */
+}
+
+#suivi thead {
+	display: table-header-group; 
+	/*overflow-x:scroll;*/
+	
+	
+	height: 143px;
+}
+
+#suivi thead tr th:nth-child(1) {
+	/*width:20em;
+	min-width:20em;*/
+
+}
+#suivi thead tr th {
+	min-width:32px;
+}
+#suivi tbody tr th {
+	width:20em;
+	min-width:20em;
+	word-break: break-word;
+}
+#suivi tbody tr td {
+	min-width:32px;
+}
+
+#suivi input[type="checkbox"] {
+	margin: 5px;
+	font-size: 1rem;
+}
+
+.mb1 { margin-bottom: 1rem; }
+.mt1 { margin-top: 1rem; }
+
+
+#suivi .first-column-iena{
+	width: 2em;
+	min-width: 2em;
+	left: 0;
+}
+#suivi .second-column-iena{
+	width: 3em;
+    min-width: 3em;
+    left:2em;
+    text-align: center;
+
+    
+}
+#suivi .third-column-iena{
+	width: 15em;
+    min-width: 15em;
+    padding-left: 6px;
+    left: 10em;
+	
+}
+
+#suivi .actions-column-iena{
+	width: 5em;
+    min-width: 5em;
+    left: 5em;
+    text-align: center;
+}
 
+tbody th{
+	font-weight: normal;
+}
+
+
+#suivi thead .first-column-iena, #suivi thead .second-column-iena, #suivi thead .third-column-iena,#suivi thead .actions-column-iena{
+	vertical-align: bottom;
+	padding-bottom: .5rem;
+}
+
+#caption-iena .caption-status{
+	display: inline-block;
+	margin-right: 20px;
+}
+
+#caption-iena .caption-status .pointer-help{
+	width: 32px;
+	height: 25px;
+	margin-right: 2px;
+	display: inline-block;
+	vertical-align: bottom;
+}
+
+#caption-iena .caption-status .pointer-help .icon-progress{
+	line-height: 26px;
+}
+#caption-iena .caption-status .caption-title{
+	display: inline-block;
+}
+
+#caption-iena{
+	margin-top: 20px;
+	margin-bottom: 40px;
+}
+
+
+.iena-icon-distance, .iena-icon-presence{
+	content: "";
+	display: block;
+	color: white;
+}
+
+.iena-icon-presence::after{
+	content: "\f0c0";
+	font-family: FontAwesome; width: 100%; display: inline-block;text-align: center; 
+	color: black;
+	font-size: large;
+}
+
+.iena-icon-distance::after{
+	content: "\f108";
+	font-family: FontAwesome; width: 100%; display: inline-block;text-align: center; 
+	color: black;
+	font-size: large;
+}
+
+.iena-caption-sections > .iena-caption-icons, .iena-caption-sections > .iena-caption-icons > * {
+	display: inline-block;
+	margin-right: 7px;
+}
+
+.iena-caption-sections > .iena-caption-icons{
+	margin-right: 20px;
+}
+
+.table-wrapper{
+  position: relative;
+  overflow: auto;
+  white-space: nowrap;
+  max-height: 600px;
+  border:none;
+}
+
+.first-column-iena, .second-column-iena, .actions-column-iena, .third-column-iena{
+    position: sticky;
+    background: inherit;
+}
+
+th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-column-iena{
+    background: white;
+    z-index: 200;
+    position: sticky;
+    top: 0;
+}
+
+#partial-table{
+	margin-bottom: 20px;
+}
 
+.iena-message{
+	margin-top: 20px;
+}
\ No newline at end of file
diff --git a/suivi_unit.php b/suivi_unit.php
index ed45ff93c92caae47733eb3d62bc771969d1d93b..56c650d66297a9f90643540f67ef5299e19b15d1 100644
--- a/suivi_unit.php
+++ b/suivi_unit.php
@@ -29,30 +29,319 @@ require_once('view/view_param_indicateur.php');
 require_once('entity/course_format_iena_section_ressources.php');
 require_once('entity/course_format_iena_sections.php');
 require_once('entity/course_format_iena_groups.php');
+$PAGE->requires->css('/course/format/iena/styles.css');
+
+
+global $COURSE, $DB, $USER, $PAGE;
+
+function init_page($course){
+	global $PAGE;
+	// Defines the id of the course with a get parameter
+	
+	// Getting DB information (*)  of the course
+	
+	$PAGE->set_title($course->fullname);
+	$PAGE->set_heading($course->fullname . " – " .get_string('table_progress', 'format_iena'));
+
+	$PAGE->set_pagelayout('incourse');
+
+
+	/* Cache le menu dans le header ?  */
+	$coursenode = $PAGE->navbar->add(get_string('table_progress', 'format_iena'), null, navigation_node::TYPE_CONTAINER, null, 'suiviena');
+	$coursenode->make_active();
+	$coursenode->force_open();
+
+}
+
+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). */
+	
+
+	// @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();
+	/* 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 = [];
+	$active_group_name = "";
+	
+	foreach ($groups as $group) {
+		/* Récupération du nom du group actif au passage */
+		if ( $group->id == $active_group_id ) {
+			$active_group_name = $group->name;
+
+			$group->selected='selected';
+		}
+		foreach ($current_user_groups_ids as $ugi) {
+			if ( $group->id == $ugi ) {
+				$current_user_groups[] = $group;
+			}
+		}
+	}
+
+	//Réservé pour l'export ?
+	/*if ( $active_group_id == 0 ) {
+		foreach ($progress as $prog) {
+
+			
+			$prog->groups = "";
+			foreach ($groups as $group) {
+				if ( in_array($prog->id, $group->members) ) {
+					$prog->groups .= $group->name . " ";
+				}
+			}
+		}
+	}*/
+	return $groups;
+
+}
+
+//Formate l'achèvement d'activités pour le tableau de suivi. Pour chaque étudiant, on aura dans le bon ordre la liste des modules et le completionstate
+function format_progress($progress, $modules, $groups, $active_group_id, $active_section_id){
+	global $CFG, $COURSE;
+	$students=array();
+	foreach ($progress as $prog_info) {
+		$progress_student=new StdClass();
+		$progress_student->firstname=$prog_info->firstname;
+		$progress_student->lastname=$prog_info->lastname;
+		//$progress_student->name=$prog_info->firstname." ".$prog_info->lastname;
+		$progress_student->id=$prog_info->id;
+		$progress_student->email=$prog_info->email;
+		$progress_student->progress=array();
+		$progress_student->report_link=$CFG->wwwroot . "/report/outline/user.php?id=" . $progress_student->id . "&course=" . $COURSE->id . "&mode=outline";
+		$progress_student->message_link=$CFG->wwwroot . "/message/index.php?id=" . $progress_student->id;
+
+
+		if ( $active_group_id == 0 ) {	
+			$progress_student->groups = "";
+			foreach ($groups as $group) {
+				if ( in_array($progress_student->id, $group->members) ) {
+					$progress_student->groups .= $group->name . " ";
+				}
+			}
+		}
+
+
+		foreach($modules as $key=>$module){
+			
+			$module_progress=new StdClass();
+			
+			if(!isset($prog_info->progress[$module->id])){
+				
+				$module_progress->completionstate='0';
+			}
+			else{
+				$module_progress->completionstate=$prog_info->progress[$module->id]->completionstate;
+			}
+			/*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;
+			
+			$progress_student->progress[$key]=$module_progress;
+		}
+
+		$students[]=$progress_student;
+	}
+	return $students;
+	
+}
+
+
+function get_activities($completion, $active_section_id){
+	$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) > 20 ? mb_substr($displayname, 0, 19, 'UTF-8').'…' : $displayname;
+		$module->section = $activity->section;
+		$modules[] = $module;
+		if($activity->section == $active_section_id || $active_section_id==0 ){
+			$module->visible=true;
+		}
+		else{
+			$module->visible=false;
+		}
+		
+	}
+	return $modules;
+}
+
+function get_sections($active_section_id){
+	global $COURSE;
+	// Liste des sections du cours
+	$modinfo = get_fast_modinfo($COURSE->id);
+	$sections_info_all = $modinfo->get_section_info_all();
+	$sections = [];
+
+	
+
+
+	foreach ($sections_info_all as $key => $section_info) {
+		$section = new StdClass();
+		$section->id = $section_info->id;
+		$section->name = $section_info->name === NULL || $section_info->name === '' ? 'Section ' . $key : $section_info->name;
+		if($section->id==$active_section_id){
+			$section->selected="selected";
+		}
+
+		$sections[] = $section;
+
+	}
+	return $sections;
+}
+
+
+
+
+function set_filters($data, $filters, $symbols, $sections, $groups, $current_user_groups, $active_group_name, $active_section_id){
+	
+	if (isset($_GET['filter'])) {
+		$filterComplete = $_GET['filter'];
+		$symbols[substr($filterComplete, 0, 1)]->selected="selected";
+		$filters[substr($filterComplete, 1)]->selected="selected";
+	} else {
+		$filters["0"]->selected="selected";
+		$symbols[">"]->selected="selected";
+	}
+
+
+	$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;
+	//$data['active_section_id']=$active_section_id;
+
+	if($active_group_name==""){
+		$data['default_group']='selected';	
+	}
+
+
+	$data['data']=array();
+	$data['data']["sections"]=$sections;
+	$data['data']["groups"]=array_values($groups);
+	$data['data']['current_user_groups']=$current_user_groups;
+	$data['data']['active_group_name']=$active_group_name;
+	$data['data']['active_section_id']=$active_section_id;
+
+	return $data;
+}
+
+function set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id){
+	
+	global $COURSE, $USER, $CFG;
+
+
+
+
+	$data["modules"]=$modules;
+	$count_modules=count($data["modules"]);
+
+	$data["students"]=format_progress($progress, $modules, $groups, $active_group_id, $active_section_id);
+	$count_students=count($data["students"]);
+
+	if($count_students>0 && $count_modules>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;
+
+
+	//Pour le téléchargement du tableau ?
+	if(!isset($data['data'])){
+		$data['data']=array();
+	}
+	
+
+	$data['data']=json_encode($data);
+	
+
+
+	return $data;
+
+
+}
+
+$filters=[
+	"0"=>(object)[
+		"value"=>"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=[
+	"="=>(object)[
+		"value"=>"=",
+		"name"=>"=",
+	],
+	"<"=>(object)[
+		"value"=>"<",
+		"name"=>"<",
+	],
+	">"=>(object)[
+		"value"=>">",
+		"name"=>">",
+	]
+];
 
-global $COURSE, $DB, $USER;
 
-// global $CFG;
-// require_once ($CFG->libdir . '/csvlib.class.php');
-// $arr = [
-// 	["a", "b", "c"],
-// 	["d", "e", "f"]
-// ];
-// csv_export_writer::download_array("machin.csv", $arr);
 
-// Defines the id of the course with a get parameter
 $courseID = required_param('courseid', PARAM_INT);
 // Define the url of the view
 $url = new moodle_url('/course/format/iena/suivi_unit.php', array('courseid' => $courseID));
 
-$PAGE->set_pagelayout('course');
+
 $PAGE->set_url($url);
 
-// Getting DB information (*)  of the course
+
+
 $course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
-require_login($course, false, NULL);
-$PAGE->set_title($course->fullname);
-$PAGE->set_heading($course->fullname . " – Suivi des étudiants");
+require_login($course);
+
+require_once($CFG->libdir . '/completionlib.php');
+$completion = new completion_info($course);
+$context = context_course::instance($COURSE->id);
 
 // if (!has_capability('moodle/course:sectionvisibility', $context = context_course::instance($courseID), $USER->id)) {
 if (!has_capability('course/iena:suivi', $context = context_course::instance($courseID), $USER->id)) {
@@ -60,46 +349,85 @@ if (!has_capability('course/iena:suivi', $context = context_course::instance($co
 	header("Location: {$link}");
 	exit;
 }
-echo $OUTPUT->header();
+
+
+if(isset($_GET['groupid'])){
+	$active_group_id = $_GET['groupid'];
+}
+else{
+	$active_group_id=0;
+}
+
+$progress = $completion->get_progress_all(
+	'',
+	array(),
+	$active_group_id,
+	'u.lastname ASC, u.firstname ASC',
+	'',
+	'',
+	$context
+);
+
+
+$active_section_id=0;
+// Section du get acquise depuis le clic sur l'indicateur dans la page du cours, section depuis laquelle on a cliqué sur le bouton pour voir le suivi. 
+
+if(isset($_GET['sectionid'])){
+	$active_section_id = $_GET['sectionid'];
+}
+
+
+
+if ( $active_group_id == 0 ) {
+	//On récupère les ids des membres parce que dans l'excel on veut savoir qui appartient à quel groupe 
+	//$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', true);
+	$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', true);
+} else {
+	//On ne récupère pas les ids des membres
+	$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', false);
+}
+
+
 
 // If a post is sent trought the page
-if ($_POST) {
+/*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 {
+} else */
+if(isset($_POST['action']) && !empty($_POST['action'])) {
+	//Si on change les filtres
+	$data=[];
+	$modules=get_activities($completion, $active_section_id);
 
-	// $view_param_indicateur = new view_param_indicateur();
-	// $sections = $view_param_indicateur->get_course_sections_modules();
-	// $Tab_id_modules = array();
-	// $i = 0;
-	
-	// foreach ($sections as $section) {
-	// 	foreach ($section->ressources as $mod) {
-	// 		$Tab_id_modules[$i] = $mod->id;
-	// 		$i++;
-	// 	}
-	// }
-	
-	// foreach ($sections as $section) {
-	// 	foreach ($Tab_id_modules as $id_module) {
-	// 		$verif_db = $DB->get_record('format_iena_settings', array('cmid' => $id_module, 'sectionid' => $section->id), '*');
-			
-	// 		if ($verif_db == false) {
-	// 			$format_iena_setting_data = new stdClass();
-	// 			$format_iena_setting_data->cmid = $id_module;
-	// 			$format_iena_setting_data->hide = 0;
-	// 			$format_iena_setting_data->courseid = $COURSE->id;
-	// 			$format_iena_setting_data->sectionid = $section->id;
-	// 			$DB->insert_record('format_iena_settings', $format_iena_setting_data, false);
-	// 		}
-	// 	}
-	// }
-	
-	// require_once('view/view_suivi_unit.php');
-	require_once('view/view_suivi_unit3.php');
+	$data=set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id);
+	echo json_encode($data);
 }
+else {
+
+	init_page($course, $PAGE);
+	echo $OUTPUT->header();
+	$current_user_groups=[];
+	$active_group_name="";
+	$data=[];
+
+	$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, $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();
+}
+
+
 
-echo $OUTPUT->footer();
\ No newline at end of file
+?>
\ No newline at end of file
diff --git a/suivi_unit_old.php b/suivi_unit_old.php
new file mode 100644
index 0000000000000000000000000000000000000000..b69a4491bdf0fc22d1df55d7ec052fa7c46ce6f9
--- /dev/null
+++ b/suivi_unit_old.php
@@ -0,0 +1,353 @@
+<?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/>.
+
+/**
+ *
+ * @package    format_iena
+ * @category   format
+ * @copyright  2018 Softia/Université lorraine
+ * @author     vrignaud camille / Thomas Fradet
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define('NO_OUTPUT_BUFFERING', true);
+require_once('../../../config.php');
+require_once('view/view_param_indicateur.php');
+require_once('entity/course_format_iena_section_ressources.php');
+require_once('entity/course_format_iena_sections.php');
+require_once('entity/course_format_iena_groups.php');
+
+global $COURSE, $DB, $USER;
+
+
+
+// Defines the id of the course with a get parameter
+$courseID = required_param('courseid', PARAM_INT);
+// Define the url of the view
+$url = new moodle_url('/course/format/iena/suivi_unit.php', array('courseid' => $courseID));
+
+
+$PAGE->set_url($url);
+
+// Getting DB information (*)  of the course
+$course = $DB->get_record('course', array('id' => $courseID), '*', MUST_EXIST);
+
+//require_login($course, false, NULL);
+require_login($course);
+$PAGE->set_title($course->fullname);
+$PAGE->set_heading($course->fullname . " – Suivi des étudiants");
+
+$PAGE->set_pagelayout('incourse');
+
+
+/* Cache le menu dans le header ?  */
+$coursenode = $PAGE->navbar->add('suiviiena', null, navigation_node::TYPE_CONTAINER, null, 'suiviena');
+$coursenode->make_active();
+$coursenode->force_open();
+
+
+
+
+
+require_once($CFG->libdir . '/completionlib.php');
+$completion = new completion_info($course);
+$context = context_course::instance($COURSE->id);
+
+// if (!has_capability('moodle/course:sectionvisibility', $context = context_course::instance($courseID), $USER->id)) {
+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;
+}
+//$PAGE->requires->js_call_amd('format_iena/suivi', 'init');
+
+
+
+echo $OUTPUT->header();
+
+/*$filters = [
+	"all" => "Tous",
+	"=100" => "100%",
+	"=0" => "0%",
+	"<100" => "&lt;100%",
+	"<50" => "&lt;50%",
+	"<25" => "&lt;25%",
+	">50" => "&gt;=50%",
+	">25" => "&gt;=25%",
+	">0" => "&gt;0%",
+];*/
+
+$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(
+		"value"=>"0",
+		"name"=>">0%",
+	),
+];
+
+
+
+/* Groupe du GET provenant du sélecteur de la page du cours, ou premier groupe de l'utilisateur, ou groupe 0 (tous les groupes). */
+if(isset($_GET['groupid'])){
+	$active_group_id = $_GET['groupid'];
+}
+else{
+	$active_group_id=NULL;
+}
+
+// @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();
+/* 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) */
+if ( $active_group_id == 0 ) {
+	//On récupère les ids des membres
+	//$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', true);
+	$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', true);
+} else {
+	//On ne récupère pas les ids des membres
+	$groups = groups_get_all_groups($COURSE->id, 0, 0, 'g.*', false);
+}
+
+$current_user_groups = [];
+$active_group_name = "";
+foreach ($groups as $group) {
+	/* Récupération du nom du group actif au passage */
+	if ( $group->id == $active_group_id ) {
+		$active_group_name = $group->name;
+		$group->selected='selected';
+	}
+	foreach ($current_user_groups_ids as $ugi) {
+		if ( $group->id == $ugi ) {
+			$current_user_groups[] = $group;
+		}
+	}
+}
+
+
+/* Liste de tous les utilisateurs avec : 
+- informations personnelles (tous les utilisateurs du cours)
+- liste des activités avec état d'achèvement (si achevées, sinon vide) */
+$progress = $completion->get_progress_all(
+	'',
+	array(),
+	$active_group_id,
+	'u.lastname ASC, u.firstname ASC',
+	'',
+	'',
+	$context
+);
+
+//Formate l'achèvement d'activités pour le tableau de suivi. Pour chaque étudiant, on aura dans le bon ordre la liste des modules et le completionstate
+function format_progress($progress, $modules){
+	global $CFG, $COURSE;
+	$students=array();
+	foreach ($progress as $prog_info) {
+		$progress_student=new StdClass();
+		$progress_student->name=$prog_info->firstname." ".$prog_info->lastname;
+		$progress_student->id=$prog_info->id;
+		$progress_student->email=$prog_info->email;
+		$progress_student->progress=array();
+		$progress_student->report_link=$CFG->wwwroot . "/report/outline/user.php?id=" . $progress_student->id . "&course=" . $COURSE->id . "&mode=outline";
+		$progress_student->message_link=$CFG->wwwroot . "/message/index.php?id=" . $progress_student->id;
+		foreach($modules as $key=>$module){
+			
+			$module_progress=new StdClass();
+			
+			if(!isset($prog_info->progress[$module->id])){
+				
+				$module_progress->completionstate='0';
+			}
+			else{
+				$module_progress->completionstate=$prog_info->progress[$module->id]->completionstate;
+			}
+			$module_progress->namemodule=$module->name;
+			
+			$progress_student->progress[$key]=$module_progress;
+		}
+
+		$students[]=$progress_student;
+	}
+	return $students;
+	
+}
+
+/* Ajoute les groupes de l'utilisateur pour l'afficher dans l'export */
+/* Si le user a le droit d'afficher pour tous les groupes ou qu'il n'y en a pas, on récupère le groupe de l'utilisateur pour qu'il puisse être téléchargé dans le tableau blobal intergroupe. */
+if ( $active_group_id == 0 ) {
+	foreach ($progress as $prog) {
+
+		
+		$prog->groups = "";
+		foreach ($groups as $group) {
+			if ( in_array($prog->id, $group->members) ) {
+				$prog->groups .= $group->name . " ";
+			}
+		}
+	}
+}
+
+/* Liste de toutes les activités du cours (sauf en attente de suppression). La liste est épurée et constitue un tableau d'objet. */
+$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) > 20 ? mb_substr($displayname, 0, 19, 'UTF-8').'…' : $displayname;
+	$module->section = $activity->section;
+	$modules[] = $module;
+}
+
+// Liste des sections du cours
+$modinfo = get_fast_modinfo($COURSE->id);
+$sections_info_all = $modinfo->get_section_info_all();
+$sections = [];
+
+// Section du get acquise depuis le clic sur l'indicateur dans la page du cours, section depuis laquelle on a cliqué sur le bouton pour voir le suivi. 
+
+if(isset($_GET['sectionid'])){
+	$active_section_id = $_GET['sectionid'];
+}
+else{
+	$active_section_id=0;
+}
+
+
+foreach ($sections_info_all as $key => $section_info) {
+	$section = new StdClass();
+	$section->id = $section_info->id;
+	$section->name = $section_info->name === NULL || $section_info->name === '' ? 'Section ' . $key : $section_info->name;
+	if($section->id==$active_section_id){
+		$section->selected="selected";
+	}
+
+	$sections[] = $section;
+
+}
+
+
+
+// Filtre actif si il existe (si la page est rechargée pour un filtre de groupe p.ex.)
+if (isset($_GET['filter'])) {
+	$filter = $_GET['filter'];
+} else {
+	$filter = 'all';
+}
+
+
+
+
+
+
+
+/*On a récupéré toutes les données, on met ça dans un tableau pour le template*/
+$data=array();
+$data['filters']=$filters;
+$data["sections"]=$sections;
+$data["groups"]=array_values($groups);
+$data['current_user_groups']=$current_user_groups;
+
+if($active_group_name==""){
+	$data['default_group']='selected';	
+}
+
+$data["modules"]=$modules;
+
+
+$data["students"]=format_progress($progress, $modules);
+
+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['data']=array();
+$data['data']["sections"]=$sections;
+$data['data']["groups"]=array_values($groups);
+$data['data']['current_user_groups']=$current_user_groups;
+$data['data']["modules"]=$modules;
+$data['data']["students"]=format_progress($progress, $modules);
+$data['data']=json_encode($data['data']);
+
+
+
+// If a post is sent trought the page
+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'])) {
+   return $data;
+}
+else {
+
+	//require_once('view/view_suivi_unit3.php');
+
+	$renderer = $PAGE->get_renderer('format_iena');
+	$renderer->display_completion($data);
+}
+
+
+
+
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/templates/course-header.mustache b/templates/course-header.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..5202db49444caa420582d80bbc3d4cf18d158251
--- /dev/null
+++ b/templates/course-header.mustache
@@ -0,0 +1,85 @@
+<div class="iena-course-header">
+	{{#student}}
+	<!--<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression : {{progress_total}}%</a>-->
+	<div class="iena-progress-header">
+		<div>
+			<h4 class="iena-progress-label">{{# str }} my_progress, format_iena {{/ str}}</h4>
+			<div class="progress-wrapper">
+				<div class="progress">
+				  	<div class="progress-bar" role="progressbar" aria-valuenow="{{progress_total}}" style="width:{{progress_total}}%" aria-valuemin="0" aria-valuemax="100"> {{progress_total}}%</div>
+
+				</div>
+			</div>
+				<a class="iena-progress-label" data-toggle="collapse" href="#progress-details" role="button" aria-expanded="false" aria-controls="progress-details"> <i class="fa fa-search-plus"></i> </a>
+		</div>
+	
+		<div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="false" style="">
+			<div class="iena-h-prog-sect collapse row"  id="progress-details">
+				<div class="details-progress col-md-7">
+					{{#progress_sections}}
+						<div class="section-progress">
+							<a href="#section-{{id}}" class="iena-h-prog-name">{{name}}</a>
+							<div class="progress-wrapper">
+								<div class="progress">
+								  <div class="progress-bar" role="progressbar" aria-valuenow="{{completion}}" style="width:{{completion}}%" aria-valuemin="0" aria-valuemax="100"></div>
+
+								</div>
+								<div class="iena-prog-label">{{completion}}%</strong> terminé</div>
+							</div>
+							<div class="iena-prog-bubbles">
+							{{#modules}}
+
+								<!-- <a href="{{url}}" class="iena-h-prog-mod-item iena-g-prog-{{completion}}"><span>{{name}}</span></a> -->
+								<div class="iena-prog-bubble iena-h-prog-mod-item state-{{completion}}">
+									
+									<span class="icon-progress"></span>
+									<a href="{{url}}" class="iena-prog-link">
+										
+										<span class="popover-module">{{name}}</span>
+									</a>
+								</div>
+							{{/modules}}
+							</div>
+							
+						</div>
+					{{/progress_sections}}
+				</div>
+				<div class="col-md-5 iena-progress-legend">
+				<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>
+						<div class="caption-status"><div class="pointer-help state-1"><span class="icon-progress"></span></div> <span class="caption-title">{{# str }} status1, format_iena {{/ str}}</span></div>
+						<div class="caption-status"><div class="pointer-help state-2"><span class="icon-progress"></span></div>  <span class="caption-title">{{# str }} status2, format_iena {{/ str}}</span></div>
+						<div class="caption-status"><div class="pointer-help state-3"><span class="icon-progress"></span></div>  <span class="caption-title">{{# str }} status3, format_iena {{/ str}}</span></div>
+					</div>
+				</div>
+			</div>
+		</div>
+			
+
+		</div>
+	</div>
+	
+	{{/student}}
+
+	{{#summary}}
+	<div class="iena-course-header-bottom" id="" aria-expanded="false">
+		<div id="title-summary-iena">
+			<h3>
+				{{# str }} aboutcourse, format_iena {{/ str}}
+			</h3>
+			<div id="summary-wrapper">
+				<div id="summary-collapse" aria-expanded="false">{{{ summary }}}</div>
+			</div>
+			<a role="button" href="#" onclick="return false" id="button-collapse" aria-expanded="false" aria-controls="summary-collapse">{{# str }} displayInfos, format_iena {{/ str}}</a>
+		</div>
+	</div>
+	{{/summary}}
+</div>
+
+{{#js}}
+require(['format_iena/header'], function(module) {
+    module.registerHeader();
+
+});
+{{/js}}
\ No newline at end of file
diff --git a/templates/section.mustache b/templates/section.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..c8109e88fe8b21ac218ef8a715053dad3604f35e
--- /dev/null
+++ b/templates/section.mustache
@@ -0,0 +1,63 @@
+<li class="section main clearfix iena-section" id="section-{{section}}" role="region">
+
+	<div class="card card_block">
+		<div class="heading-iena set_height">
+			
+			<div class="left side">{{{leftcontent}}}</div>
+
+			{{#rightcontent}}
+				<div class="right side">{{{rightcontent}}}</div>
+			{{/rightcontent}}
+			<div class="titre_section set_height">
+				{{#presence}}
+				<div class="label_item sect-date">
+					<span class="iena-icon-presence" data-toggle="tooltip" data-placement="top" title="{{#str}} in_presence, format_iena {{/str}}"></span>
+				</div>
+				{{/presence}}
+				{{#distance}}
+				<div class="label_item sect-date">
+					<span class="iena-icon-distance" data-toggle="tooltip" data-placement="top" title="{{#str}} not_presence, format_iena {{/str}}"></span>
+				</div>
+				{{/distance}}
+				
+			</div>
+			<div class="right_info">
+				
+				{{#string_date}}
+				<div class="label_item sect-date">
+					{{string_date}}
+				</div>
+				{{/string_date}}
+
+				{{#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}}
+				
+
+			</div>
+			<h3 class="sectionname set_height">{{{edit}}}</h3>
+		</div>
+
+		<div class="wrapper">
+			{{#summary}}
+			<div class="iena-description">
+				<div class="small">
+					<div class="iena-summary">{{{summary}}}</div>
+				</div>
+			</div>
+			<a href="#" class="voir-plus">Voir la description complète</a>
+			{{/summary}}
+			{{{messageavailability}}}
+			<div class="wrapper">
+				<div class="content">
+					{{{resources}}}
+					{{{addresources}}}
+				</div>
+			</div>
+		</div>
+	</div>
+
+</li>
\ No newline at end of file
diff --git a/templates/sections.mustache b/templates/sections.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..51fa14915c807c29fe57e69139a64a1308e927ca
--- /dev/null
+++ b/templates/sections.mustache
@@ -0,0 +1,18 @@
+
+<ul class="iena-editing">
+	<div class="iena-course-header"></div>
+	<!--<div class="iena-caption-sections">
+		<div class="iena-caption-icons"><span class="iena-icon-presence"></span>{{#str}} in_presence, format_iena {{/str}}</div>
+	 <div class="iena-caption-icons"><span class="iena-icon-distance"></span>{{#str}} not_presence, format_iena {{/str}}</div>
+	</div>-->
+	{{#sections}}
+		{{> format_iena/section}}
+	{{/sections}}
+</ul>
+{{#link_add_sections}}
+<div id="changenumsections" class="mdl-right">
+	<a class="add-sections" data-add-sections="{{# str }} addsections {{/ str }}" data-new-sections="" href={{{link_add_sections}}}>
+	  <i class="icon fa fa-plus fa-fw"></i>{{# str }} addsections {{/ str }}
+	</a>
+</div>
+{{/link_add_sections}}
\ No newline at end of file
diff --git a/templates/send-message.mustache b/templates/send-message.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..da29ba1a9d6333137c9554de797b899a9ba1272d
--- /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
new file mode 100644
index 0000000000000000000000000000000000000000..0c8ddc220885e80748c29099549d65c9b237b896
--- /dev/null
+++ b/templates/suivi-table.mustache
@@ -0,0 +1,67 @@
+{{#count_results}}
+	<p>{{count_results}} résultat(s)</p>
+	<div class="table-wrapper">
+		<table id="suivi">
+			<thead>
+				<tr id="modules">
+					
+					
+					<th id="first-column-head" class="first-column-iena"> <input type="checkbox" id="iena-select-all" ></th>
+					<th class="second-column-iena">%</th>
+					<th class="actions-column-iena">Actions</th>
+					<th class="third-column-iena">Etudiants</th>
+					{{#modules}}
+						{{#visible}}
+							<th class="th-rotate" data-fullname="{{name}}" data-section="{{section}}">
+								<div>
+									<span>
+										{{displayname}}
+									</span>
+								</div>
+							</th>
+						{{/visible}}
+					{{/modules}}
+				</tr>
+			</thead>
+			<tbody id="table-body">
+				{{#students}}
+					{{#visible}}
+						<tr data-userid="{{id}}" data-percent={{percentage}}>
+							<td class="first-column-iena">
+								<input type="checkbox" name="checkstudent" value="{{id}}">
+							</td>
+							<td class="second-column-iena">
+								<span class="stud_perc">{{percentage}} %</span>
+							</td>
+							<td 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>
+							</td>
+							<td class="third-column-iena">
+								{{firstname}} {{lastname}}
+								
+							</td>
+
+							{{#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>
+	</div>
+	
+
+{{/count_results}}
+{{^count_results}}
+	<div class="alert alert-primary">Il n'y a pas de résultats correspondants aux filtres sélectionnés</div>
+{{/count_results}}
+{{#js}}
+require(['format_iena/suivi-table'], function(module) {
+    module.registerSelectAll();
+
+});
+{{/js}}
\ No newline at end of file
diff --git a/templates/suivi.mustache b/templates/suivi.mustache
new file mode 100644
index 0000000000000000000000000000000000000000..86e3ed54b0d07460c6975a6dae93b5add3471386
--- /dev/null
+++ b/templates/suivi.mustache
@@ -0,0 +1,160 @@
+<div>
+
+	<h2 class="mb1" style="display: inline-block;">{{#str}}table_progress, format_iena{{/str}}</h2>
+
+	
+
+
+	<div class="context-header-settings-menu">
+        <div class="action-menu moodle-actionmenu d-inline" id="action-menu-3" data-enhance="moodle-core-actionmenu">
+
+        <div class="menubar d-flex " id="action-menu-3-menubar" role="menubar">
+
+           
+
+            <div class="action-menu-trigger">
+                <div class="dropdown">
+                    <a href="#" tabindex="0" class=" dropdown-toggle icon-no-margin" id="action-menu-toggle-3" aria-label="Menu d'actions" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true" aria-controls="action-menu-3-menu">
+                        
+                        
+					<i class="icon fa fa-cog fa-fw " title="Menu d'actions" aria-label="Menu d'actions"></i>                                
+					</a>
+                    <div class="dropdown-menu dropdown-menu-right menu align-tr-br" id="action-menu-3-menu" data-rel="menu-content" aria-labelledby="action-menu-toggle-3" role="menu" data-align="tr-br" x-placement="bottom-end" style="position: absolute; transform: translate3d(-256px, 24px, 0px); top: 0px; left: 0px; will-change: transform;">
+                        {{#link_bulkcompletion}}
+                        <div class="dropdown-item">
+
+					    	<a target="_blank" href="{{link_bulkcompletion}}" class="" role="menuitem"><i class="icon fa fa-cog fa-fw " aria-hidden="true"></i>Paramétrer le suivi</a>
+
+						</div>
+						{{/link_bulkcompletion}}
+						<div class="dropdown-item">
+
+					    	<a href="{{link_classicview}}" class="" role="menuitem"><i class="icon fa fa-pencil fa-fw " aria-hidden="true"></i>Vue classique</a>
+
+						</div>
+					                                           
+	                </div>
+	            </div>
+	        </div>
+
+        </div>
+
+	</div>
+</div>
+
+
+
+
+</div>
+
+<form style="clear: right;" class="form-inline" action="" method="GET">
+	<input name="courseid" type="number" hidden="hidden" style="display: none;" value="">
+
+	<label class="sr-only" for="section-select">Section</label>
+	<div class="input-group">
+		<div class="input-group-prepend">
+			<div class="input-group-text">Section</div>
+		</div>
+		<select class="custom-select mr-sm-2" id="section-select" name="sectionid">
+			<option value="0">Toutes</option>
+			{{#sections}}
+				<option {{selected}} value={{id}}>{{name}}</option>
+			{{/sections}}
+		</select>
+	</div>
+
+	<label class="sr-only" for="group-select">Groupes</label>
+	<div class="input-group">
+		<div class="input-group-prepend">
+			<div class="input-group-text">Groupes</div>
+		</div>
+		<select class="custom-select mr-sm-2" id="group-select" name="groupid">
+			
+			<option value="0" {{default_group}}>Tous</option>
+
+			<optgroup label="Mes groupes">
+				{{#current_user_groups}}
+					<option {{selected}} value='{{id}}'>{{name}}</option>";
+				{{/current_user_groups}}
+			</optgroup>
+			
+			<optgroup label="Autres groupes">
+				{{#groups}}
+					<option {{selected}} value='{{id}}'>{{name}}</option>";
+
+				{{/groups}}
+			</optgroup>
+			
+			
+			
+		</select>
+	</div>
+
+	<label class="sr-only" for="filter-select">Filtre %</label>
+	<div class="input-group">
+		<div class="input-group-prepend">
+			<div class="input-group-text">% achèvement</div>
+		</div>
+		<select class="custom-select mr-sm-2" id="symbol-select" name="filter">
+			
+			{{#symbols}}
+				<option {{selected}} value='{{value}}'>{{name}}</option>
+			{{/symbols}}
+			
+		</select>
+		<select class="custom-select mr-sm-2" id="filter-select" name="filter">
+			
+			{{#filters}}
+				<option {{selected}} value='{{value}}'>{{name}}</option>
+			{{/filters}}
+			
+		</select>
+	</div>
+
+
+
+</form>
+{{#msg_success}}
+	<div class="alert alert-success iena-message">Message(s) envoyé(s)</div>
+{{/msg_success}}
+{{#msg_failure}}
+	<div class="alert alert-danger  iena-message">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>
+		<div class="caption-status"><div class="pointer-help state-1"><span class="icon-progress"></span></div> <span class="caption-title">{{# str }} status1, format_iena {{/ str}}</span></div>
+		<div class="caption-status"><div class="pointer-help state-2"><span class="icon-progress"></span></div>  <span class="caption-title">{{# str }} status2, format_iena {{/ str}}</span></div>
+		<div class="caption-status"><div class="pointer-help state-3"><span class="icon-progress"></span></div>  <span class="caption-title">{{# str }} status3, format_iena {{/ str}}</span></div>
+	</div>
+</div>
+<div id="partial-table">
+	
+
+{{#js}}
+require(['format_iena/suivi', 'core/templates'], function(module) {
+    module.registerFilters();
+   	module.registerSubmit({{{ data }}});
+});
+{{/js}}
+</div>
+
+
+<div class="actions-suivi-iena">
+	<div class="input-group row">
+		<div class="input-group-prepend col-md-3">
+			<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>
+					<option  value='download'>Télécharger le tableau en csv</option>
+				
+			</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/version.php b/version.php
index b3aee7fbbf1e447e6bfc82cc1ef1441255e11111..6828d3b8dc07776989b5ea5b008ceb290bf7ede5 100644
--- a/version.php
+++ b/version.php
@@ -28,7 +28,7 @@
 	
 	defined('MOODLE_INTERNAL') || die();
 	
-	$plugin->version = 2019072200;
+	$plugin->version = 2021220901;
 	$plugin->requires = 2014111000;
 	$plugin->component = 'format_iena';
 	$plugin->release = "1.0";
diff --git a/view/view_course_header.php b/view/view_course_header.php
index cf214656811dd4e3371a301018b3ec2879bcf28a..da8733d24fdbf8aa1391a15310f4ce06615a70a1 100644
--- a/view/view_course_header.php
+++ b/view/view_course_header.php
@@ -12,10 +12,15 @@ class view_course_header {
 		$this->idSection = $idSection;
 		// $this->completion_total = $completion_total;
 		$this->course = $course;
-		$this->create_view($progress);
+		//$this->create_view($progress);
 	}
 
-	private function create_view($progress) {
+	/**
+	 * Description
+	 * @param type $progress 
+	 * @return type
+	 */
+	public function create_view($progress) {
 		
 		// $this->get_progress_bis($this->section_names, $this->idSection, $this->course);
 		
@@ -24,11 +29,11 @@ class view_course_header {
 		$infos = [
 			'progress' => $prog,
 			'teachers' => $this->get_teachers(),
-			'groups' => $this->get_groupes(),
+			//'groups' => $this->get_groupes(),
 			// 'attendance' => $this->get_attendance_link()
 		];
 		
-		$this->set_html($infos);
+		return $this->get_data($infos);
 	}
 
 	private function get_progress_bis($section_names, $idSection, $course) {
@@ -40,19 +45,6 @@ class view_course_header {
 			return false;
 		}
 
-		// $modules = $DB->get_records_sql('SELECT cmc.id, cmc.coursemoduleid, cmc.userid, cmc.completionstate, cm.section
-		// 	FROM  {course_modules_completion} as cmc
-		// 	inner join {course_modules} as cm on cm.id = cmc.coursemoduleid
-		// 	inner join {user} as u on u.id = cmc.userid
-		// 	inner join {modules} as m on m.id = cm.module
-		// 	where cm.course = ? and cm.deletioninprogress = 0
-		// 	and cmc.userid = ?
-		// 	order by section, coursemoduleid asc', array($course->id, $USER->id));
-
-		// echo "<pre>";
-		// var_dump($modules);
-		// echo "</pre>";
-
 		$sections = [];
 
 		$fast_modinfo = get_fast_modinfo($course->id);
@@ -287,6 +279,11 @@ class view_course_header {
 		return false;
 	}
 
+	private function count_students(){
+		$count = count_enrolled_users($COURSE->id);
+		return $count;
+	}
+
 	private function get_groupes() {
 		global $COURSE, $USER;
 		if ( ! $this->is_teacher($USER) ) { return false; }
@@ -301,153 +298,44 @@ class view_course_header {
 		return $array;
 	}
 
-	private function set_html($infos) {
-		
-		global $CFG, $COURSE, $USER;
-
-		// $css = file_get_contents( $CFG->wwwroot.'/course/format/iena/course-header.css' );
-		// $this->_content .= '<style>'.$css.'</style>';
-
-		$this->_content .= '<div class="iena-course-header">';
 
-
-		// begin of : top part (always visible)
-		$this->_content .= '<div class="iena-course-header-top">';
-
-		// PROGRESS TOTAL : total progression percentage
-		if ( $infos['progress'] !== false && $infos['progress']->total !== false ) {
-			$this->_content .= '<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression : '.$infos['progress']->total.'%</a>';
-		}
-		else {
-			$this->_content .= '<div class="btn"></div>';
-		}
-		// $this->_content .= '<a href="#" class="btn btn-outline-primary iena-course-h-total" onclick="iena_toggle_course_header(event)">Ma progression :%</a>';
-
-		// MESSAGES : button to send message to teachers
-		if ( $infos['teachers'] !== false ) {
-			$this->_content .= '<div class="dropdown iena-course-h-message"><a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" id="iena-course-h-message" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="sr-only">Contact : </span>Enseignants</a><div class="dropdown-menu dropdown-menu-right" aria-labelledby="iena-course-h-message">';
-			$my_group_teachers = [];
-			foreach ($infos['teachers'] as $teacher) {
-				// echo "<pre>";
-				// var_dump($teacher->id);
-				$teacher_groups = groups_get_user_groups($COURSE->id, $teacher->id)[0];
-				// var_dump($teacher_groups);
-				$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
-				// var_dump($user_groups);
-				$user_is_in_teacher_group = false;
-				foreach ($user_groups as $user_group) {
-					if ( in_array($user_group, $teacher_groups) ) {
-						$user_is_in_teacher_group = true;
-						$my_group_teachers[] = $teacher;
-						break;
+	/**
+	 * Retourne un tableau d'informations : array progress_total, array progress_sections, bool student, string summary
+	 * @param array of object $infos 
+	 * @return array
+	 */
+	private function get_data($infos){
+		global $CFG, $COURSE, $USER;
+		$course_data=[];
+		$course_data['student']=false;
+		//if user is a student
+		if(!has_capability('course/iena:suivi', $context = context_course::instance($COURSE->id), $USER->id)){
+			$course_data['progress_total']=$infos['progress']->total;
+			
+
+
+			// PROGRESS TOTAL : total progression percentage
+			if ( $infos['progress'] !== false && $infos['progress']->total !== false ) {
+				
+				
+				$course_data['progress_sections']=[];
+				// section progress total
+				foreach ($infos['progress']->sections as $section) {
+					if ( count($section->modules) > 0 ) {
+						array_push($course_data['progress_sections'], $section);
+					
 					}
 				}
-				// var_dump($user_is_in_teacher_group);
-				// echo "<hr>";
-				// echo "</pre>";
-			}
-			if ( count($my_group_teachers) > 0 ) {	
-				$this->_content .= '<span class="dropdown-header">Mon groupe</span>';
-				foreach ($my_group_teachers as $teacher) {
-					$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
-				}
-				$this->_content .= '<span class="dropdown-header">Tous les groupes</span>';
-			}
-			foreach ($infos['teachers'] as $teacher) {
-				$this->_content .= '<a class="dropdown-item" target="_blank" href="'.$CFG->wwwroot.'/message/index.php?id='.$teacher->id.'"><span class="sr-only">Envoyer un message à (nouvel onglet) : </span>'.$teacher->firstname.' '.$teacher->lastname.'</a>';
-			}
-			$this->_content .= '</div></div>';
-		}
-
-		// ATTENDANCE : button to help with attendance mod if one
-		// if ( $infos['attendance'] !== false ) {
-		// 	$this->_content .= '<a href="'.$infos['attendance'].'" class="btn btn-outline-warning iena-course-h-attendance" id="iena-attendance-btn">Présences</a>';
-		// }
-
-		// GROUP : teacher group select (input-group-lg if needed)
-		if ( $infos['groups'] !== false ) {
-			$this->_content .= '<script type=\"text/javascript\" charset=\"utf8\" src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script>';
-			$this->_content .= '<script src="'.$CFG->wwwroot.'/course/format/iena/js/groups.js"></script>';
-			$this->_content .= '<script>function change_grouplink(obj) {
-				var classList = obj.classList;
-				var id_groupe = classList[2].split("id_groupe");
-				id_group = id_groupe[1];
-				var t = obj.parentNode;
-				var t_href = t.getAttribute("href");
-				t_href += "&groupid=" + id_group;
-				t.setAttribute("href", t_href); 
-			}
-			</script>';
-			$this->_content .= '<span class="form-inline iena-course-h-group">
-			<div class="input-group-prepend">
-			<label class="input-group-text orange-bg" for="select-group">Groupe</label>
-			</div>
-			<select class="custom-select form-control" id="select-group">';
-			$this->_content .= '<option value="id_groupe0" selected>Tous les groupes</option>';
-			$this->_content .= '<optgroup label="Mes groupes">';
-			$user_groups = groups_get_user_groups($COURSE->id, $USER->id)[0];
-			foreach ($infos['groups'] as $group) {
-				if ( in_array($group['id'], $user_groups ) ) {
-					$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
-				}
-			}
-			$this->_content .= '</optgroup>';
-
-			if (has_capability('course/iena:suivi_edit', $context = context_course::instance($COURSE->id), $USER->id)) {
-				$this->_content .= '<optgroup label="Tous les groupes">';
-				foreach ($infos['groups'] as $group) {
-					$this->_content .= '<option value="id_groupe'.$group['id'].'">'.$group['name'].'</option>';
-				}
-				$this->_content .= '</optgroup>';
 			}
-
-			$this->_content .= '</select>
-			</span>';
-		}
-
-		$this->_content .= '</div><div class="iena-h-clear"></div>'; // end of : top
-
-
-		// begin of : bottom part visible at toggle
-		$this->_content .= '<div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="false" style="display:none;">';
-		// $this->_content .= '<div class="iena-course-header-bottom" id="iena-h-bottom" aria-expanded="true">';
-
-
-		// PROGRESS DETAIL
-		if ( $infos['progress'] !== false && $infos['progress']->total !== false ) {
-			// section progress begin
-			$this->_content .= '<div class="iena-h-prog-sect"><h2>Progression détaillée</h2>';
-			// section progress total
-			foreach ($infos['progress']->sections as $section) {
-				if ( count($section->modules) > 0 ) {
-					$this->_content .= '<a href="#section-'.$section->id.'" class="iena-h-prog-name btn btn-outline-success"><strong>'.$section->completion.'%</strong> – '.$section->name.'</a>';
-					// section progress each module
-					foreach ($section->modules as $module) {
-						$this->_content .= '<a href="'.$module->url.'" class="iena-h-prog-mod-item iena-g-prog-'.$module->completion.'"><span>'.$module->name.'</span></a>';
-					}
-				}
+			else {
+			
 			}
-			$this->_content .= '</div><div class="iena-h-clear"></div>';
-		}
-
-		// course summary
-		$summary_copy = $COURSE->summary;
-		$to_delete = array('<p>', '</p>', '<br>', '</br>', ' ');
-		$summary_copy = str_replace($to_delete, '', $summary_copy);
-		$summary_copy = preg_replace('/\s+/', '', $summary_copy);
-		if ( $summary_copy != "" ) {
-			$this->_content .= '<hr><h2>À propos du cours</h2><div class="iena-h-summary">' . $COURSE->summary . '</div>';
-		}
-
-		$this->_content .= '</div>'; // end of : bottom part
-
-		if ( $summary_copy != "" ) {
-			$this->_content .= '<div class="iena-course-header-toggler" id="iena-h-toggler"><hr><a href="#" onclick="iena_toggle_course_header(event)">Afficher / masquer les infos du cours</a></div>';
+			$course_data['student']=true;
 		}
 
-		$this->_content .= '<script>function iena_toggle_course_header(event) { event.preventDefault(); var bottom = document.getElementById("iena-h-bottom"); if(bottom.style.display == "none") { bottom.style.display = ""; bottom.setAttribute("aria-expanded", true); } else { bottom.style.display = "none"; bottom.setAttribute("aria-expanded", false); } }</script>';
+		$course_data['summary']=$COURSE->summary;
 
-		$this->_content .= '</div>'; // end of : iena course header
+		return $course_data;
 	}
 
 	public function get_content() {
diff --git a/view/view_send_message.php b/view/view_send_message.php
index 5aff912030b7748922a9a2ef1800a70186abad84..950cb0664e34cf5a6d71880b3b5e24e3aef0171c 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 {
 
diff --git a/view/view_suivi_unit3.php b/view/view_suivi_unit3.php
index 225212c84eb21da9962ef44a35d8a0855986a0d1..830b84a19a3123292ddf2b5bfa570cafb60cb9e4 100644
--- a/view/view_suivi_unit3.php
+++ b/view/view_suivi_unit3.php
@@ -335,29 +335,7 @@ if (isset($_GET['filter'])) {
 		</select>
 	</div>
 
-	<!-- <label class="my-1 mr-2" for="filter-select">Filtre %</label>
-	<select class="custom-select my-1 mr-sm-2" id="filter-select" name="filter">
-		<?php 
-		// $filters = [
-		// 	"all" => "Tous",
-		// 	"=100" => "100%",
-		// 	"=0" => "0%",
-		// 	"<100" => "&lt;100%",
-		// 	"<50" => "&lt;50%",
-		// 	"<25" => "&lt;25%",
-		// 	">50" => "&gt;50%",
-		// 	">25" => "&gt;25%",
-		// 	">0" => "&gt;0%",
-		// ];
-		// foreach ($filters as $value => $name) {
-		// 	if ( $value == $filter ) {
-		// 		echo "<option selected='selected' value='$value'>$name</option>";
-		// 	} else {
-		// 		echo "<option value='$value'>$name</option>";
-		// 	}
-		// }
-		?>
-	</select> -->
+
 
 </form>