]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15498: Minor tweaks to completion system (fixing bug with formatting if you have...
authorsam_marshall <sam_marshall>
Thu, 21 Aug 2008 13:54:45 +0000 (13:54 +0000)
committersam_marshall <sam_marshall>
Thu, 21 Aug 2008 13:54:45 +0000 (13:54 +0000)
course/completion.js
course/togglecompletion.php
theme/standard/styles_layout.css

index bf33e203e09ea73b39cb595a6dcae1faff56d4af..3471f5d8daf4572cae0f4064a969c21bbad0a86c 100644 (file)
@@ -1,4 +1,5 @@
 var completion_strsaved;
+var completion_wwwroot;
 
 function completion_init() { 
   var toggles=YAHOO.util.Dom.getElementsByClassName('togglecompletion', 'form');
@@ -10,9 +11,15 @@ function completion_init() {
 function completion_init_toggle(form) {
   // Store all necessary references for easy access
   var inputs=form.getElementsByTagName('input');
-  form.cmid=inputs[0].value;
-  form.otherState=inputs[1].value;
-  form.image=inputs[2];
+  for(var i=0;i<inputs.length;i++) {
+    switch(inputs[i].name) {
+      case 'id' : form.cmid=inputs[i].value; break;
+      case 'completionstate' : form.otherState=inputs[i].value; break;
+    } 
+    if(inputs[i].type=='image') {
+      form.image=inputs[i];
+    }
+  }
 
   // Create and position 'Saved' text
   var saved=document.createElement('div');
@@ -65,7 +72,12 @@ function completion_handle_failure(o) {
 
 function completion_toggle(e) {
   YAHOO.util.Event.preventDefault(e);
-  YAHOO.util.Connect.asyncRequest('POST','togglecompletion.php',
+  // By setting completion_wwwroot you can cause it to use absolute path 
+  // otherwise script assumes it is called from somewhere in /course
+  var target=completion_wwwroot 
+    ? completion_wwwroot+'/course/togglecompletion.php' 
+    : 'togglecompletion.php';
+  YAHOO.util.Connect.asyncRequest('POST',target,
       {success:completion_handle_response,failure:completion_handle_failure,scope:this},
       'id='+this.cmid+'&completionstate='+this.otherState+'&fromajax=1');
 }
index 01a9284fe18b479f94692fc147c7006c08d98e95..8c60765cd415fa806e661f4df3274f04902eca84 100644 (file)
@@ -52,6 +52,9 @@ $completion->update_state($cm,$targetstate);
 if($fromajax) {
     print 'OK';
 } else {
-    redirect('view.php?id='.$course->id);
+    // In case of use in other areas of code we allow a 'backto' parameter,
+    // otherwise go back to course page
+    $backto=optional_param('backto','view.php?id='.$course->id,PARAM_URL);
+    redirect($backto);
 }
 ?>
index bb4586ce3c225555a93f460d83c628295175ed55..f6916f0a046f74e917aee35039eb6afac1c5ea52 100644 (file)
@@ -1812,7 +1812,9 @@ border-width:0px;
   display:inline;
   position:absolute;
   right:-20px;
-  z-index:10;
+       top:0;
+       z-index:10;
+       padding:0.2em 0;
 }
 #course-view li.activity form.togglecompletion div {
   display:inline;