}
this.questionStatus[questionIndex] = {
- ok: ok, answers: answersStatus, // dbg_min_score: min_score,
- // dbg_this_score: this_score
+ ok: ok, answers: answersStatus,
};
if (count) {
this.maxScore++;
- if (ok == 'ok') {
+ if (ok === 'ok') {
this.score++;
log.score = 1;
} else {
this.logQuestions[questionIndex] = log;
},
+ getNormalizedScore: function (pct) {
+ var s = this.score / this.getQuestionsCount();
+ if (pct === undefined || pct === false) {
+ return s;
+ }
+ return Math.round(100 * s);
+ },
+
+ isPassed: function () {
+ let threshold = parseInt(this.quiz.data.threshold);
+ return isNaN(threshold) || this.getNormalizedScore(true) > threshold;
+ },
+
getMinScore: function (question) {
// Le score minimal est le score que l'utilisateur doit atteindre sur une question pour que sa réponse soit considérée
let min_score = parseInt(question.min_score);
}
this.quiz.scorm.saveState(this.getCurrentState());
+ if (this.lastAnsweredQuestion === this.getQuestionsCount()) {
+ this.quiz.scorm.completed()
+ }
+ },
+
+ getQuestionsCount: function () {
+ return this.quiz.data.questions.length - 1
},
getCurrentState: function () {
completed: function (passed) {
cubeSCORM.scormMarkAsComplete();
- cubeSCORM.setScormValue('success_status', this.quiz.score.passed ? 'passed' : 'failed');
+ cubeSCORM.setScormValue('success_status', this.quiz.score.isPassed() ? 'passed' : 'failed');
cubeSCORM.setSCORMScore(this.quiz.score.getNormalizedScore(true), 100, 0, this.quiz.score.getNormalizedScore());
this.saveState(this.defaultState)
},