Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Latest fixes from Bobo in stable

  • Loading branch information...
commit 5cae766f70f06b7db534c7038d9900d68a81f3b2 1 parent 0dd066c
moodler authored
View
136 mod/scorm/api1_2.php
@@ -1,22 +1,23 @@
//
// 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
@@ -24,7 +25,7 @@ function LMSInitialize (param) {
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
4 mod/scorm/db/mysql.php
@@ -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
2  mod/scorm/db/mysql.sql
@@ -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;
View
4 mod/scorm/db/postgres7.php
@@ -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
4 mod/scorm/db/postgres7.sql
@@ -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
9 mod/scorm/details.php
@@ -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";
View
44 mod/scorm/lib.php
@@ -349,27 +349,43 @@ function scorm_parse($basedir,$file,$scorm_id) {
$sco->scorm = $scorm_id;
delete_records("scorm_scoes","scorm",$scorm_id);
delete_records("scorm_sco_users","scormid",$scorm_id);
- print_r($manifest);
+
for ($j=1; $j<=$i; $j++) {
$sco->identifier = $manifest[$j]["identifier"];
$sco->parent = $manifest[$j]["parent"];
$sco->title = $manifest[$j]["title"];
- if (empty($resources[($manifest[$j]["identifierref"])]["href"]))
+ if (!isset($manifest[$j]["datafromlms"])) {
+ $manifest[$j]["datafromlms"] = "";
+ }
+ $sco->datafromlms = $manifest[$j]["datafromlms"];
+
+ if (!isset($resources[($manifest[$j]["identifierref"])]["href"])) {
$resources[($manifest[$j]["identifierref"])]["href"] = "";
+ }
$sco->launch = $resources[($manifest[$j]["identifierref"])]["href"];
- if (empty($resources[($manifest[$j]["identifierref"])]["type"]))
+
+ if (!isset($resources[($manifest[$j]["identifierref"])]["type"])) {
$resources[($manifest[$j]["identifierref"])]["type"] = "";
- $sco->type = $resources[($manifest[$j]["identifierref"])]["type"];
- if (empty($manifest[$j]["previous"]))
- $manifest[$j]["previous"] = 0;
- $sco->previous = $manifest[$j]["previous"];
- if (empty($manifest[$j]["continue"]))
- $manifest[$j]["continue"] = 0;
- $sco->next = $manifest[$j]["continue"];
- if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false")
- $id = insert_record("scorm_scoes",$sco);
- if ($launch==0 && $sco->launch)
- $launch = $id;
+ }
+ $sco->type = $resources[($manifest[$j]["identifierref"])]["type"];
+
+ if (!isset($manifest[$j]["previous"])) {
+ $manifest[$j]["previous"] = 0;
+ }
+ $sco->previous = $manifest[$j]["previous"];
+
+ if (!isset($manifest[$j]["continue"])) {
+ $manifest[$j]["continue"] = 0;
+ }
+ $sco->next = $manifest[$j]["continue"];
+
+ if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false") {
+ $id = insert_record("scorm_scoes",$sco);
+ }
+
+ if ($launch==0 && $sco->launch) {
+ $launch = $id;
+ }
}
return $launch;
}
View
11 mod/scorm/mod.html
@@ -48,23 +48,12 @@
echo "<br \>";
helpbutton("text", get_string("helptext"), "moodle", true, true);
?>
- <br />
</font>
</td>
<td>
<?php print_textarea($usehtmleditor, 20, 50, 680, 400, "summary", $form->summary); ?>
</td>
</tr>
- <tr valign=top>
- <td align=right><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
- <td>
- <?php
- $options[]=get_string("no");
- $options[]=get_string("yes");
- choose_from_menu ($options, "auto", $form->auto);
- ?>
- </td>
- </tr>
</table>
<input type="hidden" name=course value="<?php p($form->course) ?>">
<input type="hidden" name=coursemodule value="<?php p($form->coursemodule) ?>">
View
2  mod/scorm/version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004061800; // The (date) version of this module
+$module->version = 2004070800; // The (date) version of this module
$module->requires = 2004051600; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?
Please sign in to comment.
Something went wrong with that request. Please try again.