Change ordering of pool size check

pull/4/head^2
Timothy Lim 2016-10-21 08:38:13 +02:00
parent 3ac92b078b
commit 4f38f4d25b
1 changed files with 9 additions and 11 deletions

View File

@ -186,12 +186,19 @@ H5P.QuestionSet = function (options, contentId, contentData) {
questions:questions,
questionOrder:newOrder
};
}
// Create a pool (a subset) of questions if necessary
if (params.poolSize) {
// Sanitize input
if (params.poolSize > params.questions.length) {
poolSize = params.questions.length;
}
else {
poolSize = params.poolSize;
}
// If a previous pool exists, recreate it
if(contentData.previousState && contentData.previousState.poolOrder) {
poolOrder = contentData.previousState.poolOrder;
@ -209,14 +216,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Otherwise create a new pool
else {
// Sanitize input
if (params.poolSize > params.questions.length) {
poolSize = params.questions.length;
}
else {
poolSize = params.poolSize;
}
// Randomize and get the results
var poolResult = randomizeQuestionOrdering(params.questions, poolOrder);
poolQuestions = poolResult.questions;
@ -229,7 +228,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Replace original questions with just the ones in the pool
params.questions = poolQuestions;
}
}
// Create the html template for the question container