// 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"; var debugSCORMVersion = 'version; ?>'; version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version)) ? 'LMS' : ''; $LMS_api = ($scorm->version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version)) ? 'API' : 'API_1484_11'; $LMS_elements = array(); if ($scorm->version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version)) { $LMS_elements = array( 'cmi.core._children', 'cmi.core.student_id', 'cmi.core.student_name', 'cmi.core.lesson_location', 'cmi.core.credit', 'cmi.core.lesson_status', 'cmi.core.entry', 'cmi.core._children', 'cmi.core.score.raw', 'cmi.core.score.max', 'cmi.core.score.min', 'cmi.core.total_time', 'cmi.core.lesson_mode', 'cmi.core.exit', 'cmi.core.session_time', 'cmi.suspend_data', 'cmi.launch_data', 'cmi.comments', 'cmi.comments_from_lms', 'cmi.objectives._count', 'cmi.objectives._children', 'cmi.objectives.n.id', 'cmi.objectives.n.score._children', 'cmi.objectives.n.score.raw', 'cmi.objectives.n.score.min', 'cmi.objectives.n.score.max', 'cmi.objectives.n.status', 'cmi.student_data._children', 'cmi.student_data.mastery_score', 'cmi.student_data.max_time_allowed', 'cmi.student_data.time_limit_action', 'cmi.student_preference._children', 'cmi.student_preference.audio', 'cmi.student_preference.language', 'cmi.student_preference.speed', 'cmi.student_preference.text', 'cmi.interactions._children', 'cmi.interactions._count', 'cmi.interactions.n.id', 'cmi.interactions.n.objectives._count', 'cmi.interactions.n.objectives.m.id', 'cmi.interactions.n.time', 'cmi.interactions.n.type', 'cmi.interactions.n.correct_responses._count', 'cmi.interactions.n.correct_responses.m.pattern', 'cmi.interactions.n.weighting', 'cmi.interactions.n.student_response', 'cmi.interactions.n.result', 'cmi.interactions.n.latency'); } else { $LMS_elements = array( 'cmi._children', 'cmi._version', 'cmi.learner_id', 'cmi.learner_name', 'cmi.location', 'cmi.completion_status', 'cmi.completion_threshold', 'cmi.scaled_passing_score', 'cmi.progressive_measure', 'cmi.score._children', 'cmi.score.raw', 'cmi.score.max', 'cmi.score.min', 'cmi.score.scaled', 'cmi.total_time', 'cmi.time_limit_action', 'cmi.max_time_allowed', 'cmi.session_time', 'cmi.success_status', 'cmi.lesson_mode', 'cmi.entry', 'cmi.exit', 'cmi.credit', 'cmi.mode', 'cmi.suspend_data', 'cmi.launch_data', 'cmi.comments', 'cmi.comments_from_lms._children', 'cmi.comments_from_lms._count', 'cmi.comments_from_lms.n.comment', 'cmi.comments_from_lms.n.location', 'cmi.comments_from_lms.n.timestamp', 'cmi.comments_from_learner._children', 'cmi.comments_from_learner._count', 'cmi.comments_from_learner.n.comment', 'cmi.comments_from_learner.n.location', 'cmi.comments_from_learner.n.timestamp', 'cmi.objectives._count', 'cmi.objectives._children', 'cmi.objectives.n.id', 'cmi.objectives.n.score._children', 'cmi.objectives.n.score.raw', 'cmi.objectives.n.score.min', 'cmi.objectives.n.score.max', 'cmi.objectives.n.score.scaled', 'cmi.objectives.n.success_status', 'cmi.objectives.n.completion_status', 'cmi.objectives.n.progress_measure', 'cmi.objectives.n.description', 'cmi.student_data._children', 'cmi.student_data.mastery_score', 'cmi.student_data.max_time_allowed', 'cmi.student_data.time_limit_action', 'cmi.student_preference._children', 'cmi.student_preference.audio', 'cmi.student_preference.language', 'cmi.student_preference.speed', 'cmi.student_preference.text', 'cmi.interactions._children', 'cmi.interactions._count', 'cmi.interactions.n.id', 'cmi.interactions.n.objectives._count', 'cmi.interactions.n.objectives.m.id', 'cmi.interactions.n.time', 'cmi.interactions.n.type', 'cmi.interactions.n.correct_responses._count', 'cmi.interactions.n.correct_responses.m.pattern', 'cmi.interactions.n.weighting', 'cmi.interactions.n.learner_response', 'cmi.interactions.n.result', 'cmi.interactions.n.latency', 'cmi.interactions.n.description', 'adl.nav.request'); } ?> // add each entry to the log, or setup the log pane first time round // The code written into the header is based on the ADL test suite API interaction code // and various examples of test wrappers out in the community function UpdateLog(s) { var s1 = '