Added overall feedback to question set + bonus fixes [HFP-1174]

pull/15/head
Paal Joergensen 2017-07-03 15:09:49 +02:00
parent 8ca94b1079
commit 9401e5abe3
5 changed files with 116 additions and 45 deletions

View File

@ -225,30 +225,27 @@
font-size: 1.25em;
}
.questionset-results .feedback-section .feedback-text {
font-weight: normal;
color: #777;
}
.questionset-results .buttons {
margin-bottom: 1.5em;
margin: 2em 0 1em 0;
}
.questionset-results .result-header,
.questionset-results .result-text {
.questionset-results .result-text,
.questionset-results .feedback-section .feedback-text {
color: #1a73d9;
font-weight: bold;
}
.questionset-results .result-header {
font-size: 2em;
margin-top: 1em;
margin: 1em 0.5em 0.5em 0.5em;
}
.questionset-results .result-text {
.questionset-results .result-text,
.questionset-results .feedback-section .feedback-text {
font-size: 1.25em;
line-height: 1.25em;
margin: 1em 1em 2.25em;
margin: 1em;
}
/* No margin for questions when no frame */

View File

@ -112,11 +112,11 @@ H5P.QuestionSet = function (options, contentId, contentData) {
showResultPage: true,
noResultMessage: 'Finished',
message: 'Your result:',
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: 'You got @score of @total points',
successGreeting: '',
successComment: '',
failGreeting: '',
failComment: '',
overallFeedback: [],
finishButtonText: 'Finish',
solutionButtonText: 'Show solution',
retryButtonText: 'Retry',
@ -420,13 +420,17 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var hasAutoPlay = currentQuestion
&& currentQuestion.params.media
&& currentQuestion.params.media.params
&& currentQuestion.params.media.params.playback
&& currentQuestion.params.media.params.playback.autoplay;
if (hasAutoPlay) {
if (hasAutoPlay && typeof questionInstances[currentQuestionIndex].play === 'function') {
questionInstances[currentQuestionIndex].play();
}
};
/**
* Show solutions for subcontent, and hide subcontent buttons.
* Used for contracts with integrated content.
@ -703,12 +707,9 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Get total score.
var finals = self.getScore();
var totals = self.getMaxScore();
var scoreString = params.endGame.scoreString.replace("@score", finals).replace("@total", totals);
var scoreString = H5P.Question.determineOverallFeedback(params.endGame.overallFeedback, finals / totals).replace('@score', finals).replace('@total', totals);
var success = ((100 * finals / totals) >= params.passPercentage);
var eventData = {
score: scoreString,
passed: success
};
/**
* Makes our buttons behave like other buttons.
@ -743,10 +744,6 @@ H5P.QuestionSet = function (options, contentId, contentData) {
$myDom.append(endTemplate.render(eparams));
if (params.endGame.showResultPage) {
// Add event handlers to summary buttons
hookUpButton('.qs-finishbutton', function () {
self.trigger('h5pQuestionSetFinished', eventData);
});
hookUpButton('.qs-solutionbutton', function () {
showSolutions();
$myDom.children().hide().filter('.questionset').show();

View File

@ -14,7 +14,7 @@
"author": "Joubel",
"coreApi": {
"majorVersion": 1,
"minorVersion": 6
"minorVersion": 14
},
"license": "MIT",
"preloadedJs": [
@ -50,6 +50,11 @@
}
],
"editorDependencies": [
{
"machineName": "H5PEditor.RangeList",
"majorVersion": 1,
"minorVersion": 0
},
{
"machineName": "H5PEditor.VerticalTabs",
"majorVersion": 1,
@ -61,4 +66,4 @@
"minorVersion": 2
}
]
}
}

View File

@ -122,7 +122,7 @@
"description": "Library for this question.",
"options": [
"H5P.MultiChoice 1.9",
"H5P.DragQuestion 1.10",
"H5P.DragQuestion 1.11",
"H5P.Blanks 1.7",
"H5P.MarkTheWords 1.6",
"H5P.DragText 1.5",
@ -276,7 +276,6 @@
"label": "Feedback heading",
"importance": "low",
"default": "Your result:",
"optional": true,
"description": "This heading will be displayed at the end of the quiz when the user has answered all questions.",
"tags": [
"strong",
@ -284,27 +283,74 @@
]
},
{
"name": "scoreString",
"type": "text",
"label": "Score display text",
"name": "overallFeedback",
"type": "group",
"label": "Overall Feedback",
"importance": "low",
"description": "Text used to display Total user score. \"@score\" will be replaced by calculated score, \"@total\" will be replaced by maximum possible score. ",
"default": "You got @score of @total points",
"optional": true
"fields": [
{
"name": "overallFeedback",
"type": "list",
"widgets": [
{
"name": "RangeList",
"label": "Default"
}
],
"importance": "high",
"label": "Define custom feedback for any score range",
"description": "Example: 0-20% Bad score, 21-91% Average Score, 91-100% Great Score!",
"entity": "range",
"min": 1,
"defaultNum": 1,
"optional": true,
"field": {
"name": "overallFeedback",
"type": "group",
"importance": "low",
"fields": [
{
"name": "from",
"type": "number",
"label": "Score Range",
"min": 0,
"max": 100,
"default": 0,
"unit": "%"
},
{
"name": "to",
"type": "number",
"min": 0,
"max": 100,
"default": 100,
"unit": "%"
},
{
"name": "feedback",
"type": "text",
"label": "Feedback for defined score range",
"importance": "low",
"placeholder": "Fill in the feedback",
"optional": true
}
]
}
}
]
},
{
"name": "successGreeting",
"type": "text",
"label": "Quiz passed greeting",
"importance": "low",
"placeholder": "Congratulations!",
"default": "Congratulations!",
"optional": true,
"description": "This text will be displayed above the score if the user has successfully passed the quiz.",
"tags": [
"strong",
"em"
]
],
"deprecated": true
},
{
"name": "successComment",
@ -312,7 +358,6 @@
"widget": "html",
"label": "Passed comment",
"importance": "low",
"default": "You did very well!",
"optional": true,
"description": "This comment will be displayed after the score if the user has successfully passed the quiz.",
"tags": [
@ -322,20 +367,21 @@
"em",
"a",
"p"
]
],
"deprecated": true
},
{
"name": "failGreeting",
"type": "text",
"label": "Quiz failed title",
"importance": "low",
"default": "You did not pass this time.",
"optional": true,
"description": "This text will be displayed above the score if the user has failed the quiz.",
"tags": [
"strong",
"em"
]
],
"deprecated": true
},
{
"name": "failComment",
@ -343,7 +389,6 @@
"widget": "html",
"label": "Failed comment",
"importance": "low",
"default": "Have another try!",
"optional": true,
"description": "This comment will be displayed after the score if the user has failed the quiz.",
"tags": [
@ -353,7 +398,8 @@
"em",
"a",
"p"
]
],
"deprecated": true
},
{
"name": "solutionButtonText",
@ -460,4 +506,4 @@
}
]
}
]
]

View File

@ -52,6 +52,32 @@ H5PUpgrades['H5P.QuestionSet'] = (function ($) {
// Remove old copyright dialog question label
delete parameters.questionLabel;
finished(null, parameters);
},
/**
* Asynchronous content upgrade hook.
*
* Upgrade params to support overall feedback
*
* @param {Object} parameters
* @param {function} finished
*/
13: function (parameters, finished) {
parameters.endGame = parameters.endGame || {};
parameters.endGame.overallFeedback = [];
if (parameters.endGame.scoreString) {
parameters.endGame.overallFeedback.push({
from: 0,
to: 100,
feedback: parameters.endGame.scoreString
});
delete parameters.endGame.scoreString;
}
finished(null, parameters);
}
}