MDL-15498: Minor tweaks to completion system (fixing bug with formatting if you have a tick against a multi-paragraph label; allowing use of tick icons on other pages than course/view if required)

This commit is contained in:
sam_marshall
2008-08-21 13:54:45 +00:00
parent 1c6f36a9a8
commit e399d47cd6
3 changed files with 23 additions and 6 deletions
+16 -4
View 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');
}
+4 -1
View 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);
}
?>
+3 -1
View 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;