From 917a8ed3c471b53c060b69c3a967e3928e166a78 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 28 Jun 2016 12:29:15 +0200 Subject: [PATCH] Reset individual questions on retry. Remove finish button if a question is reset. Remove dot styling if a question is reset. HFJ-2044 --- js/questionset.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 079876c..4b9e440 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -180,9 +180,14 @@ H5P.QuestionSet = function (options, contentId) { answered = answered && (questionInstances[i]).getAnswerGiven(); } - if (currentQuestion === (params.questions.length - 1) && answered && + if (currentQuestion === (params.questions.length - 1) && questionInstances[currentQuestion]) { - questionInstances[currentQuestion].showButton('finish'); + if (answered) { + questionInstances[currentQuestion].showButton('finish'); + } + else { + questionInstances[currentQuestion].hideButton('finish'); + } } }; @@ -222,7 +227,14 @@ H5P.QuestionSet = function (options, contentId) { } else { // Set currentNess - $('.progress-dot.current', $myDom).removeClass('current'); + var $currentQuestion = $('.progress-dot.current', $myDom); + var previousQuestion = $currentQuestion.index(); + $currentQuestion.removeClass('current'); + if (previousQuestion >= 0 && !questionInstances[previousQuestion].getAnswerGiven()) { + $currentQuestion + .removeClass('answered') + .addClass('unanswered'); + } $('.progress-dot:eq(' + questionNumber +')', $myDom).addClass('current'); }