Reset individual questions on retry.

Remove finish button if a question is reset.
Remove dot styling if a question is reset.
HFJ-2044
pull/5/head
Thomas Marstrander 2016-06-28 12:29:15 +02:00
parent 7bcd2472ba
commit 917a8ed3c4
1 changed files with 15 additions and 3 deletions

View File

@ -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');
}