[svn r13609] Added limit on SetValue() of objectives (cannot set higher than current length of interactions array) - Fixes FS#2037

skala
Yannick Warnier 18 years ago
parent 570d745395
commit 3463bf2207
  1. 78
      main/newscorm/scorm_api.php

@ -511,51 +511,59 @@ function LMSSetValue(param, val) {
if(myres = param.match(/cmi.objectives.(\d+).(id|score|status)(.*)/)) if(myres = param.match(/cmi.objectives.(\d+).(id|score|status)(.*)/))
{ {
obj_id = myres[1]; obj_id = myres[1];
req_type = myres[2]; if(obj_id > item_objectives.length)
if(obj_id == null || obj_id == '')
{ {
;//do nothing G_LastError = G_InvalidArgumentError;
return_value = false;
} }
else else
{ {
if(item_objectives[obj_id]==null) req_type = myres[2];
if(obj_id == null || obj_id == '')
{ {
item_objectives[obj_id] = ['','','','','']; ;//do nothing
} }
if( req_type == "id" ) { else
//item_objectives[obj_id][0] = val.substring(51,57); {
item_objectives[obj_id][0] = val; if(item_objectives[obj_id]==null)
logit_scorm("Objective "+obj_id+"'s id updated",2); {
return_value = 'true'; item_objectives[obj_id] = ['','','','',''];
} else if ( req_type == "score" ) { }
if (myres[3] == '._children'){ if( req_type == "id" ) {
return_value = ''; //item_objectives[obj_id][0] = val.substring(51,57);
G_lastError = G_InvalidSetValue; item_objectives[obj_id][0] = val;
G_lastErrorString = 'Invalid set value, element is a keyword'; logit_scorm("Objective "+obj_id+"'s id updated",2);
}else if (myres[3] == '.raw'){
item_objectives[obj_id][2] = val;
logit_scorm("Objective "+obj_id+"'s score raw updated",2);
return_value = 'true';
}else if (myres[3] == '.max'){
item_objectives[obj_id][3] = val;
logit_scorm("Objective "+obj_id+"'s score max updated",2);
return_value = 'true'; return_value = 'true';
}else if (myres[3] == '.min'){ } else if ( req_type == "score" ) {
item_objectives[obj_id][4] = val; if (myres[3] == '._children'){
logit_scorm("Objective "+obj_id+"'s score min updated",2); return_value = '';
G_lastError = G_InvalidSetValue;
G_lastErrorString = 'Invalid set value, element is a keyword';
}else if (myres[3] == '.raw'){
item_objectives[obj_id][2] = val;
logit_scorm("Objective "+obj_id+"'s score raw updated",2);
return_value = 'true';
}else if (myres[3] == '.max'){
item_objectives[obj_id][3] = val;
logit_scorm("Objective "+obj_id+"'s score max updated",2);
return_value = 'true';
}else if (myres[3] == '.min'){
item_objectives[obj_id][4] = val;
logit_scorm("Objective "+obj_id+"'s score min updated",2);
return_value = 'true';
}else{
return_value = '';
G_lastError = G_NotImplementedError;
G_lastErrorString = 'Not implemented yet';
}
} else if ( req_type == "status" ) {
item_objectives[obj_id][1] = val;
logit_scorm("Objective "+obj_id+"'s status updated",2);
return_value = 'true'; return_value = 'true';
}else{ } else {
return_value = '';
G_lastError = G_NotImplementedError; G_lastError = G_NotImplementedError;
G_lastErrorString = 'Not implemented yet'; G_lastErrorString = 'Not implemented yet';
} }
} else if ( req_type == "status" ) {
item_objectives[obj_id][1] = val;
logit_scorm("Objective "+obj_id+"'s status updated",2);
return_value = 'true';
} else {
G_lastError = G_NotImplementedError;
G_lastErrorString = 'Not implemented yet';
} }
} }
} }

Loading…
Cancel
Save