--- /dev/null
+function QuizAttemptsLog(quiz) {
+ this.quiz = quiz;
+
+}
+
+QuizAttemptsLog.prototype = {}
+
+export default QuizAttemptsLog;
import $ from "cash-dom";
import 'swiper/css';
-import {CubeSCORM} from '/application/resources/scorm/scorm';
import QuizResize from "./quiz.resize";
import QuizAnimations from "./quiz.animations";
import QuizL10n from "./quiz.l10n";
import QuizDraganddrop from "./quiz.draganddrop";
import QuizMatch from "./quiz.match";
+import QuizAttemptsLog from "./quiz.attemptslog";
+
-window.cubeSCORM = new CubeSCORM();
window.$ = window.jQuery = $;
import ResizeObserver from 'resize-observer-polyfill';
this.animations = new QuizAnimations(this);
this.question = new QuizQuestion(this);
this.score = new QuizScore(this);
- this.scorm = new QuizScorm(this);
this.resize = new QuizResize(this);
this.utils = new QuizUtils(this);
this.accessibility = new QuizAccessibility(this);
this.l10n = new QuizL10n(this);
this.draganddrop = new QuizDraganddrop(this);
this.match = new QuizMatch(this);
+ this.attemptsLog = new QuizAttemptsLog(this);
+
+ this.scorm = new QuizScorm(this);
+ },
+
+ initQuiz: function (state) {
+ const $this = this;
// La fonction resize est appelée à chaque fois qu'un resize de la fenêtre survient (et à l'init de l'app)
$(window).on('resize', function () {
$this.quizResize();
});
- this.quizResize();
- $('#quiz').addClass('ready');
- // Afficher l'écran d'introduction et lancer l'animation
- this.screens.intro.show();
+ let callback = function () {
+ $this.quizResize();
+ $('#quiz').addClass('ready');
+ }
+
+ console.log(state);
+
+ if (state.q === undefined || state.q === -1) {
+ // Afficher l'écran d'introduction et lancer l'animation
+ this.screens.intro.show();
+ this.score.init();
+ callback();
+ } else {
+ let i;
+ for (i = 0; i - 1 < state.q; i++) {
+ this.score.setAnswer(i, state.a[i]);
+ }
+ this.screens.showScreen('q-' + i, callback);
+ }
this.progressbar.update();
},
this.questionStatus = [];
this.answers = [];
this.lastAnsweredQuestion = -1;
- this.init();
}
QuizScore.prototype = {
return min_score;
},
- updateScore: function () {
+ updateScore: function (saveState) {
this.maxScore = 0;
this.score = 0;
this.logQuestions = [];
this.checkQuestion(qn);
}
- let state = {
+ this.quiz.scorm.saveState(this.getCurrentState());
+ },
+
+ getCurrentState: function () {
+ return {
q: this.lastAnsweredQuestion + 1, a: this.answers
};
-
- if (cubeSCORM.SCORM) {
- cubeSCORM.setSCORMLocation(state);
- }
- },
+ }
};
export default QuizScore;
+import {CubeSCORM} from '/application/resources/scorm/scorm';
+
+window.cubeSCORM = new CubeSCORM();
+
function QuizScorm(quiz) {
this.quiz = quiz;
+ this.inited = false;
+ this.enabled = false;
+ //this.defaultState = {q: -1, a: []};
+ this.defaultState = {q: 0, a: [[1,1,2,1,2]]};
+ this.skipSaveState = false;
+
+ this.init();
+
}
-QuizScorm.prototype = {};
+QuizScorm.prototype = {
+
+ init: function () {
+ if (cubeSCORM.SCORM_INITED) {
+ return;
+ }
+
+ let disableScorm = window.parent !== undefined && window.parent.fluidbook !== undefined;
+
+ cubeSCORM.initScorm(disableScorm);
+ this.enabled = cubeSCORM.SCORM_OK;
+ this.inited = true;
+
+ const $this = this;
+
+ setTimeout(function () {
+ $this.skipSaveState = true;
+ $this.quiz.initQuiz(cubeSCORM.getScormLocation($this.defaultState));
+ $this.skipSaveState = false;
+ }, 50)
+ },
+
+ completed: function (passed) {
+ cubeSCORM.scormMarkAsComplete();
+ cubeSCORM.setScormValue('success_status', this.quiz.score.passed ? 'passed' : 'failed');
+ cubeSCORM.setSCORMScore(this.quiz.score.getNormalizedScore(true), 100, 0, this.quiz.score.getNormalizedScore());
+ this.saveState(this.defaultState)
+ },
+
+ saveState: function (state) {
+ console.log(state);
+ if (this.skipSaveState) {
+ return;
+ }
+ cubeSCORM.setSCORMLocation(state);
+ }
+};
export default QuizScorm;
const $this = this;
let screenToShow = $('[data-screen="' + screen + '"]');
this.hideCurrentScreen(function () {
-
-
$this.resetCountdownBackground();
screenToShow.removeClass("none").addClass("next active-screen");
if (callback !== undefined) {
//
$this.animateContent(screenToShow);
-
// Reset form to prevent browser letting a option selected after a refresh
$this.resetForm();
$this.currentQuestionAnswers = [];