diff --git a/.gitignore b/.gitignore
index e266972..c30f2fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*~
-/nbproject/private/
\ No newline at end of file
+/nbproject/private/
+.idea
\ No newline at end of file
diff --git a/css/questionset.css b/css/questionset.css
index 90cf581..5f07c33 100644
--- a/css/questionset.css
+++ b/css/questionset.css
@@ -52,7 +52,12 @@
background: #fff;
background: #cecece;
}
-.progress-dot:hover {
+
+.progress-dot.disabled {
+ cursor: default;
+}
+
+.progress-dot:not(.disabled):hover {
box-shadow: 0 0 0.5em #c7c7c7;
}
.progress-dot.answered {
@@ -61,6 +66,11 @@
.progress-dot.current {
background: #285585;
}
+
+.progress-dot.disabled:focus {
+ outline: none
+}
+
.progress-dot:focus {
outline-color: rgb(40, 130, 211);
outline-width: thin;
diff --git a/js/questionset.js b/js/questionset.js
index 2d2f6d7..8843084 100644
--- a/js/questionset.js
+++ b/js/questionset.js
@@ -42,11 +42,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
' <% if (progressType == "dots") { %>' +
'
' +
' <% for (var i=0; i' +
- ' - " tabindex="-1">
' +
+ ' - ' +
+ ' " tabindex="-1" ' +
+ ' <% if (disableBackwardsNavigation) { %> aria-disabled="true" <% } %>' +
+ ' >' +
+ '
' +
' <% } %>' +
' ' +
' <% } else if (progressType == "textual") { %>' +
@@ -131,7 +136,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var showingSolutions = false;
contentData = contentData || {};
var answerIndex;
- if (contentData.previousState) {
+ if (contentData.previousState && contentData.previousState.progress) {
currentQuestion = contentData.previousState.progress;
answerIndex = contentData.previousState.order;
}
@@ -332,6 +337,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
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');
}
@@ -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.
* Used for contracts with integrated content.
@@ -365,6 +385,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// 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');
@@ -550,9 +572,10 @@ H5P.QuestionSet = function (options, contentId, contentData) {
label += ', ' + texts.currentQuestionText;
}
+ var disabledTabindex = params.disableBackwardsNavigation && !showingSolutions;
$el.toggleClass('current', isCurrent)
.attr('aria-label', label)
- .attr('tabindex', isCurrent ? 0 : -1);
+ .attr('tabindex', isCurrent && !disabledTabindex ? 0 : -1);
};
var _displayEndGame = function () {
@@ -568,7 +591,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Get total score.
var finals = self.getScore();
- var totals = self.totalScore();
+ var totals = self.getMaxScore();
var scoreString = params.endGame.scoreString.replace("@score", finals).replace("@total", totals);
var success = ((100 * finals / totals) >= params.passPercentage);
var eventData = {
@@ -593,7 +616,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
};
var displayResults = function () {
- self.triggerXAPICompleted(self.getScore(), self.totalScore(), success);
+ self.triggerXAPICompleted(self.getScore(), self.getMaxScore(), success);
var eparams = {
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.
- this.totalScore = function () {
+ this.getMaxScore = function () {
var score = 0;
for (var i = questionInstances.length - 1; i >= 0; i--) {
score += questionInstances[i].getMaxScore();
@@ -886,6 +909,15 @@ H5P.QuestionSet = function (options, contentId, contentData) {
return score;
};
+
+ /**
+ * @deprecated since version 1.9.2
+ * @returns {number}
+ */
+ this.totalScore = function () {
+ return this.getMaxScore();
+ };
+
/**
* 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 {Object}
+ * @returns {Object} current state
*/
this.getCurrentState = function () {
- var state = {
- progress: currentQuestion,
+ return {
+ progress: showingSolutions ? questionInstances.length - 1 : currentQuestion,
answers: questionInstances.map(function (qi) {
return qi.getCurrentState();
}),
order: idMap
};
-
- return state;
};
};
diff --git a/semantics.json b/semantics.json
index 1da7d12..91ef9e0 100644
--- a/semantics.json
+++ b/semantics.json
@@ -114,7 +114,8 @@
"H5P.DragQuestion 1.7",
"H5P.Blanks 1.7",
"H5P.MarkTheWords 1.6",
- "H5P.DragText 1.5"
+ "H5P.DragText 1.5",
+ "H5P.TrueFalse 1.0"
]
}
},