Permalink
Browse files

Added store datamodel and repot

  • Loading branch information...
1 parent bacb13d commit 26b3d26d2a12910b84983ebb64b52a6762102c1b bobopinna committed Apr 29, 2005
View
@@ -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];
}
+*/
View
@@ -43,10 +43,12 @@ function scorm_backup_mods($bf,$preferences) {
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 @@ function backup_scorm_scoes ($bf,$preferences,$scorm) {
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));
View
@@ -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">
@@ -149,7 +149,7 @@ function LMSFinish (param) {
if (param == "") {
if (Initialized) {
Initialized = false;
- return StoreData('API',cmi,true);
+ return StoreData(cmi,true);
} else {
errorCode = "301";
}
@@ -203,8 +203,6 @@ function LMSSetValue (element,value) {
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 LMSSetValue (element,value) {
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 LMSSetValue (element,value) {
function LMSCommit (param) {
if (param == "") {
if (Initialized) {
- return StoreData('API',cmi,false);
+ return StoreData(cmi,false);
} else {
errorCode = "301";
}
@@ -311,13 +313,64 @@ function LMSGetDiagnostic (param) {
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;
@@ -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 @@ function GetDiagnostic (param) {
this.Commit = Commit;
this.GetLastError = GetLastError;
this.GetErrorString = GetErrorString;
- this.GetDiagnostic = GetDiagnostic;
+ this.GetDiagnostic = GetDiagnostic;
+}
+
+var API_1484_11 = new SCORMapi1_3();
View
@@ -149,6 +149,10 @@ function scorm_upgrade($oldversion) {
}
}
+ if ($oldversion < 2005042800) {
+ table_column("scorm", "", "browsemode", "TINYINT", "2", "", "1", "NOT NULL", "summary");
+ }
+
return true;
}
?>
@@ -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;
}
-
-
?>
View
@@ -14,8 +14,6 @@
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 @@
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').'" />';
}
}
View
@@ -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>
View
@@ -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) ?>" />
Oops, something went wrong.

0 comments on commit 26b3d26

Please sign in to comment.