Skip to content
Snippets Groups Projects
Commit 24ede56c authored by Myriam Delaruelle's avatar Myriam Delaruelle
Browse files

Calcul pourcentage tableau suivi

parent 9068b209
No related branches found
No related tags found
No related merge requests found
...@@ -33,12 +33,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -33,12 +33,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}); });
}, },
registerSubmit:function(data){ registerSubmit:function(data){
$("#id_submit_iena").off().on('click', function(e){ $("#id_submit_iena").off().on('click', function(e){
triggerAction(e, data); triggerAction(e, data);
}) });
calcPercentage(data);
} }
} }
...@@ -97,10 +100,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -97,10 +100,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
return String(date).length > 1? date : '0'+date ; return String(date).length > 1? date : '0'+date ;
} }
/*Number.prototype.padLeft = function(base,chr){
var len = (String(base || 10).length - String(this).length)+1;
return len > 0? new Array(len).join(chr || '0')+this : this;
}*/
function table_download(data) { function table_download(data) {
...@@ -208,4 +208,30 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -208,4 +208,30 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
document.body.removeChild(link); 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;
}
}); });
...@@ -27,14 +27,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -27,14 +27,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
return{ return{
registerSelectAll:function(){ registerSelectAll:function(){
$("#section-select").on('change', function(e){ /*$("#section-select").on('change', function(e){
changeFilter(e, 'section'); changeFilter(e, 'section');
}); });*/
$("#group-select").on('change', function(e){ $("#group-select").on('change', function(e){
changeFilter(e, 'group'); changeFilter(e, 'group');
}); });
}, },
} }
...@@ -67,6 +68,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -67,6 +68,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
data: {action: 'test'}, data: {action: 'test'},
type: 'post', type: 'post',
success: function(request) { success: function(request) {
console.log(JSON.parse(request));
templates.render('format_iena/suivi-table', JSON.parse(request)) templates.render('format_iena/suivi-table', JSON.parse(request))
.done(function(html, js){ .done(function(html, js){
$("#partial-table").html(html); $("#partial-table").html(html);
...@@ -86,6 +88,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -86,6 +88,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}); });
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment