Permalink
Browse files

Updated backup to popup windows. Modified auto-continue feature. Adde…

…d nav.event data model. Patched a problem with time data model.
  • Loading branch information...
1 parent f9af7fd commit 6d9c91c72ea1c9cfa66522d5a4210c330e869e63 bobopinna committed Jul 1, 2004
Showing with 94 additions and 30 deletions.
  1. +54 −15 mod/scorm/api1_2.php
  2. +1 −0 mod/scorm/backuplib.php
  3. +18 −9 mod/scorm/cmi.php
  4. +3 −3 mod/scorm/playscorm.php
  5. +1 −0 mod/scorm/restorelib.php
  6. +17 −3 mod/scorm/scormAPI.php
View
69 mod/scorm/api1_2.php
@@ -46,6 +46,15 @@ function LMSInitialize (param) {
//
// end CMI Initialization
//
+
+ nav = new Object();
+ <?php
+ if ($scorm->auto) {
+ echo 'nav.event = "continue";'."\n";
+ } else {
+ echo 'nav.event = "";'."\n";
+ }
+ ?>
return "true";
} else {
@@ -93,14 +102,28 @@ function LMSGetValue (param) {
function LMSSetValue (param,value) {
if (Initialized) {
//top.status="SET "+param+" = "+value;
- //top.alert("SET "+param+" = "+value);
+ top.alert("SET "+param+" = "+value);
switch (param) {
case "cmi.core.session_time":
- cmi.core.total_time = AddTime(cmi.core.total_time, value);
- //top.status="SET cmi.core.total_time = "+cmi.core.total_time;
- eval(param+'="'+value+'";');
- errorCode = 0;
- return "true";
+ //top.alert(typeof(value));
+ if (typeof(value) == "string") {
+ var parsedtime = value.match(/[0-9]+/g);
+ if (((parsedtime.length == 3) || (parsedtime.length == 4)) && (parsedtime[0]>=0) && (parsedtime[0]<=9999) && (parsedtime[1]>=0) && (parsedtime[1]<=59) && (parsedtime[2]>=0) && (parsedtime[2]<=59)) {
+ if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) {
+ errorCode = 405;
+ return "false";
+ }
+ eval(param+'="'+value+'";');
+ errorCode = 0;
+ return "true";
+ } else {
+ errorCode = 405;
+ return "false";
+ }
+ } else {
+ errorCode = 405;
+ return "false";
+ }
break;
case "cmi.core.lesson_status":
if ((value!="passed")&&(value!="completed")&&(value!="failed")&&(value!="incomplete")&&(value!="browsed")) {
@@ -159,6 +182,17 @@ function LMSSetValue (param,value) {
errorCode = 403;
return "false";
break;
+ case "nav.event":
+ if ((value == "previous") || (value == "continue")) {
+ eval(param+'="'+value+'";');
+ //changeSco(value);
+ errorCode = 0;
+ return "true";
+ } else {
+ 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
@@ -183,8 +217,6 @@ function LMSCommit (param) {
cmiform.cmi_core_lesson_location.value = cmi.core.lesson_location;
cmiform.cmi_core_lesson_status.value = cmi.core.lesson_status;
cmiform.cmi_core_exit.value = cmi.core.exit;
- cmiform.cmi_core_session_time.value = cmi.core.session_time;
- cmiform.cmi_core_total_time.value = cmi.core.total_time;
cmiform.cmi_core_score_raw.value = cmi.core.score.raw;
cmiform.cmi_suspend_data.value = cmi.suspend_data;
cmiform.submit();
@@ -208,16 +240,23 @@ function LMSFinish (param) {
} else {
Initialized = false;
errorCode = 0;
+ cmi.core.total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
+ if (<?php echo $navObj ?>cmi.document.theform) {
+ cmiform = <?php echo $navObj ?>cmi.document.forms[0];
+ cmiform.scoid.value = "<?php echo $sco->id; ?>";
+ cmiform.cmi_core_total_time.value = cmi.core.total_time;
+ cmiform.submit();
+ }
+ if (nav.event != "") {
<?php
- if ($scorm->auto) {
- if ($sco != $last) {
- echo "setTimeout('".$navObj."document.navform.next.click();',500);\n";
- } else {
- echo "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=".$cm->id."';\n";
- echo "setTimeout('top.location = exitloc;',500);\n";
- }
+ if ($sco != $last) {
+ echo "setTimeout('top.changeSco(nav.event);',500);\n";
+ } else {
+ echo "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=".$cm->id."';\n";
+ echo "setTimeout('top.location = exitloc;',500);\n";
}
?>
+ }
return "true";
}
}
View
1 mod/scorm/backuplib.php
@@ -47,6 +47,7 @@ function scorm_backup_mods($bf,$preferences) {
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
+ fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
View
27 mod/scorm/cmi.php
@@ -33,15 +33,24 @@
require_login($course->id);
if ($_POST["scoid"]) {
- set_field("scorm_sco_users","cmi_core_lesson_location",$_POST["cmi_core_lesson_location"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_core_lesson_status",$_POST["cmi_core_lesson_status"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_core_exit",$_POST["cmi_core_exit"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_core_session_time",$_POST["cmi_core_session_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_core_score_raw",$_POST["cmi_core_score_raw"],"scoid",$_POST["scoid"],"userid",$USER->id);
- set_field("scorm_sco_users","cmi_suspend_data",$_POST["cmi_suspend_data"],"scoid",$_POST["scoid"],"userid",$USER->id);
- /* if ($scorm->auto)
- $result="<script language=\"Javascript\">\n\ttop.nav.document.navform.next.click();\n </script>\n"; */
+ if ($_POST["cmi_core_lesson_location"]) {
+ set_field("scorm_sco_users","cmi_core_lesson_location",$_POST["cmi_core_lesson_location"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
+ if ($_POST["cmi_core_lesson_status"]) {
+ set_field("scorm_sco_users","cmi_core_lesson_status",$_POST["cmi_core_lesson_status"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
+ if ($_POST["cmi_core_exit"]) {
+ set_field("scorm_sco_users","cmi_core_exit",$_POST["cmi_core_exit"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
+ if ($_POST["cmi_core_total_time"]) {
+ set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
+ if ($_POST["cmi_core_score_raw"]) {
+ set_field("scorm_sco_users","cmi_core_score_raw",$_POST["cmi_core_score_raw"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
+ if ($_POST["cmi_suspend_data"]) {
+ set_field("scorm_sco_users","cmi_suspend_data",$_POST["cmi_suspend_data"],"scoid",$_POST["scoid"],"userid",$USER->id);
+ }
}
?>
<html>
View
6 mod/scorm/playscorm.php
@@ -193,7 +193,7 @@ function expandCollide(which,list) {
<form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
<input name=\"scoid\" type=\"hidden\" />
<input name=\"mode\" type=\"hidden\" value=\"".$mode."\" />
- <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" />&nbsp;\n";
+ <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('previous');\" />&nbsp;\n";
if ($scorm->popup == "") {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
@@ -217,7 +217,7 @@ function expandCollide(which,list) {
}
choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
}
- echo " &nbsp;<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />\n";
+ echo " &nbsp;<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('continue')\" />\n";
echo " </form>
</td>\n";
@@ -241,7 +241,7 @@ function expandCollide(which,list) {
echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$mode.$scoid."\"></script>\n";
echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\">\n";
- echo "\t <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$mode."&frameset=top\">\n";
+ echo "\t <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id&mode=".$mode."&frameset=top\">\n";
echo "\t <frame name=\"main\" src=\"\">\n";
echo "</frameset>\n";
echo "</html>\n";
View
1 mod/scorm/restorelib.php
@@ -51,6 +51,7 @@ function scorm_restore_mods($mod,$restore) {
$scorm->launch = backup_todb($info['MOD']['#']['LAUNCH']['0']['#']);
$scorm->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$scorm->auto = backup_todb($info['MOD']['#']['AUTO']['0']['#']);
+ $scorm->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
$scorm->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the scorm
View
20 mod/scorm/scormAPI.php
@@ -40,7 +40,21 @@
//
if (!empty($scoid)) {
// Direct sco request
- $sco = get_record("scorm_scoes","id",$scoid);
+ //$sco = get_record("scorm_scoes","id",$scoid);
+ if ($sco = get_record("scorm_scoes","id",$scoid)) {
+ if ($sco->launch == '') {
+ // Search for th first launchable sco
+ if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
+ $sco = current($scoes);
+ while ($sco->id < $scoid) {
+ $sco = next($scoes);
+ }
+ while ($sco->launch == '') {
+ $sco = next($scoes);
+ }
+ }
+ }
+ }
} else {
// Search for first incomplete sco
foreach ( $scoes_user as $sco_user ) {
@@ -134,7 +148,7 @@
}
$navObj = "top.";
if ($scorm->popup == "")
- $navObj = "top.nav.";
+ $navObj = "top.navigation.";
include("api1_2.php");
@@ -169,7 +183,7 @@ function SCOInitialize() {
}
function changeSco(direction) {
- if (direction == "prev")
+ if (direction == "previous")
<?php echo $navObj ?>document.navform.scoid.value="<?php echo $prevsco; ?>";
else
<?php echo $navObj ?>document.navform.scoid.value="<?php echo $nextsco; ?>";

0 comments on commit 6d9c91c

Please sign in to comment.