Permalink
Browse files

Latest fixes from Bobo in stable

  • Loading branch information...
1 parent 0dd066c commit 5cae766f70f06b7db534c7038d9900d68a81f3b2 moodler committed Jul 16, 2004
View
@@ -1,30 +1,31 @@
//
// SCORM API 1.2 Implementation
//
+
function SCORMapi() {
var cmi= new Object();
var nav = new Object();
- var errorCode = 0;
+ var errorCode = "0";
var Initialized = false;
function LMSInitialize (param) {
if (param != "") {
- errorCode = 201;
+ errorCode = "201";
return "false";
}
if (!Initialized) {
Initialized = true;
- errorCode = 0;
+ errorCode = "0";
//
// CMI Initialization SCORM 1.2
//
cmi.core = new Object();
cmi.core._children = "student_id,student_name,lesson_location,credit,lesson_status,exit,entry,session_time,total_time,lesson_mode,score,suspend_data,launch_data";
cmi.core.student_id = "<?php echo $USER->username; ?>";
- cmi.core.student_name = "<?php echo $USER->firstname." ".$USER->lastname; ?>";
+ cmi.core.student_name = "<?php echo $USER->lastname.", ".$USER->firstname; ?>";
cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
cmi.core.credit = "<?php if ($mode != 'normal') {
echo "no-credit";
@@ -48,8 +49,12 @@ function LMSInitialize (param) {
cmi.core.score = new Object();
cmi.core.score._children = "raw,min,max";
cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw; ?>";
+ cmi.core.score.min = "";
+ cmi.core.score.max = "";
cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
- cmi.launch_data = "<?php echo $sco_user->cmi_launch_data; ?>";
+ cmi.launch_data = "<?php echo $sco->datafromlms; ?>";
+ cmi.comments = "";
+ cmi.comments_from_lms = "";
//
// end CMI Initialization
//
@@ -65,7 +70,7 @@ function LMSInitialize (param) {
return "true";
} else {
- errorCode = 101;
+ errorCode = "101";
return "false";
}
}
@@ -85,23 +90,48 @@ function LMSGetValue (param) {
case "cmi.core.lesson_mode":
case "cmi.core.score._children":
case "cmi.core.score.raw":
+ case "cmi.core.score.min":
+ case "cmi.core.score.max":
case "cmi.launch_data":
case "cmi.suspend_data":
- errorCode = 0;
+ case "cmi.comments":
+ case "cmi.comments_from_lms":
+ errorCode = "0";
return eval(param);
break;
case "cmi.core.exit":
case "cmi.core.session_time":
- errorCode = 404;
+ errorCode = "404";
return "";
break;
default:
- errorCode = 401;
- return "";
+ errorCode = "401";
+ param = param.replace(/.(\d+)./g,"[$1].");
+
+ children = param.match(/._children$/);
+ if (children != null) {
+ objType = typeof eval(children[1]);
+ //alert (param+" :"+objType);
+ if (objType != "undefined") {
+
+ errorCode = "202";
+ }
+ }
+
+ counted = param.match(/._count$/);
+ if (counted != null) {
+ objType = typeof eval(counted[1]);
+ //alert (param+" :"+objType);
+ if (objType != "undefined") {
+ errorCode = "203";
+ }
+ }
+ //alert(param+": "+errorCode);
+ return "";
break;
}
} else {
- errorCode = 301;
+ errorCode = "301";
return "";
}
}
@@ -117,65 +147,80 @@ function LMSSetValue (param,value) {
//top.alert(parsedtime);
if (((parsedtime.length == 4) || (parsedtime.length == 5)) && (parsedtime[2]>=0) && (parsedtime[2]<=59) && (parsedtime[3]>=0) && (parsedtime[3]<=59)) {
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
} else {
- errorCode = 405;
+ errorCode = "405";
return "false";
}
} else {
- errorCode = 405;
+ errorCode = "405";
return "false";
}
} else {
- errorCode = 405;
+ errorCode = "405";
return "false";
}
break;
case "cmi.core.lesson_status":
if ((value!="passed")&&(value!="completed")&&(value!="failed")&&(value!="incomplete")&&(value!="browsed")) {
- errorCode = 405;
+ errorCode = "405";
return "false";
}
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
break;
case "cmi.core.score.raw":
case "cmi.core.score.min":
case "cmi.core.score.max":
- if ((parseFloat(value,10)).toString() != value) {
- errorCode = 405;
- return "false";
- } else {
- rawvalue = parseFloat(value,10);
- if ((rawvalue<0) || (rawvalue>100)) {
- errorCode = 405;
- return "false";
- }
+ if (value != "") {
+ if ((parseFloat(value,10)).toString() != value) {
+ errorCode = "405";
+ return "false";
+ } else {
+ rawvalue = parseFloat(value,10);
+ if ((rawvalue<0) || (rawvalue>100)) {
+ errorCode = "405";
+ return "false";
+ }
+ }
}
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
break;
case "cmi.core.exit":
if ((value!="time-out")&&(value!="suspend")&&(value!="logout")&&(value!="")) {
- errorCode = 405;
+ errorCode = "405";
return "false";
}
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
break;
case "cmi.core.lesson_location":
+ if (value.length > 255) {
+ errorCode = "405";
+ return "false";
+ }
+ eval(param+'="'+value+'";');
+ errorCode = "0";
+ return "true";
+ break;
case "cmi.suspend_data":
+ case "cmi.comments":
+ if (value.length > 4096) {
+ errorCode = "405";
+ return "false";
+ }
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
break;
case "cmi.core._children":
case "cmi.core.score._children":
- errorCode = 402;
+ errorCode = "402";
return "false";
break;
case "cmi.core.student_id":
@@ -185,34 +230,35 @@ function LMSSetValue (param,value) {
case "cmi.core.total_time":
case "cmi.core.lesson_mode":
case "cmi.launch_data":
- errorCode = 403;
+ case "cmi.comments_from_lms":
+ errorCode = "403";
return "false";
break;
case "nav.event":
if ((value == "previous") || (value == "continue")) {
eval(param+'="'+value+'";');
- errorCode = 0;
+ errorCode = "0";
return "true";
} else {
- erroCode = 405;
+ erroCode = "405";
return "false";
}
break;
default:
- //errorCode = 401; This is more correct but may have problem with some SCOes
- errorCode = 0; // With this disable any possible SCO errors alert
+ errorCode = "401"; //This is more correct but may have problem with some SCOes
+ //errorCode = "0"; // With this disable any possible SCO errors alert
return "false";
break;
}
} else {
- errorCode = 301;
+ errorCode = "301";
return "false";
}
}
function LMSCommit (param) {
if (param != "") {
- errorCode = 201;
+ errorCode = "201";
return "false";
}
if (Initialized) {
@@ -226,25 +272,25 @@ function LMSCommit (param) {
cmiform.cmi_suspend_data.value = cmi.suspend_data;
cmiform.submit();
}
- errorCode = 0;
+ errorCode = "0";
return "true";
} else {
- errorCode = 301;
+ errorCode = "301";
return "false";
}
}
function LMSFinish (param) {
if (param != "") {
- errorCode = 201;
+ errorCode = "201";
return "false";
}
if (!Initialized) {
- errorCode = 301;
+ errorCode = "301";
return "false";
} else {
Initialized = false;
- errorCode = 0;
+ errorCode = "0";
cmi.core.total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
//top.alert(cmi.core.total_time);
if (<?php echo $navObj ?>cmi.document.theform) {
@@ -279,7 +325,7 @@ function LMSGetErrorString (param) {
errorString["201"] = "Invalid argument error";
errorString["202"] = "Element cannot have children";
errorString["203"] = "Element not an array - cannot have count";
- errorString["301"] = "Not initializated";
+ errorString["301"] = "Not initialized";
errorString["401"] = "Not implemented error";
errorString["402"] = "Invalid set value, element is a keyword";
errorString["403"] = "Element is read only";
@@ -329,4 +375,4 @@ function AddTime (first, second) {
this.LMSGetDiagnostic = LMSGetDiagnostic;
}
-var API = new SCORMapi();
+var API = new SCORMapi();
View
@@ -14,6 +14,10 @@ function scorm_upgrade($oldversion) {
table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
}
+ if ($oldversion < 2004070800) {
+ table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
+ modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
+ }
return true;
}
View
@@ -25,6 +25,7 @@ CREATE TABLE prefix_scorm_scoes (
launch varchar(255) NOT NULL default '',
type varchar(5) NOT NULL default '',
title varchar(255) NOT NULL default '',
+ datafromlms longtext,
next tinyint(1) unsigned NOT NULL default '0',
previous tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (id),
@@ -43,7 +44,6 @@ CREATE TABLE prefix_scorm_sco_users (
cmi_core_session_time varchar(13) NOT NULL default '00:00:00',
cmi_core_score_raw float(3) NOT NULL default '0',
cmi_suspend_data longtext,
- cmi_launch_data longtext,
PRIMARY KEY (id)
) TYPE=MyISAM;
@@ -14,6 +14,10 @@ function scorm_upgrade($oldversion) {
table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
}
+ if ($oldversion < 2004070800) {
+ table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
+ modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
+ }
return true;
}
@@ -23,6 +23,7 @@ CREATE TABLE prefix_scorm_scoes (
launch varchar(255) NOT NULL default '',
type varchar(5) NOT NULL default '',
title varchar(255) NOT NULL default '',
+ datafromlms text NOT NULL default ''
next integer NOT NULL default '0',
previous integer NOT NULL default '0'
);
@@ -38,8 +39,7 @@ CREATE TABLE prefix_scorm_sco_users (
cmi_core_total_time varchar(13) NOT NULL default '00:00:00',
cmi_core_session_time varchar(13) NOT NULL default '00:00:00',
cmi_core_score_raw real NOT NULL default '0',
- cmi_suspend_data text NOT NULL default '',
- cmi_launch_data text NOT NULL default ''
+ cmi_suspend_data text NOT NULL default ''
);
#
View
@@ -52,8 +52,11 @@
} else {
$result = "datadir";
}
-
+ $errorlogs = '';
if ($result != "regular") {
+ /*foreach ($error_array as $errormsg) {
+ $errorlogs .= get_string($errormsg->type,"scorm",$errormsg->data) . "\n";
+ }*/
//
// Delete files and temporary directory
//
@@ -79,6 +82,10 @@
echo "<table cellpadding=\"5\" align=\"center\">\n";
echo " <tr><td align=\"right\" nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>\n";
echo " <tr><td align=\"right\" nowrap><p><b>".get_string("validation","scorm").":</b></p></td><td><p>".get_string($result,"scorm")."</p></a></td></tr>\n";
+ if ($errorlogs != '') {
+ //$lines = round(count($error_array)/4);
+ //echo " <tr><td align=\"right\" nowrap><p><b>".get_string("errorlogs","scorm").":</b></p></td><td><textarea rows=\"".$lines."\" readonly>".$errorlogs."</textarea></a></td></tr>\n";
+ }
if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance)))
echo " <tr><td align=\"center\" colspan=\"2\" nowrap><p><b>".get_string("trackingloose","scorm")."</b></p></td></tr>\n";
echo "</table>\n";
Oops, something went wrong.

0 comments on commit 5cae766

Please sign in to comment.