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 1 commit
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
9 changes: 7 additions & 2 deletions js/dragquestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use two whitespaces instead of tabs, as described in H5P code style document.

if(this.points == maxScore)
scoreText = this.options.feedback.replace('@score', this.points).replace('@total', maxScore);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use H5P code style guidelines for if clauses, i.e. curly braces

else
scoreText = this.options.incorrect_feedback.replace('@score', this.points).replace('@total', maxScore);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect_feedback is undefined for old content. It needs a default value set in JS. see extended options

this.setFeedback(scoreText, this.points, maxScore);
};

Expand Down
14 changes: 11 additions & 3 deletions semantics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic common fields default to "false", there is no need to specify this. You can remove the "common": false line.

},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New semantics must be added to all language files

"label": "Incorrect feedback text",
"name": "incorrect_feedback",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript variable should be in camelCase for consistency with other variables, i.e. change to "incorrectFeedback"

"type": "text",
"default": "Sorry, this answer is incorrect",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think default text should tell the score. I think it is fine to keep the default text that was here previously, and let authors customize this if they want. i.e. change to "You got @score of @ToTal points".

"description": "Feedback text when incorrect answer is given, variables available: @score and @total.'",
"common": false
},
{
"name": "question",
Expand Down