Skip to content
Snippets Groups Projects
Commit f65bbe40 authored by DELARUELLE Myriam's avatar DELARUELLE Myriam
Browse files

fix js caching + cleaning error messages

parent 74456bea
Branches
No related tags found
No related merge requests found
...@@ -157,13 +157,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -157,13 +157,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
parsedrequest=JSON.parse(request); parsedrequest=JSON.parse(request);
data=calcPercentage(parsedrequest); data=calcPercentage(parsedrequest);
console.log(data); if(data.countstudents<1500 && !localStorage.groups){
if(data.countstudents.length<1000 && !localStorage.groups){
localStorage.setItem("courseid",parsedrequest["courseid"]); localStorage.setItem("courseid",parsedrequest["courseid"]);
localStorage.setItem("groups",parsedrequest["groups"]); localStorage.setItem("groups",parsedrequest["groups"]);
} }
initActivityFilter(false); initActivityFilter(false);
updateActivitiesFilterLabel(false); updateActivitiesFilterLabel(false);
changeSection(false); changeSection(false);
...@@ -235,7 +233,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -235,7 +233,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
data=calcPercentage(parsedrequest); data=calcPercentage(parsedrequest);
showHideStudents(); showHideStudents();
if(data.countstudents.length<1000){ if(data.countstudents<1500){
localStorage.setItem("courseid",parsedrequest["courseid"] ) localStorage.setItem("courseid",parsedrequest["courseid"] )
localStorage.setItem("groups",JSON.stringify(parsedrequest["groups"])); localStorage.setItem("groups",JSON.stringify(parsedrequest["groups"]));
...@@ -398,7 +397,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -398,7 +397,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
} }
} }
} }
if(data.countstudents.length<1000){ if(data.countstudents<1500){
localStorage.setItem("activities",JSON.stringify(activitiesToStore)); localStorage.setItem("activities",JSON.stringify(activitiesToStore));
} }
...@@ -744,7 +743,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -744,7 +743,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
updateGroupsFilterLabel(); updateGroupsFilterLabel();
}); });
if(localStorage.groups && JSON.parse(localStorage.groups) != 0 && localStorage.courseid && localStorage.courseid==courseid ){ if(localStorage.groups && JSON.parse(localStorage.groups) != 0 && localStorage.courseid && localStorage.courseid==courseid ){
console.log("on est passé dans le cache alors qu'on aurait pas dû");
var checkedGroups=JSON.parse(localStorage.groups); var checkedGroups=JSON.parse(localStorage.groups);
//var checkedGroups=JSON.parse(localStorage.groups); //var checkedGroups=JSON.parse(localStorage.groups);
...@@ -768,9 +766,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], ...@@ -768,9 +766,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
//} //}
} }
else{ else{
if(data.countstudents<1000){ if(data.countstudents<1500){
checkAllGroupsFilter(); checkAllGroupsFilter();
} }
else{
$('.selectallgroups').prop('checked', false);
$('.group-option').prop('checked', false);
}
} }
} }
......
...@@ -172,7 +172,6 @@ function get_activities($completion, $activesectionid) { ...@@ -172,7 +172,6 @@ function get_activities($completion, $activesectionid) {
} }
function get_sections($activesectionid) { function get_sections($activesectionid) {
error_log("on passe par ici alors qu'on devrait pas");
global $COURSE; global $COURSE;
// Liste des sections du cours. // Liste des sections du cours.
$modinfo = get_fast_modinfo($COURSE->id); $modinfo = get_fast_modinfo($COURSE->id);
...@@ -282,7 +281,7 @@ function get_progress_students($modules, $progress, $groups, $activegroupsids, $ ...@@ -282,7 +281,7 @@ function get_progress_students($modules, $progress, $groups, $activegroupsids, $
$context $context
); );
//On active le cache seulement s'il y a plus de x étudiants //On active le cache seulement s'il y a plus de x étudiants
if($countstudents<1000){ if($countstudents<1500){
error_log("on set le cache"); error_log("on set le cache");
$cache->set($courseid."-".$activegroupsids[$i], $progressrequest); $cache->set($courseid."-".$activegroupsids[$i], $progressrequest);
} }
...@@ -338,7 +337,6 @@ function get_progress_student($identifier, $completion, $modules){ ...@@ -338,7 +337,6 @@ function get_progress_student($identifier, $completion, $modules){
$where_params = array(); $where_params = array();
//regarder get_in_or_equal //regarder get_in_or_equal
error_log("flag2");
for($i=0; $i<count($users);$i++){ for($i=0; $i<count($users);$i++){
// foreach($users as $user){ // foreach($users as $user){
...@@ -357,12 +355,11 @@ function get_progress_student($identifier, $completion, $modules){ ...@@ -357,12 +355,11 @@ function get_progress_student($identifier, $completion, $modules){
} }
$arrayprogress=(object) array_unique(array_merge((array) $arrayprogress, (array) $completion_student), SORT_REGULAR); $arrayprogress=(object) array_unique(array_merge((array) $arrayprogress, (array) $completion_student), SORT_REGULAR);
} }
error_log("flag3");
return format_progress($arrayprogress, $modules, false, true); return format_progress($arrayprogress, $modules, false, true);
} }
else{ else{
error_log("Pas trouvé ?");
//On a pas trouvé d'utilisateur //On a pas trouvé d'utilisateur
return array("error"=>"Pas d'utilisateurs trouvés"); return array("error"=>"Pas d'utilisateurs trouvés");
} }
...@@ -453,7 +450,7 @@ if (isset($_POST['groupsid'])) { ...@@ -453,7 +450,7 @@ if (isset($_POST['groupsid'])) {
$activegroupsids = $_POST['groupsid']; $activegroupsids = $_POST['groupsid'];
} else { } else {
if($countstudents>1000){ if($countstudents>1500){
$activegroupsids = array(); $activegroupsids = array();
} }
...@@ -541,7 +538,6 @@ else if(isset($_POST['action']) && $_POST['action'] == 'search_student' && isset ...@@ -541,7 +538,6 @@ else if(isset($_POST['action']) && $_POST['action'] == 'search_student' && isset
$data=[]; $data=[];
$sanitized=filter_var($_POST['search_input'], FILTER_SANITIZE_STRING); $sanitized=filter_var($_POST['search_input'], FILTER_SANITIZE_STRING);
error_log($sanitized);
$modules = get_activities($completion, $activesectionid); $modules = get_activities($completion, $activesectionid);
$data["modules"]=$modules; $data["modules"]=$modules;
$data["students"]=get_progress_student($sanitized, $completion, $modules); $data["students"]=get_progress_student($sanitized, $completion, $modules);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment