$string['options'] = 'Options';
$string['activityloading'] = "You will be automatically redirected to the activity in"; // used in conjunction with numseconds
$string['activitypleasewait'] = "Activity loading, please wait ....";
+$string['scormloggingon'] = "API Logging is On";
+$string['scormloggingoff'] = "API Logging is Off";
?>
\ No newline at end of file
'cmi.suspend_data':{'defaultvalue':'<?php echo isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
'cmi.launch_data':{'defaultvalue':'<?php echo isset($userdata->datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.comments':{'defaultvalue':'<?php echo isset($userdata->{'cmi.comments'})?$userdata->{'cmi.comments'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
+ // deprecated evaluation attributes
'cmi.evaluation.comments._count':{'defaultvalue':'0', 'mod':'r', 'writeerror':'402'},
'cmi.evaluation.comments._children':{'defaultvalue':comments_children, 'mod':'r', 'writeerror':'402'},
'cmi.evaluation.comments.n.content':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
cmi.student_data = new Object();
cmi.student_preference = new Object();
cmi.interactions = new Object();
+ // deprecated evaluation attributes
cmi.evaluation = new Object();
cmi.evaluation.comments = new Object();
--- /dev/null
+// hopefully fool ie IE proof way of getting DOM element
+function safeGetElement(doc, el) {
+ return doc.ids ? doc.ids[el] : doc.getElementById ? doc.getElementById(el) : doc.all[el];
+}
+
+// Add in a JS controlled link for toggling the Debug logging
+var logButton = document.createElement('a');
+logButton.id = 'mod-scorm-log-toggle';
+logButton.name = 'logToggle';
+logButton.href = 'javascript:toggleLog();';
+if (getLoggingActive() == "A") {
+ logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
+} else {
+ logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
+}
+var content = safeGetElement(document, 'content');
+content.appendChild(logButton);
+
+// retrieve cookie data
+function getCookie (cookie_name){
+ var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
+ if ( results ) {
+ return (unescape(results[2]));
+ } else {
+ return null;
+ }
+}
+
+// retrieve the logging flag from a Cookie
+function getLoggingActive () {
+ var loggingActive = getCookie('SCORMLoggingActive');
+ if (!loggingActive) {
+ loggingActive = 'A';
+ }
+ return loggingActive;
+}
+
+// set the logging flag in a cookie
+function setLoggingActive (flag) {
+ new cookie("SCORMLoggingActive", flag, 365, "/").set();
+}
+
+// toggle the logging
+function toggleLog () {
+ if (getLoggingActive() == "A") {
+ AppendToLog("Moodle Logging Deactivated", 0);
+ setLoggingActive('N');
+ logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
+ } else {
+ setLoggingActive('A');
+ AppendToLog("Moodle Logging Activated", 0);
+ logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
+ logPopUpWindow.focus();
+ }
+}
+
+// globals for the log accumulation
+var logString = "";
+var logRow = 0;
+var logPopUpWindow = "N";
+
+// add each entry to the log, or setup the log pane first time round
+function UpdateLog(s) {
+ var s1 = '<html><head><style>\n'
+ + 'body {font-family: Arial, Helvetica, Sans-Serif;font-size: xx-small;'
+ + 'margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; '
+ + 'background-color: ffffff;}\n'
+ + '.even {background-color: ffffff; width: 100%;}\n'
+ + '.odd {background-color: e8f2fe; width: 100%;}\n'
+ + '.error {background-color: ffffff; color: red; width: 100%;}\n'
+ + '<\/style><\/head><body STYLE="background-color: ffffff; color: black"'
+ + 'marginwidth="0" leftmargin="0" hspace="0">'
+ + '<input type="hidden" id="mod-scorm-logstate" name="mod-scorm-logstate" value="A" \/>'
+ + '<h3 id="mod-scorm-marker">SCORM API Activity Log<\/h3>';
+
+ // Is logging active?
+ if (getLoggingActive() != "A") {
+ return;
+ }
+
+ var popupdoc = '';
+ logString += s;
+ if (logPopUpWindow != 'N' && !logPopUpWindow.closed) {
+ popupdoc = logPopUpWindow.document;
+ popupdoc.body.innerHTML += s;
+ } else {
+ logPopUpWindow = open( '', 'logpopupwindow', '' );
+ popupdoc = logPopUpWindow.document;
+ // Is logging active?
+ var marker = safeGetElement(popupdoc, 'mod-scorm-marker');
+ if (marker) {
+ popupdoc.body.innerHTML += s;
+ } else {
+ popupdoc.open();
+ popupdoc.write(s1);
+ popupdoc.write(logString);
+ popupdoc.write('<\/body><\/html>')
+ popupdoc.close();
+ popupdoc.title = 'SCORM API Activity Log';
+ logPopUpWindow.focus();
+ }
+ }
+ if (popupdoc.body.childNodes.length > 0) {
+ popupdoc.body.lastChild.scrollIntoView();
+ };
+}
+
+//add an individual log entry
+function AppendToLog(s, rc) {
+ var sStyle;
+ if (rc != 0) {
+ sStyle = 'class="error';
+ } else if (logRow % 2 != 0) {
+ sStyle = 'class="even';
+ } else {
+ sStyle = 'class="odd';
+ }
+ sStyle += '"';
+ var now = new Date();
+ now.setTime( now.getTime() );
+ s = '<div ' + sStyle + '>' + now.toGMTString() + ': ' + s + '<\/div>';
+ UpdateLog(s);
+ // switch colours for a new section of work
+ if (s.match(/Commit|Loaded|Initialize|Terminate|Finish|Moodle SCORM|Moodle Logging/)) {
+ logRow++;
+ }
+}
+
+// format a log entry
+function LogAPICall(func, nam, val, rc) {
+ // drop call to GetLastError for the time being - it produces too much chatter
+ if (func.match(/GetLastError/)) {
+ return;
+ }
+ var s = func + '("' + nam + '"';
+ if (val != null && ! (func.match(/GetValue|GetLastError/))) {
+ s += ', "' + val + '"';
+ }
+ s += ')';
+ if (func.match(/GetValue/)) {
+ s += ' - ' + val;
+ }
+ s += ' => ' + String(rc);
+ AppendToLog(s, rc);
+}
cmi_children = 'core, suspend_data, launch_data, comments, objectives, student_data, student_preference, interactions';
core_children = 'student_id, student_name, lesson_location, credit, lesson_status, entry, score, total_time, lesson_mode, exit, session_time';
score_children = 'raw, min, max';
+ comments_children = 'content, location, time';
objectives_children = 'id, score, status';
student_data_children = 'mastery_score, max_time_allowed, time_limit_action';
student_preference_children = 'audio, language, speed, text';
'cmi.suspend_data':{'defaultvalue':'<?php echo isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
'cmi.launch_data':{'defaultvalue':'<?php echo isset($userdata->datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'},
'cmi.comments':{'defaultvalue':'<?php echo isset($userdata->{'cmi.comments'})?$userdata->{'cmi.comments'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
+ // deprecated evaluation attributes
+ 'cmi.evaluation.comments._count':{'defaultvalue':'0', 'mod':'r', 'writeerror':'402'},
+ 'cmi.evaluation.comments._children':{'defaultvalue':comments_children, 'mod':'r', 'writeerror':'402'},
+ 'cmi.evaluation.comments.n.content':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
+ 'cmi.evaluation.comments.n.location':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
+ 'cmi.evaluation.comments.n.time':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMITime, 'mod':'rw', 'writeerror':'405'},
'cmi.comments_from_lms':{'mod':'r', 'writeerror':'403'},
'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r', 'writeerror':'402'},
'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
cmi.student_data = new Object();
cmi.student_preference = new Object();
cmi.interactions = new Object();
+ // deprecated evaluation attributes
+ cmi.evaluation = new Object();
+ cmi.evaluation.comments = new Object();
// Navigation Object
var nav = new Object();
errorCode = "0";
if (param == "") {
if (!Initialized) {
+ Initialized = true;
+ errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Initialized SCORM 1.2");';
+ //echo 'alert("Initialized SCORM 1.2");';
+ echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
}
?>
- Initialized = true;
- errorCode = "0";
return "true";
} else {
errorCode = "101";
} else {
errorCode = "201";
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
+ }
+ ?>
return "false";
}
errorCode = "0";
if (param == "") {
if (Initialized) {
- <?php
- if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Finished SCORM 1.2");';
- }
- ?>
Initialized = false;
result = StoreData(cmi,true);
if (nav.event != '') {
setTimeout('top.document.location=top.next;',500);
}
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ //echo 'alert("Finished SCORM 1.2");';
+ echo 'LogAPICall("LMSFinish", param, "", 0);';
+ }
+ ?>
return "true";
} else {
errorCode = "301";
} else {
errorCode = "201";
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSFinish", param, "", errorCode);';
+ }
+ ?>
return "false";
}
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert(element+": "+eval(element));';
+ //echo 'alert(element+": "+eval(element));';
+ echo 'LogAPICall("LMSGetValue", element, eval(element), 0);';
}
?>
return eval(element);
} else {
errorCode = "301";
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSGetValue", element, "", errorCode);';
+ }
+ ?>
return "";
}
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert(element+":= "+value);';
+ echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
+ //echo 'alert(element+":= "+value);';
}
?>
return "true";
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert(element+":= "+value);';
+ echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
+ //echo 'alert(element+":= "+value);';
}
?>
return "true";
} else {
errorCode = "301";
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
+ }
+ ?>
return "false";
}
result = StoreData(cmi,false);
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Data Commited");';
+ echo 'LogAPICall("Commit", param, "", 0);';
+ //echo 'alert("Data Commited");';
}
?>
return "true";
} else {
errorCode = "201";
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSCommit", param, "", 0);';
+ }
+ ?>
return "false";
}
function LMSGetLastError () {
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSGetLastError", "", "", errorCode);';
+ }
+ ?>
return errorCode;
}
errorString["403"] = "Element is read only";
errorString["404"] = "Element is write only";
errorString["405"] = "Incorrect data type";
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSGetErrorString", param, errorString[param], 0);';
+ }
+ ?>
return errorString[param];
} else {
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSGetErrorString", param, "No error string found!", 0);';
+ }
+ ?>
return "";
}
}
if (param == "") {
param = errorCode;
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("LMSGetDiagnostic", param, param, 0);';
+ }
+ ?>
return param;
}
}
var API = new SCORMapi1_2();
+
+<?php
+// pull in the debugging utilities
+if (debugging('',DEBUG_DEVELOPER)) {
+ include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
+ echo 'AppendToLog("Moodle SCORM 1.2 API Loaded", 0);';
+}
+ ?>
+
errorCode = "0";
if (param == "") {
if ((!Initialized) && (!Terminated)) {
+ Initialized = true;
+ errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Initialized SCORM 1.3");';
+// echo 'alert("Initialized SCORM 1.3");';
+ echo 'LogAPICall("Initialize", param, "", errorCode);';
}
?>
- Initialized = true;
- errorCode = "0";
return "true";
} else {
if (Initialized) {
}
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Initialize: "+GetErrorString(errorCode));';
+// echo 'alert("Initialize: "+GetErrorString(errorCode));';
+ echo 'LogAPICall("Initialize", param, "", errorCode);';
}
?>
return "false";
if ((Initialized) && (!Terminated)) {
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Terminated SCORM 1.3");';
+// echo 'alert("Terminated SCORM 1.3");';
+ echo 'LogAPICall("Terminate", param, "", 0);';
}
?>
Initialized = false;
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("GetValue("+element+") -> "+eval(element));';
+// echo 'alert("GetValue("+element+") -> "+eval(element));';
+ echo 'LogAPICall("GetValue", element, eval(element), 0);';
}
?>
return eval(element);
}
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("GetValue("+element+") -> "+GetErrorString(errorCode));';
+// echo 'alert("GetValue("+element+") -> "+GetErrorString(errorCode));';
+ echo 'LogAPICall("GetValue", element, "", errorCode);';
}
?>
return "";
nodes[0] = value;
}
-
-
-
-
-
-
if ((nodes.length > 0) && (nodes.length <= correct_responses[interactiontype].max)) {
expression = new RegExp(correct_responses[interactiontype].format);
for (var i=0; (i < nodes.length) && (errorCode=="0"); i++) {
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("SetValue("+element+","+value+") -> OK");';
+// echo 'alert("SetValue("+element+","+value+") -> OK");';
+ echo 'LogAPICall("SetValue", element, value, errorCode);';
}
?>
return "true";
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("SetValue("+element+","+value+") -> OK");';
+// echo 'alert("SetValue("+element+","+value+") -> OK");';
+ echo 'LogAPICall("SetValue", element, value, errorCode);';
}
?>
return "true";
}
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("SetValue("+element+","+value+") -> "+GetErrorString(errorCode));';
+ echo 'LogAPICall("SetValue", element, value, errorCode);';
}
?>
return "false";
result = StoreData(cmi,false);
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Data Commited");';
+ echo 'LogAPICall("Commit", param, "", 0);';
+ //echo 'alert("Data Commited");';
}
?>
return "true";
}
<?php
if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("Commit: "+GetErrorString(errorCode));';
+ echo 'LogAPICall("Commit", param, "", 0);';
+// echo 'alert("Commit: "+GetErrorString(errorCode));';
}
?>
return "false";
}
function GetLastError () {
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("GetLastError", "", "", errorCode);';
+ }
+ ?>
return errorCode;
}
errorString = "Data Model Dependency Not Established";
break;
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("GetErrorString", param, errorString, 0);';
+ }
+ ?>
return errorString;
} else {
- return "";
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("GetErrorString", param, "No error string found!", 0);';
+ }
+ ?>
+ return "";
}
}
function GetDiagnostic (param) {
if (diagnostic != "") {
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("GetDiagnostic", param, diagnostic, 0);';
+ }
+ ?>
return diagnostic;
}
+ <?php
+ if (debugging('',DEBUG_DEVELOPER)) {
+ echo 'LogAPICall("GetDiagnostic", param, param, 0);';
+ }
+ ?>
return param;
}
function AddTime (first, second) {
<?php
- if (debugging('',DEBUG_DEVELOPER)) {
- echo 'alert("AddTime: "+first+" + "+second);';
- }
+// if (debugging('',DEBUG_DEVELOPER)) {
+// echo 'alert("AddTime: "+first+" + "+second);';
+// }
?>
var timestring = 'P';
var matchexpr = /^P((\d+)Y)?((\d+)M)?((\d+)D)?(T((\d+)H)?((\d+)M)?((\d+(\.\d{1,2})?)S)?)?$/;
datastring += '&attempt=<?php echo $attempt ?>';
datastring += '&scoid=<?php echo $scoid ?>';
<?php
- if (debugging('',DEBUG_DEVELOPER)) {
- echo 'popupwin(datastring);';
- }
+// if (debugging('',DEBUG_DEVELOPER)) {
+// echo 'popupwin(datastring);';
+// }
?>
var myRequest = NewHttpReq();
var result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
<?php
- if (debugging('',DEBUG_DEVELOPER)) {
- echo 'popupwin(result);';
- }
+// if (debugging('',DEBUG_DEVELOPER)) {
+// echo 'popupwin(result);';
+// }
?>
var results = String(result).split('\n');
if ((results.length > 2) && (navrequest != '')) {
}
var API_1484_11 = new SCORMapi1_3();
+
+<?php
+// pull in the debugging utilities
+if (debugging('',DEBUG_DEVELOPER)) {
+ include_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
+ echo 'AppendToLog("Moodle SCORM 1.3 API Loaded", 0);';
+}
+ ?>
\ No newline at end of file
}
+a#mod-scorm-log-toggle {
+ font-size: 0.7em;
+ font-weight: bold;
+}