Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #9 Added 'Incorrect feedback text' support #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions js/dragquestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -669,14 +670,21 @@ 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.
* 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.incorrectFeedback.replace('@score', this.points).replace('@total', maxScore);
}
this.setFeedback(scoreText, this.points, maxScore);
};

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"contentType": "Question",
"majorVersion": 1,
"minorVersion": 6,
"patchVersion": 2,
"patchVersion": 3,
"embedTypes": [
"iframe"
],
Expand Down
22 changes: 14 additions & 8 deletions semantics.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@
"default": "Show solution",
"common": true
},
{
"label": "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
},
{
"name": "question",
"type": "group",
Expand Down Expand Up @@ -244,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",
Expand Down