|
@@ -14,8 +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;
|
|
|
var _ServerBusy = 102;
|
|
@@ -34,11 +33,12 @@ var _IncorrectDataType = 405;
|
|
|
* Using the singleton pattern to ensure there's only one API object.
|
|
|
* @return object The API object as given by the LMS
|
|
|
*/
|
|
|
-var API = new function ()
|
|
|
+var API = new function()
|
|
|
{
|
|
|
if (_apiHandle == null) {
|
|
|
_apiHandle = getAPI();
|
|
|
}
|
|
|
+
|
|
|
return _apiHandle;
|
|
|
}
|
|
|
|
|
@@ -96,14 +96,14 @@ function ErrorHandler()
|
|
|
errDescription += "\n";
|
|
|
errDescription += api.LMSGetDiagnostic(null);
|
|
|
}
|
|
|
- alert(errDescription);
|
|
|
+ console.log(errDescription);
|
|
|
} else {
|
|
|
var errDescription = API.LMSGetErrorString(errCode);
|
|
|
if (_debug) {
|
|
|
errDescription += "\n";
|
|
|
errDescription += api.LMSGetDiagnostic(null);
|
|
|
}
|
|
|
- alert(errDescription);
|
|
|
+ console.log(errDescription);
|
|
|
}
|
|
|
}
|
|
|
return errCode;
|
|
@@ -161,7 +161,6 @@ function doLMSGetValue(name)
|
|
|
var errDescription = API.LMSGetErrorString(errCode);
|
|
|
alert("LMSGetValue(" + name + ") failed. \n" + errDescription);
|
|
|
return "";
|
|
|
- return value.toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -400,8 +399,8 @@ function checkAnswers(interrupted)
|
|
|
var tmpScore = 0;
|
|
|
var status = 'not attempted';
|
|
|
var scoreMax = 0;
|
|
|
- for (var i=0; i<questions.length;i++) {
|
|
|
- if(questions[i] != undefined && questions[i] != null){
|
|
|
+ for (var i=0; i < questions.length; i++) {
|
|
|
+ if (questions[i] != undefined && questions[i] != null){
|
|
|
var idQuestion = questions[i];
|
|
|
var type = questions_types[idQuestion];
|
|
|
var interactionScore = 0;
|
|
@@ -410,7 +409,7 @@ function checkAnswers(interrupted)
|
|
|
var interactionType = '';
|
|
|
|
|
|
if (type == 'mcma') {
|
|
|
- var interactionType = 'choice';
|
|
|
+ interactionType = 'choice';
|
|
|
var myScore = 0;
|
|
|
for(var j=0; j<questions_answers[idQuestion].length;j++) {
|
|
|
var idAnswer = questions_answers[idQuestion][j];
|
|
@@ -423,7 +422,7 @@ function checkAnswers(interrupted)
|
|
|
interactionScore = myScore;
|
|
|
scoreMax += questions_score_max[idQuestion];
|
|
|
} else if (type == 'mcua') {
|
|
|
- var interactionType = 'choice';
|
|
|
+ interactionType = 'choice';
|
|
|
var myScore = 0;
|
|
|
for (var j=0; j<questions_answers[idQuestion].length;j++) {
|
|
|
var idAnswer = questions_answers[idQuestion][j];
|
|
@@ -442,7 +441,7 @@ function checkAnswers(interrupted)
|
|
|
interactionScore = myScore;
|
|
|
scoreMax += questions_score_max[idQuestion];
|
|
|
} else if (type == 'tf') {
|
|
|
- var interactionType = 'true-false';
|
|
|
+ interactionType = 'true-false';
|
|
|
var myScore = 0;
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
|
|
|
var idAnswer = questions_answers[idQuestion][j];
|
|
@@ -463,7 +462,7 @@ function checkAnswers(interrupted)
|
|
|
interactionScore = myScore;
|
|
|
scoreMax += questions_score_max[idQuestion];
|
|
|
} else if (type == 'fib') {
|
|
|
- var interactionType = 'fill-in';
|
|
|
+ interactionType = 'fill-in';
|
|
|
var myScore = 0;
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
|
|
|
var idAnswer = questions_answers[idQuestion][j];
|
|
@@ -484,7 +483,7 @@ function checkAnswers(interrupted)
|
|
|
interactionScore = myScore;
|
|
|
scoreMax += questions_score_max[idQuestion];
|
|
|
} else if (type == 'matching') {
|
|
|
- var interactionType = 'matching';
|
|
|
+ interactionType = 'matching';
|
|
|
var myScore = 0;
|
|
|
for (var j = 0; j < questions_answers[idQuestion].length; j++) {
|
|
|
var idAnswer = questions_answers[idQuestion][j];
|
|
@@ -508,20 +507,21 @@ function checkAnswers(interrupted)
|
|
|
scoreMax += questions_score_max[idQuestion];
|
|
|
} else if (type == 'free') {
|
|
|
//ignore for now as a score cannot be given
|
|
|
- var interactionType = 'free';
|
|
|
+ interactionType = 'free';
|
|
|
var answer = document.getElementById('question_'+(idQuestion)+'_free');
|
|
|
if (answer && answer.value) {
|
|
|
interactionAnswers += answer.value
|
|
|
}
|
|
|
|
|
|
- interactionScore = questions_score_max[idQuestion];
|
|
|
+ //interactionScore = questions_score_max[idQuestion];
|
|
|
+ interactionScore = 0;
|
|
|
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') {
|
|
|
- var interactionType = 'sequencing';
|
|
|
+ interactionType = 'sequencing';
|
|
|
interactionScore = 0;
|
|
|
//if(question_score && question_score[idQuestion]){
|
|
|
// interactionScore = question_score[idQuestion];
|
|
@@ -533,60 +533,48 @@ function checkAnswers(interrupted)
|
|
|
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
|
|
|
//}
|
|
|
} else if (type == 'exact') {
|
|
|
- var interactionType = 'exact';
|
|
|
+ interactionType = 'exact';
|
|
|
interactionScore = 0;
|
|
|
- // not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function
|
|
|
- /*
|
|
|
-
|
|
|
- var myScore = 0;
|
|
|
var real_answers = new Array();
|
|
|
-
|
|
|
- for(var j=0; j<questions_answers[idQuestion].length;j++) {
|
|
|
+ console.log(questions_answers_correct[idQuestion]);
|
|
|
+ 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(questions_answers_ponderation[idQuestion][idAnswer] != 0 ) {
|
|
|
+ var answer = document.getElementById('question_' + (idQuestion) + '_exact_' + (idAnswer));
|
|
|
+
|
|
|
+ if (answer.checked == true) {
|
|
|
+ if (questions_answers_correct[idQuestion][idAnswer] != 0) {
|
|
|
real_answers[j] = true;
|
|
|
} else {
|
|
|
real_answers[j] = false;
|
|
|
}
|
|
|
} else {
|
|
|
- if(questions_answers_ponderation[idQuestion][idAnswer] != 0) {
|
|
|
+ if (questions_answers_correct[idQuestion][idAnswer] != 0) {
|
|
|
real_answers[j] = false;
|
|
|
} else {
|
|
|
real_answers[j] = true;
|
|
|
}
|
|
|
}
|
|
|
- //alert(real_answers[j] +' ' + answer.checked + ' ' + questions_answers_ponderation[idQuestion][idAnswer]);
|
|
|
}
|
|
|
|
|
|
var final_answer = true;
|
|
|
- for(var z=0; z<real_answers.length ;z++) {
|
|
|
- if (!real_answers[z]) {
|
|
|
- final_answer = false;
|
|
|
- }
|
|
|
- }
|
|
|
+ for (var z = 0; z < real_answers.length; z++) {
|
|
|
+ if (real_answers[z] == false) {
|
|
|
+ final_answer = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (final_answer) {
|
|
|
+ if (final_answer) {
|
|
|
//getting only the first score where we save the weight of all the question
|
|
|
- myScore += questions_answers_ponderation[idQuestion][1];
|
|
|
+ interactionScore = questions_answers_ponderation[idQuestion][1];
|
|
|
}
|
|
|
-
|
|
|
- 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];
|
|
|
- */
|
|
|
}
|
|
|
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);
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
doLMSSetValue('cmi.core.score.min', 0);
|