From 590a3a517feff26e3d5cdd2657b698e8576c59ab Mon Sep 17 00:00:00 2001
From: Myriam Delaruelle
 <Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr>
Date: Fri, 12 Mar 2021 15:08:54 +0100
Subject: [PATCH] Tableau suivi

---
 amd/build/suivi-table.js         | 191 +------------------
 amd/build/suivi.js               | 314 +++++++++++++++++++++++++++----
 lang/en/format_iena.php          |   5 +
 lang/fr/format_iena.php          |   7 +
 styles.css                       |  75 +++++++-
 suivi_unit.php                   |  58 ++++--
 templates/course-header.mustache |   2 +-
 templates/suivi-table.mustache   |  57 ++++--
 templates/suivi.mustache         |  25 ++-
 9 files changed, 460 insertions(+), 274 deletions(-)

diff --git a/amd/build/suivi-table.js b/amd/build/suivi-table.js
index f7fc7be..0dccd03 100644
--- a/amd/build/suivi-table.js
+++ b/amd/build/suivi-table.js
@@ -21,33 +21,24 @@
  * @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) {
+define(['jquery'],
+       function($) {
        	var all_selected=false;
-       	var data=[];
        	return{
        		registerSelectAll:function(){
-
+       			all_selected=false;
        			$('#iena-select-all').on('click', function(e){
-	    			select_all_studs(e);
+					select_all_studs(e);
 	    		});
 	    		
 	    		
 	    		
-       		},
-       		
-       		registerSubmit:function(data){
-       			$("#id_submit_iena").off().on('click', function(e){
-	    			triggerAction(e, data);
-	    		});
-	    		
-	    		calcPercentage(data);
        		}
-       		
        	}
 
    
     function select_all_studs(e) {
+    	
 		all_selected=!all_selected;
 		var counter = 0;
 		var checks = document.querySelectorAll("#table-body tr");
@@ -61,177 +52,5 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
 	}
 
 
-	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;
-
-	}
-
-
-	function triggerAction(e, data){
-		value=$("#select-actions-suivi-iena").val();
-		
-		if(value=="msg"){
-			console.log("on va envoyer un message");
-		}
-		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(data) {
-		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++ ) {
-			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){
-
-		data.modules(find(isHidden));
-		for (var i = 0; i < data.students.length; i++) {
-			var done=0;
-			var nb_modules=0;
-			for(var j=0; j < data.students[i].progress;j++){
-
-				if(data.modules.find(module => module.id === data.students[i].progress[j].idmodule).visibility != "hidden"){
-					nb_modules++
-					if(data.students[i].progress[j].completionstate == 1 || data.students[i].progress[j].completionstate ==2){
-						done++;
-					}
-					
-				}
-			}
-			data.students[i].percentage=100 * done / nb_modules;
-		}
-	}
-
-	function isHidden(module, id) {
-		return module.id === id;
-	}
 
 });
diff --git a/amd/build/suivi.js b/amd/build/suivi.js
index 3348430..7132217 100644
--- a/amd/build/suivi.js
+++ b/amd/build/suivi.js
@@ -24,34 +24,39 @@
 define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
        function($, ajax, templates, str) {
        	var all_selected=false;
+       	var data=[];
        	return{
-       		registerSelectAll:function(){
-
-	    		/*$("#section-select").on('change', function(e){
-	    			changeFilter(e, 'section');
-	    		});*/
+       		registerFilters:function(){
+       			
 	    		$("#group-select").on('change', function(e){
 	    			changeFilter(e, 'group');
 	    		});
 	    		
        		},
+       		
+       		registerSubmit:function(infos){
+       			data=infos;
+       			$("#id_submit_iena").on('click', function(e){
+	    			triggerAction(e);
+	    		});
+	    		$("#section-select").on('change', function(){
+	    			changeSection();
+	    		});
+	    		
+	    		calcPercentage(data);
+       		}
+       		
 
        		
        		
        	}
 
-    function changeFilter(e, list){
+    function getCompleteUrl(){
     	url=window.location.search;
     	urlParams = new URLSearchParams(url);
     	courseid=urlParams.get('courseid');
-    	sectionid=urlParams.get('sectionid');
-    	groupid=urlParams.get('groupid');
-    	if(list=='section'){
-    		sectionid=$("#section-select").val();
-    	}
-    	else if(list=="group"){
-    		groupid=$("#group-select").val();
-    	}
+    	groupid=$("#group-select").val();
+    	sectionid=$("#section-select").val();
     	completeUrl='suivi_unit.php?courseid='+courseid;
     	if(sectionid){
     		completeUrl+='&sectionid='+sectionid;
@@ -59,35 +64,268 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
     	if(groupid){
     		completeUrl+="&groupid="+groupid;
     	}
-    	var loadingStudents = str.get_string('loadingResults', 'format_iena');
-    	$.when(loadingStudents).done(function(localizedEditString) {
-	         $("#partial-table").html("<div class='alert alert-primary' role='alert'>"+localizedEditString+"</div>");
-	    });	
+    	return completeUrl;
+    }
 
+    function changeFilter(e, list){
+    	completeUrl=getCompleteUrl();
+    	loadMessage("loading");
     	$.ajax({ url: completeUrl,
-         data: {action: 'test'},
-         type: 'post',
-         success: function(request) { 
-         	console.log(JSON.parse(request));
-         	templates.render('format_iena/suivi-table', JSON.parse(request))
-         	.done(function(html, js){
-         		 $("#partial-table").html(html);
-         		 templates.runTemplateJS(js);
-         		 window.history.pushState('suivi',"", completeUrl);
-         	})
-	        .fail(function(){
-	        	var errorLoadingStudents = str.get_string('errorLoadingResults', 'format_iena');
-	        	$.when(errorLoadingStudents).done(function(localizedEditString) {
-			         $("#partial-table").html("<div class='alert alert-danger' role='alert'>"+localizedEditString+"</div>");
-			    });	
-	        });	
-           
-         	
-         	
-		}
+        	data: {action: 'test'},
+        	type: 'post',
+        	success: function(request) { 
+
+        		calcPercentage(JSON.parse(request));
+
+         		//reloadTable(JSON.parse(request));	
+			}
 		});
     }
 
+    function changeCompletion(){
+    	symbol=$("#symbol-select").val();
+    	filter=$("#filter-select").val();
+    }
+
+    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++;
+    			console.log("on met les rés à true");
+    			for(var j = 0; j<data.students.length; j++){
+    				var prog=data.students[j].progress.find(progress => progress.idmodule === data.modules[i].id);
+					prog.visible=true;
+    			}
+    		}
+    		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){
+    		console.log("pas de résultats");
+    		reloadTable(data);
+    	}
+    	else{
+    		calcPercentage(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){
+    	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);
+     	})
+        .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;
+
+	}
+
+
+	function triggerAction(e){
+		value=$("#select-actions-suivi-iena").val();
+		
+		if(value=="msg"){
+			console.log("on va envoyer un message");
+		}
+		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){
+		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);
+		}
+		reloadTable(data);
+	}
 
 
 
diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php
index a3aaa2b..f497669 100644
--- a/lang/en/format_iena.php
+++ b/lang/en/format_iena.php
@@ -84,5 +84,10 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$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";
 
 
diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php
index d72dbde..29d7439 100644
--- a/lang/fr/format_iena.php
+++ b/lang/fr/format_iena.php
@@ -84,3 +84,10 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
 	$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 au dessus de la note";
+	$string['status3']="Activité complétée en dessous de la note";
+
+
diff --git a/styles.css b/styles.css
index b276df4..ee62536 100644
--- a/styles.css
+++ b/styles.css
@@ -542,7 +542,7 @@ th.th-rotate {
 th.th-rotate > div {
 	transform: 
 	/* Magic Numbers */
-	translate(17px, 49px)
+	translate(18px, 53px)
 	/* 45 is really 360 - 45 */
 	rotate(315deg);
 	width: 30px;
@@ -550,6 +550,10 @@ th.th-rotate > div {
 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; }
@@ -583,17 +587,20 @@ th.th-rotate > div > span {
 	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;
 }	
 
 
@@ -638,8 +645,9 @@ th.th-rotate > div > span {
 }
 
 #suivi thead tr th:nth-child(1) {
-	width:20em;
-	min-width:20em;
+	/*width:20em;
+	min-width:20em;*/
+
 }
 #suivi thead tr th {
 	min-width:32px;
@@ -659,4 +667,63 @@ th.th-rotate > div > span {
 }
 
 .mb1 { margin-bottom: 1rem; }
-.mt1 { margin-top: 1rem; }
\ No newline at end of file
+.mt1 { margin-top: 1rem; }
+
+
+#suivi .first-column-iena{
+	width: 2em;
+	min-width: 2em;
+}
+#suivi .second-column-iena{
+	width: 3em;
+    min-width: 3em;
+
+    
+}
+#suivi .third-column-iena{
+	width: 15em;
+	min-width: 15em;
+	
+	
+}
+
+#suivi .actions-column-iena{
+	width: 5em;
+	min-width: 5em;
+}
+
+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;
+}
+
diff --git a/suivi_unit.php b/suivi_unit.php
index d0b354e..eb4eac1 100644
--- a/suivi_unit.php
+++ b/suivi_unit.php
@@ -105,7 +105,7 @@ function get_groups($context, $active_group_id, $progress, $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){
+function format_progress($progress, $modules, $groups, $active_group_id, $active_section_id){
 	global $CFG, $COURSE;
 	$students=array();
 	foreach ($progress as $prog_info) {
@@ -120,17 +120,13 @@ function format_progress($progress, $modules, $groups, $active_group_id){
 		$progress_student->message_link=$CFG->wwwroot . "/message/index.php?id=" . $progress_student->id;
 
 
-		if ( $active_group_id == 0 ) {
-			
-
-				
+		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 . " ";
 				}
 			}
-			
 		}
 
 
@@ -145,6 +141,12 @@ function format_progress($progress, $modules, $groups, $active_group_id){
 			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;
 			
@@ -162,14 +164,18 @@ 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 = 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;
+			$module->visible=true;
+		}
+		else{
+			$module->visible=false;
 		}
 		
 	}
@@ -236,7 +242,7 @@ function set_filters($data, $filters, $sections, $groups, $current_user_groups,
 	return $data;
 }
 
-function set_data($data, $modules, $progress, $groups, $active_group_id){
+function set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id){
 	
 	global $COURSE, $USER, $CFG;
 
@@ -246,7 +252,7 @@ function set_data($data, $modules, $progress, $groups, $active_group_id){
 	$data["modules"]=$modules;
 	$count_modules=count($data["modules"]);
 
-	$data["students"]=format_progress($progress, $modules, $groups, $active_group_id);
+	$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){
@@ -266,9 +272,9 @@ function set_data($data, $modules, $progress, $groups, $active_group_id){
 		$data['data']=array();
 	}
 	
-	$data['data']["modules"]=$modules;
-	$data['data']["students"]=$data["students"];
-	$data['data']=json_encode($data['data']);
+
+	$data['data']=json_encode($data);
+	
 
 
 	return $data;
@@ -315,6 +321,18 @@ $filters=[
 	),
 ];
 
+$symbols=[
+	"0"=>array(
+		"value"=>"=",
+	),
+	"1"=>array(
+		"value"=>"<",
+	),
+	"2"=>array(
+		"value"=>">",
+	)
+];
+
 
 
 $courseID = required_param('courseid', PARAM_INT);
@@ -391,7 +409,7 @@ if ($_POST && !isset($_POST["action"])) {
 	$data=[];
 	$modules=get_activities($completion, $active_section_id);
 
-	$data=set_data($data, $modules, $progress, $groups, $active_group_id);
+	$data=set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id);
 	echo json_encode($data);
 	//$renderer = $PAGE->get_renderer('format_iena');
 
@@ -410,7 +428,7 @@ else {
 	$groups=get_groups($context, $active_group_id, $progress, $groups);
 	$sections=get_sections($active_section_id);
 	$data=set_filters($data, $filters, $sections, $groups, $current_user_groups, $active_group_name, $active_section_id);
-	$data=set_data($data, $modules, $progress, $groups, $active_group_id);
+	$data=set_data($data, $modules, $progress, $groups, $active_group_id, $active_section_id);
 	$renderer = $PAGE->get_renderer('format_iena');
 	$renderer->display_completion($data);
 	echo $OUTPUT->footer();
diff --git a/templates/course-header.mustache b/templates/course-header.mustache
index 5c749ee..2a8376b 100644
--- a/templates/course-header.mustache
+++ b/templates/course-header.mustache
@@ -48,7 +48,7 @@
 
 	
 	<div class="iena-course-header-bottom" id="" aria-expanded="false">
-		<div id="title-summary-iena" class="container">
+		<div id="title-summary-iena">
 			<h3>
 				{{# str }} aboutcourse, format_iena {{/ str}}
 			</h3>
diff --git a/templates/suivi-table.mustache b/templates/suivi-table.mustache
index 3a0da99..171787c 100644
--- a/templates/suivi-table.mustache
+++ b/templates/suivi-table.mustache
@@ -5,41 +5,58 @@
 		<tr id="modules">
 			
 			
-			<th id="first-column-head"> <input type="checkbox" id="iena-select-all" >Etudiants</th>
+			<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}}
-				<th class="th-rotate" data-fullname="{{name}}" data-section="{{section}}">
-					<div>
-						<span>
-							{{displayname}}
-						</span>
-					</div>
-				</th>
+				{{#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}}
-			<tr data-userid="{{id}}" data-percent={{percent}}>
-				<th>
+			<tr data-userid="{{id}}" data-percent={{percentage}}>
+				<th class="first-column-iena">
 					<input type="checkbox" name="checkstudent" value="{{id}}">
-					<span class="stud_perc">{{percent}}</span>
+				</th>
+				<th class="second-column-iena">
+					<span class="stud_perc">{{percentage}} %</span>
+				</th>
+				<th class="actions-column-iena">
 					<a href="{{report_link}}" target="_blank"><i class="icon fa fa-graduation-cap fa-fw"></i></a>
-					<a href="{{message_link}}" target="_blank"><i class="icon fa fa-envelope fa-fw"></i></a>{{firstname}} {{lastname}}
+					<a href="{{message_link}}" target="_blank"><i class="icon fa fa-envelope fa-fw"></i></a>
 				</th>
+				<th class="third-column-iena">
+					{{firstname}} {{lastname}}
+					
+				</th>
+
 				{{#progress}}
-					<td title="{{namemodule}}" data-section="{{id}}" class="pointer-help state-{{completionstate}}"><span class="icon-progress"></span></td>
+					{{#visible}}
+						<td title="{{namemodule}}" data-section="{{id}}" class="pointer-help state-{{completionstate}}"><span class="icon-progress"></span></td>
+					{{/visible}}
 				{{/progress}}
 			</tr>
 		{{/students}}
 	</tbody>
 </table>
-{{#js}}
-require(['format_iena/suivi-table', 'core/templates'], function(module) {
-    module.registerSelectAll();
-    module.registerSubmit({{{ data }}});
-});
-{{/js}}
+
 {{/count_results}}
 {{^count_results}}
-	<p>Il n'y a pas de résultats correspondants aux filtres sélectionnés</p>
+	<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
index 2f2c5ac..47118b4 100644
--- a/templates/suivi.mustache
+++ b/templates/suivi.mustache
@@ -93,8 +93,15 @@
 	<label class="sr-only" for="filter-select">Filtre %</label>
 	<div class="input-group">
 		<div class="input-group-prepend">
-			<div class="input-group-text">Filtre</div>
+			<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}}'>{{value}}</option>
+			{{/symbols}}
+			
+		</select>
 		<select class="custom-select mr-sm-2" id="filter-select" name="filter">
 			
 			{{#filters}}
@@ -107,13 +114,21 @@
 
 
 </form>
-
+<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">
-{{> format_iena/suivi-table }}
+	
+
 {{#js}}
 require(['format_iena/suivi', 'core/templates'], function(module) {
-    module.registerSelectAll();
-   
+    module.registerFilters();
+   	module.registerSubmit({{{ data }}});
 });
 {{/js}}
 </div>
-- 
GitLab