Improve syntax for update_toc() - use jQuery whenever possible - refs #398

(cherry picked from commit 7642f07e71d4c26cf3af94c43b8ecae00fe9ccd9)
1.9.x
Yannick Warnier 11 years ago
parent 7a92c560fb
commit 4b828a3db6
  1. 76
      main/newscorm/scorm_api.php

@ -4,9 +4,9 @@
/**
* API event handler functions for Scorm 1.1 and 1.2 and 1.3
*
* @author Denes Nagy <darkden@freemail.hu>
* @author Yannick Warnier <ywarnier@beeznest.org>
* @version v 1.0
* @author Denes Nagy <darkden@freemail.hu> (original author - 2003-2004)
* @author Yannick Warnier <ywarnier@beeznest.org> (extended and maintained - 2005-2014)
* @version v 1.1
* @access public
* @package chamilo.learnpath.scorm
*/
@ -552,7 +552,7 @@ function LMSGetValue(param) {
} else if(param == 'cmi.interactions._children'){
// ---- cmi.interactions._children
result = 'id,time,type,correct_responses,weighting,student_response,result,latency';
} else{
} else {
// ---- anything else
// Invalid argument error
olms.G_LastError = G_InvalidArgumentError ;
@ -1162,60 +1162,34 @@ function update_toc(update_action, update_id, change_ids) {
logit_lms('update_toc("'+update_action+'", '+update_id+')',2);
if (update_id != 0) {
switch (update_action) {
case 'unhighlight':
if (update_id%2==0) {
myelem.attr('class',"scorm_item_2");
// Switch function is broken
if (update_action == "unhighlight" || update_action == "highlight") {
if (update_action == "unhighlight") {
myelem.removeClass('scorm_item_highlight');
} else {
myelem.attr('class',"scorm_item_1");
}
break;
case 'highlight':
if (change_ids=='yes') {
olms.lms_next_item = update_id;
olms.lms_previous_item = update_id;
}
myelem.attr('class',"scorm_item_highlight");
break;
case 'not attempted':
if( myelemimg.attr('src') != '../img/notattempted.gif') {
myelemimg.attr('src','../img/notattempted.gif');
myelemimg.attr('alt','n');
}
break;
case 'incomplete':
if( myelemimg.attr('src') != '../img/incomplete.png') {
myelemimg.attr('src','../img/incomplete.png');
myelemimg.attr('alt','i');
}
break;
case 'completed':
if( myelemimg.attr('src') != '../img/completed.png') {
myelemimg.attr('src','../img/completed.png');
myelemimg.attr('alt','c');
}
break;
case 'failed':
if( myelemimg.attr('src') != '../img/delete.png') {
myelemimg.attr('src','../img/delete.png');
myelemimg.attr('alt','f');
myelem.addClass('scorm_item_highlight');
}
break;
case 'passed':
if( myelemimg.attr('src') != '../img/completed.png' && myelemimg.attr('alt') != 'passed') {
myelemimg.attr('src','../img/completed.png');
myelemimg.attr('alt','p');
}
break;
case 'browsed':
if( myelemimg.attr('src') != '../img/completed.png' && myelemimg.attr('alt') != 'browsed') {
myelemimg.attr('src','../img/completed.png');
myelemimg.attr('alt','b');
}
break;
default:
} else {
myelem.removeClass("scorm_not_attempted scorm_incomplete scorm_completed scorm_failed scorm_passed");
if (update_action == "not attempted") {
myelem.addClass('scorm_not_attempted');
} else if (update_action == "incomplete") {
myelem.addClass('scorm_incomplete');
} else if (update_action == "completed") {
myelem.addClass('scorm_completed');
} else if (update_action == "failed") {
myelem.addClass('scorm_failed');
} else if (update_action == "passed") {
myelem.addClass('scorm_passed');
} else if (update_action == "browsed") {
myelem.addClass('scorm_completed');
} else {
logit_lms('Update action unknown',1);
break;
}
}
}
return true;

Loading…
Cancel
Save