From 439f850729b0cdab4bfac417ec7facf75f3f170f Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 25 Sep 2015 10:57:16 +0200 Subject: [PATCH 01/16] Prevent crashing JS. --- js/questionset.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index ff08a33..aa4c178 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -143,7 +143,8 @@ H5P.QuestionSet = function (options, contentId) { answered = answered && (questionInstances[i]).getAnswerGiven(); } - if (currentQuestion === (params.questions.length - 1) && answered) { + if (currentQuestion === (params.questions.length - 1) && answered && + questionInstances[currentQuestion]) { questionInstances[currentQuestion].showButton('finish'); } }; @@ -157,13 +158,15 @@ H5P.QuestionSet = function (options, contentId) { questionNumber = params.questions.length - 1; } - // Hide all questions + // Hide all questions $('.question-container', $myDom).hide().eq(questionNumber).show(); - // Trigger resize on question in case the size of the QS has changed. - var instance = questionInstances[questionNumber]; - if (instance.$ !== undefined) { - instance.trigger('resize'); + if (questionInstances[questionNumber]) { + // Trigger resize on question in case the size of the QS has changed. + var instance = questionInstances[questionNumber]; + if (instance.$ !== undefined) { + instance.trigger('resize'); + } } // Update progress indicator From b00490bbe63ec31f1b18bf00dd2634fdc7155e3e Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 25 Sep 2015 11:13:05 +0200 Subject: [PATCH 02/16] Added wysiwyg support to title field. --- css/questionset.css | 9 +++++++-- js/questionset.js | 2 +- semantics.json | 10 +++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index fef0b6f..7e98e2d 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -61,16 +61,21 @@ line-height: 2em; font-weight: bold; text-align: center; + margin-top: 0.5em; } -.intro-page .title > span { +.intro-page .title > div { + display: inline-block; padding: 0.125em 0.5em; border-radius: 0.125em; background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */ background: rgba(255,255,255,0.8); /* Gives WCAG contrast ratio of 5.6:1 with the current font color */ } +.intro-page .title > div p { + margin: 0; +} .intro-page .introduction { font-size: 1.25em; - margin: 0 1em; + margin: 0.5em 1em 0; border-radius: 0.25em; background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */ background: rgba(255,255,255,0.8); /* Gives WCAG contrast ratio of 5.6:1 with the current font color */ diff --git a/js/questionset.js b/js/questionset.js index aa4c178..d5d937b 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -23,7 +23,7 @@ H5P.QuestionSet = function (options, contentId) { '<% if (introPage.showIntroPage) { %>' + '
' + ' <% if (introPage.title) { %>' + - '
<%= introPage.title %>
' + + '
<%= introPage.title %>
' + ' <% } %>' + ' <% if (introPage.introduction) { %>' + '
<%= introPage.introduction %>
' + diff --git a/semantics.json b/semantics.json index a83cdc9..0c19678 100644 --- a/semantics.json +++ b/semantics.json @@ -12,15 +12,11 @@ { "name": "title", "type": "text", + "widget": "html", + "tags": ["p", "br", "strong", "em"], "label": "Title", "optional": true, - "description": "This title will be displayed above the introduction text.", - "tags": [ - "sub", - "sup", - "strong", - "em" - ] + "description": "This title will be displayed above the introduction text." }, { "name": "introduction", From 4a0d548c64860e631d1bc7639b3747b2a3c62bf6 Mon Sep 17 00:00:00 2001 From: Andrew Downes Date: Tue, 20 Oct 2015 11:32:51 +0100 Subject: [PATCH 03/16] Report quiz set success Depends on https://github.com/h5p/h5p-php-library/pull/4 --- js/questionset.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/questionset.js b/js/questionset.js index e63cd50..9796e33 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -264,7 +264,7 @@ H5P.QuestionSet = function (options, contentId) { passed: success }; var displayResults = function () { - self.triggerXAPICompleted(self.getScore(), self.totalScore()); + self.triggerXAPICompleted(self.getScore(), self.totalScore(), success); if (!params.endGame.showResultPage) { self.trigger('h5pQuestionSetFinished', eventData); From b57423bdc70913277901fcaf176cc411d19610fa Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 27 Oct 2015 10:48:43 +0100 Subject: [PATCH 04/16] Updated italian translation. --- language/it.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/language/it.json b/language/it.json index 42f76ea..6f52c6f 100644 --- a/language/it.json +++ b/language/it.json @@ -8,11 +8,11 @@ }, { "label": "Titolo", - "description": "Questo titolo verr� visualizzato sopra il testo introduttivo." + "description": "Questo titolo verrà visualizzato sopra il testo introduttivo." }, { "label": "Testo introduttivo", - "description": "Questo testo verr� visualizzato prima dell'inizio del quiz." + "description": "Questo testo verrà visualizzato prima dell'inizio del quiz." }, { "label": "Testo pulsante Start" @@ -73,7 +73,7 @@ }, { "label": "Testo Avanzamento", - "description": "esto utilizzato se il testo Avanzamento � selezionato." + "description": "esto utilizzato se il testo Avanzamento è selezionato." } ] }, @@ -85,27 +85,27 @@ }, { "label": "Intestazione Feedback", - "description": "Questa intestazione verr� visualizzata alla fine del quiz, dopo che l'utente avr� risposto a tutte le domande." + "description": "Questa intestazione verrà visualizzata alla fine del quiz, dopo che l'utente avrà risposto a tutte le domande." }, { "label": "Testo visualizza punteggio", - "description": "Testo utilizzato per visualizzare il punteggio Totale dell'utente. \"@score\" verr� rimpiazzato dal punteggio calcolato, \"@total\" sar� rimpiazzato dal punteggio massimo possibile. " + "description": "Testo utilizzato per visualizzare il punteggio Totale dell'utente. \"@score\" verrà rimpiazzato dal punteggio calcolato, \"@total\" sarà rimpiazzato dal punteggio massimo possibile. " }, { "label": "Messaggio di superamento quiz", - "description": "Questo testo verr� visualizzato sopra il punteggio se l'utente ha superato con successo il quiz." + "description": "Questo testo verrà visualizzato sopra il punteggio se l'utente ha superato con successo il quiz." }, { "label": "Commento di superamento quiz", - "description": "Questo commento verr� visualizzato dopo il punteggio se l'utente ha superato con successo il quiz." + "description": "Questo commento verrà visualizzato dopo il punteggio se l'utente ha superato con successo il quiz." }, { "label": "Titolo quiz fallito", - "description": "Questo testo verr� visualizzato sopra il punteggio se l'utente non ha superato il quiz." + "description": "Questo testo verrà visualizzato sopra il punteggio se l'utente non ha superato il quiz." }, { "label": "Commento quiz fallito", - "description": "Questo commento verr� visualizzato dopo il punteggio se l'utente non ha superato il quiz." + "description": "Questo commento verrà visualizzato dopo il punteggio se l'utente non ha superato il quiz." }, { "label": "Etichetta pulsante Soluzione", @@ -129,11 +129,11 @@ }, { "label": "Video di superamento quiz", - "description": "Questo video verr� visualizzato sopra il punteggio se l'utente ha superato con successo il quiz." + "description": "Questo video verrà visualizzato sopra il punteggio se l'utente ha superato con successo il quiz." }, { "label": "Video quiz fallito", - "description": "Questo testo verr� visualizzato se l'utente non ha superato il quiz." + "description": "Questo testo verrà visualizzato se l'utente non ha superato il quiz." } ] }, @@ -143,15 +143,15 @@ "fields": [ { "label": "Abilita ignora impostazioni per \"Mostra soluzione\" e \"Riprova\".", - "description": "Se questa opzione � abilitata le proprie impostazioni per le domande saranno ignorate e verranno utilizzate le impostazioni seguenti." + "description": "Se questa opzione è abilitata le proprie impostazioni per le domande saranno ignorate e verranno utilizzate le impostazioni seguenti." }, { "label": "Abilita pulsanti \"Mostra soluzione\".", - "description": "L'attivazione di questa opzione far� in modo che le domande mostrino il tasto \"Mostra soluzione\"." + "description": "L'attivazione di questa opzione farà in modo che le domande mostrino il tasto \"Mostra soluzione\"." }, { "label": "Abilita \"Riprova\".", - "description": "L'attivazione di questa opzione far� in modo che per l'utente sia abilitata l'opzione \"Riprova\"." + "description": "L'attivazione di questa opzione farà in modo che per l'utente sia abilitata l'opzione \"Riprova\"." } ] }, From f66b7452b70cb4016d00e52d327e0efa6b0c89d1 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 6 Nov 2015 09:20:36 +0100 Subject: [PATCH 05/16] Updated MC --- library.json | 4 ++-- semantics.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 01aaffc..afe9c46 100644 --- a/library.json +++ b/library.json @@ -3,8 +3,8 @@ "description": "Put together a set of different questions that has to be solved. (Quiz)", "contentType": "question", "majorVersion": 1, - "minorVersion": 5, - "patchVersion": 1, + "minorVersion": 6, + "patchVersion": 0, "embedTypes": [ "iframe" ], diff --git a/semantics.json b/semantics.json index 42bef62..4552b59 100644 --- a/semantics.json +++ b/semantics.json @@ -106,7 +106,7 @@ "label": "Question type", "description": "Library for this question.", "options": [ - "H5P.MultiChoice 1.4", + "H5P.MultiChoice 1.5", "H5P.DragQuestion 1.5", "H5P.Blanks 1.4", "H5P.MarkTheWords 1.4", From 3423fabc1596538d12cf0dfdcc7fcd8c384c3a3d Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Fri, 6 Nov 2015 14:24:11 +0100 Subject: [PATCH 06/16] Revert "Added wysiwyg support to title field." This reverts commit b00490bbe63ec31f1b18bf00dd2634fdc7155e3e. --- css/questionset.css | 9 ++------- js/questionset.js | 2 +- semantics.json | 10 +++++++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 1f25e8d..325f94d 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -61,21 +61,16 @@ line-height: 2em; font-weight: bold; text-align: center; - margin-top: 0.5em; } -.intro-page .title > div { - display: inline-block; +.intro-page .title > span { padding: 0.125em 0.5em; border-radius: 0.125em; background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */ background: rgba(255,255,255,0.8); /* Gives WCAG contrast ratio of 5.6:1 with the current font color */ } -.intro-page .title > div p { - margin: 0; -} .intro-page .introduction { font-size: 1.25em; - margin: 0.5em 1em 0; + margin: 0 1em; border-radius: 0.25em; background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */ background: rgba(255,255,255,0.8); /* Gives WCAG contrast ratio of 5.6:1 with the current font color */ diff --git a/js/questionset.js b/js/questionset.js index 9796e33..8034da3 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -23,7 +23,7 @@ H5P.QuestionSet = function (options, contentId) { '<% if (introPage.showIntroPage) { %>' + '
' + ' <% if (introPage.title) { %>' + - '
<%= introPage.title %>
' + + '
<%= introPage.title %>
' + ' <% } %>' + ' <% if (introPage.introduction) { %>' + '
<%= introPage.introduction %>
' + diff --git a/semantics.json b/semantics.json index 4552b59..cd20d2d 100644 --- a/semantics.json +++ b/semantics.json @@ -12,11 +12,15 @@ { "name": "title", "type": "text", - "widget": "html", - "tags": ["p", "br", "strong", "em"], "label": "Title", "optional": true, - "description": "This title will be displayed above the introduction text." + "description": "This title will be displayed above the introduction text.", + "tags": [ + "sub", + "sup", + "strong", + "em" + ] }, { "name": "introduction", From 3a038ea0276e1d90a721253bb78e71a1d6ed1c98 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 18 Nov 2015 09:38:44 +0100 Subject: [PATCH 07/16] Fixed stopping media when changing question.[HFJ-1218] --- js/questionset.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/js/questionset.js b/js/questionset.js index 8034da3..ce65aed 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -160,6 +160,12 @@ H5P.QuestionSet = function (options, contentId) { } }; + var _stopQuestion = function (questionNumber) { + if (questionInstances[questionNumber]) { + pauseMedia(questionInstances[questionNumber]) + } + }; + var _showQuestion = function (questionNumber) { // Sanitize input. if (questionNumber < 0) { @@ -404,6 +410,7 @@ H5P.QuestionSet = function (options, contentId) { // Add next question button question.addButton('next', '', function () { + _stopQuestion(currentQuestion); _showQuestion(currentQuestion + 1); }); } @@ -411,6 +418,7 @@ H5P.QuestionSet = function (options, contentId) { // Add previous question button if (questionInstances[0] !== question) { question.addButton('prev', '', function () { + _stopQuestion(currentQuestion); _showQuestion(currentQuestion - 1); }); } @@ -444,6 +452,7 @@ H5P.QuestionSet = function (options, contentId) { // Set event listeners. $('.progress-dot', $myDom).click(function () { + _stopQuestion(currentQuestion); _showQuestion($(this).index()); }); @@ -549,6 +558,36 @@ H5P.QuestionSet = function (options, contentId) { this.showSolutions = function() { 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(); + } + else if (instance.video !== undefined && + instance.video.pause !== undefined && + (instance.video.pause instanceof Function || + typeof instance.video.pause === 'function')) { + instance.video.pause(); + } + else if (instance.stop !== undefined && + (instance.stop instanceof Function || + typeof instance.stop === 'function')) { + instance.stop(); + } + } + catch (err) { + // Prevent crashing, log error. + H5P.error(err); + } + }; }; H5P.QuestionSet.prototype = Object.create(H5P.EventDispatcher.prototype); H5P.QuestionSet.prototype.constructor = H5P.QuestionSet; From 2d9a7cccdad42304493abddb12d8450b599de883 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 18 Nov 2015 09:59:45 +0100 Subject: [PATCH 08/16] Added missing semi colon HFJ-1218 --- js/questionset.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/questionset.js b/js/questionset.js index ce65aed..903c977 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -162,7 +162,7 @@ H5P.QuestionSet = function (options, contentId) { var _stopQuestion = function (questionNumber) { if (questionInstances[questionNumber]) { - pauseMedia(questionInstances[questionNumber]) + pauseMedia(questionInstances[questionNumber]); } }; From a36014c1e03b3eb6710888a3e7b84ffc1d7e028d Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 18 Nov 2015 10:00:19 +0100 Subject: [PATCH 09/16] Stop video when finished HFJ-1218 --- js/questionset.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/questionset.js b/js/questionset.js index 903c977..39de57b 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -403,6 +403,7 @@ H5P.QuestionSet = function (options, contentId) { // Add finish question set button question.addButton('finish', params.texts.finishButton, function () { + _stopQuestion(currentQuestion); _displayEndGame(); }, false); From fcbcfc951eba2efb584942dcb2421df918fb1c8e Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 18 Nov 2015 10:00:44 +0100 Subject: [PATCH 10/16] Only pause is needed in Question Set (questions only have pause) HFJ-1218 --- js/questionset.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 39de57b..86ce470 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -572,17 +572,6 @@ H5P.QuestionSet = function (options, contentId) { typeof instance.pause === 'function')) { instance.pause(); } - else if (instance.video !== undefined && - instance.video.pause !== undefined && - (instance.video.pause instanceof Function || - typeof instance.video.pause === 'function')) { - instance.video.pause(); - } - else if (instance.stop !== undefined && - (instance.stop instanceof Function || - typeof instance.stop === 'function')) { - instance.stop(); - } } catch (err) { // Prevent crashing, log error. @@ -590,5 +579,6 @@ H5P.QuestionSet = function (options, contentId) { } }; }; + H5P.QuestionSet.prototype = Object.create(H5P.EventDispatcher.prototype); H5P.QuestionSet.prototype.constructor = H5P.QuestionSet; From 93a6fbdfc960e059c9e05493f2064fd52c73d6e8 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Mon, 23 Nov 2015 15:26:15 +0100 Subject: [PATCH 11/16] Let Question and QuestionSet behaviour settings decide if try again and show solution buttons should be shown. [HFJ-1363] --- css/questionset.css | 6 ------ 1 file changed, 6 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 19b2b32..a6959fa 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -221,9 +221,3 @@ .h5p-no-frame .questionset .h5p-question > *:last-child { margin-bottom: 0; } - -/* Hide retry and show solution buttons */ -.questionset .h5p-question .h5p-question-try-again, -.questionset .h5p-question .h5p-question-show-solution { - display: none; -} From 370c5c88031c9208fa2f65894b42df3dccac3306 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Fri, 27 Nov 2015 20:40:48 +0100 Subject: [PATCH 12/16] Trigger attempted event the first time a user sees a question - HFJ-1397 --- js/questionset.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/questionset.js b/js/questionset.js index 86ce470..dd4b4a5 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -181,6 +181,7 @@ H5P.QuestionSet = function (options, contentId) { if (questionInstances[questionNumber]) { // Trigger resize on question in case the size of the QS has changed. var instance = questionInstances[questionNumber]; + instance.setActivityStarted(); if (instance.$ !== undefined) { instance.trigger('resize'); } @@ -352,7 +353,9 @@ H5P.QuestionSet = function (options, contentId) { // Function for attaching the multichoice to a DOM element. this.attach = function (target) { - this.setActivityStarted(); + if (this.isRoot()) { + this.setActivityStarted(); + } if (typeof(target) === "string") { $myDom = $('#' + target); } From db69bc60a36ba19bf3b72ce03bbda251dd3eae91 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sat, 28 Nov 2015 21:00:16 +0100 Subject: [PATCH 13/16] Add question number to interactions - HFJ-1400 --- js/questionset.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/questionset.js b/js/questionset.js index dd4b4a5..9f931d8 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -439,6 +439,10 @@ H5P.QuestionSet = function (options, contentId) { // An activity within this activity is not allowed to send completed events event.setVerb('answered'); } + if (event.data.statement.context.extensions === undefined) { + event.data.statement.context.extensions = []; + } + event.data.statement.context.extensions['http://id.tincanapi.com/extension/ending-point'] = currentQuestion + 1; }); if (question.getAnswerGiven()) { $('.progress-dot:eq(' + i +')', $myDom).removeClass('unanswered').addClass('answered'); From 1e4ec27ae33f87f65270ec5e87752a93d0ccf4e2 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Tue, 1 Dec 2015 14:42:04 +0100 Subject: [PATCH 14/16] currentQuestion had to be set earlier [HFJ-1400] --- js/questionset.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/questionset.js b/js/questionset.js index 9f931d8..c34a4a8 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -175,6 +175,8 @@ H5P.QuestionSet = function (options, contentId) { questionNumber = params.questions.length - 1; } + currentQuestion = questionNumber; + // Hide all questions $('.question-container', $myDom).hide().eq(questionNumber).show(); @@ -199,7 +201,6 @@ H5P.QuestionSet = function (options, contentId) { } // Remember where we are - currentQuestion = questionNumber; _updateButtons(); self.trigger('resize'); return currentQuestion; From bc1dd91715fbaa6ded16348f13c1f74aff5b87ab Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 2 Dec 2015 15:45:43 +0100 Subject: [PATCH 15/16] Bumped version --- library.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index afe9c46..0e2dc7a 100644 --- a/library.json +++ b/library.json @@ -4,7 +4,7 @@ "contentType": "question", "majorVersion": 1, "minorVersion": 6, - "patchVersion": 0, + "patchVersion": 1, "embedTypes": [ "iframe" ], @@ -61,4 +61,4 @@ "minorVersion": 0 } ] -} +} \ No newline at end of file From 51c614a2be980767901f714b830387aae88e4715 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 11 Dec 2015 12:51:27 +0100 Subject: [PATCH 16/16] Updated MarkTheWords --- library.json | 2 +- semantics.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 0e2dc7a..b527d18 100644 --- a/library.json +++ b/library.json @@ -4,7 +4,7 @@ "contentType": "question", "majorVersion": 1, "minorVersion": 6, - "patchVersion": 1, + "patchVersion": 2, "embedTypes": [ "iframe" ], diff --git a/semantics.json b/semantics.json index cd20d2d..8e478dd 100644 --- a/semantics.json +++ b/semantics.json @@ -113,7 +113,7 @@ "H5P.MultiChoice 1.5", "H5P.DragQuestion 1.5", "H5P.Blanks 1.4", - "H5P.MarkTheWords 1.4", + "H5P.MarkTheWords 1.5", "H5P.DragText 1.4" ] }