+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSInitialize was not successful."); \n'
+ ' return "false"; \n'
+ ' } \n'
- + ' var result = api.<?echo $LMS_prefix; ?>Initialize(""); \n'
+ + ' var result = api.<?php echo $LMS_prefix; ?>Initialize(""); \n'
+ ' if (result.toString() != "true") { \n'
+ ' var err = ErrorHandler(); \n'
+ ' } \n'
+ ' return "false"; \n'
+ ' } else { \n'
+ ' // call the LMSFinish function that should be implemented by the API \n'
- + ' var result = api.<?echo $LMS_prefix; ?>Finish(""); \n'
+ + ' var result = api.<?php echo $LMS_prefix; ?>Finish(""); \n'
+ ' if (result.toString() != "true") { \n'
+ ' var err = ErrorHandler(); \n'
+ ' } \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetValue was not successful."); \n'
+ ' return ""; \n'
+ ' } else { \n'
- + ' var value = api.<?echo $LMS_prefix; ?>GetValue(name); \n'
- + ' var errCode = api.<?echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ + ' var value = api.<?php echo $LMS_prefix; ?>GetValue(name); \n'
+ + ' var errCode = api.<?php echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ ' if (errCode != _NoError) { \n'
+ ' // an error was encountered so display the error description \n'
- + ' var errDescription = api.<?echo $LMS_prefix; ?>GetErrorString(errCode); \n'
- + ' alert("<?echo $LMS_prefix; ?>GetValue("+name+") failed. \\n"+ errDescription); \n'
+ + ' var errDescription = api.<?php echo $LMS_prefix; ?>GetErrorString(errCode); \n'
+ + ' alert("<?php echo $LMS_prefix; ?>GetValue("+name+") failed. \\n"+ errDescription); \n'
+ ' return ""; \n'
+ ' } else { \n'
+ ' return value.toString(); \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSSetValue was not successful."); \n'
+ ' return; \n'
+ ' } else { \n'
- + ' var result = api.<?echo $LMS_prefix; ?>SetValue(name, value); \n'
+ + ' var result = api.<?php echo $LMS_prefix; ?>SetValue(name, value); \n'
+ ' if (result.toString() != "true") { \n'
+ ' var err = ErrorHandler(); \n'
+ ' } \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSCommit was not successful."); \n'
+ ' return "false"; \n'
+ ' } else { \n'
- + ' var result = api.<?echo $LMS_prefix; ?>Commit(""); \n'
+ + ' var result = api.<?php echo $LMS_prefix; ?>Commit(""); \n'
+ ' if (result != "true") { \n'
+ ' var err = ErrorHandler(); \n'
+ ' } \n'
+ ' //since we can\'t get the error code from the LMS, return a general error \n'
+ ' return _GeneralError; \n'
+ ' } \n'
- + ' return api.<?echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ + ' return api.<?php echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ '} \n'
+ ' \n'
+ 'function doLMSGetErrorString(errorCode) { \n'
+ ' if (api == null) { \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetErrorString was not successful."); \n'
+ ' } \n'
- + ' return api.<?echo $LMS_prefix; ?>GetErrorString(errorCode).toString(); \n'
+ + ' return api.<?php echo $LMS_prefix; ?>GetErrorString(errorCode).toString(); \n'
+ '} \n'
+ ' \n'
+ 'function doLMSGetDiagnostic(errorCode) { \n'
+ ' if (api == null) { \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSGetDiagnostic was not successful."); \n'
+ ' } \n'
- + ' return api.<?echo $LMS_prefix; ?>GetDiagnostic(errorCode).toString(); \n'
+ + ' return api.<?php echo $LMS_prefix; ?>GetDiagnostic(errorCode).toString(); \n'
+ '} \n'
+ ' \n'
+ 'function LMSIsInitialized() { \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\nLMSIsInitialized() failed."); \n'
+ ' return false; \n'
+ ' } else { \n'
- + ' var value = api.<?echo $LMS_prefix; ?>GetValue("cmi.core.student_name"); \n'
- + ' var errCode = api.<?echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ + ' var value = api.<?php echo $LMS_prefix; ?>GetValue("cmi.core.student_name"); \n'
+ + ' var errCode = api.<?php echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ ' if (errCode == _NotInitialized) { \n'
+ ' return false; \n'
+ ' } else { \n'
+ ' return; \n'
+ ' } \n'
+ ' // check for errors caused by or from the LMS \n'
- + ' var errCode = api.<?echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ + ' var errCode = api.<?php echo $LMS_prefix; ?>GetLastError().toString(); \n'
+ ' if (errCode != _NoError) { \n'
+ ' // an error was encountered so display the error description \n'
- + ' var errDescription = api.<?echo $LMS_prefix; ?>GetErrorString(errCode); \n'
+ + ' var errDescription = api.<?php echo $LMS_prefix; ?>GetErrorString(errCode); \n'
+ ' if (_Debug == true) { \n'
+ ' errDescription += "\\n"; \n'
- + ' errDescription += api.<?echo $LMS_prefix; ?>GetDiagnostic(null); \n'
+ + ' errDescription += api.<?php echo $LMS_prefix; ?>GetDiagnostic(null); \n'
+ ' // by passing null to LMSGetDiagnostic, we get any available diagnostics \n'
+ ' // on the previous error. \n'
+ ' } \n'
+ '} \n'
+ ' \n'
+ 'function findAPI(win) { \n'
- + ' while ((win.<?echo $LMS_api; ?> == null) && (win.parent != null) && (win.parent != win)) { \n'
+ + ' while ((win.<?php echo $LMS_api; ?> == null) && (win.parent != null) && (win.parent != win)) { \n'
+ ' findAPITries++; \n'
+ ' // Note: 7 is an arbitrary number, but should be more than sufficient \n'
+ ' if (findAPITries > 7) { \n'
+ ' } \n'
+ ' win = win.parent; \n'
+ ' } \n'
- + ' return win.<?echo $LMS_api; ?>; \n'
+ + ' return win.<?php echo $LMS_api; ?>; \n'
+ '} \n'
+ ' \n'
+ 'function getAPI() { \n'
+ ' var result = doLMSInitialize(); \n'
+ ' var msg; \n'
+ ' if(result == "true") { \n'
- + ' msg = "<?echo $LMS_prefix; ?>Initialize Successful!"; \n'
+ + ' msg = "<?php echo $LMS_prefix; ?>Initialize Successful!"; \n'
+ ' } else { \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var errString = doLMSGetErrorString(err); \n'
- + ' msg = "<?echo $LMS_prefix; ?>Initialize Failed! Error Code: "+err; \n'
+ + ' msg = "<?php echo $LMS_prefix; ?>Initialize Failed! Error Code: "+err; \n'
+ ' msg += " Error Description: " + errString; \n'
+ ' } \n'
+ ' document.initForm.msgtxt.value= msg; \n'
+ ' var result = doLMSCommit(); \n'
+ ' var msg; \n'
+ ' if(result == "true") { \n'
- + ' msg = "<?echo $LMS_prefix; ?>Commit was Successful!"; \n'
+ + ' msg = "<?php echo $LMS_prefix; ?>Commit was Successful!"; \n'
+ ' } else { \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var errString = doLMSGetErrorString(err); \n'
- + ' var msg = "<?echo $LMS_prefix; ?>Commit Failed! Error Code: "+err; \n'
+ + ' var msg = "<?php echo $LMS_prefix; ?>Commit Failed! Error Code: "+err; \n'
+ ' msg += " Error Description: " + errString; \n'
+ ' } \n'
+ ' document.otherForm.msgtxt.value = msg; \n'
+ ' var result = doLMSGetValue(value); \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var errString = doLMSGetErrorString(err); \n'
- + ' msg = "<?echo $LMS_prefix; ?>GetValue Returned: " + result; \n'
+ + ' msg = "<?php echo $LMS_prefix; ?>GetValue Returned: " + result; \n'
+ ' msg += "\\nError Code: " + err; \n'
+ ' msg += "\\nError Description: " + errString; \n'
+ ' document.elemForm.msgtxt.value = msg; \n'
+ ' var api = getAPIHandle(); \n'
+ ' if (api == null) { \n'
+ ' alert("Unable to locate the LMS\'s API Implementation.\\n"+ \n'
- + ' "<?echo $LMS_prefix; ?>SetValue was not successful."); \n'
+ + ' "<?php echo $LMS_prefix; ?>SetValue was not successful."); \n'
+ ' return false; \n'
+ ' } \n'
+ ' // Try to set the element \n'
- + ' var result = api.<?echo $LMS_prefix; ?>SetValue( item, setValue ); \n'
+ + ' var result = api.<?php echo $LMS_prefix; ?>SetValue( item, setValue ); \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var errString = doLMSGetErrorString(err); \n'
- + ' msg = "<?echo $LMS_prefix; ?>SetValue returned: " + result; \n'
+ + ' msg = "<?php echo $LMS_prefix; ?>SetValue returned: " + result; \n'
+ ' msg += "\\nError Code: " + err; \n'
+ ' msg += "\\nError Description: " + errString; \n'
+ ' document.elemForm.msgtxt.value = msg; \n'
+ ' \n'
+ ' function tryLMSGetLastError() { \n'
+ ' var err = doLMSGetLastError(); \n'
- + ' document.otherForm.msgtxt.value = "<?echo $LMS_prefix; ?>GetLastError returned Error Code: " + err; \n'
+ + ' document.otherForm.msgtxt.value = "<?php echo $LMS_prefix; ?>GetLastError returned Error Code: " + err; \n'
+ ' } \n'
+ ' \n'
+ ' function tryLMSGetErrorString() { \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var errString = doLMSGetErrorString(err); \n'
- + ' document.otherForm.msgtxt.value = "<?echo $LMS_prefix; ?>GetErrorString returned: " + errString; \n'
+ + ' document.otherForm.msgtxt.value = "<?php echo $LMS_prefix; ?>GetErrorString returned: " + errString; \n'
+ ' } \n'
+ ' \n'
+ ' function tryLMSGetDiagnostic() { \n'
+ ' var err = doLMSGetLastError(); \n'
+ ' var diagnostic = doLMSGetDiagnostic(err); \n'
- + ' document.otherForm.msgtxt.value = "<?echo $LMS_prefix; ?>GetDiagnostic returned: " + diagnostic; \n'
+ + ' document.otherForm.msgtxt.value = "<?php echo $LMS_prefix; ?>GetDiagnostic returned: " + diagnostic; \n'
+ ' } \n'
+ ' \n'
+ '</script>\n'
+ ' <table width="100%" border="0">'
+ ' <tr>'
+ ' <td>'
- + ' <input type = "button" value = "Call <?echo $LMS_prefix; ?>Initialize()" onclick = "tryLMSInitialize();" id="Initialize" name="Initialize" />'
+ + ' <input type = "button" value = "Call <?php echo $LMS_prefix; ?>Initialize()" onclick = "tryLMSInitialize();" id="Initialize" name="Initialize" />'
+ ' </td>'
+ ' <td>'
+ ' <label>Result: </label><input type="text" name="msgtxt" id="msgtxt" size="80" readonly value="NotCalled" />'
+ ' </select>'
+ ' <input type="text" name="API_ELEMENT" id="API_ELEMENT" size="40"><br />'
+ ' <br />'
- + ' <label><b>Select API Function to Call</b></label> <input type = "button" value = "<?echo $LMS_prefix; ?>GetValue()"'
+ + ' <label><b>Select API Function to Call</b></label> <input type = "button" value = "<?php echo $LMS_prefix; ?>GetValue()"'
+ ' onclick = "tryLMSGetValue();" id="lmsGetButton"'
+ ' name="lmsGetButton"> -- OR -- '
- + ' <input type="button" value="<?echo $LMS_prefix; ?>SetValue()"'
+ + ' <input type="button" value="<?php echo $LMS_prefix; ?>SetValue()"'
+ ' onclick="tryLMSSetValue();" id="lmsSetButton"'
+ ' name="lmsSetButton">'
+ ' <label><b> value to Set: </b></label> <input type="text" name="SET_VAL" id="SET_VAL" size="25">'