|
|
@ -42,11 +42,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
' <% 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">' +
|
|
|
|
|
|
|
|
' <a href="#" ' +
|
|
|
|
|
|
|
|
' class="progress-dot unanswered<%' +
|
|
|
|
|
|
|
|
' if (disableBackwardsNavigation) { %> disabled <% } %>"' +
|
|
|
|
' aria-label="<%=' +
|
|
|
|
' aria-label="<%=' +
|
|
|
|
' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' +
|
|
|
|
' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' +
|
|
|
|
' + ", " + texts.unansweredText' +
|
|
|
|
' + ", " + texts.unansweredText %>" tabindex="-1" ' +
|
|
|
|
' %>" tabindex="-1"></a></li>' +
|
|
|
|
' <% if (disableBackwardsNavigation) { %> aria-disabled="true" <% } %>' +
|
|
|
|
|
|
|
|
' ></a>' +
|
|
|
|
|
|
|
|
' </li>' +
|
|
|
|
' <% } %>' +
|
|
|
|
' <% } %>' +
|
|
|
|
' </div>' +
|
|
|
|
' </div>' +
|
|
|
|
' <% } else if (progressType == "textual") { %>' +
|
|
|
|
' <% } else if (progressType == "textual") { %>' +
|
|
|
@ -131,7 +136,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
var showingSolutions = false;
|
|
|
|
var showingSolutions = false;
|
|
|
|
contentData = contentData || {};
|
|
|
|
contentData = contentData || {};
|
|
|
|
var answerIndex;
|
|
|
|
var answerIndex;
|
|
|
|
if (contentData.previousState) {
|
|
|
|
if (contentData.previousState && contentData.previousState.progress) {
|
|
|
|
currentQuestion = contentData.previousState.progress;
|
|
|
|
currentQuestion = contentData.previousState.progress;
|
|
|
|
answerIndex = contentData.previousState.order;
|
|
|
|
answerIndex = contentData.previousState.order;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -332,6 +337,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
for (var i = 0; i < questionInstances.length; i++) {
|
|
|
|
for (var i = 0; i < questionInstances.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
// Enable back and forth navigation in solution mode
|
|
|
|
// Enable back and forth navigation in solution mode
|
|
|
|
|
|
|
|
toggleDotsNavigation(true);
|
|
|
|
if (i < questionInstances.length - 1) {
|
|
|
|
if (i < questionInstances.length - 1) {
|
|
|
|
questionInstances[i].showButton('next');
|
|
|
|
questionInstances[i].showButton('next');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -352,6 +358,20 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 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.
|
|
|
@ -365,6 +385,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
|
|
|
|
|
|
|
|
// Hide back and forth navigation in normal mode
|
|
|
|
// Hide back and forth navigation in normal mode
|
|
|
|
if (params.disableBackwardsNavigation) {
|
|
|
|
if (params.disableBackwardsNavigation) {
|
|
|
|
|
|
|
|
toggleDotsNavigation(false);
|
|
|
|
|
|
|
|
|
|
|
|
// Check if first question is answered by default
|
|
|
|
// Check if first question is answered by default
|
|
|
|
if (i === 0 && questionInstances[i].getAnswerGiven()) {
|
|
|
|
if (i === 0 && questionInstances[i].getAnswerGiven()) {
|
|
|
|
questionInstances[i].showButton('next');
|
|
|
|
questionInstances[i].showButton('next');
|
|
|
@ -550,9 +572,10 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
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 () {
|
|
|
@ -568,7 +591,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
|
|
|
|
|
|
|
|
// 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 = {
|
|
|
@ -593,7 +616,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
@ -878,7 +901,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
@ -886,6 +909,15 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -980,18 +1012,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the complete state of question set and sub-content
|
|
|
|
* Returns the complete state of question set and sub-content
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @returns {Object}
|
|
|
|
* @returns {Object} current state
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
this.getCurrentState = function () {
|
|
|
|
this.getCurrentState = function () {
|
|
|
|
var state = {
|
|
|
|
return {
|
|
|
|
progress: currentQuestion,
|
|
|
|
progress: showingSolutions ? questionInstances.length - 1 : currentQuestion,
|
|
|
|
answers: questionInstances.map(function (qi) {
|
|
|
|
answers: questionInstances.map(function (qi) {
|
|
|
|
return qi.getCurrentState();
|
|
|
|
return qi.getCurrentState();
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
order: idMap
|
|
|
|
order: idMap
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|