|
|
|
@ -14,7 +14,7 @@ |
|
|
|
|
var _debug = false; |
|
|
|
|
var findAPITries = 0; |
|
|
|
|
var _apiHandle = null; //private variable
|
|
|
|
|
var errMsgLocate = "Unable to locate the LMS's API implementation"; |
|
|
|
|
var errMsgLocate = "Unable to locate the LMS's API implementation" |
|
|
|
|
|
|
|
|
|
var _NoError = 0; |
|
|
|
|
var _GeneralException = 101; |
|
|
|
@ -28,6 +28,7 @@ var _InvalidSetValue = 402; |
|
|
|
|
var _ElementIsReadOnly = 403; |
|
|
|
|
var _ElementIsWriteOnly = 404; |
|
|
|
|
var _IncorrectDataType = 405; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the API handle right into the local API object and ensure there is only one. |
|
|
|
|
* Using the singleton pattern to ensure there's only one API object. |
|
|
|
@ -35,8 +36,7 @@ var _IncorrectDataType = 405; |
|
|
|
|
*/ |
|
|
|
|
var API = new function () |
|
|
|
|
{ |
|
|
|
|
if (_apiHandle == null) |
|
|
|
|
{ |
|
|
|
|
if (_apiHandle == null) { |
|
|
|
|
_apiHandle = getAPI(); |
|
|
|
|
} |
|
|
|
|
return _apiHandle; |
|
|
|
@ -49,11 +49,9 @@ var API = new function () |
|
|
|
|
*/ |
|
|
|
|
function findAPI(win) |
|
|
|
|
{ |
|
|
|
|
while((win.API == null) && (win.parent != null) && (win.parent != win)) |
|
|
|
|
{ |
|
|
|
|
while((win.API == null) && (win.parent != null) && (win.parent != win)) { |
|
|
|
|
findAPITries++; |
|
|
|
|
if(findAPITries>10) |
|
|
|
|
{ |
|
|
|
|
if (findAPITries>10) { |
|
|
|
|
alert("Error finding API - too deeply nested"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
@ -61,6 +59,7 @@ function findAPI(win) |
|
|
|
|
} |
|
|
|
|
return win.API; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the API from the current window/frame or from parent objects if not found |
|
|
|
|
* @return object The API object recovered from the LMS's implementation of the SCORM API |
|
|
|
@ -70,13 +69,11 @@ function getAPI() |
|
|
|
|
//window is the global/root object of the current window/frame
|
|
|
|
|
var MyAPI = findAPI(window); |
|
|
|
|
//look through parents if any
|
|
|
|
|
if((MyAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) |
|
|
|
|
{ |
|
|
|
|
if ((MyAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) { |
|
|
|
|
MyAPI = findAPI(window.opener); |
|
|
|
|
} |
|
|
|
|
//still not found? error message
|
|
|
|
|
if(MyAPI == null) |
|
|
|
|
{ |
|
|
|
|
if (MyAPI == null) { |
|
|
|
|
alert("Unable to find SCORM API adapter.\nPlease check your LMS is considering this page as SCORM and providing the right JavaScript interface.") |
|
|
|
|
} |
|
|
|
|
return MyAPI; |
|
|
|
@ -87,71 +84,60 @@ function getAPI() |
|
|
|
|
*/ |
|
|
|
|
function ErrorHandler() |
|
|
|
|
{ |
|
|
|
|
if(API == null) |
|
|
|
|
{ |
|
|
|
|
if (API == null) { |
|
|
|
|
alert("Unable to locate the LMS's API. Cannot determine LMS error code"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var errCode = API.LMSGetLastError().toString(); |
|
|
|
|
if(errCode != _NoError) |
|
|
|
|
{ |
|
|
|
|
if(errCode == _NotImplementedError) |
|
|
|
|
{ |
|
|
|
|
if (errCode != _NoError) { |
|
|
|
|
if (errCode == _NotImplementedError) { |
|
|
|
|
var errDescription = "The LMS doesn't support this feature"; |
|
|
|
|
if(_debug) |
|
|
|
|
{ |
|
|
|
|
if (_debug) { |
|
|
|
|
errDescription += "\n"; |
|
|
|
|
errDescription += api.LMSGetDiagnostic(null); |
|
|
|
|
} |
|
|
|
|
alert (errDescription); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
alert(errDescription); |
|
|
|
|
} else { |
|
|
|
|
var errDescription = API.LMSGetErrorString(errCode); |
|
|
|
|
if(_debug) |
|
|
|
|
{ |
|
|
|
|
if (_debug) { |
|
|
|
|
errDescription += "\n"; |
|
|
|
|
errDescription += api.LMSGetDiagnostic(null); |
|
|
|
|
} |
|
|
|
|
alert (errDescription); |
|
|
|
|
alert(errDescription); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return errCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls the LMSInitialize method of the LMS's API object |
|
|
|
|
* @return string The string value of the LMS returned value or false if error (should be "true" otherwise) |
|
|
|
|
*/ |
|
|
|
|
function doLMSInitialize() |
|
|
|
|
{ |
|
|
|
|
if(API == null) |
|
|
|
|
{ |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSInitialize failed"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var result = API.LMSInitialize(""); |
|
|
|
|
if(result.toString() != "true") |
|
|
|
|
{ |
|
|
|
|
if (result.toString() != "true") { |
|
|
|
|
var err = ErrorHandler(); |
|
|
|
|
} |
|
|
|
|
return result.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls the LMSFinish method of the LMS's API object |
|
|
|
|
* @return string The string value of the LMS return value, or false if error (should be "true" otherwise) |
|
|
|
|
*/ |
|
|
|
|
function doLMSFinish() |
|
|
|
|
{ |
|
|
|
|
if(API == null) |
|
|
|
|
{ |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSFinish failed"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
var result = API.LMSFinish(''); |
|
|
|
|
if(result.toString() != "true") |
|
|
|
|
{ |
|
|
|
|
if (result.toString() != "true") { |
|
|
|
|
var err = ErrorHandler(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -164,28 +150,22 @@ function doLMSFinish() |
|
|
|
|
*/ |
|
|
|
|
function doLMSGetValue(name) |
|
|
|
|
{ |
|
|
|
|
if (API == null) |
|
|
|
|
{ |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSGetValue was not successful."); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
var value = API.LMSGetValue(name); |
|
|
|
|
var errCode = API.LMSGetLastError().toString(); |
|
|
|
|
if (errCode != _NoError) |
|
|
|
|
{ |
|
|
|
|
if (errCode != _NoError) { |
|
|
|
|
// an error was encountered so display the error description
|
|
|
|
|
var errDescription = API.LMSGetErrorString(errCode); |
|
|
|
|
alert("LMSGetValue("+name+") failed. \n"+ errDescription); |
|
|
|
|
alert("LMSGetValue(" + name + ") failed. \n" + errDescription); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
return value.toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls the LMSSetValue method of the API object |
|
|
|
|
* @param string The name of the SCORM parameter to set |
|
|
|
@ -194,74 +174,68 @@ function doLMSGetValue(name) |
|
|
|
|
*/ |
|
|
|
|
function doLMSSetValue(name, value) |
|
|
|
|
{ |
|
|
|
|
if (API == null) |
|
|
|
|
{ |
|
|
|
|
alert("Unable to locate the LMS's API Implementation.\nLMSSetValue was not successful."); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
var result = API.LMSSetValue(name, value); |
|
|
|
|
if (result.toString() != "true") |
|
|
|
|
{ |
|
|
|
|
var err = ErrorHandler(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
if (API == null) { |
|
|
|
|
alert("Unable to locate the LMS's API Implementation.\nLMSSetValue was not successful."); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
var result = API.LMSSetValue(name, value); |
|
|
|
|
if (result.toString() != "true") { |
|
|
|
|
var err = ErrorHandler(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls the LMSCommit method |
|
|
|
|
*/ |
|
|
|
|
function doLMSCommit() |
|
|
|
|
{ |
|
|
|
|
if(API == null) |
|
|
|
|
{ |
|
|
|
|
alert(errMsgLocate +"\nLMSCommit was not successful."); |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSCommit was not successful."); |
|
|
|
|
return "false"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
var result = API.LMSCommit(""); |
|
|
|
|
if (result != "true") |
|
|
|
|
{ |
|
|
|
|
if (result != "true") { |
|
|
|
|
var err = ErrorHandler(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls GetLastError() |
|
|
|
|
*/ |
|
|
|
|
function doLMSGetLastError() |
|
|
|
|
{ |
|
|
|
|
if (API == null) |
|
|
|
|
{ |
|
|
|
|
alert(errMsgLocate + "\nLMSGetLastError was not successful."); //since we can't get the error code from the LMS, return a general error
|
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSGetLastError was not successful."); |
|
|
|
|
//since we can't get the error code from the LMS, return a general error
|
|
|
|
|
return _GeneralError; |
|
|
|
|
} |
|
|
|
|
return API.LMSGetLastError().toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls LMSGetErrorString() |
|
|
|
|
*/ |
|
|
|
|
function doLMSGetErrorString(errorCode) |
|
|
|
|
{ |
|
|
|
|
if (API == null) |
|
|
|
|
{ |
|
|
|
|
alert(errMsgLocate + "\nLMSGetErrorString was not successful."); |
|
|
|
|
} |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSGetErrorString was not successful."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return API.LMSGetErrorString(errorCode).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls LMSGetDiagnostic() |
|
|
|
|
*/ |
|
|
|
|
function doLMSGetDiagnostic(errorCode) |
|
|
|
|
{ |
|
|
|
|
if (API == null) |
|
|
|
|
{ |
|
|
|
|
alert(errMsgLocate + "\nLMSGetDiagnostic was not successful."); |
|
|
|
|
} |
|
|
|
|
if (API == null) { |
|
|
|
|
alert(errMsgLocate + "\nLMSGetDiagnostic was not successful."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return API.LMSGetDiagnostic(errorCode).toString(); |
|
|
|
|
} |
|
|
|
@ -278,17 +252,16 @@ var exitPageStatus; |
|
|
|
|
function loadPage() |
|
|
|
|
{ |
|
|
|
|
var result = doLMSInitialize(); |
|
|
|
|
if(result) |
|
|
|
|
{ |
|
|
|
|
if (result) { |
|
|
|
|
var status = doLMSGetValue("cmi.core.lesson_status"); |
|
|
|
|
if(status == "not attempted") |
|
|
|
|
{ |
|
|
|
|
doLMSSetValue("cmi.core.lesson_status","incomplete"); |
|
|
|
|
if (status == "not attempted") { |
|
|
|
|
doLMSSetValue("cmi.core.lesson_status", "incomplete"); |
|
|
|
|
} |
|
|
|
|
exitPageStatus = false; |
|
|
|
|
startTimer(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Starts the local timer |
|
|
|
|
*/ |
|
|
|
@ -296,23 +269,21 @@ function startTimer() |
|
|
|
|
{ |
|
|
|
|
startTime = new Date().getTime(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calculates the total time and sends the result to the LMS |
|
|
|
|
*/ |
|
|
|
|
function computeTime() |
|
|
|
|
{ |
|
|
|
|
if ( startTime != 0 ) |
|
|
|
|
{ |
|
|
|
|
var currentDate = new Date().getTime(); |
|
|
|
|
var elapsedSeconds = ( (currentDate - startTime) / 1000 ); |
|
|
|
|
var formattedTime = convertTotalSeconds( elapsedSeconds ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
formattedTime = "00:00:00.0"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
doLMSSetValue( "cmi.core.session_time", formattedTime ); |
|
|
|
|
if (startTime != 0) { |
|
|
|
|
var currentDate = new Date().getTime(); |
|
|
|
|
var elapsedSeconds = ( (currentDate - startTime) / 1000 ); |
|
|
|
|
var formattedTime = convertTotalSeconds(elapsedSeconds); |
|
|
|
|
} else { |
|
|
|
|
formattedTime = "00:00:00.0"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
doLMSSetValue( "cmi.core.session_time", formattedTime ); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Formats the time in a SCORM time format |
|
|
|
@ -330,31 +301,28 @@ function convertTotalSeconds(ts) |
|
|
|
|
var strWholeSec = strSec; |
|
|
|
|
var strFractionSec = ""; |
|
|
|
|
|
|
|
|
|
if (strSec.indexOf(".") != -1) |
|
|
|
|
{ |
|
|
|
|
strWholeSec = strSec.substring(0, strSec.indexOf(".")); |
|
|
|
|
strFractionSec = strSec.substring(strSec.indexOf(".")+1, strSec.length); |
|
|
|
|
if (strSec.indexOf(".") != -1) { |
|
|
|
|
strWholeSec = strSec.substring(0, strSec.indexOf(".")); |
|
|
|
|
strFractionSec = strSec.substring(strSec.indexOf(".") + 1, strSec.length); |
|
|
|
|
} |
|
|
|
|
if (strWholeSec.length < 2) |
|
|
|
|
{ |
|
|
|
|
if (strWholeSec.length < 2) { |
|
|
|
|
strWholeSec = "0" + strWholeSec; |
|
|
|
|
} |
|
|
|
|
strSec = strWholeSec; |
|
|
|
|
if (strFractionSec.length) |
|
|
|
|
{ |
|
|
|
|
strSec = strSec+ "." + strFractionSec; |
|
|
|
|
if (strFractionSec.length) { |
|
|
|
|
strSec = strSec + "." + strFractionSec; |
|
|
|
|
} |
|
|
|
|
if ((ts % 3600) != 0 ) |
|
|
|
|
if ((ts % 3600) != 0) |
|
|
|
|
var hour = 0; |
|
|
|
|
else var hour = (ts / 3600); |
|
|
|
|
if ( (tmp % 60) != 0 ) |
|
|
|
|
if ((tmp % 60) != 0) |
|
|
|
|
var min = 0; |
|
|
|
|
else var min = (tmp / 60); |
|
|
|
|
if ((new String(hour)).length < 2) |
|
|
|
|
hour = "0"+hour; |
|
|
|
|
hour = "0" + hour; |
|
|
|
|
if ((new String(min)).length < 2) |
|
|
|
|
min = "0"+min; |
|
|
|
|
var rtnVal = hour+":"+min+":"+strSec; |
|
|
|
|
min = "0" + min; |
|
|
|
|
var rtnVal = hour + ":" + min + ":" + strSec; |
|
|
|
|
return rtnVal |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -370,6 +338,7 @@ function doBack() |
|
|
|
|
result = doLMSCommit(); |
|
|
|
|
result = doLMSFinish(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Handles the closure of the current SCO before an interruption. This is only useful if the LMS |
|
|
|
|
* deals with the cmi.core.exit, cmi.core.lesson_status and cmi.core.lesson_mode *and* the SCO |
|
|
|
@ -390,6 +359,7 @@ function doContinue(status) |
|
|
|
|
result = doLMSCommit(); |
|
|
|
|
result = doLMSFinish(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* handles the recording of everything on a normal shutdown |
|
|
|
|
*/ |
|
|
|
@ -402,6 +372,7 @@ function doQuit() |
|
|
|
|
result = doLMSCommit(); |
|
|
|
|
result = doLMSFinish(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Called upon unload event from body element |
|
|
|
|
*/ |
|
|
|
@ -429,7 +400,7 @@ function checkAnswers(interrupted) |
|
|
|
|
var tmpScore = 0; |
|
|
|
|
var status = 'not attempted'; |
|
|
|
|
var scoreMax = 0; |
|
|
|
|
for(var i=0; i<questions.length;i++) { |
|
|
|
|
for (var i=0; i<questions.length;i++) { |
|
|
|
|
if(questions[i] != undefined && questions[i] != null){ |
|
|
|
|
var idQuestion = questions[i]; |
|
|
|
|
var type = questions_types[idQuestion]; |
|
|
|
@ -441,179 +412,115 @@ function checkAnswers(interrupted) |
|
|
|
|
if (type == 'mcma') { |
|
|
|
|
var interactionType = 'choice'; |
|
|
|
|
var myScore = 0; |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) |
|
|
|
|
{ |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) { |
|
|
|
|
var idAnswer = questions_answers[idQuestion][j]; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer)); |
|
|
|
|
if(answer.checked) |
|
|
|
|
{ |
|
|
|
|
if (answer.checked) { |
|
|
|
|
interactionAnswers += idAnswer+'__|';// changed by isaac flores
|
|
|
|
|
myScore +=questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
|
|
|
|
|
/*for(k=0;k<questions_answers_correct[idQuestion].length;k++) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_correct[idQuestion][k] == idAnswer) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_ponderation[idQuestion][idAnswer]) |
|
|
|
|
{ |
|
|
|
|
myScore += questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myScore ++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interactionScore = myScore; |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
|
|
|
|
|
//{
|
|
|
|
|
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
|
|
|
|
|
//}
|
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
} |
|
|
|
|
else if(type == 'mcua') |
|
|
|
|
{ |
|
|
|
|
} else if (type == 'mcua') { |
|
|
|
|
var interactionType = 'choice'; |
|
|
|
|
var myScore = 0; |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) |
|
|
|
|
{ |
|
|
|
|
for (var j=0; j<questions_answers[idQuestion].length;j++) { |
|
|
|
|
var idAnswer = questions_answers[idQuestion][j]; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_unique_'+(idAnswer)); |
|
|
|
|
if(answer.checked) |
|
|
|
|
{ |
|
|
|
|
if (answer.checked) { |
|
|
|
|
interactionAnswers += idAnswer; |
|
|
|
|
if(questions_answers_correct[idQuestion] == idAnswer) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_ponderation[idQuestion][idAnswer]) |
|
|
|
|
{ |
|
|
|
|
if (questions_answers_correct[idQuestion] == idAnswer) { |
|
|
|
|
if (questions_answers_ponderation[idQuestion][idAnswer]) { |
|
|
|
|
myScore += questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myScore ++; |
|
|
|
|
} else { |
|
|
|
|
myScore++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interactionScore = myScore; |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//interactionCorrectResponses += questions_answers_correct[idQuestion].toString();
|
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
} |
|
|
|
|
else if(type == 'tf') |
|
|
|
|
{ |
|
|
|
|
} else if (type == 'tf') { |
|
|
|
|
var interactionType = 'true-false'; |
|
|
|
|
var myScore = 0; |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) |
|
|
|
|
{ |
|
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) { |
|
|
|
|
var idAnswer = questions_answers[idQuestion][j]; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_tf_'+(idAnswer)); |
|
|
|
|
if(answer.checked.value) |
|
|
|
|
{ |
|
|
|
|
var answer = document.getElementById('question_' + idQuestion + '_tf_' + (idAnswer)); |
|
|
|
|
if (answer.checked.value) { |
|
|
|
|
interactionAnswers += idAnswer; |
|
|
|
|
for(k=0;k<questions_answers_correct[idQuestion].length;k++) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_correct[idQuestion][k] == idAnswer) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_ponderation[idQuestion][idAnswer]) |
|
|
|
|
{ |
|
|
|
|
for (k = 0; k < questions_answers_correct[idQuestion].length; k++) { |
|
|
|
|
if (questions_answers_correct[idQuestion][k] == idAnswer) { |
|
|
|
|
if (questions_answers_ponderation[idQuestion][idAnswer]) { |
|
|
|
|
myScore += questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myScore ++; |
|
|
|
|
} else { |
|
|
|
|
myScore++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interactionScore = myScore; |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//interactionCorrectResponses += questions_answers_correct[idQuestion].toString();
|
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
} |
|
|
|
|
else if(type == 'fib') |
|
|
|
|
{ |
|
|
|
|
} else if (type == 'fib') { |
|
|
|
|
var interactionType = 'fill-in'; |
|
|
|
|
var myScore = 0; |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) |
|
|
|
|
{ |
|
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) { |
|
|
|
|
var idAnswer = questions_answers[idQuestion][j]; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_fib_'+(idAnswer)); |
|
|
|
|
if(answer.value) |
|
|
|
|
{ |
|
|
|
|
interactionAnswers += answer.value+'__|';//changed by isaac flores
|
|
|
|
|
for(k=0;k<questions_answers_correct[idQuestion].length;k++) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_correct[idQuestion][k] == answer.value) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_ponderation[idQuestion][idAnswer]) |
|
|
|
|
{ |
|
|
|
|
if (answer.value) { |
|
|
|
|
interactionAnswers += answer.value + '__|';//changed by isaac flores
|
|
|
|
|
for (k = 0; k < questions_answers_correct[idQuestion].length; k++) { |
|
|
|
|
if (questions_answers_correct[idQuestion][k] == answer.value) { |
|
|
|
|
if (questions_answers_ponderation[idQuestion][idAnswer]) { |
|
|
|
|
myScore += questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myScore ++; |
|
|
|
|
} else { |
|
|
|
|
myScore++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interactionScore = myScore; |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
|
|
|
|
|
//{
|
|
|
|
|
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
|
|
|
|
|
//}
|
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
} |
|
|
|
|
else if(type == 'matching') |
|
|
|
|
{ |
|
|
|
|
} else if (type == 'matching') { |
|
|
|
|
var interactionType = 'matching'; |
|
|
|
|
var myScore = 0; |
|
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) |
|
|
|
|
{ |
|
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) { |
|
|
|
|
var idAnswer = questions_answers[idQuestion][j]; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_matching_'+(idAnswer)); |
|
|
|
|
if(answer && answer.value) |
|
|
|
|
{ |
|
|
|
|
interactionAnswers += answer.value+'__|';//changed by isaac flores
|
|
|
|
|
for(k=0;k<questions_answers_correct[idQuestion].length;k++) |
|
|
|
|
{ |
|
|
|
|
var answer = document.getElementById('question_' + (idQuestion) + '_matching_' + (idAnswer)); |
|
|
|
|
if (answer && answer.value) { |
|
|
|
|
interactionAnswers += answer.value + '__|';//changed by isaac flores
|
|
|
|
|
for (k = 0; k < questions_answers_correct[idQuestion].length; k++) { |
|
|
|
|
var left = questions_answers_correct[idQuestion][k][0]; |
|
|
|
|
var right = questions_answers_correct[idQuestion][k][1]; |
|
|
|
|
if(left == idAnswer && right == answer.value) |
|
|
|
|
{ |
|
|
|
|
if(questions_answers_ponderation[idQuestion][idAnswer]) |
|
|
|
|
{ |
|
|
|
|
if (left == idAnswer && right == answer.value) { |
|
|
|
|
if (questions_answers_ponderation[idQuestion][idAnswer]) { |
|
|
|
|
myScore += questions_answers_ponderation[idQuestion][idAnswer]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myScore ++; |
|
|
|
|
} else { |
|
|
|
|
myScore++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interactionScore = myScore; |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
|
|
|
|
|
//{
|
|
|
|
|
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
|
|
|
|
|
//}
|
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
} else if(type == 'free') { |
|
|
|
|
} else if (type == 'free') { |
|
|
|
|
//ignore for now as a score cannot be given
|
|
|
|
|
var interactionType = 'likert'; |
|
|
|
|
interactionScore = 0; |
|
|
|
|
var interactionType = 'free'; |
|
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_free'); |
|
|
|
|
if (answer && answer.value) { |
|
|
|
|
interactionAnswers += answer.value |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interactionScore = questions_score_max[idQuestion]; |
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
|
|
|
|
|
//interactionAnswers = document.getElementById('question_'+(idQuestion)+'_free').value;
|
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//interactionCorrectResponses += questions_answers_correct[idQuestion].toString();
|
|
|
|
|
} else if(type == 'hotspot') { |
|
|
|
|
} else if (type == 'hotspot') { |
|
|
|
|
var interactionType = 'sequencing'; |
|
|
|
|
interactionScore = 0; |
|
|
|
|
//if(question_score && question_score[idQuestion]){
|
|
|
|
@ -625,7 +532,7 @@ function checkAnswers(interrupted) |
|
|
|
|
//{
|
|
|
|
|
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
|
|
|
|
|
//}
|
|
|
|
|
} else if(type == 'exact') { |
|
|
|
|
} else if (type == 'exact') { |
|
|
|
|
var interactionType = 'exact'; |
|
|
|
|
interactionScore = 0; |
|
|
|
|
// not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function
|
|
|
|
@ -674,47 +581,32 @@ function checkAnswers(interrupted) |
|
|
|
|
scoreMax += questions_score_max[idQuestion]; |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//
|
|
|
|
|
} |
|
|
|
|
tmpScore += interactionScore; |
|
|
|
|
|
|
|
|
|
doLMSSetValue('cmi.interactions.'+idQuestion+'.id','Q'+idQuestion); |
|
|
|
|
doLMSSetValue('cmi.interactions.'+idQuestion+'.type',interactionType); |
|
|
|
|
doLMSSetValue('cmi.interactions.'+idQuestion+'.student_response',interactionAnswers); |
|
|
|
|
doLMSSetValue('cmi.interactions.'+idQuestion+'.result',interactionScore); |
|
|
|
|
//correct responses work by pattern, see SCORM Runtime Env Doc
|
|
|
|
|
//doLMSSetValue('cmi.interactions.'+idQuestion+'.correct_responses',questions_answers_correct[idQuestion]);
|
|
|
|
|
//doLMSSetValue('cmi.interactions.'+idQuestion+'.correct_responses',interactionCorrectResponses);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
doLMSSetValue('cmi.core.score.min',0); |
|
|
|
|
doLMSSetValue('cmi.core.score.max',scoreMax); |
|
|
|
|
doLMSSetValue('cmi.core.score.raw',tmpScore); |
|
|
|
|
//doLMSSetValue('cmi.student_data.mastery_score',(scoreMax*0.7));
|
|
|
|
|
doLMSSetValue('cmi.core.score.min', 0); |
|
|
|
|
doLMSSetValue('cmi.core.score.max', scoreMax); |
|
|
|
|
doLMSSetValue('cmi.core.score.raw', tmpScore); |
|
|
|
|
//get status
|
|
|
|
|
var mastery_score = doLMSGetValue('cmi.student_data.mastery_score'); |
|
|
|
|
if(mastery_score <= 0) |
|
|
|
|
{ |
|
|
|
|
mastery_score = (scoreMax*0.80); |
|
|
|
|
if (mastery_score <= 0) { |
|
|
|
|
mastery_score = (scoreMax * 0.80); |
|
|
|
|
} |
|
|
|
|
if(tmpScore > mastery_score) |
|
|
|
|
{ |
|
|
|
|
if (tmpScore > mastery_score) { |
|
|
|
|
status = 'passed'; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
status = 'failed'; |
|
|
|
|
} |
|
|
|
|
doLMSSetValue('cmi.core.lesson_status',status); |
|
|
|
|
doLMSSetValue('cmi.core.lesson_status', status); |
|
|
|
|
|
|
|
|
|
if (interrupted && (status != 'completed') && (status != 'passed')) |
|
|
|
|
{ |
|
|
|
|
doLMSSetValue('cmi.core.exit','suspended'); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (interrupted && (status != 'completed') && (status != 'passed')) { |
|
|
|
|
doLMSSetValue('cmi.core.exit', 'suspended'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; //do not submit the form
|
|
|
|
|
} |
|
|
|
|