Return score and passed as event data in 'h5pQuestionSetFinished' event
parent
b4d4944e12
commit
748412e206
|
@ -80,7 +80,7 @@ H5P.QuestionSet = function (options) {
|
||||||
randomOrder: false,
|
randomOrder: false,
|
||||||
initialQuestion: 0,
|
initialQuestion: 0,
|
||||||
backgroundImage: "",
|
backgroundImage: "",
|
||||||
progressType: 'textual',
|
progressType: 'dots',
|
||||||
passPercentage: 50,
|
passPercentage: 50,
|
||||||
questions: [],
|
questions: [],
|
||||||
introPage: {
|
introPage: {
|
||||||
|
@ -210,7 +210,10 @@ H5P.QuestionSet = function (options) {
|
||||||
var totals = totalScore();
|
var totals = totalScore();
|
||||||
var scoreString = params.endGame.resultPage.scoreString.replace("@score", finals).replace("@total", totals);
|
var scoreString = params.endGame.resultPage.scoreString.replace("@score", finals).replace("@total", totals);
|
||||||
var success = ((100 * finals / totals) >= params.passPercentage);
|
var success = ((100 * finals / totals) >= params.passPercentage);
|
||||||
|
var eventData = {
|
||||||
|
score: scoreString,
|
||||||
|
passed: success
|
||||||
|
};
|
||||||
// Display result page.
|
// Display result page.
|
||||||
if (params.endGame.showResultPage) {
|
if (params.endGame.showResultPage) {
|
||||||
// Render result page into.
|
// Render result page into.
|
||||||
|
@ -228,14 +231,14 @@ H5P.QuestionSet = function (options) {
|
||||||
// Init anims.
|
// Init anims.
|
||||||
console.log("Now we should have started some anims...");
|
console.log("Now we should have started some anims...");
|
||||||
// On animation finished:
|
// On animation finished:
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished');
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
} else {
|
} else {
|
||||||
// Trigger finished event.
|
// Trigger finished event.
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished');
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished');
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue