From 0eff1d46142dcd806cb9d6568e5f6256bdf1dd5d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 25 Sep 2023 16:51:07 +0200 Subject: [PATCH] wip #6186 @0.5 --- js/quiz.accessibility.js | 1 - js/quiz.js | 4 ++-- js/quiz.resize.js | 11 +++++++---- js/quiz.score.js | 2 +- js/quiz.utils.js | 1 - 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/js/quiz.accessibility.js b/js/quiz.accessibility.js index 852ac57..c0380fc 100644 --- a/js/quiz.accessibility.js +++ b/js/quiz.accessibility.js @@ -15,7 +15,6 @@ QuizAccessibility.prototype = { $('[aria-keyshortcuts="' + key + '"]').each(function () { if ($this.quiz.utils.isEnabled($(this))) { - console.log('click ', $(this)); $(this).get(0).click(); return true; } diff --git a/js/quiz.js b/js/quiz.js index 0d08fe4..2eae95b 100644 --- a/js/quiz.js +++ b/js/quiz.js @@ -58,7 +58,7 @@ Quiz.prototype = { $('#quiz').addClass('ready'); } - console.log(state); + console.log('init state : ', state); if (state.q === undefined || state.q === -1) { // Afficher l'écran d'introduction et lancer l'animation @@ -70,7 +70,7 @@ Quiz.prototype = { for (i = 0; i - 1 < state.q; i++) { this.score.setAnswer(i, state.a[i]); } - this.screens.showScreen('q-' + i, callback); + this.screens.showScreen('q-' + (state.q + 1), callback); } this.progressbar.update(); }, diff --git a/js/quiz.resize.js b/js/quiz.resize.js index 91da404..1584e88 100644 --- a/js/quiz.resize.js +++ b/js/quiz.resize.js @@ -11,6 +11,9 @@ function QuizResize(quiz) { QuizResize.prototype = { + /** + * If the quiz is opened in a popup (it occurs often in LMS), try to resize it to its natural desktop size + */ resizePopup: function () { if (window.opener === null) { return; @@ -22,17 +25,17 @@ QuizResize.prototype = { let decorationHeight = window.outerHeight - window.innerHeight; let decorationWidth = window.outerWidth - window.innerWidth; - window.resizeTo(Math.min(screen.width, this.desktopWidth+decorationWidth), Math.min(screen.height, this.desktopHeight + decorationHeight)); + window.resizeTo(Math.min(screen.width, this.desktopWidth + decorationWidth), Math.min(screen.height, this.desktopHeight + decorationHeight)); }, measureSizes: function () { this.ww = $(window).width(); this.hh = $(window).height(); this.ratio = this.ww / this.hh; - }, resize: function () { - this.measureSizes(); - + }, + resize: function () { + this.measureSizes(); this.updateViewport(); if (this.isMobile()) { diff --git a/js/quiz.score.js b/js/quiz.score.js index 972d0ac..dec9675 100644 --- a/js/quiz.score.js +++ b/js/quiz.score.js @@ -150,7 +150,7 @@ QuizScore.prototype = { getCurrentState: function () { return { - q: this.lastAnsweredQuestion + 1, a: this.answers + q: this.lastAnsweredQuestion, a: this.answers }; } }; diff --git a/js/quiz.utils.js b/js/quiz.utils.js index 473512e..66a3215 100644 --- a/js/quiz.utils.js +++ b/js/quiz.utils.js @@ -24,7 +24,6 @@ QuizUtils.prototype = { if ($(e).hasClass('disabled') || $(e).closest('.disabled').length > 0) { return false; } - console.log('is enabled', e); return true; }, -- 2.39.5