First step to SCORM2004, new communication subsystem

This commit is contained in:
bobopinna
2005-02-17 16:04:42 +00:00
parent 4c6b9b84d6
commit 92a489eb6a
7 changed files with 77 additions and 108 deletions
+4 -4
View File
@@ -54,13 +54,13 @@ function closeMain() {
var errorCode = "0";
function SCORM_Call (call,param,value) {
if (arguments.caller.length < 2) {
if (arguments.length < 2) {
alert ("Invalid SCORM_Call function call: too few arguments.\nYou need pass at least 2 parameters");
} else if (arguments.caller.length == 3) {
} else if (arguments.length == 3) {
param = param.concat("&value=",value);
}
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php?id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&param="+param);
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php?id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&call="+call+"&param="+param);
results = result.split('\n');
errorCode = results[1];
@@ -180,7 +180,7 @@ function SCORMapi2004() {
errorString["401"] = "Undefinited Data Model";
errorString["402"] = "Unimplemented Data Model Element";
errorString["403"] = "Data Model Element Value Not Initialized";
errorString["404"] = "Data Model Element Is Read Only;
errorString["404"] = "Data Model Element Is Read Only";
errorString["405"] = "Data Model Element Is Write Only";
errorString["406"] = "Data Model Element Type Mismatch";
errorString["407"] = "Data Model Element Value Out Of Range";
+4 -42
View File
@@ -31,47 +31,9 @@
}
require_login($course->id, false, $cm);
if (!empty($_POST['scoid'])) {
//echo 'scoid: '.$_POST['scoid']."\n";
if (!empty($_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);
//echo 'cmi_core_lesson_location: '.$_POST['cmi_core_lesson_location']."\n";
}
if (!empty($_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);
//echo 'cmi_core_lesson_status: '.$_POST['cmi_core_lesson_status']."\n";
}
if (!empty($_POST['cmi_core_exit'])) {
set_field('scorm_sco_users','cmi_core_exit',$_POST['cmi_core_exit'],'scoid',$_POST['scoid'],'userid',$USER->id);
//echo 'cmi_core_exit: '.$_POST['cmi_core_exit']."\n";
}
if (!empty($_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);
//echo 'cmi_core_score_raw: '.$_POST['cmi_core_score_raw']."\n";
}
if (!empty($_POST['cmi_suspend_data'])) {
set_field('scorm_sco_users','cmi_suspend_data',$_POST['cmi_suspend_data'],'scoid',$_POST['scoid'],'userid',$USER->id);
//echo 'cmi_suspend_data: '.$_POST['cmi_suspend_data']."\n";
}
if (!empty($_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);
//echo 'cmi_core_total_time: '.$_POST['cmi_core_total_time']."\n";
}
if (isset($_POST['call']) && confirm_sesskey()) {
}
?>
<html>
<head>
<title>cmi</title>
</head>
<body>
<form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>">
<input type="hidden" name="scoid" />
<input type="hidden" name="cmi_core_lesson_location" />
<input type="hidden" name="cmi_core_lesson_status" />
<input type="hidden" name="cmi_core_exit" />
<input type="hidden" name="cmi_core_total_time" />
<input type="hidden" name="cmi_core_score_raw" />
<input type="hidden" name="cmi_suspend_data" />
</form>
</body>
</html>
+2 -2
View File
@@ -8,7 +8,7 @@
error("Course ID is incorrect");
}
require_course_login($course->id, false, $cm);
require_course_login($course->id);
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
@@ -20,7 +20,7 @@
$strsummary = get_string("summary");
$strlastmodified = get_string("lastmodified");
print_header_simple("$strscorms", "", "$navigation $strscorms",
print_header_simple("$strscorms", "", "$strscorms",
"", "", true, "", navmenu($course));
if ($course->format == "weeks" or $course->format == "topics") {
+2 -5
View File
@@ -115,19 +115,16 @@ function scorm_update_instance($scorm) {
$scorm->auto = '0';
}
$id = update_record('scorm', $scorm);
//
// Check if scorm manifest needs to be reparsed
//
if ($scorm->launch == 0) {
$basedir = $CFG->dataroot."/".$scorm->course;
$scormdir = "/moddata/scorm";
$scorm->launch = scorm_parse($basedir,$scormdir.$scorm->datadir."/imsmanifest.xml",$id);
set_field("scorm","launch",$scorm->launch,"id",$id);
$scorm->launch = scorm_parse($basedir,$scormdir.$scorm->datadir."/imsmanifest.xml",$scorm->id);
}
return $id;
return update_record('scorm', $scorm);
}
+7 -6
View File
@@ -43,12 +43,17 @@
function validate_scorm(theform,filename) {
//alert(filename);
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php?id=<?php p($form->course) ?>&reference="+filename+"<?php p($scormid.$datadir) ?>");
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php?id=<?php p($form->course) ?>&reference="+filename+"<?php echo $scormid.$datadir ?>");
//alert(result);
results = result.split('\n');
if ((results[0] == "found") || (results[0] == "regular")) {
theform.launch.value = results[1];
theform.datadir.value = results[2];
if (results[1] == 0) {
theform.launch.value = results[1];
if ('<?php echo $scormid ?>' != '') {
return confirm('<?php print_string('trackingloose','scorm') ?>');
}
}
return true;
} else {
result = '<?php print_string('validation','scorm') ?>: '+ results[0] + '\n';
@@ -140,10 +145,6 @@
<td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
<td>
<?php
$options = array();
$options[0] = get_string("gradescoes", "scorm");
$options[1] = get_string("gradehighest", "scorm");
$options[2] = get_string("gradeaverage", "scorm");
choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
?>
+4 -7
View File
@@ -102,10 +102,7 @@
if ($scorm->popup != "") {
$bodyscripts = "onUnload='SCOFinish(); closeMain();' ";
}
//print_header($pagetitle, "$course->fullname",
// "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">$scorm->name</a>",
// "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'),"",$bodyscripts);
print_header($pagetitle, "$course->fullname",
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">$scorm->name</a>",
"", "", true, update_module_button($cm->id, $course->id, $strscorm), "", "", $bodyscripts);
echo "<table width=\"100%\">\n <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td>\n";
@@ -275,7 +272,7 @@
$options[$sco->id] = $indenting."&gt; ".$sco->title;
}
}
choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
choose_from_menu($options, "courseStructure", "", $scoid, "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('continue')\" />\n";
echo " </form>
@@ -296,8 +293,8 @@
echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"request.js\"></script>\n";
echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"api.php?id=$cm->id\"></script>\n";
echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"SCOFinish();\">\n";
echo "\t <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id".$modestring.$currentorgstring."&frameset=top\">\n";
echo "<frameset rows=\"$CFG->scorm_framesize,*\" onUnload=\"SCOFinish();\">\n";
echo "\t <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id".$modestring.$currentorgstring.$scoidstring."&frameset=top\">\n";
echo "\t <frame name=\"main\" src=\"loadSCO.php?id=$cm->id$scoidstring\">\n";
echo "</frameset>\n";
echo "</html>\n";
+54 -42
View File
@@ -5,57 +5,70 @@
require_login();
//
// Create a temporary directory to unzip package and validate imsmanifest
//
$reference = clean_param($_GET["reference"], PARAM_PATH);
$courseid = $_GET["id"];
$datadir = '';
$launch = 0;
if (isset($_GET["datadir"])) {
$datadir = $_GET["datadir"];
}
$scormid = 0;
$launch = 0;
$result = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir, $datadir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
unzip_file($tempdir."/".basename($reference), $tempdir, false);
$result = scorm_validate($tempdir."/imsmanifest.xml");
} else {
$result = "packagedir";
}
} else {
$result = "datadir";
}
$errorlogs = '';
if (($result != "regular") && ($result != "found")) {
$result = get_string($result,'scorm');
if ($CFG->scorm_validate == 'domxml') {
foreach ($errors as $error) {
$errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n";
if (isset($_GET["instance"])) {
$scormid = $_GET["instance"];
$launch = 1;
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
// This is a new package
$launch = 0;
} else {
// Old package already validated
$result = 'found';
}
}
}
if ($launch == 0) {
//
// Package must be validated
//
// Create a temporary directory to unzip package and validate imsmanifest
$tempdir = '';
$scormdir = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir, $datadir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
unzip_file($tempdir."/".basename($reference), $tempdir, false);
$result = scorm_validate($tempdir."/imsmanifest.xml");
} else {
$result = "packagedir";
}
} else {
$result = "datadir";
}
if (($result != "regular") && ($result != "found")) {
// Generate error log string
$result = get_string($result,'scorm');
if ($CFG->scorm_validate == 'domxml') {
foreach ($errors as $error) {
$errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n";
}
}
if (is_dir($tempdir)) {
// Delete files and temporary directory
scorm_delete_files($tempdir);
} else {
// Delete package file
unlink ($tempdir."/".basename($reference));
}
}
//
// Delete files and temporary directory
//
if (is_dir($tempdir))
scorm_delete_files($tempdir);
} else {
//
// Delete package file
//
unlink ($tempdir."/".basename($reference));
if (isset($_GET["instance"])) {
$fp = fopen($CFG->dataroot.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$_GET["instance"])) {
$launch = $scorm->launch;
if ($scorm->timemodified < $fstat["mtime"]) {
$launch = 0;
}
}
$datadir = substr($tempdir,strlen($scormdir));
}
}
//
@@ -63,7 +76,6 @@
//
echo $result . "\n";
echo $launch . "\n";
$datadir = substr($tempdir,strlen($scormdir));
echo $datadir . "\n";
if ($errorlogs != '') {
echo $errorlogs;