diff --git a/css/questionset.css b/css/questionset.css index 49ebe12..152b284 100644 --- a/css/questionset.css +++ b/css/questionset.css @@ -54,7 +54,7 @@ } .questionset-results .greeting { - margin-top: 180px; + margin: 1em; } .questionset-results .score { diff --git a/js/questionset.js b/js/questionset.js index 2a7c822..27edb9c 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -71,14 +71,14 @@ H5P.QuestionSet = function (options, contentId) { title: '', randomOrder: false, initialQuestion: 0, - backgroundImage: '', + backgroundImage: undefined, progressType: 'dots', passPercentage: 50, questions: [], introPage: { showIntroPage: true, - title: 'Welcome', - introduction: 'Click start to start.', + title: '', + introduction: '', startButtonText: 'Start' }, texts: { @@ -89,19 +89,15 @@ H5P.QuestionSet = function (options, contentId) { }, endGame: { showResultPage: true, - resultPage: { - successGreeting: 'Congratulations!', - successComment: 'You have enough correct answers to pass the test.', - failGreeting: 'Sorry!', - failComment: "You don't have enough correct answers to pass this test.", - scoreString: '@score/@total', - finishButtonText: 'Finish' - }, - animations: { - showAnimations: false, - successVideo: undefined, - failVideo: undefined - } + successGreeting: 'Congratulations!', + successComment: 'You have enough correct answers to pass the test.', + failGreeting: 'Sorry!', + failComment: "You don't have enough correct answers to pass this test.", + scoreString: '@score/@total', + finishButtonText: 'Finish', + showAnimations: false, + successVideo: undefined, + failVideo: undefined } }; @@ -186,7 +182,7 @@ H5P.QuestionSet = function (options, contentId) { // Get total score. var finals = getScore(); var totals = totalScore(); - var scoreString = params.endGame.resultPage.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 eventData = { score: scoreString, @@ -199,11 +195,11 @@ H5P.QuestionSet = function (options, contentId) { } var eparams = { - greeting: (success ? params.endGame.resultPage.succesGreeting : params.endGame.resultPage.failGreeting), + greeting: (success ? params.endGame.successGreeting : params.endGame.failGreeting), score: scoreString, scoreclass: (success ? 'success' : 'fail'), - resulttext: (success ? params.endGame.resultPage.successComment : params.endGame.resultPage.failComment), - finishButtonText: params.endGame.resultPage.finishButtonText + resulttext: (success ? params.endGame.successComment : params.endGame.failComment), + finishButtonText: params.endGame.finishButtonText }; // Show result page. @@ -214,8 +210,8 @@ H5P.QuestionSet = function (options, contentId) { }); }; - if (params.endGame.animations.showAnimations) { - var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo; + if (params.endGame.showAnimations) { + var videoData = success ? params.endGame.successVideo : params.endGame.failVideo; if (videoData) { var $videoContainer = $('
').appendTo($myDom); @@ -231,8 +227,8 @@ H5P.QuestionSet = function (options, contentId) { }; video.attach($videoContainer); - if (params.endGame.animations.skipButtonText) { - $('' + params.endGame.animations.skipButtonText + '').click(function () { + if (params.endGame.skipButtonText) { + $('' + params.endGame.skipButtonText + '').click(function () { video.stop(); $videoContainer.hide(); displayResults(); @@ -256,9 +252,12 @@ H5P.QuestionSet = function (options, contentId) { } // Render own DOM into target. - $myDom.html(template.render(params)).css({ - backgroundImage: 'url(' + cp + params.backgroundImage.path + ')' - }); + $myDom.html(template.render(params)); + if (params.backgroundImage !== undefined) { + $myDom.css({ + background: 'url(' + cp + params.backgroundImage.path + ')' + }); + } // Attach questions for (var i = 0; i < questionInstances.length; i++) { diff --git a/semantics.json b/semantics.json index db0c03d..acd3f6b 100644 --- a/semantics.json +++ b/semantics.json @@ -15,12 +15,14 @@ "name": "initialQuestion", "type": "number", "label": "Initial question", - "description": "Which question to start with. Count from 0." + "description": "Which question to start with. Count from 0.", + "default": 0 }, { "name": "backgroundImage", "type": "image", "label": "Background image", + "optional": true, "description": "An optional background image for the Question set." }, { @@ -52,6 +54,7 @@ }, { "name": "questions", + "label": "Questions", "type": "list", "entity": "question", "field": { @@ -74,28 +77,35 @@ { "name": "introPage", "type": "group", - "label": "Intro page", - "description": "Data for the intro page.", + "label": "Quiz introduction", "fields": [ { "name": "showIntroPage", "type": "boolean", - "label": "Show intro page?" + "label": "Display introduction" }, { "name": "title", "type": "text", - "label": "Title" + "label": "Title", + "optional": true, + "description": "This title will be displayed above the introduction text." }, { "name": "introduction", "type": "text", - "label": "Introduction text" + "widget": "textarea", + "label": "Introduction text", + "optional": true, + "description": "This text will be displayed before the quiz starts." }, { "name": "startButtonText", "type": "text", - "label": "Start button text" + "label": "Start button text", + "optional": true, + "placeholder": "Start Quiz", + "default": "Start Quiz" } ] }, @@ -135,87 +145,85 @@ { "name": "endGame", "type": "group", - "label": "End game data", + "label": "Quiz finished", "fields": [ { "name": "showResultPage", "type": "boolean", - "label": "Show result page", + "label": "Display results", "default": true }, { - "name": "resultPage", - "type": "group", - "label": "Result page", - "description": "Data and texts for the result page.", - "fields": [ - { - "name": "successGreeting", - "type": "text", - "label": "Success greeting", - "description": "Title in result page on success." - }, - { - "name": "successComment", - "type": "text", - "label": "Success comment", - "description": "Comment shown after the score." - }, - { - "name": "failGreeting", - "type": "text", - "label": "Failed greeting", - "description": "Title in result page on failed quiz." - }, - { - "name": "failComment", - "type": "text", - "label": "Failed comment", - "description": "Comment shown after the score on failed quiz." - }, - { - "name": "finishButtonText", - "type": "text", - "label": "Finish button text", - "description": "Text for the finish button." - } - ] + "name": "successGreeting", + "type": "text", + "label": "Quiz passed title", + "placeholder": "Congratulations!", + "default": "Congratulations!", + "description": "This title will be displayed above results if the user has successfully passed the quiz." }, { - "name": "animations", - "type": "group", - "label": "Animations", - "fields": [ - { - "name": "showAnimations", - "type": "boolean", - "label": "Show animations" - }, - { - "name": "skippable", - "type": "boolean", - "label": "Skippable" - }, - { - "name": "skipButtonText", - "type": "text", - "label": "Skip button text", - "common": true - }, - { - "name": "successVideo", - "type": "video", - "label": "Success video", - "description": "Video displayed on successful quiz." - }, - { - "name": "failVideo", - "type": "video", - "label": "Fail video", - "description": "Video displayed on failed quiz." - } - ] + "name": "successComment", + "type": "text", + "widget": "textarea", + "label": "Passed comment", + "default": "You did very well!", + "description": "This comment will be displayed after the score if the user has successfully passed the quiz." + }, + { + "name": "failGreeting", + "type": "text", + "label": "Quiz failed title", + "placeholder": "Oh, no!", + "default": "Oh, no!", + "description": "This title will be displayed above the results if the user has failed the quiz." + }, + { + "name": "failComment", + "type": "text", + "widget": "textarea", + "label": "Failed comment", + "default": "This didn't go so well.", + "description": "This comment will be displayed after the score if the user has failed the quiz." + }, + { + "name": "finishButtonText", + "type": "text", + "label": "Finish button text", + "default": "Finish", + "description": "Text for the finish button." + }, + { + "name": "showAnimations", + "type": "boolean", + "label": "Display video before quiz results" + }, + { + "name": "skippable", + "type": "boolean", + "label": "Enable skip video button" + }, + { + "name": "skipButtonText", + "type": "text", + "label": "Skip video button label", + "default": "Skip video", + "description": "This is the label for the button which allows users to skip videos after a quiz.", + "common": true + }, + { + "name": "successVideo", + "type": "video", + "label": "Passed video", + "optional": true, + "description": "This video will be played if the user successfully passed the quiz." + }, + { + "name": "failVideo", + "type": "video", + "label": "Fail video", + "optional": true, + "description": "This video will be played if the user failes the quiz." } ] } -] +] \ No newline at end of file