From c3c098b6c094d5523de41e2f471a22f6e713a143 Mon Sep 17 00:00:00 2001 From: Sergey Yuhnevich Date: Fri, 2 Jun 2017 16:18:56 +0300 Subject: [PATCH] Add configuration for check button --- library.json | 4 ++-- scripts/mark-the-words.js | 37 ++++++++++++++++++++----------------- semantics.json | 8 ++++++++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/library.json b/library.json index 51be07c..13df3f3 100644 --- a/library.json +++ b/library.json @@ -3,7 +3,7 @@ "description": "Test your users by making them select the correct words from a text.", "majorVersion": 1, "minorVersion": 6, - "patchVersion": 8, + "patchVersion": 9, "coreApi": { "majorVersion": 1, "minorVersion": 6 @@ -48,4 +48,4 @@ "minorVersion": 2 } ] -} \ No newline at end of file +} diff --git a/scripts/mark-the-words.js b/scripts/mark-the-words.js index a1f1955..a37831c 100644 --- a/scripts/mark-the-words.js +++ b/scripts/mark-the-words.js @@ -28,6 +28,7 @@ H5P.MarkTheWords = (function ($, Question, Word, KeyboardNav, XapiGenerator) { taskDescription: "", textField: "This is a *nice*, *flexible* content type.", behaviour: { + enableCheck: true, enableRetry: true, enableSolutionsButton: true }, @@ -222,26 +223,28 @@ H5P.MarkTheWords = (function ($, Question, Word, KeyboardNav, XapiGenerator) { 'class': 'h5p-button-bar' }); - this.addButton('check-answer', this.params.checkAnswerButton, function () { - self.isAnswered = true; - self.keyboardNav.setTabbableAt(0); - self.keyboardNav.disableSelectability(); - self.feedbackSelectedWords(); - self.hideButton('check-answer'); + if (this.params.behaviour.enableCheck) { + this.addButton('check-answer', this.params.checkAnswerButton, function () { + self.isAnswered = true; + self.keyboardNav.setTabbableAt(0); + self.keyboardNav.disableSelectability(); + self.feedbackSelectedWords(); + self.hideButton('check-answer'); - var answers = self.calculateScore(); + var answers = self.calculateScore(); - if (!self.showEvaluation(answers)) { - // Only show if a correct answer was not found. - if (self.params.behaviour.enableSolutionsButton && (answers.correct < self.answers)) { - self.showButton('show-solution'); - } - if (self.params.behaviour.enableRetry) { - self.showButton('try-again'); + if (!self.showEvaluation(answers)) { + // Only show if a correct answer was not found. + if (self.params.behaviour.enableSolutionsButton && (answers.correct < self.answers)) { + self.showButton('show-solution'); + } + if (self.params.behaviour.enableRetry) { + self.showButton('try-again'); + } } - } - self.trigger(self.XapiGenerator.generateAnsweredEvent()); - }); + self.trigger(self.XapiGenerator.generateAnsweredEvent()); + }); + } this.addButton('try-again', this.params.tryAgainButton, this.resetTask.bind(this), false); diff --git a/semantics.json b/semantics.json index 76d2527..64d8631 100644 --- a/semantics.json +++ b/semantics.json @@ -81,6 +81,14 @@ "description": "These options will let you control how the task behaves.", "optional": true, "fields": [ + { + "name": "enableCheck", + "type": "boolean", + "label": "Enable \"Check\" button", + "importance": "low", + "default": true, + "optional": true + }, { "name": "enableRetry", "type": "boolean",