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

added events that triggers flushing the cache

parent 8b8ef088
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
.done(function(html, js){
$("#container-modal").html(html);
console.log($("#container-modal"));
$('#details-modal').modal('toggle');
//templates.runTemplateJS(js);
//window.history.pushState('suivi',"", url);
......
......@@ -78,22 +78,21 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
//initActivityFilter();
},
registerSelectAllGroupsFilter:function(){
checkAllGroupsFilter();
$('.selectallgroups').click(function() {
if ($(".selectallgroups").is(':checked')) {
checkAllGroupsFilter();
} else {
$('.group-option').prop('checked', false);
var message=str.get_string('selectedActivities', 'format_iena');
$.when(message).done(function(localizedEditString) {
$(".group-dropdown-text").html('0 '+localizedEditString);
});
changeGroup();
displayTotalGroupsFilter();
changeGroup();
}
});
},
initTable:function(){
initActivityFilter(false);
displayTotalActivitiesFilter(false);
displayTotalGroupsFilter(false);
displayActivities(false);
initGroupFilter(false);
registerGroupFilter();
......@@ -124,14 +123,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
groupid=$("#group-select").val();
sectionid=$("#section-select").val();
filter=$("#symbol-select").val() + $("#filter-select").val();
/*checkedActivities=$('input[name="options[]"]:checked');
activities=[];
for(var i=0; i< checkedActivities.length; i++){
if(checkedActivities[i].value >0){
activities.push(checkedActivities[i].value);
}
}*/
completeUrl='suivi_unit.php?courseid='+courseid;
if(sectionid){
completeUrl+='&sectionid='+sectionid;
......@@ -158,10 +149,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
data: {action: 'fetchgroups', groupsid:groupsid},
type: 'post',
success: function(request) {
data=calcPercentage(JSON.parse(request));
//initGroupFilter();
changeSection();
localStorage.setItem("groups",request);
displayTotalGroupsFilter(false);
}
});
}
......@@ -619,7 +611,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
else {
$('.selectallgroups').prop('checked', false);
}
//displayTotalActivitiesFilter();
displayTotalActivitiesFilter();
//displayActivities();
});
......@@ -630,6 +622,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
if(localStorage.groups){
var checkedGroups=JSON.parse(localStorage.groups);
var groups=$("input[type='checkbox'].justone-group");
if($("input[type='checkbox'].justone-group[value="+checkedGroups[0]+"]").length > 0){
if(groups.length===checkedGroups.length ){
$(".selectallgroups").prop("checked", true);
......@@ -648,19 +641,42 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}
}
}
//displayTotalActivitiesFilter();
else{
checkAllGroupsFilter();
}
displayTotalActivitiesFilter();
//displayActivities();
}
//Coche toutes les activités quand on change de section
//Coche tous les groupes quand le select all est coché
function checkAllGroupsFilter(){
$('.selectallgroups').prop('checked', true);
$('.group-option').prop('checked', true);
console.log("on check bien tout du coup ?");
changeGroup();
$(".select-text").html(' Deselect');
}
//Update activities filter label
function displayTotalGroupsFilter(){
var total = $('input[name="groupoptions[]"]:checked').length;
if(total == $('input[name="groupoptions[]"]').length){
var message=str.get_string('allActivities', 'format_iena');
$.when(message).done(function(localizedEditString) {
$(".dropdown-text-group").html(localizedEditString);
});
}
else{
var message=str.get_string('selectedActivities', 'format_iena');
$.when(message).done(function(localizedEditString) {
$(".dropdown-text-group").html(total + ' '+localizedEditString);
});
}
}
});
......@@ -19,4 +19,13 @@ class format_iena_observer {
public static function user_module_completion(\core\event\course_module_completion_updated $event){
cache_helper::purge_by_event('iena_newprogress');
}
public static function group_add_member(\core\event\group_member_added $event){
cache_helper::purge_by_event('iena_newprogress');
}
public static function group_remove_member(\core\event\group_member_removed $event){
cache_helper::purge_by_event('iena_newprogress');
}
}
......@@ -13,6 +13,14 @@ $observers = array(
array(
'eventname' => '\core\event\course_module_completion_updated',
'callback' => 'format_iena_observer::user_module_completion',
),
array(
'eventname' => '\core\event\group_member_added',
'callback' => 'format_iena_observer::group_add_member',
),
array(
'eventname' => '\core\event\group_member_removed',
'callback' => 'format_iena_observer::group_remove_member',
)
);
......
......@@ -34,8 +34,8 @@ class format_iena extends format_topics {
*/
public function course_format_options($foreditform = false) {
global $PAGE;
static $courseformatoptions = false;
if ($courseformatoptions === false) {
/*static $courseformatoptions = false;
if ($courseformatoptions === false) {*/
$courseformatoptions['allmodulesbreadcrum'] = array(
'default' => 0,
'type' => PARAM_INT,
......@@ -44,7 +44,7 @@ class format_iena extends format_topics {
'default' => 1,
'type' => PARAM_INT,
);
}
//}
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
$choicetab = array();
$choicetab['1'] = get_string('yes', 'format_iena');
......
......@@ -1210,3 +1210,7 @@ border-bottom: 1px solid #dee2e6;
background-color: #efefef;
margin-bottom: 10px;
}
#iena-group-dropdown optgroup{
margin-left: 8px;
}
\ No newline at end of file
......@@ -371,7 +371,6 @@ for($i=0; $i<count($activegroupsids); $i++){
}
$activesectionid = 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.
......
......@@ -77,15 +77,19 @@
</div>
<div class="dropdown mr-sm-2 iena-custom-dropdown" id="group-select" name="groupid">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
<span class="group-dropdown-text">Tous les groupes</span>
<span class="dropdown-text-group">Tous les groupes</span>
<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-form" id="iena-group-dropdown">
<li>
<label class="checkbox">
<input type="checkbox" class="selectallgroups" checked value='0' {{default_group}}>Tous les groupes</label>
</li>
<li class="divider"></li>
<li>
<label class="checkbox">
<input type="checkbox" class="selectwithoutgroups group-option justone-group" name="groupoptions[]" value='-1'>Sans groupe</label>
</li>
<optgroup label="Mes groupes">
</optgroup>
<ul class="iena-dynamic-options">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment