2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 echo html_writer
::start_tag('script');
20 <!--// hopefully fool ie IE proof way of getting DOM element
21 function safeGetElement(doc
, el
) {
22 return doc
.ids ? doc
.ids
[el
] : doc
.getElementById ? doc
.getElementById(el
) : doc
.all
[el
];
24 // Find elements by class name
25 var aryClassElements
= new Array();
26 function getNextElementByClassName( strClassName
, obj
) {
27 if ( obj
.className
== strClassName
) {
28 aryClassElements
[aryClassElements
.length
] = obj
;
30 for ( var i
= 0; i
< obj
.childNodes
.length
; i++
)
31 getNextElementByClassName( strClassName
, obj
.childNodes
[i
] );
34 function getElementsByClassName( strClassName
, obj
) {
35 aryClassElements
= new Array();
36 getNextElementByClassName( strClassName
, obj
);
37 if (aryClassElements
.length
> 0) {
38 return aryClassElements
[0];
45 // retrieve cookie data
46 function getCookie (cookie_name
){
47 var results
= document
.cookie
.match ( '(^|;) ?' + cookie_name +
'=([^;]*)(;|$)' );
49 return (unescape(results
[2]));
55 // retrieve the logging flag from a Cookie
56 function getLoggingActive () {
57 var loggingActive
= getCookie('SCORMLoggingActive');
64 // set the logging flag in a cookie
65 function setLoggingActive (flag
) {
66 new cookie("SCORMLoggingActive", flag
, 365, "/").set();
70 function toggleLog () {
71 if (getLoggingActive() == "A") {
72 AppendToLog("Moodle Logging Deactivated", 0);
73 setLoggingActive('N');
74 logButton
.innerHTML
= '-><?php echo addslashes_js(get_string('scormloggingoff
', 'scorm
')); ?>';
76 setLoggingActive('A');
77 AppendToLog("Moodle Logging Activated", 0);
78 logButton
.innerHTML
= '<?php echo addslashes_js(get_string('scormloggingon
', 'scorm
')); ?>';
79 logPopUpWindow
.focus();
83 // globals for the log accumulation
86 var logPopUpWindow
= "N";
87 var debugSCORMVersion
= '<?php echo $scorm->version; ?>';
89 $lmsprefix = (scorm_version_check($scorm->version
, SCORM_12
) ||
empty($scorm->version
)) ?
'LMS' : '';
90 $lmsapi = (scorm_version_check($scorm->version
, SCORM_12
) ||
empty($scorm->version
)) ?
'API' : 'API_1484_11';
92 $lmselements = array();
93 if (scorm_version_check($scorm->version
, SCORM_12
) ||
empty($scorm->version
)) {
94 $lmselements = array( 'cmi.core._children',
95 'cmi.core.student_id',
96 'cmi.core.student_name',
97 'cmi.core.lesson_location',
99 'cmi.core.lesson_status',
101 'cmi.core._children',
102 'cmi.core.score.raw',
103 'cmi.core.score.max',
104 'cmi.core.score.min',
105 'cmi.core.total_time',
106 'cmi.core.lesson_mode',
108 'cmi.core.session_time',
112 'cmi.comments_from_lms',
113 'cmi.objectives._count',
114 'cmi.objectives._children',
115 'cmi.objectives.n.id',
116 'cmi.objectives.n.score._children',
117 'cmi.objectives.n.score.raw',
118 'cmi.objectives.n.score.min',
119 'cmi.objectives.n.score.max',
120 'cmi.objectives.n.status',
121 'cmi.student_data._children',
122 'cmi.student_data.mastery_score',
123 'cmi.student_data.max_time_allowed',
124 'cmi.student_data.time_limit_action',
125 'cmi.student_preference._children',
126 'cmi.student_preference.audio',
127 'cmi.student_preference.language',
128 'cmi.student_preference.speed',
129 'cmi.student_preference.text',
130 'cmi.interactions._children',
131 'cmi.interactions._count',
132 'cmi.interactions.n.id',
133 'cmi.interactions.n.objectives._count',
134 'cmi.interactions.n.objectives.m.id',
135 'cmi.interactions.n.time',
136 'cmi.interactions.n.type',
137 'cmi.interactions.n.correct_responses._count',
138 'cmi.interactions.n.correct_responses.m.pattern',
139 'cmi.interactions.n.weighting',
140 'cmi.interactions.n.student_response',
141 'cmi.interactions.n.result',
142 'cmi.interactions.n.latency');
144 $lmselements = array( 'cmi._children',
149 'cmi.completion_status',
150 'cmi.completion_threshold',
151 'cmi.scaled_passing_score',
152 'cmi.progressive_measure',
153 'cmi.score._children',
159 'cmi.time_limit_action',
160 'cmi.max_time_allowed',
162 'cmi.success_status',
171 'cmi.comments_from_lms._children',
172 'cmi.comments_from_lms._count',
173 'cmi.comments_from_lms.n.comment',
174 'cmi.comments_from_lms.n.location',
175 'cmi.comments_from_lms.n.timestamp',
176 'cmi.comments_from_learner._children',
177 'cmi.comments_from_learner._count',
178 'cmi.comments_from_learner.n.comment',
179 'cmi.comments_from_learner.n.location',
180 'cmi.comments_from_learner.n.timestamp',
181 'cmi.objectives._count',
182 'cmi.objectives._children',
183 'cmi.objectives.n.id',
184 'cmi.objectives.n.score._children',
185 'cmi.objectives.n.score.raw',
186 'cmi.objectives.n.score.min',
187 'cmi.objectives.n.score.max',
188 'cmi.objectives.n.score.scaled',
189 'cmi.objectives.n.success_status',
190 'cmi.objectives.n.completion_status',
191 'cmi.objectives.n.progress_measure',
192 'cmi.objectives.n.description',
193 'cmi.student_data._children',
194 'cmi.student_data.mastery_score',
195 'cmi.student_data.max_time_allowed',
196 'cmi.student_data.time_limit_action',
197 'cmi.student_preference._children',
198 'cmi.student_preference.audio',
199 'cmi.student_preference.language',
200 'cmi.student_preference.speed',
201 'cmi.student_preference.text',
202 'cmi.interactions._children',
203 'cmi.interactions._count',
204 'cmi.interactions.n.id',
205 'cmi.interactions.n.objectives._count',
206 'cmi.interactions.n.objectives.m.id',
207 'cmi.interactions.n.time',
208 'cmi.interactions.n.type',
209 'cmi.interactions.n.correct_responses._count',
210 'cmi.interactions.n.correct_responses.m.pattern',
211 'cmi.interactions.n.weighting',
212 'cmi.interactions.n.learner_response',
213 'cmi.interactions.n.result',
214 'cmi.interactions.n.latency',
215 'cmi.interactions.n.description',
220 // add each entry to the log, or setup the log pane first time round
221 // The code written into the header is based on the ADL test suite API interaction code
222 // and various examples of test wrappers out in the community
223 function UpdateLog(s
) {
224 var s1
= '<html><head><style>\n'
225 +
'body {font-family: Arial, Helvetica, Sans-Serif;font-size: xx-small;'
226 +
'margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; '
227 +
'background-color: ffffff;}\n'
228 +
'.even {background-color: ffffff; width: 100%;}\n'
229 +
'.odd {background-color: e8f2fe; width: 100%;}\n'
230 +
'.error {background-color: ffffff; color: red; width: 100%;}\n'
233 +
'var LMSVersion = \'<?php echo $scorm->version; ?>\';\n'
235 +
'function checkLMSVersion() { \n'
236 +
' if (this.document.body.childNodes.length > 0) { \n'
237 +
' if (this.document.body.lastChild.id == LMSVersion) { \n'
241 +
' alert(\'LMS Version: \' + this.document.body.lastChild.id + \n'
242 +
' \' does not equal: \' + LMSVersion + \n'
243 +
' \' so API calls will fail - did navigate to another SCORM package?\'); \n'
244 +
' return false; \n'
247 +
'var saveElement = ""; \n'
248 +
'function setAPIValue() { \n'
249 +
' document.elemForm.API_ELEMENT.value = document.elemForm.ELEMENT_LIST.value; \n'
250 +
' saveElement = document.elemForm.API_ELEMENT.value; \n'
253 +
'var _Debug = false; // set this to false to turn debugging off \n'
255 +
'// Define exception/error codes \n'
256 +
'var _NoError = 0; \n'
257 +
'var _GeneralException = 101; \n'
258 +
'var _ServerBusy = 102; \n'
259 +
'var _InvalidArgumentError = 201; \n'
260 +
'var _ElementCannotHaveChildren = 202; \n'
261 +
'var _ElementIsNotAnArray = 203; \n'
262 +
'var _NotInitialized = 301; \n'
263 +
'var _NotImplementedError = 401; \n'
264 +
'var _InvalidSetValue = 402; \n'
265 +
'var _ElementIsReadOnly = 403; \n'
266 +
'var _ElementIsWriteOnly = 404; \n'
267 +
'var _IncorrectDataType = 405; \n'
269 +
'// local variable definitions \n'
270 +
'var apiHandle = null; \n'
271 +
'var API = null; \n'
272 +
'var findAPITries = 0; \n'
275 +
'function doLMSInitialize() { \n'
276 +
' checkLMSVersion(); \n'
277 +
' var api = getAPIHandle(); \n'
278 +
' if (api == null) { \n'
279 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSInitialize was not successful."); \n'
280 +
' return "false"; \n'
282 +
' var result = api.<?php echo $lmsprefix; ?>Initialize(""); \n'
283 +
' if (result.toString() != "true") { \n'
284 +
' var err = ErrorHandler(); \n'
286 +
' return result.toString(); \n'
289 +
'function doLMSFinish() { \n'
290 +
' checkLMSVersion(); \n'
291 +
' var api = getAPIHandle(); \n'
292 +
' if (api == null) { \n'
293 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSFinish was not successful."); \n'
294 +
' return "false"; \n'
296 +
' // call the LMSFinish function that should be implemented by the API \n'
297 +
' var result = api.<?php echo $lmsprefix; ?>Finish(""); \n'
298 +
' if (result.toString() != "true") { \n'
299 +
' var err = ErrorHandler(); \n'
302 +
' return result.toString(); \n'
305 +
'function doLMSTerminate() { \n'
306 +
' checkLMSVersion(); \n'
307 +
' var api = getAPIHandle(); \n'
308 +
' if (api == null) { \n'
309 +
' alert("Unable to locate the LMS\'s API Implementation.\\nTerminate was not successful."); \n'
310 +
' return "false"; \n'
312 +
' // call the Terminate function that should be implemented by the API \n'
313 +
' var result = api.Terminate(""); \n'
314 +
' if (result.toString() != "true") { \n'
315 +
' var err = ErrorHandler(); \n'
318 +
' return result.toString(); \n'
321 +
'function doLMSGetValue(name) { \n'
322 +
' checkLMSVersion(); \n'
323 +
' var api = getAPIHandle(); \n'
324 +
' if (api == null) { \n'
325 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetValue was not successful."); \n'
328 +
' var value = api.<?php echo $lmsprefix; ?>GetValue(name); \n'
329 +
' var errCode = api.<?php echo $lmsprefix; ?>GetLastError().toString(); \n'
330 +
' if (errCode != _NoError) { \n'
331 +
' // an error was encountered so display the error description \n'
332 +
' var errDescription = api.<?php echo $lmsprefix; ?>GetErrorString(errCode); \n'
333 +
' alert("<?php echo $lmsprefix; ?>GetValue("+name+") failed. \\n"+ errDescription); \n'
336 +
' return value.toString(); \n'
341 +
'function doLMSSetValue(name, value) { \n'
342 +
' checkLMSVersion(); \n'
343 +
' var api = getAPIHandle(); \n'
344 +
' if (api == null) { \n'
345 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSSetValue was not successful."); \n'
348 +
' var result = api.<?php echo $lmsprefix; ?>SetValue(name, value); \n'
349 +
' if (result.toString() != "true") { \n'
350 +
' var err = ErrorHandler(); \n'
356 +
'function doLMSCommit() { \n'
357 +
' checkLMSVersion(); \n'
358 +
' var api = getAPIHandle(); \n'
359 +
' if (api == null) { \n'
360 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSCommit was not successful."); \n'
361 +
' return "false"; \n'
363 +
' var result = api.<?php echo $lmsprefix; ?>Commit(""); \n'
364 +
' if (result != "true") { \n'
365 +
' var err = ErrorHandler(); \n'
368 +
' return result.toString(); \n'
371 +
'function doLMSGetLastError() { \n'
372 +
' var api = getAPIHandle(); \n'
373 +
' if (api == null) { \n'
374 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetLastError was not successful."); \n'
375 +
' //since we can\'t get the error code from the LMS, return a general error \n'
376 +
' return _GeneralError; \n'
378 +
' return api.<?php echo $lmsprefix; ?>GetLastError().toString(); \n'
381 +
'function doLMSGetErrorString(errorCode) { \n'
382 +
' var api = getAPIHandle(); \n'
383 +
' if (api == null) { \n'
384 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetErrorString was not successful."); \n'
386 +
' return api.<?php echo $lmsprefix; ?>GetErrorString(errorCode).toString(); \n'
389 +
'function doLMSGetDiagnostic(errorCode) { \n'
390 +
' var api = getAPIHandle(); \n'
391 +
' if (api == null) { \n'
392 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetDiagnostic was not successful."); \n'
394 +
' return api.<?php echo $lmsprefix; ?>GetDiagnostic(errorCode).toString(); \n'
397 +
'function LMSIsInitialized() { \n'
398 +
' // there is no direct method for determining if the LMS API is initialized \n'
399 +
' // for example an LMSIsInitialized function defined on the API so we\'ll try \n'
400 +
' // a simple LMSGetValue and trap for the LMS Not Initialized Error \n'
401 +
' var api = getAPIHandle(); \n'
402 +
' if (api == null) { \n'
403 +
' alert("Unable to locate the LMS\'s API Implementation.\\nLMSIsInitialized() failed."); \n'
404 +
' return false; \n'
406 +
' var value = api.<?php echo $lmsprefix; ?>GetValue("cmi.core.student_name"); \n'
407 +
' var errCode = api.<?php echo $lmsprefix; ?>GetLastError().toString(); \n'
408 +
' if (errCode == _NotInitialized) { \n'
409 +
' return false; \n'
416 +
'function ErrorHandler() { \n'
417 +
' var api = getAPIHandle(); \n'
418 +
' if (api == null) { \n'
419 +
' alert("Unable to locate the LMS\'s API Implementation.\\nCannot determine LMS error code."); \n'
422 +
' // check for errors caused by or from the LMS \n'
423 +
' var errCode = api.<?php echo $lmsprefix; ?>GetLastError().toString(); \n'
424 +
' if (errCode != _NoError) { \n'
425 +
' // an error was encountered so display the error description \n'
426 +
' var errDescription = api.<?php echo $lmsprefix; ?>GetErrorString(errCode); \n'
427 +
' if (_Debug == true) { \n'
428 +
' errDescription += "\\n"; \n'
429 +
' errDescription += api.<?php echo $lmsprefix; ?>GetDiagnostic(null); \n'
430 +
' // by passing null to LMSGetDiagnostic, we get any available diagnostics \n'
431 +
' // on the previous error. \n'
433 +
' alert(errDescription); \n'
435 +
' return errCode; \n'
438 +
'function getAPIHandle() { \n'
439 +
' if (apiHandle == null) { \n'
440 +
' apiHandle = getAPI(); \n'
442 +
' return apiHandle; \n'
445 +
'function findAPI(win) { \n'
446 +
' while ((win.<?php echo $lmsapi; ?> == null) && (win.parent != null) && (win.parent != win)) { \n'
447 +
' findAPITries++; \n'
448 +
' // Note: 7 is an arbitrary number, but should be more than sufficient \n'
449 +
' if (findAPITries > 7) { \n'
450 +
' alert("Error finding API -- too deeply nested."); \n'
453 +
' win = win.parent; \n'
455 +
' return win.<?php echo $lmsapi; ?>; \n'
458 +
'function getAPI() { \n'
459 +
' var theAPI = findAPI(window); \n'
460 +
' if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) { \n'
461 +
' theAPI = findAPI(window.opener); \n'
463 +
' if (theAPI == null) { \n'
464 +
' alert("Unable to find an API adapter"); \n'
466 +
' return theAPI \n'
469 +
' function tryLMSInitialize() { \n'
470 +
' var result = doLMSInitialize(); \n'
472 +
' if(result == "true") { \n'
473 +
' msg = "<?php echo $lmsprefix; ?>Initialize Successful!"; \n'
475 +
' var err = doLMSGetLastError(); \n'
476 +
' var errString = doLMSGetErrorString(err); \n'
477 +
' msg = "<?php echo $lmsprefix; ?>Initialize Failed! Error Code: "+err; \n'
478 +
' msg += " Error Description: " + errString; \n'
480 +
' document.initForm.msgtxt.value= msg; \n'
483 +
' function tryLMSCommit() { \n'
484 +
' var result = doLMSCommit(); \n'
486 +
' if(result == "true") { \n'
487 +
' msg = "<?php echo $lmsprefix; ?>Commit was Successful!"; \n'
489 +
' var err = doLMSGetLastError(); \n'
490 +
' var errString = doLMSGetErrorString(err); \n'
491 +
' var msg = "<?php echo $lmsprefix; ?>Commit Failed! Error Code: "+err; \n'
492 +
' msg += " Error Description: " + errString; \n'
494 +
' document.otherForm.msgtxt.value = msg; \n'
495 +
' document.elemForm.API_ELEMENT.value = saveElement; \n'
498 +
' function tryLMSFinish() { \n'
499 +
' // set now, in case the SCO is unloaded on LMSFinish \n'
500 +
' doLMSSetValue("cmi.core.lesson_status", "completed"); \n'
501 +
' doLMSSetValue("cmi.core.exit", ""); \n'
502 +
' doLMSSetValue("cmi.core.session_time", "00:00:30"); \n'
503 +
' var result = doLMSFinish(); \n'
505 +
' if(result == "true") { \n'
506 +
' msg = "LMSFinish Successful!"; \n'
507 +
' document.otherForm.msgtxt.value = msg; \n'
509 +
' var err = doLMSGetLastError(); \n'
510 +
' var errString = doLMSGetErrorString(err); \n'
511 +
' var msg = "LMSFinish Failed! Error Code: "+err; \n'
512 +
' msg += " Error Description: " + errString; \n'
513 +
' document.otherForm.msgtxt.value = msg; \n'
517 +
' function tryLMSTerminate() { \n'
518 +
' var result = doLMSTerminate(); \n'
520 +
' if(result == "true") { \n'
521 +
' msg = "Terminate Successful!"; \n'
522 +
' document.otherForm.msgtxt.value = msg; \n'
524 +
' var err = doLMSGetLastError(); \n'
525 +
' var errString = doLMSGetErrorString(err); \n'
526 +
' var msg = "Terminate Failed! Error Code: "+err; \n'
527 +
' msg += " Error Description: " + errString; \n'
528 +
' document.otherForm.msgtxt.value = msg; \n'
532 +
' function tryLMSGetValue() { \n'
533 +
' var value = document.elemForm.API_ELEMENT.value; \n'
535 +
' var result = doLMSGetValue(value); \n'
536 +
' var err = doLMSGetLastError(); \n'
537 +
' var errString = doLMSGetErrorString(err); \n'
538 +
' msg = "<?php echo $lmsprefix; ?>GetValue Returned: " + result; \n'
539 +
' msg += "\\nError Code: " + err; \n'
540 +
' msg += "\\nError Description: " + errString; \n'
541 +
' document.elemForm.msgtxt.value = msg; \n'
542 +
' document.elemForm.API_ELEMENT.value = saveElement; \n'
545 +
' function tryLMSSetValue() { \n'
546 +
' // Get the element that is to be set \n'
547 +
' var setValue = document.elemForm.SET_VAL.value; \n'
548 +
' var item = document.elemForm.API_ELEMENT.value; \n'
550 +
' var api = getAPIHandle(); \n'
551 +
' if (api == null) { \n'
552 +
' alert("Unable to locate the LMS\'s API Implementation.\\n"+ \n'
553 +
' "<?php echo $lmsprefix; ?>SetValue was not successful."); \n'
554 +
' return false; \n'
556 +
' // Try to set the element \n'
557 +
' var result = api.<?php echo $lmsprefix; ?>SetValue( item, setValue ); \n'
558 +
' var err = doLMSGetLastError(); \n'
559 +
' var errString = doLMSGetErrorString(err); \n'
560 +
' msg = "<?php echo $lmsprefix; ?>SetValue returned: " + result; \n'
561 +
' msg += "\\nError Code: " + err; \n'
562 +
' msg += "\\nError Description: " + errString; \n'
563 +
' document.elemForm.msgtxt.value = msg; \n'
564 +
' document.elemForm.API_ELEMENT.value = saveElement; \n'
567 +
' function tryLMSGetLastError() { \n'
568 +
' var err = doLMSGetLastError(); \n'
569 +
' document.otherForm.msgtxt.value = "<?php echo $lmsprefix; ?>GetLastError returned Error Code: " + err; \n'
572 +
' function tryLMSGetErrorString() { \n'
573 +
' var err = doLMSGetLastError(); \n'
574 +
' var errString = doLMSGetErrorString(err); \n'
575 +
' document.otherForm.msgtxt.value = "<?php echo $lmsprefix; ?>GetErrorString returned: " + errString; \n'
578 +
' function tryLMSGetDiagnostic() { \n'
579 +
' var err = doLMSGetLastError(); \n'
580 +
' var diagnostic = doLMSGetDiagnostic(err); \n'
581 +
' document.otherForm.msgtxt.value = "<?php echo $lmsprefix; ?>GetDiagnostic returned: " + diagnostic; \n'
585 +
'<\/head><body STYLE="background-color: ffffff; color: black"'
586 +
'marginwidth="0" leftmargin="0" hspace="0">'
587 +
'<h1>SCORM Debugging interface</h1>'
588 +
'<h2>SCORM Version Detected: <?php echo $scorm->version; ?></h2>'
589 +
'<input type="hidden" id="mod-scorm-logstate" name="mod-scorm-logstate" value="A" \/>'
590 +
'<form name="initForm" onsubmit="return false;">'
591 +
' <table width="100%" border="0">'
594 +
' <input type = "button" value = "Call <?php echo $lmsprefix; ?>Initialize()"'
595 +
' onclick = "tryLMSInitialize();" id="Initialize" name="Initialize" />'
598 +
' <label>Result: </label><input type="text" name="msgtxt" id="msgtxt" size="80" readonly value="NotCalled" />'
604 +
'<form name="elemForm" id="elemForm" onsubmit="return false;">'
605 +
' <table width="100%" border="0">'
607 +
' <td><b>Select Data Model Element to Get or Set</b> '
608 +
' <select name = "ELEMENT_LIST" id="ELEMENT_LIST" onchange="setAPIValue()">'
609 +
' <option value="NONE">--None Selected--</option>'
610 +
' <option value="">******************************************</option>'
613 foreach ($lmselements as $element) {
614 echo ' + \' <option value="'.$element.'">'.$element.'</option>\\n\'';
619 +
' <input type="text" name="API_ELEMENT" id="API_ELEMENT" size="40"><br />'
621 +
' <label><b>Select API Function to Call</b></label> '
622 +
' <input type = "button" value = "<?php echo $lmsprefix; ?>GetValue()"'
623 +
' onclick = "tryLMSGetValue();" id="lmsGetButton"'
624 +
' name="lmsGetButton"> -- OR -- '
625 +
' <input type="button" value="<?php echo $lmsprefix; ?>SetValue()"'
626 +
' onclick="tryLMSSetValue();" id="lmsSetButton"'
627 +
' name="lmsSetButton">'
628 +
' <label><b> value to Set: </b></label> <input type="text" name="SET_VAL" id="SET_VAL" size="25">'
630 +
' <label>Result: </label><br />'
631 +
' <textarea name="msgtxt" id="msgtxt" rows="2" cols="150" wrap="VIRTUAL" readonly>None</textarea>'
637 +
'<form name="otherForm" onsubmit="return false;">'
638 +
' <h3>Additional API Functions</h3>'
639 +
' <table width="100%" border="0">'
641 +
' <td><input type="button"'
642 +
' value="<?php echo $lmsprefix; ?>GetLastError() "'
643 +
' onclick="tryLMSGetLastError();"'
644 +
' id="lastErrorButton"'
645 +
' name="lastErrorButton">'
646 +
' <input type="button"'
647 +
' value="<?php echo $lmsprefix; ?>GetErrorString() "'
648 +
' onclick="tryLMSGetErrorString();"'
649 +
' id="getErrorStringButton"'
650 +
' name="getErrorStringButton">'
651 +
' <input type="button"'
652 +
' value="<?php echo $lmsprefix; ?>GetDiagnostic() "'
653 +
' onclick="tryLMSGetDiagnostic();"'
654 +
' id="getDiagnosticButton"'
655 +
' name="getDiagnosticButton">'
656 +
' <input type="button"'
657 +
' value="<?php echo $lmsprefix; ?>Commit() "'
658 +
' onclick="tryLMSCommit();"'
659 +
' id="commitButton"'
660 +
' name="commitButton">'
661 +
' <input type="button"'
662 +
' value="<?php echo scorm_version_check($scorm->version, SCORM_12) ? 'LMSFinish
' : 'Terminate
'; ?>() "'
664 +
' <?php echo scorm_version_check($scorm->version, SCORM_12) ? 'LMSFinish
' : 'LMSTerminate
'; ?>();"'
665 +
' id="finishButton"'
666 +
' name="finishButton">'
671 +
' <label>Result: </label><br />'
672 +
' <textarea name="msgtxt" id="msgtxt" rows="2" cols="150" wrap="VIRTUAL" readonly>None</textarea>'
677 +
'<h3 id="mod-scorm-marker">SCORM API Activity Log<\/h3>';
679 // Is logging active?
680 if (getLoggingActive() != "A") {
686 if (logPopUpWindow
!= 'N' && !logPopUpWindow
.closed
) {
687 popupdoc
= logPopUpWindow
.document
;
688 popupdoc
.body
.innerHTML +
= s
;
690 logPopUpWindow
= open( '', 'scormlogpopupwindow', '' );
691 popupdoc
= logPopUpWindow
.document
;
692 // Is logging active?
693 var marker
= safeGetElement(popupdoc
, 'mod-scorm-marker');
695 popupdoc
.body
.innerHTML +
= s
;
699 popupdoc
.write(logString
);
700 popupdoc
.write('<\/body><\/html>')
702 popupdoc
.title
= 'SCORM API Activity Log';
703 logPopUpWindow
.focus();
706 if (popupdoc
.body
&& popupdoc
.body
.childNodes
.length
> 0) {
707 popupdoc
.body
.lastChild
.scrollIntoView();
711 //add an individual log entry
712 function AppendToLog(s
, rc
) {
715 sStyle
= 'class="error"';
716 } else if (logRow %
2 != 0) {
717 sStyle
= 'class="even"';
719 sStyle
= 'class="odd"';
721 var now
= new Date();
722 now
.setTime( now
.getTime() );
723 s
= '<div ' + sStyle +
' id="<?php echo $scorm->version; ?>">' + now
.toGMTString() +
': ' + s +
'<\/div>';
725 // switch colours for a new section of work
726 if (s
.match(/Commit|Loaded|Initialize|Terminate|Finish|Moodle SCORM|Moodle Logging
/)) {
731 // format a log entry
732 function LogAPICall(func
, nam
, val
, rc
) {
733 // drop call to GetLastError for the time being - it produces too much chatter
734 if (func
.match(/GetLastError
/)) {
737 var s
= func +
'("' + nam +
'"';
738 if (val
!= null && ! (func
.match(/GetValue|GetLastError
/))) {
739 s +
= ', "' + val +
'"';
742 if (func
.match(/GetValue
/)) {
745 s +
= ' => ' +
String(rc
) +
" scoid = " + scorm_current_node
.scoid
;
748 if (scorm_debugging($scorm) && ($sco->scormtype
== 'asset')) {
750 hint
= 'Item <?php echo $sco->identifier; ?> has been defined as an Asset: it should never call the SCORM API';
751 AppendToLog(hint
, 101);
758 // Add in a JS controlled link for toggling the Debug logging
759 if (!document
.getElementById('mod-scorm-log-toggle')) {
760 var logButton
= document
.createElement('a');
761 logButton
.id
= 'mod-scorm-log-toggle';
762 logButton
.name
= 'logToggle';
763 logButton
.href
= 'javascript:toggleLog();';
764 if (getLoggingActive() == "A") {
765 logButton
.innerHTML
= '<?php echo addslashes_js(get_string('scormloggingon
', 'scorm
')); ?>';
767 logButton
.innerHTML
= '<?php echo addslashes_js(get_string('scormloggingoff
', 'scorm
')); ?>';
769 var content
= safeGetElement(document
, 'scormpage');
770 content
.insertBefore(logButton
, content
.firstChild
);
775 echo html_writer
::end_tag('script');