From 7a86d92290ce143e26711a280fdaf7e771692e37 Mon Sep 17 00:00:00 2001 From: supriyarajgopal-spi Date: Thu, 1 Sep 2016 12:44:11 +0530 Subject: [PATCH 1/2] Issue #9 Added 'Incorrect feedback text' support 'Incorrect feedback text' field is added and showScore() is modified to show (in)correct feedback per drag-and-drop question. Also made the 'common' setting as 'false' and changed the label for 'Feedback' field so that it appears on every drag-and-drop question instead of for the whole question set --- js/dragquestion.js | 9 +++++++-- semantics.json | 14 +++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/js/dragquestion.js b/js/dragquestion.js index 241f3db5..342af2e3 100644 --- a/js/dragquestion.js +++ b/js/dragquestion.js @@ -669,14 +669,19 @@ H5P.DragQuestion = (function ($) { }; /** - * Shows the score to the user when the score button i pressed. + * Shows the score to the user when the score button is pressed. + * Modified by SUPRIYA RAJGOPAL on 1Sep16 to show (in)correct feedback depending on the points scored */ C.prototype.showScore = function () { var maxScore = this.calculateMaxScore(); if (this.options.behaviour.singlePoint) { maxScore = 1; } - var scoreText = this.options.feedback.replace('@score', this.points).replace('@total', maxScore); + var scoreText; + if(this.points == maxScore) + scoreText = this.options.feedback.replace('@score', this.points).replace('@total', maxScore); + else + scoreText = this.options.incorrect_feedback.replace('@score', this.points).replace('@total', maxScore); this.setFeedback(scoreText, this.points, maxScore); }; diff --git a/semantics.json b/semantics.json index 4f39689e..bc63299d 100644 --- a/semantics.json +++ b/semantics.json @@ -22,12 +22,20 @@ "common": true }, { - "label": "Feedback text", + "label": "Correct feedback text", "name": "feedback", "type": "text", "default": "You got @score of @total points", - "description": "Feedback text, variables available: @score and @total. Example: 'You got @score of @total points.'", - "common": true + "description": "Feedback text when correct answer is given, variables available: @score and @total. Example: 'You got @score of @total points.'", + "common": false + }, + { + "label": "Incorrect feedback text", + "name": "incorrect_feedback", + "type": "text", + "default": "Sorry, this answer is incorrect", + "description": "Feedback text when incorrect answer is given, variables available: @score and @total.'", + "common": false }, { "name": "question", From c3a40ffcb0342d6e669cef0913c96400695a829b Mon Sep 17 00:00:00 2001 From: supriyarajgopal-spi Date: Mon, 24 Oct 2016 16:49:17 +0530 Subject: [PATCH 2/2] Implemented suggestions by H5P moderator - Indentation - Camel casing - Changes to semantics.json - Added default Incorrect Feedback text --- js/dragquestion.js | 15 +++++++++------ library.json | 2 +- semantics.json | 30 ++++++++++++++---------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/js/dragquestion.js b/js/dragquestion.js index 342af2e3..c37040a5 100644 --- a/js/dragquestion.js +++ b/js/dragquestion.js @@ -25,6 +25,7 @@ H5P.DragQuestion = (function ($) { correct: 'Show solution', tryAgain: 'Retry', feedback: 'You got @score of @total points', + incorrectFeedback: 'You got @score of @total points', question: { settings: { questionTitle: 'Drag and drop', @@ -670,18 +671,20 @@ H5P.DragQuestion = (function ($) { /** * Shows the score to the user when the score button is pressed. - * Modified by SUPRIYA RAJGOPAL on 1Sep16 to show (in)correct feedback depending on the points scored + * Show (in)correct feedback depending on the points scored */ C.prototype.showScore = function () { var maxScore = this.calculateMaxScore(); if (this.options.behaviour.singlePoint) { maxScore = 1; } - var scoreText; - if(this.points == maxScore) - scoreText = this.options.feedback.replace('@score', this.points).replace('@total', maxScore); - else - scoreText = this.options.incorrect_feedback.replace('@score', this.points).replace('@total', maxScore); + var scoreText; + if (this.points == maxScore) { + scoreText = this.options.feedback.replace('@score', this.points).replace('@total', maxScore); + } + else { + scoreText = this.options.incorrectFeedback.replace('@score', this.points).replace('@total', maxScore); + } this.setFeedback(scoreText, this.points, maxScore); }; diff --git a/library.json b/library.json index fb4bbf9c..50efae0c 100644 --- a/library.json +++ b/library.json @@ -4,7 +4,7 @@ "contentType": "Question", "majorVersion": 1, "minorVersion": 6, - "patchVersion": 2, + "patchVersion": 3, "embedTypes": [ "iframe" ], diff --git a/semantics.json b/semantics.json index bc63299d..8cc74279 100644 --- a/semantics.json +++ b/semantics.json @@ -21,22 +21,6 @@ "default": "Show solution", "common": true }, - { - "label": "Correct feedback text", - "name": "feedback", - "type": "text", - "default": "You got @score of @total points", - "description": "Feedback text when correct answer is given, variables available: @score and @total. Example: 'You got @score of @total points.'", - "common": false - }, - { - "label": "Incorrect feedback text", - "name": "incorrect_feedback", - "type": "text", - "default": "Sorry, this answer is incorrect", - "description": "Feedback text when incorrect answer is given, variables available: @score and @total.'", - "common": false - }, { "name": "question", "type": "group", @@ -252,6 +236,20 @@ } ] }, + { + "label": "Correct feedback text", + "name": "feedback", + "type": "text", + "default": "You got @score of @total points", + "description": "Feedback text when correct answer is given, variables available: @score and @total. Example: 'You got @score of @total points.'" + }, + { + "label": "Incorrect feedback text", + "name": "incorrectFeedback", + "type": "text", + "default": "You got @score of @total points", + "description": "Feedback text when incorrect answer is given, variables available: @score and @total.'" + }, { "name": "backgroundOpacity", "type": "text",