]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17275: Completion system - needs reload if you use Back button to return to page...
authorsam_marshall <sam_marshall>
Tue, 18 Nov 2008 14:45:13 +0000 (14:45 +0000)
committersam_marshall <sam_marshall>
Tue, 18 Nov 2008 14:45:13 +0000 (14:45 +0000)
course/completion.js
course/view.php

index 67480482583425d02c5b674147d5fd088c49acf7..6a46d06fe2c224700bc2500bc3af3cd57950887f 100644 (file)
@@ -2,7 +2,15 @@ var completion_strsaved, completion_strtitley, completion_strtitlen,
   completion_stralty, completion_straltn;
 var completion_wwwroot;
 
-function completion_init() { 
+function completion_init() {
+  // Check the reload-forcing
+  var changeDetector=document.getElementById('completion_dynamic_change');
+  if(changeDetector.value==1) {
+    changeDetector.value=0;  
+    window.location.reload();
+    return; 
+  }
+
   var toggles=YAHOO.util.Dom.getElementsByClassName('togglecompletion', 'form');
   for(var i=0;i<toggles.length;i++) {
     completion_init_toggle(toggles[i]);
@@ -35,6 +43,7 @@ function completion_init_toggle(form) {
 }
 
 function completion_handle_response(o) {
+  document.getElementById('completion_dynamic_change').value=1;
   if(o.responseText!='OK') {
     alert('An error occurred when attempting to save your tick mark.\n\n('+o.responseText+'.)');
     return;
index 49eebbc5d2280e9d8cb413ae3950b6c1a86f2982..51870e5e933fa4bae68cfd9b7d1cf36a6acbde71 100644 (file)
             'completion_stralty' => get_string('completion-alt-manual-y','completion'),
             'completion_straltn' => get_string('completion-alt-manual-n','completion'),
         ));
+        // This value tracks whether there has been a dynamic change to the page.
+        // It is used so that if a user does this - (a) set some tickmarks, (b)
+        // go to another page, (c) clicks Back button - the page will
+        // automatically reload. Otherwise it would start with the wrong tick
+        // values.
+        print '<form action="."><div><input type="hidden" id="completion_dynamic_change"
+          name="completion_dynamic_change" value="0" /></div></form>';
     }
 
     // Course wrapper start.