Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
b1d8e19
Fix invalid language files
fnoks Jan 3, 2022
3ab3eea
Fix making resetTask a public function
fnoks Jan 5, 2022
dad9bbe
Fix using public resetTask internally
fnoks Jan 5, 2022
058a129
JI-3031 Fix replace submit button for submit button Question set (#87)
ravimajithia Jan 5, 2022
030fbe2
Dinis Medeiros <[email protected]> updated Portuguese translati…
weblate Jan 9, 2022
af26454
Iñigo Zendegi Urzelai <[email protected]> updated Basque transla…
weblate Jan 9, 2022
107f1a6
joep jacobs <[email protected]> updated Dutch translation using We…
weblate Jan 9, 2022
c8fd4ff
German Valero <[email protected]> updated Spanish (Mexico) (es-MX) (es-…
weblate Jan 9, 2022
44657ad
Matīss Sīlis <[email protected]> updated Latvian translation usi…
weblate Jan 9, 2022
e7d24fc
Oliver Tacke <[email protected]> updated German translation using Web…
weblate Jan 9, 2022
b76f50f
German Valero <[email protected]> updated Spanish translation using Web…
weblate Jan 9, 2022
8eb0d9b
Fix invalid language file
fnoks Jan 18, 2022
5a4e174
Bump
fnoks Jan 18, 2022
f522684
Merge branch 'release'
fnoks Jan 19, 2022
efee7ac
Recursive bump
fnoks Jan 19, 2022
afbe387
Merge branch 'master' into release
fnoks Jan 19, 2022
956f6ef
JI-3168 Fix resume content for Question set when intro screen is enab…
ravimajithia Jan 31, 2022
5e301d6
JI-3165 Fix submit button not displayed
ravimajithia Jan 31, 2022
5e7b3ea
Update nl.json (#91)
icc Feb 1, 2022
710e187
Update fr.json (#92)
icc Feb 1, 2022
bf4eb30
Update ko.json
totoromaum Feb 1, 2022
0a8ad01
Merge pull request #88 from translate-h5p/weblate-h5p-h5p-question-set
fnoks Feb 3, 2022
362db2e
Merge pull request #93 from totoromaum/patch-2
fnoks Feb 3, 2022
f699989
Merge branch 'master' into release
fnoks Feb 3, 2022
2635116
Minor nump
fnoks Feb 3, 2022
c5df57c
Fix invalid language file
fnoks Feb 3, 2022
e41f069
Anonymous <[email protected]> updated Vietnamese translation using …
weblate Feb 6, 2022
2c74efa
Alex Gabilondo <[email protected]> updated Basque translation usin…
weblate Feb 6, 2022
b0e2e57
joep jacobs <[email protected]> updated Dutch translation using We…
weblate Feb 6, 2022
70ef854
Merge branch 'release'
fnoks Feb 20, 2022
1072725
JI-3240 Send actual que index in context when que randomized
Feb 22, 2022
a05dd00
JI-3236 Fix contrast ratio of progress dots
Feb 23, 2022
3fa8563
Merge pull request #96 from h5p/JI-3236-a11y-progress-dot-draker
j0kerZ Feb 23, 2022
ccb5534
Bump
fnoks Feb 25, 2022
ac11eff
Merge pull request #94 from translate-h5p/weblate-h5p-h5p-question-set
fnoks Feb 25, 2022
1a55298
Merge pull request #95 from h5p/JI-3240-question-send-actual-question…
fnoks Feb 25, 2022
ec04d89
Merge branch 'master' into release
fnoks Feb 25, 2022
defdc5e
Fix invalid language file
fnoks Feb 25, 2022
97fb62c
Merge branch 'release'
fnoks Mar 15, 2022
44c99f0
JI-3414 Fix autoplay (#97)
fnoks Apr 8, 2022
1e145e5
Recursive bump H5P.Audio + Video
fnoks Apr 11, 2022
2bcd2c5
Merge branch 'master' into release
fnoks Apr 11, 2022
baa2637
Merge branch 'release'
fnoks Apr 11, 2022
d914e0d
JI-3418 Fix QS: Submit button is show during Show Solution (#99)
ravimajithia Apr 26, 2022
499fb8c
Bump Essay
fnoks May 3, 2022
49b3f29
JI-3251 Add final score to announcer on end screen
May 4, 2022
b41cfef
JI-3251 Update translations for scoreBarLabel.
May 4, 2022
7cc1eda
Merge pull request #101 from h5p/JI-3251-Question-Set-A11y--NVDA-or-J…
ravimajithia May 6, 2022
2e8b12b
Revert "JI-3418 Fix QS: Submit button is show during Show Solution (#…
fnoks May 19, 2022
b1ba908
Iñigo Zendegi Urzelai <[email protected]> updated Basque transla…
weblate May 27, 2022
be6792d
Antonio Aneiros <[email protected]> updated Galician translat…
weblate May 27, 2022
85f3492
German Valero <[email protected]> updated Spanish (Mexico) (es-MX) (es-…
weblate May 27, 2022
6e63c57
German Valero <[email protected]> updated Spanish translation using Web…
weblate May 27, 2022
50cee07
Anonymous <[email protected]> updated Portuguese (Brazil) translati…
weblate May 27, 2022
dc1c30e
Merge branch 'release'
fnoks May 30, 2022
fe06bc9
Merge pull request #98 from translate-h5p/weblate-h5p-h5p-question-set
fnoks Jun 2, 2022
9168be3
Update .en.json default translations
fnoks Jun 2, 2022
2dc227a
Bump
fnoks Jun 2, 2022
7fbfcd6
Bohumil Havel <[email protected]> updated Czech translation using …
weblate Jun 15, 2022
0fc5fd7
Antonio Aneiros <[email protected]> updated Galician translat…
weblate Jun 15, 2022
c48e7a5
Matīss Sīlis <[email protected]> updated Latvian translation usi…
weblate Jun 15, 2022
623e74e
Antonio Aneiros <[email protected]> updated Spanish translati…
weblate Jun 15, 2022
5e6dbf2
Merge branch 'master' of github.com:h5p/h5p-question-set
fnoks Jul 18, 2022
cad76c7
Merge branch 'release'
fnoks Jul 18, 2022
ed14e7b
Merge pull request #102 from translate-h5p/weblate-h5p-h5p-question-set
fnoks Jul 18, 2022
9470a37
Fix invalid language files
fnoks Jul 18, 2022
cf05bee
HFP-3575 Fix button being button
fnoks Jul 19, 2022
438e4ea
HFP-3567 Fix navigation role
fnoks Jul 19, 2022
a8b944d
HFP-3566 Fix title not being header semantically
fnoks Jul 19, 2022
5d7f713
HFP-3553 Improve progressbar accessibility
fnoks Jul 19, 2022
503f5ba
Bump
fnoks Jul 20, 2022
86a7ec1
HFP-3553 Fix styling of progress dots
fnoks Jul 21, 2022
a2beee1
Update sl.json
miropuhek Jul 25, 2022
31b3b0d
Merge branch 'release'
fnoks Jul 25, 2022
05d77a5
Fix dissapearing finish button text
fnoks Jul 25, 2022
92774be
Merge pull request #104 from miropuhek/patch-2
fnoks Jul 25, 2022
5b9c12a
Bump
fnoks Jul 25, 2022
b9addd2
Update el.json
e-me Aug 2, 2022
eb4be61
Merge branch 'release'
fnoks Aug 9, 2022
ac1f0fa
Merge pull request #105 from e-me/patch-2
fnoks Aug 9, 2022
dc560cc
Revert essay status being hidden
icc Aug 10, 2022
b253a78
Bump
fnoks Aug 17, 2022
af5c5a1
Create mn.json
mongolkwon Aug 17, 2022
cd93bcb
Merge pull request #106 from mongolkwon/patch-1
fnoks Aug 19, 2022
7f150d7
Merge branch 'master' into release
fnoks Aug 19, 2022
836fd39
Bump
fnoks Aug 19, 2022
93076fd
Merge branch 'release'
fnoks Aug 19, 2022
5d42a43
Upgrade 1.17 to 1.20
basit-tkxel Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions css/questionset.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,58 @@
}
.progress-dot {
display: inline-block;
width: 0.6em;
height: 0.6em;
width: 0.5625em;
height: 0.5625em;
border-radius: 50%;
margin: 0 0.25em;
cursor: pointer;
background: #fff;
background: #cecece;
border: 1px solid #1356a3;
position: relative;
transition: transform 0.2s;
}

.progress-dot.disabled {
cursor: default;
}

.progress-dot:not(.disabled):hover {
box-shadow: 0 0 0.5em #c7c7c7;
transform: scale(1.25);
}
.progress-dot.answered {
background: #73a2d5;
background: #1356a3;
}
.progress-dot:before {
display: block;
content: "";
border: 2px solid transparent;
width: calc(100% + 10px);
height: calc(100% + 10px);
border-radius: 50%;
position: absolute;
box-sizing: border-box;
left: -5px;
top: -5px;
transition: border-color 0.5s;
}
.progress-dot.current {
background: #285585;

.progress-dot.current:before {
border-color: #285585;
}

.progress-dot.disabled:focus {
.progress-dot.disabled:focus-visible {
outline: none
}

.progress-dot:focus {
outline-color: rgb(40, 130, 211);
outline-width: thin;
outline-style: solid;
transform: scale(1.15);
}

.intro-page .title {
font-size: 2em;
line-height: 2em;
line-height: 1.5;
font-weight: bold;
text-align: center;
}
.intro-page .title > span {
.intro-page .title > h1 {
padding: 0.125em 0.5em;
border-radius: 0.125em;
background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */
Expand Down
112 changes: 42 additions & 70 deletions js/questionset.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ H5P.QuestionSet = function (options, contentId, contentData) {
prevButton: 'Previous question',
nextButton: 'Next question',
finishButton: 'Finish',
submitButton: 'Submit',
textualProgress: 'Question: @current of @total questions',
jumpToQuestion: 'Question %d of %total',
questionLabel: 'Question',
readSpeakerProgress: 'Question @current of @total',
unansweredText: 'Unanswered',
answeredText: 'Answered',
currentQuestionText: 'Current question'
currentQuestionText: 'Current question',
navigationLabel: 'Questions'
},
endGame: {
showResultPage: true,
noResultMessage: 'Finished',
message: 'Your result:',
scoreBarLabel: 'You got @finals out of @totals points',
oldFeedback: {
successGreeting: '',
successComment: '',
Expand All @@ -60,6 +63,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
},
overallFeedback: [],
finishButtonText: 'Finish',
submitButtonText: 'Submit',
solutionButtonText: 'Show solution',
retryButtonText: 'Retry',
submitButtonText: 'Submit',
Expand All @@ -77,29 +81,31 @@ H5P.QuestionSet = function (options, contentId, contentData) {
},
disableBackwardsNavigation: false
};
this.isSubmitting = contentData
&& (contentData.isScoringEnabled || contentData.isReportingEnabled);
var params = $.extend(true, {}, defaults, options);

var texttemplate =
'<% if (introPage.showIntroPage) { %>' +
'<% if (introPage.showIntroPage && noOfQuestionAnswered === 0) { %>' +
'<div class="intro-page">' +
' <% if (introPage.title) { %>' +
' <div class="title"><span><%= introPage.title %></span></div>' +
' <div class="title"><h1><%= introPage.title %></h1></div>' +
' <% } %>' +
' <% if (introPage.introduction) { %>' +
' <div class="introduction"><%= introPage.introduction %></div>' +
' <% } %>' +
' <div class="buttons"><a href="#" class="qs-startbutton h5p-joubelui-button h5p-button"><%= introPage.startButtonText %></a></div>' +
' <div class="buttons"><button class="qs-startbutton h5p-joubelui-button h5p-button"><%= introPage.startButtonText %></button></div>' +
'</div>' +
'<% } %>' +
'<div tabindex="-1" class="qs-progress-announcer"></div>' +
'<div class="questionset<% if (introPage.showIntroPage) { %> hidden<% } %>">' +
'<div class="questionset<% if (introPage.showIntroPage && noOfQuestionAnswered === 0) { %> hidden<% } %>">' +
' <% for (var i=0; i<questions.length; i++) { %>' +
' <div class="question-container"></div>' +
' <% } %>' +
' <div class="qs-footer">' +
' <div class="qs-progress">' +
' <div class="qs-progress" role="navigation" aria-label="<%= texts.navigationLabel %>">' +
' <% if (progressType == "dots") { %>' +
' <ul class="dots-container" role="navigation">' +
' <ul class="dots-container">' +
' <% for (var i=0; i<questions.length; i++) { %>' +
' <li class="progress-item">' +
' <a href="#" ' +
Expand Down Expand Up @@ -248,9 +254,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
}
}

// Create the html template for the question container
var $template = $(template.render(params));

// Set overrides for questions
var override;
if (params.override.showSolutionButton || params.override.retryButton || params.override.checkButton === false) {
Expand Down Expand Up @@ -319,6 +322,21 @@ H5P.QuestionSet = function (options, contentId, contentData) {

// Create question instances from questions given by params
questionInstances = createQuestionInstancesFromQuestions(params.questions);
params.noOfQuestionAnswered = 0;
if (contentData.previousState) {
// get numbers of questions answered by user
if (contentData.previousState.answers) {
for (var i = 0; i < questionInstances.length; i++) {
let answered = questionInstances[i].getAnswerGiven();
if (answered){
params.noOfQuestionAnswered++;
}
}
}
}

// Create the html template for the question container
var $template = $(template.render(params));

// Randomize questions only on instantiation
if (params.randomQuestions && contentData.previousState === undefined) {
Expand Down Expand Up @@ -369,12 +387,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
}
};

var _stopQuestion = function (questionNumber) {
if (questionInstances[questionNumber]) {
pauseMedia(questionInstances[questionNumber]);
}
};

var _showQuestion = function (questionNumber, preventAnnouncement) {
// Sanitize input.
if (questionNumber < 0) {
Expand All @@ -386,8 +398,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {

currentQuestion = questionNumber;

handleAutoPlay(currentQuestion);

// Hide all questions
$('.question-container', $myDom).hide().eq(questionNumber).show();

Expand Down Expand Up @@ -440,31 +450,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
return currentQuestion;
};

/**
* Handle autoplays, limit to one at a time
*
* @param {number} currentQuestionIndex
*/
var handleAutoPlay = function (currentQuestionIndex) {
for (var i = 0; i < questionInstances.length; i++) {
questionInstances[i].pause();
}

var currentQuestion = params.questions[currentQuestionIndex];

var hasAutoPlay = currentQuestion &&
currentQuestion.params.media &&
currentQuestion.params.media.params &&
currentQuestion.params.media.params.playback &&
currentQuestion.params.media.params.playback.autoplay;

if (hasAutoPlay && typeof questionInstances[currentQuestionIndex].play === 'function') {
questionInstances[currentQuestionIndex].play();
}
};



/**
* Show solutions for subcontent, and hide subcontent buttons.
* Used for contracts with integrated content.
Expand Down Expand Up @@ -689,7 +674,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
return;
}

_stopQuestion(currentQuestion);
if (currentQuestion + direction >= questionInstances.length) {
_displayEndGame();
}
Expand Down Expand Up @@ -793,7 +777,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
message: params.endGame.showResultPage ? params.endGame.message : params.endGame.noResultMessage,
comment: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successGreeting : params.endGame.oldFeedback.failGreeting) : undefined,
resulttext: params.endGame.showResultPage ? (success ? params.endGame.oldFeedback.successComment : params.endGame.oldFeedback.failComment) : undefined,
finishButtonText: params.endGame.finishButtonText,
finishButtonText: (self.isSubmitting) ? params.endGame.submitButtonText : params.endGame.finishButtonText,
solutionButtonText: params.endGame.solutionButtonText,
retryButtonText: params.endGame.retryButtonText,
submitButtonText: params.currikisettings.currikil10n.submitAnswer
Expand All @@ -811,7 +795,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
_showQuestion(params.initialQuestion);
});
hookUpButton('.qs-retrybutton', function () {
resetTask();
self.resetTask();
$myDom.children().hide();

var $intro = $('.intro-page', $myDom);
Expand Down Expand Up @@ -842,8 +826,9 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Announce that the question set is complete
setTimeout(function () {
$('.qs-progress-announcer', $myDom)
.html(eparams.message + '.' +
.html(eparams.message +
scoreString + '.' +
(params.endGame.scoreBarLabel).replace('@finals', finals).replace('@totals', totals) + '.' +
eparams.comment + '.' +
eparams.resulttext)
.show().focus();
Expand Down Expand Up @@ -924,7 +909,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
registerImageLoadedListener(question);

// Add finish button
question.addButton('finish', params.texts.finishButton,
const finishButtonText = (self.isSubmitting) ? params.texts.submitButton : params.texts.finishButton
question.addButton('finish', finishButtonText,
moveQuestion.bind(this, 1), false);

// Add next button
Expand All @@ -937,7 +923,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Add previous button
question.addButton('prev', '', moveQuestion.bind(this, -1),
!(questionInstances[0] === question || params.disableBackwardsNavigation), {
href: '#', // Use href since this is a navigation button
href: '#', // Use href since this is a navigation buttonq
'aria-label': params.texts.prevButton
});

Expand Down Expand Up @@ -1040,7 +1026,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
if (params.disableBackwardsNavigation && !showingSolutions) {
return;
}
_stopQuestion(currentQuestion);
_showQuestion($(this).parent().index());
};

Expand Down Expand Up @@ -1203,25 +1188,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
renderSolutions = true;
};

/**
* Stop the given element's playback if any.
*
* @param {object} instance
*/
var pauseMedia = function (instance) {
try {
if (instance.pause !== undefined &&
(instance.pause instanceof Function ||
typeof instance.pause === 'function')) {
instance.pause();
}
}
catch (err) {
// Prevent crashing, log error.
H5P.error(err);
}
};

/**
* Returns the complete state of question set and sub-content
*
Expand Down Expand Up @@ -1301,10 +1267,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
*/
this.getContext = function () {
// Get question index and add 1, count starts from 0
return {
let contextObject = {
type: 'question',
value: (currentQuestion + 1)
};

// Send actual index of the question if questions are randomized
if (params.randomQuestions) {
contextObject.actual = questionOrder[currentQuestion] + 1;
}
return contextObject;
};
};

Expand Down
Loading