', {
'class': 'hidden-but-read',
}).appendTo(this.$scoreStatus);
UI.createButton({
text: t.retryButton,
'class': 'mq-control-button',
click: function () {
self.trigger('retry');
self.update(0, '00:00');
self.scoreBar.reset();
}
}).appendTo(this.$feedbackContainer);
this.$resultAnnouncer = $('
', {
'class': 'h5p-baq-live-feedback',
'aria-live': 'assertive',
}).appendTo(this.$resultPage);
/**
* Creates result page
*
* @return {H5P.jQuery}
*/
this.create = function () {
return this.$resultPage;
};
/**
* Get score as a string
* @param {Number} score Current score
* @return {String} Score string
*/
this.getReadableScore = function (score) {
return t.score + ' ' + score + '/' + this.maxScore;
};
/**
* Get readable time
* @param {String} time Current time in the format: "minutes:seconds"
* @returns {*|void|string|null}
*/
this.getReadableTime = function (time) {
return t.time.replace('@time', time.replace(':', ', '));
};
/**
* Announce result page info
* @param {Number} score Current score
* @param {String} time Current time in the format: "minutes:seconds"
*/
this.announce = function (score, time) {
let text = t.resultPageHeader + ' ';
text += this.getReadableScore(score) + '. ';
text += this.getReadableTime(time);
// Readspeaker needs a small delay after creating the aria live field
// in order to pick up the change
setTimeout(function () {
self.$resultAnnouncer.text(text);
}, 100);
};
/**
* Updates result page
*
* @param {number} score
* @param {string} time
*/
this.update = function (score, time) {
let minutes = parseInt(time.split(':')[0], 10);
let seconds = parseInt(time.split(':')[1], 10);
const dateTime = 'PT' + minutes + 'M' + seconds + 'S';
const timeHtml = '' + time + ' ';
this.$time.html(H5P.ArithmeticQuiz.tReplace(t.time, {time: timeHtml}));
this.$ariaTime.html(this.getReadableTime(time));
this.scoreBar.setScore(score);
this.$ariaScoreBar.text(this.getReadableScore(score));
this.announce(score, time);
};
}
ResultPage.prototype = Object.create(H5P.EventDispatcher.prototype);
ResultPage.prototype.constructor = ResultPage;
return ResultPage;
})(H5P.jQuery, H5P.JoubelUI);