Prevent crashing JS.

pull/2/head
Frode Petterson 2015-09-25 10:57:16 +02:00
parent e1ce82fcf4
commit 439f850729
1 changed files with 9 additions and 6 deletions

View File

@ -143,7 +143,8 @@ H5P.QuestionSet = function (options, contentId) {
answered = answered && (questionInstances[i]).getAnswerGiven(); answered = answered && (questionInstances[i]).getAnswerGiven();
} }
if (currentQuestion === (params.questions.length - 1) && answered) { if (currentQuestion === (params.questions.length - 1) && answered &&
questionInstances[currentQuestion]) {
questionInstances[currentQuestion].showButton('finish'); questionInstances[currentQuestion].showButton('finish');
} }
}; };
@ -160,11 +161,13 @@ H5P.QuestionSet = function (options, contentId) {
// Hide all questions // Hide all questions
$('.question-container', $myDom).hide().eq(questionNumber).show(); $('.question-container', $myDom).hide().eq(questionNumber).show();
if (questionInstances[questionNumber]) {
// Trigger resize on question in case the size of the QS has changed. // Trigger resize on question in case the size of the QS has changed.
var instance = questionInstances[questionNumber]; var instance = questionInstances[questionNumber];
if (instance.$ !== undefined) { if (instance.$ !== undefined) {
instance.trigger('resize'); instance.trigger('resize');
} }
}
// Update progress indicator // Update progress indicator
// Test if current has been answered. // Test if current has been answered.