commit
5254473da2
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
|
.idea
|
|
@ -52,7 +52,12 @@
|
||||||
background: #fff;
|
background: #fff;
|
||||||
background: #cecece;
|
background: #cecece;
|
||||||
}
|
}
|
||||||
.progress-dot:hover {
|
|
||||||
|
.progress-dot.disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-dot:not(.disabled):hover {
|
||||||
box-shadow: 0 0 0.5em #c7c7c7;
|
box-shadow: 0 0 0.5em #c7c7c7;
|
||||||
}
|
}
|
||||||
.progress-dot.answered {
|
.progress-dot.answered {
|
||||||
|
@ -61,6 +66,11 @@
|
||||||
.progress-dot.current {
|
.progress-dot.current {
|
||||||
background: #285585;
|
background: #285585;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progress-dot.disabled:focus {
|
||||||
|
outline: none
|
||||||
|
}
|
||||||
|
|
||||||
.progress-dot:focus {
|
.progress-dot:focus {
|
||||||
outline-color: rgb(40, 130, 211);
|
outline-color: rgb(40, 130, 211);
|
||||||
outline-width: thin;
|
outline-width: thin;
|
||||||
|
@ -151,6 +161,12 @@
|
||||||
width: 2.1875em;
|
width: 2.1875em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h5p-question .h5p-question-prev.truncated,
|
||||||
|
.h5p-question .h5p-question-next.truncated {
|
||||||
|
padding: 0;
|
||||||
|
line-height: 2.2335em;
|
||||||
|
}
|
||||||
|
|
||||||
.h5p-question .h5p-question-next,
|
.h5p-question .h5p-question-next,
|
||||||
.h5p-question .h5p-question-finish {
|
.h5p-question .h5p-question-finish {
|
||||||
margin: 0 0 1.5em 0.5em;
|
margin: 0 0 1.5em 0.5em;
|
||||||
|
|
|
@ -8,11 +8,12 @@ var H5P = H5P || {};
|
||||||
*
|
*
|
||||||
* @param {Array} options
|
* @param {Array} options
|
||||||
* @param {int} contentId
|
* @param {int} contentId
|
||||||
|
* @param {Object} contentData
|
||||||
* @returns {H5P.QuestionSet} Instance
|
* @returns {H5P.QuestionSet} Instance
|
||||||
*/
|
*/
|
||||||
H5P.QuestionSet = function (options, contentId) {
|
H5P.QuestionSet = function (options, contentId, contentData) {
|
||||||
if (!(this instanceof H5P.QuestionSet)) {
|
if (!(this instanceof H5P.QuestionSet)) {
|
||||||
return new H5P.QuestionSet(options, contentId);
|
return new H5P.QuestionSet(options, contentId, contentData);
|
||||||
}
|
}
|
||||||
H5P.EventDispatcher.call(this);
|
H5P.EventDispatcher.call(this);
|
||||||
var $ = H5P.jQuery;
|
var $ = H5P.jQuery;
|
||||||
|
@ -41,11 +42,16 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
' <% if (progressType == "dots") { %>' +
|
' <% if (progressType == "dots") { %>' +
|
||||||
' <ul class="dots-container" role="navigation">' +
|
' <ul class="dots-container" role="navigation">' +
|
||||||
' <% for (var i=0; i<questions.length; i++) { %>' +
|
' <% for (var i=0; i<questions.length; i++) { %>' +
|
||||||
' <li class="progress-item"><a href="#" class="progress-dot unanswered" ' +
|
' <li class="progress-item">' +
|
||||||
' aria-label="<%=' +
|
' <a href="#" ' +
|
||||||
' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' +
|
' class="progress-dot unanswered<%' +
|
||||||
' + ", " + texts.unansweredText' +
|
' if (disableBackwardsNavigation) { %> disabled <% } %>"' +
|
||||||
' %>" tabindex="-1"></a></li>' +
|
' aria-label="<%=' +
|
||||||
|
' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' +
|
||||||
|
' + ", " + texts.unansweredText %>" tabindex="-1" ' +
|
||||||
|
' <% if (disableBackwardsNavigation) { %> aria-disabled="true" <% } %>' +
|
||||||
|
' ></a>' +
|
||||||
|
' </li>' +
|
||||||
' <% } %>' +
|
' <% } %>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' <% } else if (progressType == "textual") { %>' +
|
' <% } else if (progressType == "textual") { %>' +
|
||||||
|
@ -76,7 +82,6 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
randomOrder: false,
|
|
||||||
initialQuestion: 0,
|
initialQuestion: 0,
|
||||||
progressType: 'dots',
|
progressType: 'dots',
|
||||||
passPercentage: 50,
|
passPercentage: 50,
|
||||||
|
@ -113,21 +118,109 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
retryButtonText: 'Retry',
|
retryButtonText: 'Retry',
|
||||||
showAnimations: false,
|
showAnimations: false,
|
||||||
skipButtonText: 'Skip video'
|
skipButtonText: 'Skip video'
|
||||||
}
|
},
|
||||||
|
disableBackwardsNavigation: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var template = new EJS({text: texttemplate});
|
var template = new EJS({text: texttemplate});
|
||||||
var endTemplate = new EJS({text: resulttemplate});
|
var endTemplate = new EJS({text: resulttemplate});
|
||||||
var params = $.extend(true, {}, defaults, options);
|
var params = $.extend(true, {}, defaults, options);
|
||||||
|
|
||||||
|
var poolOrder; // Order of questions in a pool
|
||||||
var currentQuestion = 0;
|
var currentQuestion = 0;
|
||||||
var questionInstances = [];
|
var questionInstances = [];
|
||||||
|
var questionOrder; //Stores order of questions to allow resuming of question set
|
||||||
var $myDom;
|
var $myDom;
|
||||||
var scoreBar;
|
var scoreBar;
|
||||||
var up;
|
var up;
|
||||||
renderSolutions = false;
|
var renderSolutions = false;
|
||||||
|
var showingSolutions = false;
|
||||||
|
contentData = contentData || {};
|
||||||
|
|
||||||
|
// Bring question set up to date when resuming
|
||||||
|
if (contentData.previousState) {
|
||||||
|
if (contentData.previousState.progress) {
|
||||||
|
currentQuestion = contentData.previousState.progress;
|
||||||
|
}
|
||||||
|
questionOrder = contentData.previousState.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a pool of questions if necessary
|
||||||
|
/**
|
||||||
|
* Randomizes questions in an array and updates an array containing their order
|
||||||
|
* @param {array} questions
|
||||||
|
* @param {array} questionOrder
|
||||||
|
* @return {Object.<array, array>} questionOrdering
|
||||||
|
*/
|
||||||
|
var randomizeQuestionOrdering = function (questions, questionOrder) {
|
||||||
|
|
||||||
|
// Save the original order of the questions in a multidimensional array [[question0,0],[question1,1]...
|
||||||
|
var questionOrdering = questions.map(function(questionInstance, index) { return [questionInstance, index] });
|
||||||
|
|
||||||
|
// Shuffle the multidimensional array
|
||||||
|
questionOrdering = H5P.shuffleArray(questionOrdering);
|
||||||
|
|
||||||
|
// Retrieve question objects from the first index
|
||||||
|
var questions = [];
|
||||||
|
for (var i = 0; i < questionOrdering.length; i++) {
|
||||||
|
questions[i] = questionOrdering[i][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the new shuffled order from the second index
|
||||||
|
var newOrder = [];
|
||||||
|
for (var i = 0; i< questionOrdering.length; i++) {
|
||||||
|
|
||||||
|
// Use a previous order if it exists
|
||||||
|
if(questionOrder) {
|
||||||
|
newOrder[i] = questionOrder[questionOrdering[i][1]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newOrder[i] = questionOrdering[i][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the questions in their new order *with* their new order
|
||||||
|
return {
|
||||||
|
questions: questions,
|
||||||
|
questionOrder: newOrder
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a pool (a subset) of questions if necessary
|
||||||
|
if (params.poolSize && params.poolSize < params.questions.length) {
|
||||||
|
|
||||||
|
// If a previous pool exists, recreate it
|
||||||
|
if(contentData.previousState && contentData.previousState.poolOrder) {
|
||||||
|
poolOrder = contentData.previousState.poolOrder;
|
||||||
|
|
||||||
|
// Recreate the pool from the saved data
|
||||||
|
var pool = [];
|
||||||
|
for (var i = 0; i < poolOrder.length; i++) {
|
||||||
|
pool[i] = params.questions[poolOrder[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace original questions with just the ones in the pool
|
||||||
|
params.questions = pool;
|
||||||
|
}
|
||||||
|
else { // Otherwise create a new pool
|
||||||
|
// Randomize and get the results
|
||||||
|
var poolResult = randomizeQuestionOrdering(params.questions, poolOrder);
|
||||||
|
var poolQuestions = poolResult.questions;
|
||||||
|
poolOrder = poolResult.questionOrder;
|
||||||
|
|
||||||
|
// Discard extra questions
|
||||||
|
|
||||||
|
poolQuestions = poolQuestions.slice(0, params.poolSize);
|
||||||
|
poolOrder = poolOrder.slice(0, params.poolSize);
|
||||||
|
|
||||||
|
// Replace original questions with just the ones in the pool
|
||||||
|
params.questions = poolQuestions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the html template for the question container
|
||||||
var $template = $(template.render(params));
|
var $template = $(template.render(params));
|
||||||
|
|
||||||
// Set overrides for questions
|
// Set overrides for questions
|
||||||
var override;
|
var override;
|
||||||
if (params.override.showSolutionButton || params.override.retryButton) {
|
if (params.override.showSolutionButton || params.override.retryButton) {
|
||||||
|
@ -147,7 +240,16 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
|
|
||||||
// Instantiate question instances
|
// Instantiate question instances
|
||||||
for (var i = 0; i < params.questions.length; i++) {
|
for (var i = 0; i < params.questions.length; i++) {
|
||||||
var question = params.questions[i];
|
|
||||||
|
var question;
|
||||||
|
// If a previous order exists, use it
|
||||||
|
if (questionOrder !== undefined) {
|
||||||
|
question = params.questions[questionOrder[i]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Use a generic order when initialzing for the first time
|
||||||
|
question = params.questions[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (override) {
|
if (override) {
|
||||||
// Extend subcontent with the overrided settings.
|
// Extend subcontent with the overrided settings.
|
||||||
|
@ -158,8 +260,12 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
question.params.overrideSettings = question.params.overrideSettings || {};
|
question.params.overrideSettings = question.params.overrideSettings || {};
|
||||||
question.params.overrideSettings.$confirmationDialogParent = $template.last();
|
question.params.overrideSettings.$confirmationDialogParent = $template.last();
|
||||||
question.params.overrideSettings.instance = this;
|
question.params.overrideSettings.instance = this;
|
||||||
|
var hasAnswers = contentData.previousState && contentData.previousState.answers;
|
||||||
var questionInstance = H5P.newRunnable(question, contentId, undefined, undefined, {parent: self});
|
var questionInstance = H5P.newRunnable(question, contentId, undefined, undefined,
|
||||||
|
{
|
||||||
|
previousState: hasAnswers ? contentData.previousState.answers[i] : undefined,
|
||||||
|
parent: self
|
||||||
|
});
|
||||||
questionInstance.on('resize', function () {
|
questionInstance.on('resize', function () {
|
||||||
up = true;
|
up = true;
|
||||||
self.trigger('resize');
|
self.trigger('resize');
|
||||||
|
@ -167,6 +273,13 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
questionInstances.push(questionInstance);
|
questionInstances.push(questionInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Randomize questions only on instantiation
|
||||||
|
if (params.randomQuestions && contentData.previousState === undefined) {
|
||||||
|
var result = randomizeQuestionOrdering(questionInstances,questionOrder);
|
||||||
|
questionInstances = result.questions;
|
||||||
|
questionOrder = result.questionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
// Resize all interactions on resize
|
// Resize all interactions on resize
|
||||||
self.on('resize', function () {
|
self.on('resize', function () {
|
||||||
if (up) {
|
if (up) {
|
||||||
|
@ -182,6 +295,17 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
|
|
||||||
// Update button state.
|
// Update button state.
|
||||||
var _updateButtons = function () {
|
var _updateButtons = function () {
|
||||||
|
// Verify that current question is answered when backward nav is disabled
|
||||||
|
if (params.disableBackwardsNavigation) {
|
||||||
|
if (questionInstances[currentQuestion].getAnswerGiven()
|
||||||
|
&& questionInstances.length-1 !== currentQuestion) {
|
||||||
|
questionInstances[currentQuestion].showButton('next');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
questionInstances[currentQuestion].hideButton('next');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var answered = true;
|
var answered = true;
|
||||||
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
||||||
answered = answered && (questionInstances[i]).getAnswerGiven();
|
answered = answered && (questionInstances[i]).getAnswerGiven();
|
||||||
|
@ -271,7 +395,18 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
var showSolutions = function () {
|
var showSolutions = function () {
|
||||||
|
showingSolutions = true;
|
||||||
for (var i = 0; i < questionInstances.length; i++) {
|
for (var i = 0; i < questionInstances.length; i++) {
|
||||||
|
|
||||||
|
// Enable back and forth navigation in solution mode
|
||||||
|
toggleDotsNavigation(true);
|
||||||
|
if (i < questionInstances.length - 1) {
|
||||||
|
questionInstances[i].showButton('next');
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
questionInstances[i].showButton('prev');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Do not read answers
|
// Do not read answers
|
||||||
questionInstances[i].toggleReadSpeaker(true);
|
questionInstances[i].toggleReadSpeaker(true);
|
||||||
|
@ -285,15 +420,45 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles whether dots are enabled for navigation
|
||||||
|
*/
|
||||||
|
var toggleDotsNavigation = function (enable) {
|
||||||
|
$('.progress-dot', $myDom).each(function () {
|
||||||
|
$(this).toggleClass('disabled', !enable);
|
||||||
|
$(this).attr('aria-disabled', enable ? 'false' : 'true');
|
||||||
|
// Remove tabindex
|
||||||
|
if (!enable) {
|
||||||
|
$(this).attr('tabindex', '-1');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the task and every subcontent task.
|
* Resets the task and every subcontent task.
|
||||||
* Used for contracts with integrated content.
|
* Used for contracts with integrated content.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
var resetTask = function () {
|
var resetTask = function () {
|
||||||
|
showingSolutions = false;
|
||||||
for (var i = 0; i < questionInstances.length; i++) {
|
for (var i = 0; i < questionInstances.length; i++) {
|
||||||
try {
|
try {
|
||||||
questionInstances[i].resetTask();
|
questionInstances[i].resetTask();
|
||||||
|
|
||||||
|
// Hide back and forth navigation in normal mode
|
||||||
|
if (params.disableBackwardsNavigation) {
|
||||||
|
toggleDotsNavigation(false);
|
||||||
|
|
||||||
|
// Check if first question is answered by default
|
||||||
|
if (i === 0 && questionInstances[i].getAnswerGiven()) {
|
||||||
|
questionInstances[i].showButton('next');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
questionInstances[i].hideButton('next');
|
||||||
|
}
|
||||||
|
|
||||||
|
questionInstances[i].hideButton('prev');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
H5P.error("subcontent does not contain a valid resetTask function");
|
H5P.error("subcontent does not contain a valid resetTask function");
|
||||||
|
@ -311,6 +476,11 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
|
|
||||||
//Force the last page to be reRendered
|
//Force the last page to be reRendered
|
||||||
rendered = false;
|
rendered = false;
|
||||||
|
|
||||||
|
if (params.randomQuestions) {
|
||||||
|
randomizeQuestions();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var rendered = false;
|
var rendered = false;
|
||||||
|
@ -319,13 +489,77 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
rendered = false;
|
rendered = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Randomizes question instances
|
||||||
|
*/
|
||||||
|
var randomizeQuestions = function () {
|
||||||
|
|
||||||
|
var result = randomizeQuestionOrdering(questionInstances,questionOrder);
|
||||||
|
questionInstances = result.questions;
|
||||||
|
questionOrder = result.questionOrder;
|
||||||
|
|
||||||
|
// Find all question containers and detach questions from them
|
||||||
|
$('.question-container', $myDom).each(function (){
|
||||||
|
$(this).children().detach();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reattach questions and their buttons in the new order
|
||||||
|
for (var i = 0; i < questionInstances.length; i++) {
|
||||||
|
|
||||||
|
var question = questionInstances[i];
|
||||||
|
|
||||||
|
// Make sure styles are not being added twice
|
||||||
|
$('.question-container:eq(' + i + ')', $myDom).attr('class', 'question-container');
|
||||||
|
|
||||||
|
question.attach($('.question-container:eq(' + i + ')', $myDom));
|
||||||
|
|
||||||
|
//Show buttons if necessary
|
||||||
|
if(questionInstances[questionInstances.length -1] === question
|
||||||
|
&& question.hasButton('finish')) {
|
||||||
|
question.showButton('finish');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(questionInstances[questionInstances.length -1] !== question
|
||||||
|
&& question.hasButton('next')) {
|
||||||
|
question.showButton('next');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(questionInstances[0] !== question
|
||||||
|
&& question.hasButton('prev')
|
||||||
|
&& !params.disableBackwardsNavigation) {
|
||||||
|
question.showButton('prev');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide relevant buttons since the order has changed
|
||||||
|
if (questionInstances[0] === question) {
|
||||||
|
question.hideButton('prev');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionInstances[questionInstances.length-1] === question) {
|
||||||
|
question.hideButton('next');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionInstances[questionInstances.length-1] !== question) {
|
||||||
|
question.hideButton('finish');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var moveQuestion = function (direction) {
|
var moveQuestion = function (direction) {
|
||||||
|
if (params.disableBackwardsNavigation && !questionInstances[currentQuestion].getAnswerGiven()) {
|
||||||
|
questionInstances[currentQuestion].hideButton('next');
|
||||||
|
questionInstances[currentQuestion].hideButton('finish');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_stopQuestion(currentQuestion);
|
_stopQuestion(currentQuestion);
|
||||||
if (currentQuestion + direction >= questionInstances.length) {
|
if (currentQuestion + direction >= questionInstances.length) {
|
||||||
_displayEndGame();
|
_displayEndGame();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Allow movement if backward navigation enabled or answer given
|
||||||
_showQuestion(currentQuestion + direction);
|
_showQuestion(currentQuestion + direction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -377,9 +611,10 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
label += ', ' + texts.currentQuestionText;
|
label += ', ' + texts.currentQuestionText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var disabledTabindex = params.disableBackwardsNavigation && !showingSolutions;
|
||||||
$el.toggleClass('current', isCurrent)
|
$el.toggleClass('current', isCurrent)
|
||||||
.attr('aria-label', label)
|
.attr('aria-label', label)
|
||||||
.attr('tabindex', isCurrent ? 0 : -1);
|
.attr('tabindex', isCurrent && !disabledTabindex ? 0 : -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _displayEndGame = function () {
|
var _displayEndGame = function () {
|
||||||
|
@ -395,7 +630,7 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
|
|
||||||
// Get total score.
|
// Get total score.
|
||||||
var finals = self.getScore();
|
var finals = self.getScore();
|
||||||
var totals = self.totalScore();
|
var totals = self.getMaxScore();
|
||||||
var scoreString = params.endGame.scoreString.replace("@score", finals).replace("@total", totals);
|
var scoreString = params.endGame.scoreString.replace("@score", finals).replace("@total", totals);
|
||||||
var success = ((100 * finals / totals) >= params.passPercentage);
|
var success = ((100 * finals / totals) >= params.passPercentage);
|
||||||
var eventData = {
|
var eventData = {
|
||||||
|
@ -420,7 +655,7 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var displayResults = function () {
|
var displayResults = function () {
|
||||||
self.triggerXAPICompleted(self.getScore(), self.totalScore(), success);
|
self.triggerXAPICompleted(self.getScore(), self.getMaxScore(), success);
|
||||||
|
|
||||||
var eparams = {
|
var eparams = {
|
||||||
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
|
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
|
||||||
|
@ -511,7 +746,7 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
});
|
});
|
||||||
video.play();
|
video.play();
|
||||||
|
|
||||||
if (params.endGame.skipButtonText) {
|
if (params.endGame.skippable) {
|
||||||
$('<a class="h5p-joubelui-button h5p-button skip">' + params.endGame.skipButtonText + '</a>').click(function () {
|
$('<a class="h5p-joubelui-button h5p-button skip">' + params.endGame.skipButtonText + '</a>').click(function () {
|
||||||
video.pause();
|
video.pause();
|
||||||
$videoContainer.hide();
|
$videoContainer.hide();
|
||||||
|
@ -577,28 +812,27 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
// Listen for image resize
|
// Listen for image resize
|
||||||
registerImageLoadedListener(question);
|
registerImageLoadedListener(question);
|
||||||
|
|
||||||
// Add next/finish button
|
// Add finish button
|
||||||
if (questionInstances[questionInstances.length -1] === question) {
|
question.addButton('finish', params.texts.finishButton,
|
||||||
|
moveQuestion.bind(this, 1), false);
|
||||||
|
|
||||||
// Add finish question set button
|
// Add next button
|
||||||
question.addButton('finish', params.texts.finishButton,
|
question.addButton('next', '', moveQuestion.bind(this, 1),
|
||||||
moveQuestion.bind(this, 1), false);
|
!params.disableBackwardsNavigation || !!question.getAnswerGiven(), {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Add next question button
|
|
||||||
question.addButton('next', '', moveQuestion.bind(this, 1), true, {
|
|
||||||
href: '#', // Use href since this is a navigation button
|
href: '#', // Use href since this is a navigation button
|
||||||
'aria-label': params.texts.nextButton
|
'aria-label': params.texts.nextButton
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Add previous question button
|
// Add previous button
|
||||||
if (questionInstances[0] !== question) {
|
question.addButton('prev', '', moveQuestion.bind(this, -1),
|
||||||
question.addButton('prev', '', moveQuestion.bind(this, -1), true, {
|
!(questionInstances[0] === question || params.disableBackwardsNavigation), {
|
||||||
href: '#', // Use href since this is a navigation button
|
href: '#', // Use href since this is a navigation button
|
||||||
'aria-label': params.texts.prevButton
|
'aria-label': params.texts.prevButton
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide next button if it is the last question
|
||||||
|
if(questionInstances[questionInstances.length -1] === question) {
|
||||||
|
question.hideButton('next');
|
||||||
}
|
}
|
||||||
|
|
||||||
question.on('xAPI', function (event) {
|
question.on('xAPI', function (event) {
|
||||||
|
@ -619,6 +853,9 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
}
|
}
|
||||||
event.data.statement.context.extensions['http://id.tincanapi.com/extension/ending-point'] = currentQuestion + 1;
|
event.data.statement.context.extensions['http://id.tincanapi.com/extension/ending-point'] = currentQuestion + 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mark question if answered
|
||||||
|
toggleAnsweredDot(i, question.getAnswerGiven());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow other libraries to add transitions after the questions have been inited
|
// Allow other libraries to add transitions after the questions have been inited
|
||||||
|
@ -637,9 +874,13 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
* @param {Object} [event]
|
* @param {Object} [event]
|
||||||
*/
|
*/
|
||||||
var handleProgressDotClick = function (event) {
|
var handleProgressDotClick = function (event) {
|
||||||
|
// Disable dots when backward nav disabled
|
||||||
|
event.preventDefault();
|
||||||
|
if (params.disableBackwardsNavigation && !showingSolutions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_stopQuestion(currentQuestion);
|
_stopQuestion(currentQuestion);
|
||||||
_showQuestion($(this).parent().index());
|
_showQuestion($(this).parent().index());
|
||||||
event.preventDefault();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set event listeners.
|
// Set event listeners.
|
||||||
|
@ -675,12 +916,14 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Hide all but initial Question.
|
// Hide all but current question
|
||||||
_showQuestion(params.initialQuestion, true);
|
_showQuestion(currentQuestion, true);
|
||||||
|
|
||||||
if (renderSolutions) {
|
if (renderSolutions) {
|
||||||
showSolutions();
|
showSolutions();
|
||||||
}
|
}
|
||||||
|
// Update buttons in case they have changed (restored user state)
|
||||||
|
_updateButtons();
|
||||||
|
|
||||||
this.trigger('resize');
|
this.trigger('resize');
|
||||||
|
|
||||||
|
@ -697,7 +940,7 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get total score possible for questionset.
|
// Get total score possible for questionset.
|
||||||
this.totalScore = function () {
|
this.getMaxScore = function () {
|
||||||
var score = 0;
|
var score = 0;
|
||||||
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
||||||
score += questionInstances[i].getMaxScore();
|
score += questionInstances[i].getMaxScore();
|
||||||
|
@ -705,6 +948,15 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
return score;
|
return score;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 1.9.2
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
this.totalScore = function () {
|
||||||
|
return this.getMaxScore();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gather copyright information for the current content.
|
* Gather copyright information for the current content.
|
||||||
*
|
*
|
||||||
|
@ -795,6 +1047,22 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
H5P.error(err);
|
H5P.error(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the complete state of question set and sub-content
|
||||||
|
*
|
||||||
|
* @returns {Object} current state
|
||||||
|
*/
|
||||||
|
this.getCurrentState = function () {
|
||||||
|
return {
|
||||||
|
progress: showingSolutions ? questionInstances.length - 1 : currentQuestion,
|
||||||
|
answers: questionInstances.map(function (qi) {
|
||||||
|
return qi.getCurrentState();
|
||||||
|
}),
|
||||||
|
order: questionOrder,
|
||||||
|
poolOrder: poolOrder
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
H5P.QuestionSet.prototype = Object.create(H5P.EventDispatcher.prototype);
|
H5P.QuestionSet.prototype = Object.create(H5P.EventDispatcher.prototype);
|
||||||
|
|
|
@ -103,6 +103,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Disable backwards navigation",
|
||||||
|
"description": "This option will only allow you to move forward in Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "انتهاء المسابقة",
|
"label": "انتهاء المسابقة",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -108,6 +108,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Disable backwards navigation",
|
||||||
|
"description": "This option will only allow you to move forward in Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Quiz beendet",
|
"label": "Quiz beendet",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -108,6 +108,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Disable backwards navigation",
|
||||||
|
"description": "This option will only allow you to move forward in Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Quiz terminé",
|
"label": "Quiz terminé",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -103,6 +103,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Disable backwards navigation",
|
||||||
|
"description": "This option will only allow you to move forward in Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Quiz terminato",
|
"label": "Quiz terminato",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -105,6 +105,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Slå av bakoverknapp",
|
||||||
|
"description": "Slå på for å nekte å gå tilbake i Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Spørsmålssett avslutning",
|
"label": "Spørsmålssett avslutning",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -105,6 +105,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Slå av bakoverknapp",
|
||||||
|
"description": "Slå på for å nekte å gå tilbake i Question Set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Spørsmålssett avslutning",
|
"label": "Spørsmålssett avslutning",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"description": "Put together a set of different questions that has to be solved. (Quiz)",
|
"description": "Put together a set of different questions that has to be solved. (Quiz)",
|
||||||
"contentType": "question",
|
"contentType": "question",
|
||||||
"majorVersion": 1,
|
"majorVersion": 1,
|
||||||
"minorVersion": 9,
|
"minorVersion": 10,
|
||||||
"patchVersion": 0,
|
"patchVersion": 0,
|
||||||
"embedTypes": [
|
"embedTypes": [
|
||||||
"iframe"
|
"iframe"
|
||||||
|
|
|
@ -114,7 +114,8 @@
|
||||||
"H5P.DragQuestion 1.7",
|
"H5P.DragQuestion 1.7",
|
||||||
"H5P.Blanks 1.7",
|
"H5P.Blanks 1.7",
|
||||||
"H5P.MarkTheWords 1.6",
|
"H5P.MarkTheWords 1.6",
|
||||||
"H5P.DragText 1.5"
|
"H5P.DragText 1.5",
|
||||||
|
"H5P.TrueFalse 1.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -193,6 +194,29 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "disableBackwardsNavigation",
|
||||||
|
"type": "boolean",
|
||||||
|
"label": "Disable backwards navigation",
|
||||||
|
"description": "This option will only allow you to move forward in Question Set",
|
||||||
|
"optional": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "randomQuestions",
|
||||||
|
"type": "boolean",
|
||||||
|
"label": "Randomize questions",
|
||||||
|
"description": "Enable to randomize the order of questions on display.",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "poolSize",
|
||||||
|
"type": "number",
|
||||||
|
"min": 1,
|
||||||
|
"label": "Number of questions to be shown:",
|
||||||
|
"description": "Create a randomized batch of questions from the total.",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "endGame",
|
"name": "endGame",
|
||||||
"type": "group",
|
"type": "group",
|
||||||
|
|
Loading…
Reference in New Issue