From c4a78bfdcd71d43be62adbf04c5cbc4216959cc5 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 12 Aug 2015 14:46:49 +0200 Subject: [PATCH 1/9] Use new button design. Add navigation buttons to Question, instead of to QS. Added specific stylings for new button design. HFJ-946 --- css/questionset.css | 77 +++++++++++++++++++++----------------------- js/questionset.js | 78 +++++++++++++++++++++++++++------------------ library.json | 7 +++- 3 files changed, 89 insertions(+), 73 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 19130c0..6dceb75 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -62,7 +62,7 @@ font-weight: bold; text-align: center; } -.intro-page .title > span { +.intro-page .title > span { padding: 0.125em 0.5em; border-radius: 0.125em; background: rgb(255,255,255); /* Fallback for browsers not supporting rgba */ @@ -91,37 +91,7 @@ .qs-footer { overflow: hidden; } -.qs-footer .h5p-button, .qs-startbutton, .qs-finishbutton, .questionset-results .h5p-button, .video-container > .h5p-button { - display: inline-block; - padding: 0 0.7em; - border: 0.2em solid #fff; - border-radius: 0.4em; - margin: 0 0.5em 1em; - cursor: pointer; - color: #ffffff; - box-shadow: 0 0 0.5em #999; - line-height: 1.9em; - background: rgb(100,152,254); /* Old browsers */ - background: -moz-linear-gradient(top, rgba(100,152,254,1) 0%, rgba(4,104,206,1) 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(100,152,254,1)), color-stop(100%,rgba(4,104,206,1))); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* IE10+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6498fe', endColorstr='#0468ce',GradientType=0 ); /* IE6-9 */ -} -.qs-footer .h5p-button:hover, .qs-startbutton:hover, .questionset-results .h5p-button:hover, .video-container > .h5p-button:hover { - text-decoration: none; - box-shadow: 0 0 0.5em #999; - color: #ffffff; - border-color: #fff; - background: rgb(4,104,206); /* Old browsers */ - background: -moz-linear-gradient(top, rgba(4,104,206,1) 0%, rgba(100,152,254,1) 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(4,104,206,1)), color-stop(100%,rgba(100,152,254,1))); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* IE10+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0468ce', endColorstr='#6498fe',GradientType=0 ); /* IE6-9 */ -} + .qs-footer > .prev { float: left; } @@ -144,28 +114,53 @@ float: right; } -.qs-footer a.next.h5p-button:after { - font-family: 'H5PFontAwesome4'; - content: "\f054"; /* TODO: Use margin not whitespace, spacing is not content! */ +.h5p-question .h5p-question-prev, +.h5p-question .h5p-question-finish, +.h5p-question .h5p-question-next { + float: right; } -.qs-footer a.prev.h5p-button:before { - font-family: 'H5PFontAwesome4'; +.h5p-question .h5p-question-prev, +.h5p-question .h5p-question-next { + padding: 0; + height: 2.1875em; + width: 2.1875em; +} + +.h5p-question .h5p-question-next, +.h5p-question .h5p-question-finish { + margin: 0 0 1.5em 0.5em; +} + +.h5p-question .h5p-question-prev { + margin: 0 0.5em 1.5em 0.5em; +} + +.h5p-question .h5p-question-next:before { + content: "\f054"; + padding-right: 0; + position: relative; + left: 2px; +} + +.h5p-question .h5p-question-prev:before { content: "\f053"; + padding-right: 0; + position: relative; + left: -2px; } .questionset-results .qs-finishbutton { display: none; } -.qs-footer a.finish.h5p-button:before { - font-family: 'H5PFontAwesome4'; - content: "\f00c "; +.h5p-question .h5p-question-finish:before { + content: "\f00c"; } .questionset-results a.h5p-button.qs-solutionbutton:before { font-family: 'H5PFontAwesome4'; - content: "\f06e "; + content: "\f06e "; /* TODO: Use margin not whitespace, spacing is not content! */ } .video-container { diff --git a/js/questionset.js b/js/questionset.js index 27be0d4..20eba15 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -28,7 +28,7 @@ H5P.QuestionSet = function (options, contentId) { ' <% if (introPage.introduction) { %>' + '
<%= introPage.introduction %>
' + ' <% } %>' + - '
<%= introPage.startButtonText %>
' + + '
<%= introPage.startButtonText %>
' + '' + '<% } %>' + '
' + @@ -47,9 +47,6 @@ H5P.QuestionSet = function (options, contentId) { ' ' + ' <% } %>' + '
' + - ' ' + - ' ' + - ' <%= texts.finishButton %>' + ' ' + ''; @@ -60,7 +57,11 @@ H5P.QuestionSet = function (options, contentId) { '
' + '
<% if (comment) { %>

<%= comment %>

<% } %><%= score %>
<%= resulttext %>
' + ' ' + - '
<%= finishButtonText %><%= solutionButtonText %>
' + + '
' + + ' <%= finishButtonText %>' + + ' <%= solutionButtonText %>' + + ' ' + + '
' + ''; var defaults = { @@ -126,11 +127,15 @@ H5P.QuestionSet = function (options, contentId) { } var questionInstance = H5P.newRunnable(question, contentId, undefined, undefined, {parent: self}); questionInstances.push(questionInstance); - questionInstance.on('resize', function() { - self.trigger('resize'); - }); } + // Resize all interactions on resize + self.on('resize', function () { + for (var i = 0; i < questionInstances.length; i++) { + questionInstances[i].trigger('resize'); + } + }); + // Update button state. var _updateButtons = function () { var answered = true; @@ -138,19 +143,8 @@ H5P.QuestionSet = function (options, contentId) { answered = answered && (questionInstances[i]).getAnswerGiven(); } - if (currentQuestion === 0) { - $('.prev.h5p-button', $myDom).hide(); - } else { - $('.prev.h5p-button', $myDom).show(); - } - if (currentQuestion === (params.questions.length - 1)) { - $('.next.h5p-button', $myDom).hide(); - if (answered) { - $('.finish.h5p-button', $myDom).show(); - } - } else { - $('.next.h5p-button', $myDom).show(); - $('.finish.h5p-button', $myDom).hide(); + if (currentQuestion === (params.questions.length - 1) && answered) { + questionInstances[currentQuestion].showButton('finish'); } }; @@ -222,6 +216,10 @@ H5P.QuestionSet = function (options, contentId) { console.log("subcontent does not contain a valid resetTask() function"); } } + + // Hide finish button + questionInstances[questionInstances.length - 1].hideButton('finish'); + //Force the last page to be reRendered rendered = false; }; @@ -314,7 +312,7 @@ H5P.QuestionSet = function (options, contentId) { video.play(); if (params.endGame.skipButtonText) { - $('').click(function () { + $('').click(function () { video.pause(); $videoContainer.hide(); displayResults(); @@ -364,6 +362,33 @@ H5P.QuestionSet = function (options, contentId) { var question = questionInstances[i]; question.attach($('.question-container:eq(' + i + ')', $myDom)); + + // Disable feedback for question + question.setBehaviour({disableFeedback: true}); + + // Add next/finish button + if (questionInstances[questionInstances.length -1] === question) { + + // Add finish question set button + question.addButton('finish', params.texts.finishButton, function () { + _displayEndGame(); + }); + + } else { + + // Add next question button + question.addButton('next', '', function () { + _showQuestion(currentQuestion + 1); + }); + } + + // Add previous question button + if (questionInstances[0] !== question) { + question.addButton('prev', '', function () { + _showQuestion(currentQuestion - 1); + }); + } + question.on('xAPI', function (event) { var shortVerb = event.getVerb(); if (shortVerb === 'interacted') { @@ -393,15 +418,6 @@ H5P.QuestionSet = function (options, contentId) { $('.progress-dot', $myDom).click(function () { _showQuestion($(this).index()); }); - $('.next.h5p-button', $myDom).click(function () { - _showQuestion(currentQuestion + 1); - }); - $('.prev.h5p-button', $myDom).click(function () { - _showQuestion(currentQuestion - 1); - }); - $('.finish.h5p-button', $myDom).click(function () { - _displayEndGame(); - }); // Hide all but initial Question. _showQuestion(params.initialQuestion); diff --git a/library.json b/library.json index fbe9cd5..897cc19 100644 --- a/library.json +++ b/library.json @@ -41,6 +41,11 @@ "machineName": "H5P.Video", "majorVersion": 1, "minorVersion": 1 + }, + { + "machineName": "H5P.JoubelUI", + "majorVersion": 1, + "minorVersion": 1 } ], "editorDependencies": [ @@ -55,4 +60,4 @@ "minorVersion": 0 } ] -} \ No newline at end of file +} From 396abf92b77910a00c58b5788b0b5cd6649747d7 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 12 Aug 2015 15:30:10 +0200 Subject: [PATCH 2/9] No left, right, top or bot margins for Questions inside QS without frame. HFJ-949 --- css/questionset.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/css/questionset.css b/css/questionset.css index 6dceb75..ce830fa 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -264,3 +264,17 @@ color: #6aa81b; text-align: left; } + +/* No margin for questions when no frame */ +.h5p-no-frame .questionset .h5p-question > * { + margin-left: 0; + margin-right: 0; +} + +.h5p-no-frame .questionset .h5p-question > *:first-child { + margin-top: 0; +} + +.h5p-no-frame .questionset .h5p-question > *:last-child { + margin-bottom: 0; +} From ad0acb28984ca304c04cf066a6d165eabcb19e11 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Thu, 13 Aug 2015 10:35:55 +0200 Subject: [PATCH 3/9] Changed retry icon for whole task for consistency. Accepts answered and attempted xapi verbs as well to mark a question as answered. HFJ-946 --- css/questionset.css | 2 +- js/questionset.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index ce830fa..8448f36 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -107,7 +107,7 @@ .questionset-results a.h5p-button.qs-retrybutton:before { font-family: 'H5PFontAwesome4'; padding-right: 0.5em; - content: "\f021"; + content: "\f01e"; } .qs-footer > .next, .qs-footer > .finish, .qs-finishbutton { diff --git a/js/questionset.js b/js/questionset.js index 20eba15..be4ec96 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -391,7 +391,9 @@ H5P.QuestionSet = function (options, contentId) { question.on('xAPI', function (event) { var shortVerb = event.getVerb(); - if (shortVerb === 'interacted') { + if (shortVerb === 'interacted' || + shortVerb === 'answered' || + shortVerb === 'attempted') { $('.progress-dot:eq(' + currentQuestion +')', $myDom).removeClass('unanswered').addClass('answered'); _updateButtons(); } From 0fb9b8882fc4269c26c797fe8bcafa52f5e9d132 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 18 Aug 2015 13:58:33 +0200 Subject: [PATCH 4/9] Added Question design to QS HFJ-946 --- css/questionset.css | 85 +++++++-------------------------------------- js/questionset.js | 24 ++++++++----- 2 files changed, 27 insertions(+), 82 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 8448f36..62b6068 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -187,82 +187,17 @@ padding: 0.625em; } -.questionset-results .greeting { - text-align: left; - border-bottom: 0.1em solid #ddd; - width: 100%; +.questionset-results .feedback-section { + margin: 1.5em; } -.questionset-results .score { - margin: 0; - display: block; - margin-bottom: 2em; -} - -.questionset-results .resulttext { - text-align: left; - font-size: 1.25em; - line-height: 1.25em; - margin: 1em 0em; - background-repeat: no-repeat; - background-position: left center; -} - -.questionset-results .resulttext.fail em { - font-style: normal; - color: #b9272d; -} - -.questionset-results .score.success .emoticon:before { - font-family: icomoon-questionset; - font-size: 5em; - line-height: 100%; - content: "\e606"; - float: left; -} - -.questionset-results .score.fail .emoticon:before { - font-family: icomoon-questionset; - font-size: 5em; - line-height: 100%; - content: "\e607"; - float: left; -} - -.questionset-results .resulttext.success, -.questionset-results .resulttext.almost, -.questionset-results .resulttext.fail -{ - display: block; - background: #eee; - padding: 1em; - border-radius: 1em; - margin-left: 6.5em; - position: relative; - font-size: 1em; -} - -.questionset-results .resulttext.success:before, -.questionset-results .resulttext.fail:before -{ - font-family: icomoon-questionset; - content: ""; - font-size: 5em; - position: absolute; - left: -14px; - top: 36px; - height: 0; - width: 0; - border-top: 15px solid transparent; - border-bottom: 15px solid transparent; - border-right: 15px solid #eee; +.questionset-results .feedback-section .feedback-text { + font-weight: bold; + color: #1a73d9; display: inline-block; -} - -.questionset-results .resulttext.success em { - font-style: normal; - color: #6aa81b; - text-align: left; + position: relative; + top: -1em; + margin-top: .8em; } /* No margin for questions when no frame */ @@ -278,3 +213,7 @@ .h5p-no-frame .questionset .h5p-question > *:last-child { margin-bottom: 0; } + +.h5p-no-frame .questionset-results .feedback-section { + margin-top: 0; +} diff --git a/js/questionset.js b/js/questionset.js index be4ec96..47753fc 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -52,10 +52,9 @@ H5P.QuestionSet = function (options, contentId) { var resulttemplate = '
' + - '
<%= message %>
' + - '
' + - '
' + - '
<% if (comment) { %>

<%= comment %>

<% } %><%= score %>
<%= resulttext %>
' + + ' ' + '
' + ' <%= finishButtonText %>' + @@ -110,6 +109,7 @@ H5P.QuestionSet = function (options, contentId) { var currentQuestion = 0; var questionInstances = []; var $myDom; + var scoreBar; renderSolutions = false; // Instantiate question instances @@ -258,11 +258,7 @@ H5P.QuestionSet = function (options, contentId) { } var eparams = { - message: params.endGame.message, comment: (success ? params.endGame.successGreeting : params.endGame.failGreeting), - score: scoreString, - scoreclass: (success ? 'success' : 'fail'), - resulttext: (success ? params.endGame.successComment : params.endGame.failComment), finishButtonText: params.endGame.finishButtonText, solutionButtonText: params.endGame.solutionButtonText }; @@ -270,7 +266,7 @@ H5P.QuestionSet = function (options, contentId) { // Show result page. $myDom.children().hide(); $myDom.append(endTemplate.render(eparams)); - $('.qs-finishbutton').click(function () { + $('.qs-finishbutton', $myDom).click(function () { self.trigger('h5pQuestionSetFinished', eventData); }); $('.qs-solutionbutton', $myDom).click(function () { @@ -284,6 +280,16 @@ H5P.QuestionSet = function (options, contentId) { resetTask(); $myDom.children().hide().filter('.questionset').show(); _showQuestion(params.initialQuestion);}); + + if (scoreBar === undefined) { + scoreBar = H5P.JoubelUI.createScoreBar(totals); + } + console.log($myDom); + console.log($('.feedback-scorebar', $myDom)); + scoreBar.appendTo($('.feedback-scorebar', $myDom)); + scoreBar.setScore(finals); + console.log($('.feedback-text', $myDom)); + $('.feedback-text', $myDom).html(scoreString); }; if (params.endGame.showAnimations) { From fdc91abcf8498a1f9ff787e2fb4761b5b9597bd3 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 18 Aug 2015 14:02:13 +0200 Subject: [PATCH 5/9] Removed debugging lines HFJ-946 --- js/questionset.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 47753fc..e0ff70f 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -284,11 +284,8 @@ H5P.QuestionSet = function (options, contentId) { if (scoreBar === undefined) { scoreBar = H5P.JoubelUI.createScoreBar(totals); } - console.log($myDom); - console.log($('.feedback-scorebar', $myDom)); scoreBar.appendTo($('.feedback-scorebar', $myDom)); scoreBar.setScore(finals); - console.log($('.feedback-text', $myDom)); $('.feedback-text', $myDom).html(scoreString); }; From 8623bb5670a1c7803cc52e56337157bab8322626 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 18 Aug 2015 14:16:07 +0200 Subject: [PATCH 6/9] Repositioned buttons, added bottom margin, repositioned feedback-text. HFJ-946 --- css/questionset.css | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/css/questionset.css b/css/questionset.css index 62b6068..cdb03e1 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -194,10 +194,10 @@ .questionset-results .feedback-section .feedback-text { font-weight: bold; color: #1a73d9; - display: inline-block; - position: relative; - top: -1em; - margin-top: .8em; +} + +.questionset-results .buttons { + margin-bottom: 1.5em; } /* No margin for questions when no frame */ @@ -206,14 +206,12 @@ margin-right: 0; } +.h5p-no-frame .questionset-results .feedback-section, .h5p-no-frame .questionset .h5p-question > *:first-child { margin-top: 0; } +.h5p-no-frame .questionset-results .buttons, .h5p-no-frame .questionset .h5p-question > *:last-child { margin-bottom: 0; } - -.h5p-no-frame .questionset-results .feedback-section { - margin-top: 0; -} From b9cd56820f7ed17460ca33c3a8f75638d2e83de4 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 19 Aug 2015 16:05:16 +0200 Subject: [PATCH 7/9] Adjusted paddings/margins for H5P.Question HFJ-942 --- css/questionset.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/questionset.css b/css/questionset.css index cdb03e1..fef0b6f 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -188,7 +188,7 @@ } .questionset-results .feedback-section { - margin: 1.5em; + margin: 1em; } .questionset-results .feedback-section .feedback-text { From 7c6aa504fd4e1b9e8a442d27c67cb4b5e60d40f4 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Thu, 20 Aug 2015 16:14:29 +0200 Subject: [PATCH 8/9] Replaced console logs with useful error messages. HFJ-946 --- js/questionset.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index e0ff70f..4333b60 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -195,8 +195,7 @@ H5P.QuestionSet = function (options, contentId) { questionInstances[i].showSolutions(); } catch(error) { - console.log(error); - console.log("subcontent does not contain a valid showSolutions() function"); + H5P.error("subcontent does not contain a valid showSolutions function"); } } }; @@ -212,8 +211,7 @@ H5P.QuestionSet = function (options, contentId) { questionInstances[i].resetTask(); } catch(error) { - console.log(error); - console.log("subcontent does not contain a valid resetTask() function"); + H5P.error("subcontent does not contain a valid resetTask function"); } } From 9b0844c480231becd0be973dd9f55a1fe74b0c8e Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Thu, 20 Aug 2015 16:16:02 +0200 Subject: [PATCH 9/9] Display error stack as well as useful error message. HFJ-946 --- js/questionset.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/questionset.js b/js/questionset.js index 4333b60..ff08a33 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -196,6 +196,7 @@ H5P.QuestionSet = function (options, contentId) { } catch(error) { H5P.error("subcontent does not contain a valid showSolutions function"); + H5P.error(error); } } }; @@ -212,6 +213,7 @@ H5P.QuestionSet = function (options, contentId) { } catch(error) { H5P.error("subcontent does not contain a valid resetTask function"); + H5P.error(error); } }