From 7bbb7f497473c2e0f4dd283fb4c94ffbead7f89f Mon Sep 17 00:00:00 2001 From: piers Date: Thu, 21 Aug 2008 00:36:12 +0000 Subject: [PATCH] MDL-13431 - SCORM results not transferring to Gradebook. SCORM API debugging tool. --- lang/en_utf8/scorm.php | 2 + mod/scorm/datamodels/aicc.js.php | 2 + mod/scorm/datamodels/debug.js.php | 145 +++++++++++++++++++++++++++ mod/scorm/datamodels/scorm_12.js.php | 94 ++++++++++++++--- mod/scorm/datamodels/scorm_13.js.php | 92 +++++++++++------ mod/scorm/styles.php | 4 + 6 files changed, 299 insertions(+), 40 deletions(-) create mode 100644 mod/scorm/datamodels/debug.js.php diff --git a/lang/en_utf8/scorm.php b/lang/en_utf8/scorm.php index 10cba52913..5e6fdaf58d 100644 --- a/lang/en_utf8/scorm.php +++ b/lang/en_utf8/scorm.php @@ -161,4 +161,6 @@ $string['updatefreq'] = 'Auto-update frequency'; $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 diff --git a/mod/scorm/datamodels/aicc.js.php b/mod/scorm/datamodels/aicc.js.php index 7e122d6eb2..64a3069f32 100644 --- a/mod/scorm/datamodels/aicc.js.php +++ b/mod/scorm/datamodels/aicc.js.php @@ -74,6 +74,7 @@ function AICCapi() { 'cmi.suspend_data':{'defaultvalue':'{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, 'cmi.launch_data':{'defaultvalue':'datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'}, 'cmi.comments':{'defaultvalue':'{'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'}, @@ -130,6 +131,7 @@ function AICCapi() { 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(); diff --git a/mod/scorm/datamodels/debug.js.php b/mod/scorm/datamodels/debug.js.php new file mode 100644 index 0000000000..e8a64730ad --- /dev/null +++ b/mod/scorm/datamodels/debug.js.php @@ -0,0 +1,145 @@ +// 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 = ''; +} else { + logButton.innerHTML = ''; +} +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 = ''; + } else { + setLoggingActive('A'); + AppendToLog("Moodle Logging Activated", 0); + logButton.innerHTML = ''; + 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 = '