Added store datamodel and repot

This commit is contained in:
bobopinna
2005-04-29 14:13:37 +00:00
parent bacb13df7e
commit 26b3d26d2a
13 changed files with 165 additions and 74 deletions
+8 -33
View File
@@ -84,28 +84,6 @@ function underscore(str) {
return str.replace(/\./g,"__");
}
function CollectData(apiname,data,parent) {
var datastring = '';
for (property in data) {
if (typeof data[property] == 'object') {
datastring += CollectData(apiname,data[property],parent+'.'+property);
} else {
element = parent+'.'+property;
expression = new RegExp(CMIIndex,'g');
elementmodel = element.replace(expression,'.n.');
if ((typeof eval(apiname+'.datamodel["'+elementmodel+'"]')) != "undefined") {
if (eval(apiname+'.datamodel["'+elementmodel+'"].mod') != 'r') {
if (eval(apiname+'.datamodel["'+elementmodel+'"].defaultvalue') != data[property]) {
datastring += '&'+underscore(element)+'='+escape(data[property]);
//alert(element+'='+data[property]);
}
}
}
}
}
return datastring;
}
function AddTime (first, second) {
var sFirst = first.split(":");
var sSecond = second.split(":");
@@ -127,16 +105,13 @@ function AddTime (first, second) {
return hours + ":" + mins + ":" + secs;
}
function StoreData(apiname,data,storetotaltime) {
datastring = CollectData(apiname,data,'cmi');
if (storetotaltime) {
datastring += eval(apiname+'.TotalTime();');
/*
function SCOFinish() {
// Workaround for Safari
if (typeof API != 'undefined') {
result = API.LMSFinish('');
} else {
result = API_1484_11.Terminate('');
}
//popupwin(datastring);
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
results = result.split('\n');
//alert(results);
errorCode = results[1];
return results[0];
}
*/
+5 -2
View File
@@ -43,10 +43,12 @@
fwrite ($bf,full_tag("MODTYPE",4,false,"scorm"));
fwrite ($bf,full_tag("NAME",4,false,$scorm->name));
fwrite ($bf,full_tag("REFERENCE",4,false,$scorm->reference));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->reference));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->reference));
fwrite ($bf,full_tag("VERSION",4,false,$scorm->version));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->maxgrade));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->grademethod));
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("BROWSEMODE",4,false,$scorm->browsemode));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
@@ -92,6 +94,7 @@
fwrite ($bf,full_tag("PARENT",6,false,$sco->parent));
fwrite ($bf,full_tag("IDENTIFIER",6,false,$sco->identifier));
fwrite ($bf,full_tag("LAUNCH",6,false,$sco->launch));
fwrite ($bf,full_tag("PARAMETERS",6,false,$sco->parameters));
fwrite ($bf,full_tag("SCORMTYPE",6,false,$sco->scormtype));
fwrite ($bf,full_tag("TITLE",6,false,$sco->title));
fwrite ($bf,full_tag("PREREQUISITES",6,false,$sco->prerequisites));
+15 -1
View File
@@ -1,8 +1,13 @@
<?php
if (empty($CFG->scorm_frameheight)) {
$CFG->scorm_frameheight = 640;
}
?>
<form method="post" action="module.php" name="form">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table cellpadding="9" cellspacing="0" >
<tr valign="top">
<!--<tr valign="top">
<td align="right">scorm_validate:</td>
<td>
<?php
@@ -20,6 +25,15 @@
<td>
<?php print_string("validationtype", "scorm") ?>
</td>
</tr> -->
<tr valign="top">
<td align="right">scorm_frameheight:</td>
<td>
<input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
</td>
<td>
<?php print_string("frameheight", "scorm") ?>
</td>
</tr>
<tr>
<td colspan="3" align="center">
+62 -9
View File
@@ -149,7 +149,7 @@ function SCORMapi1_2() {
if (param == "") {
if (Initialized) {
Initialized = false;
return StoreData('API',cmi,true);
return StoreData(cmi,true);
} else {
errorCode = "301";
}
@@ -203,8 +203,6 @@ function SCORMapi1_2() {
elementIndex = elementIndexes[i];
//alert(elementIndex+' '+elementIndexes[i+1]);
if (elementIndexes[i+1].match(/^\d+$/)) {
//alert('Matched: '+elementIndexes[i+1]);
//alert('Check: '+subelement+'.'+elementIndex);
if ((typeof eval(subelement+'.'+elementIndex)) == "undefined") {
eval(subelement+'.'+elementIndex+' = new Object();');
eval(subelement+'.'+elementIndex+'._count = 0;');
@@ -241,7 +239,11 @@ function SCORMapi1_2() {
errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
}
} else {
eval(element+'="'+value+'";');
if (element == 'cmi.comments') {
eval(element+'+="'+value+'";');
} else {
eval(element+'="'+value+'";');
}
errorCode = "0";
//alert('LMSSetValue: '+element+'\nModel: '+elementmodel+'\nValue: '+value);
return "true";
@@ -268,7 +270,7 @@ function SCORMapi1_2() {
function LMSCommit (param) {
if (param == "") {
if (Initialized) {
return StoreData('API',cmi,false);
return StoreData(cmi,false);
} else {
errorCode = "301";
}
@@ -311,13 +313,64 @@ function SCORMapi1_2() {
function TotalTime() {
total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
//////////////alert (cmi.core.total_time+' '+cmi.core.session_time+' '+total_time);
return '&'+underscore('cmi.core.total_time')+'='+escape(total_time);
}
this.datamodel = datamodel;
this.TotalTime = TotalTime;
function CollectData(data,parent) {
var datastring = '';
for (property in data) {
if (typeof data[property] == 'object') {
datastring += CollectData(data[property],parent+'.'+property);
} else {
element = parent+'.'+property;
expression = new RegExp(CMIIndex,'g');
elementmodel = element.replace(expression,'.n.');
if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property]) {
datastring += '&'+underscore(element)+'='+escape(data[property]);
//alert(element+'='+data[property]);
}
}
}
}
}
return datastring;
}
function StoreData(data,storetotaltime) {
if (storetotaltime) {
if (cmi.core.lesson_mode == 'normal') {
if (cmi.core.credit == 'credit') {
cmi.core.lesson_status = 'completed';
if (cmi.student_data.mastery_score != '') {
if (cmi.core.score.raw >= cmi.student_data.mastery_score) {
cmi.core.lesson_status = 'passed';
} else {
cmi.core.lesson_status = 'failed';
}
}
}
}
if (cmi.core.lesson_mode == 'browse') {
if (datamodel['cmi.core.lesson_status'].defaultvalue == '') {
cmi.core.lesson_status = 'browsed';
}
}
datastring = CollectData(data,'cmi');
datastring += TotalTime();
} else {
datastring = CollectData(data,'cmi');
}
//popupwin(datastring);
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
results = result.split('\n');
//alert(results);
errorCode = results[1];
return results[0];
}
this.LMSInitialize = LMSInitialize;
this.LMSFinish = LMSFinish;
this.LMSGetValue = LMSGetValue;
+10 -3
View File
@@ -1,4 +1,8 @@
// Standard Data Type Definition
//
// SCORM 1.3 API Implementation
//
function SCORMapi1_3() {
// Standard Data Type Definition
CMIString255 = '^.{0,255}$';
CMIString4096 = '^[.|\\n|\\r]{0,4096}$';
CMITime = '^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$';
@@ -27,7 +31,7 @@
audio_range = '-1#100';
speed_range = '-100#100';
text_range = '-1#1';
// The SCORM 1.2 data model
// The SCORM 1.3 data model
var datamodel = {
'cmi._children':{'defaultvalue':cmi_children, 'mod':'r', 'writeerror':'402'},
'cmi._version':{'defaultvalue':'3.4', 'mod':'r', 'writeerror':'402'},
@@ -302,4 +306,7 @@
this.Commit = Commit;
this.GetLastError = GetLastError;
this.GetErrorString = GetErrorString;
this.GetDiagnostic = GetDiagnostic;
this.GetDiagnostic = GetDiagnostic;
}
var API_1484_11 = new SCORMapi1_3();
+4
View File
@@ -149,6 +149,10 @@ function scorm_upgrade($oldversion) {
}
}
if ($oldversion < 2005042800) {
table_column("scorm", "", "browsemode", "TINYINT", "2", "", "1", "NOT NULL", "summary");
}
return true;
}
?>
+4 -3
View File
@@ -133,7 +133,7 @@ function scorm_upgrade($oldversion) {
}
if ($oldversion < 2005042700) {
$trackingdata = get_records_select("scorm_scoes_track","","id ASC");
$trackingdata = get_records_select("scorm_scoes_track","1","id ASC");
if (!empty($trackingdata)) {
$oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
$newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data');
@@ -146,10 +146,11 @@ function scorm_upgrade($oldversion) {
}
}
if ($oldversion < 2005042800) {
table_column("scorm", "", "browsemode", "integer", "", "", "1", "NOT NULL", "summary");
}
return true;
}
?>
+7 -5
View File
@@ -14,8 +14,6 @@ $SCORM_GRADE_METHOD = array (VALUESCOES => get_string('gradescoes', 'scorm'),
if (!isset($CFG->scorm_validate)) {
$scormvalidate = 'none';
//I've commented this out for Moodle 1.4, as I've seen errors in
//SCORM packages even though the actual package worked fine. -- Martin Dougiamas
if (extension_loaded('domxml') && version_compare(phpversion(),'5.0.0','<')) {
$scormvalidate = 'domxml';
}
@@ -25,6 +23,10 @@ if (!isset($CFG->scorm_validate)) {
set_config('scorm_validate', $scormvalidate);
}
if (!isset($CFG->scorm_frameheight)) {
set_config('scorm_frameheight','640');
}
function scorm_add_instance($scorm) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
@@ -903,7 +905,7 @@ function scorm_display_structure($scorm,$liststyle,$currentorg='',$scoid='',$mod
}
$strstatus = get_string($usertrack->status,'scorm');
echo "<img src='pix/".$usertrack->status.".gif' alt='$strstatus' title='$strstatus' />";
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete')) {
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
$incomplete = true;
if ($play && empty($scoid)) {
$scoid = $sco->id;
@@ -917,10 +919,10 @@ function scorm_display_structure($scorm,$liststyle,$currentorg='',$scoid='',$mod
$scoid = $sco->id;
}
if ($sco->scormtype == 'sco') {
echo '<img src="pix/notattempted.gif" alt="'.get_string('notattempted','scorm').'" />';
echo '<img src="pix/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
$incomplete = true;
} else {
echo '<img src="pix/asset.gif" alt="'.get_string('asset','scorm').'" />';
echo '<img src="pix/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
+2 -3
View File
@@ -99,10 +99,9 @@
<html>
<head>
<title>LoadSCO</title>
<meta http-equiv="refresh" content="1;URL=<?php echo $result ?>" />
</head>
<body>
<script language="javascript">
document.location='<?php echo $result ?>';
</script>
&nbsp;
</body>
</html>
+18 -3
View File
@@ -24,6 +24,9 @@
if (empty($form->grademethod)) {
$form->grademethod = "0";
}
if (empty($form->browsemode)) {
$form->browsemode = "1";
}
$scormid = '';
if (!empty($form->instance)) {
$scormid = '&instance='.$form->instance;
@@ -161,17 +164,29 @@
$options = array();
$options[0]=get_string("no");
$options[1]=get_string("yes");
choose_from_menu ($options, "auto", $form->auto);
choose_from_menu ($options, "auto", $form->auto,'');
helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string("enablebrowse","scorm") ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string("no");
$options[1]=get_string("yes");
choose_from_menu ($options, "browsemode", $form->browsemode, '');
helpbutton("browsemode", get_string("browsemode", "scorm"), "scorm", true);
?>
</td>
</tr>
</table>
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
<input type="hidden" name="maxgrade" value="<?php p($form->maxgrade) ?>" />
<input type="hidden" name="grademethod" value="<?php p($form->grademethod) ?>" />
<!-- <input type="hidden" name="maxgrade" value="<?php p($form->maxgrade) ?>" />
<input type="hidden" name="grademethod" value="<?php p($form->grademethod) ?>" />-->
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
+14 -4
View File
@@ -80,10 +80,12 @@
//
// Print the page header
//
//$bodyscripts = "onUnload='SCOFinish();'";
//$bodyscripts = "onunload='SCOFinish();'";
$bodyscripts = '';
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm));
'', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts);
?>
<style type="text/css">
.scormlist {
@@ -140,8 +142,16 @@
<tr><td nowrap>
<?php
$sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
if ($mode == 'normal') {
if ($trackdata = scorm_get_tracks($USER->id,$sco->id)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
}
}
}
add_to_log($course->id, 'scorm', 'view', "playscorm.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
$scoidstring = '&scoid='.$sco->id;
$modestring = '&mode='.$mode;
$SESSION->scorm_scoid = $sco->id;
?>
@@ -159,10 +169,10 @@
</table>
</td>
<td class="fullscreen" height="90%">
<iframe name="main" class="fullscreen" height="640" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring ?>"></iframe>
<iframe name="main" class="fullscreen" height="<?php echo $CFG->scorm_frameheight ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring ?>"></iframe>
</td></tr>
</table>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstring ?>"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></script>
</body>
</html>
+1 -1
View File
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2005042700; // The (date) version of this module
$module->version = 2005042800; // The (date) version of this module
$module->requires = 2005021600; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?
+15 -7
View File
@@ -114,13 +114,21 @@
print_simple_box_end();
echo "<form name=\"theform\" method=\"post\" action=\"playscorm.php?id=$cm->id\">\n";
echo "<table align=\"center\">\n<tr>\n<td align=\"center\">";
print_string("mode","scorm");
echo ": <input type=\"radio\" id=\"b\" name=\"mode\" value=\"browse\" /><label for=\"b\">".get_string("browse","scorm")."</label>\n";
if ($incomplete === true) {
echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked=\"checked\" /><label for=\"n\">".get_string("normal","scorm")."</label>\n";
} else {
echo "<input type=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked=\"checked\" /><label for=\"r\">".get_string("review","scorm")."</label>\n";
}
if ($scorm->browsemode == 1) {
print_string("mode","scorm");
echo ": <input type=\"radio\" id=\"b\" name=\"mode\" value=\"browse\" /><label for=\"b\">".get_string("browse","scorm")."</label>\n";
if ($incomplete === true) {
echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked=\"checked\" /><label for=\"n\">".get_string("normal","scorm")."</label>\n";
} else {
echo "<input type=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked=\"checked\" /><label for=\"r\">".get_string("review","scorm")."</label>\n";
}
} else {
if ($incomplete === true) {
echo '<input type="hidden" name="mode" value="normal" />'."\n";
} else {
echo '<input type="hidden" name="mode" value="review" />'."\n";
}
}
echo "</td>\n</tr>\n<tr><td align=\"center\">";
echo '<input type="hidden" name="scoid" />
<input type="hidden" name="currentorg" value="'.$orgidentifier.'" />