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

HFP-3825 Do not send xAPI completed on resume #286

Open
wants to merge 1 commit 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
22 changes: 16 additions & 6 deletions src/scripts/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ CoursePresentation.prototype.attach = function ($container) {
new SlideBackground(this);

if (this.previousState && this.previousState.progress) {
this.jumpToSlide(this.previousState.progress, false, null, false, true);
this.jumpToSlide(this.previousState.progress, false, null, false, true, true);
}
};

Expand Down Expand Up @@ -1843,9 +1843,11 @@ CoursePresentation.prototype.attachAllElements = function () {
*
* @param {number} slideNumber The slide number to jump to.
* @param {Boolean} [noScroll] Skip UI scrolling.
* @param {Boolean} [handleFocus] If true, will focus the slide number announcer.
* @param {Boolean} [noXAPI] If true, will not trigger xAPI events.
* @returns {Boolean} Always true.
*/
CoursePresentation.prototype.processJumpToSlide = function (slideNumber, noScroll, handleFocus) {
CoursePresentation.prototype.processJumpToSlide = function (slideNumber, noScroll, handleFocus, noXAPI) {
var that = this;
if (this.editor === undefined && this.contentId) { // Content ID avoids crash when previewing in editor before saving
var progressedEvent = this.createXAPIEventTemplate('progressed');
Expand Down Expand Up @@ -1940,7 +1942,7 @@ CoursePresentation.prototype.processJumpToSlide = function (slideNumber, noScrol

if (that.summarySlideObject) {
// Update summary slide if on last slide, do not jump
that.summarySlideObject.updateSummarySlide(slideNumber, true);
that.summarySlideObject.updateSummarySlide(slideNumber, true, noXAPI);
}

// Editor specific settings
Expand All @@ -1962,9 +1964,17 @@ CoursePresentation.prototype.processJumpToSlide = function (slideNumber, noScrol
* @param {Boolean} [noScroll] Skip UI scrolling.
* @param {Function|null} [callback] Callback to execute on successfull navigation
* @param {Boolean} [ignoreConfirmationDialog] Will not show confirmation dialog for summary slide
* @param {Boolean} [noXAPI] If true, will not trigger xAPI events.
* @returns {Boolean}
*/
CoursePresentation.prototype.jumpToSlide = function (slideNumber, noScroll = false, callback = null, handleFocus = false, ignoreConfirmationDialog = false) {
CoursePresentation.prototype.jumpToSlide = function (
slideNumber,
noScroll = false,
callback = null,
handleFocus = false,
ignoreConfirmationDialog = false,
noXAPI = false
) {
if (this.standalone
&& this.showSummarySlide
&& slideNumber === this.slides.length - 1
Expand All @@ -1988,14 +1998,14 @@ CoursePresentation.prototype.jumpToSlide = function (slideNumber, noScroll = fal
return false;
});
confirmationDialog.on('confirmed', () => {
this.processJumpToSlide(slideNumber, noScroll, handleFocus);
this.processJumpToSlide(slideNumber, noScroll, handleFocus, noXAPI);
if (callback) {
callback();
}
});
}
else {
this.processJumpToSlide(slideNumber, noScroll, handleFocus);
this.processJumpToSlide(slideNumber, noScroll, handleFocus, noXAPI);
if (callback) {
callback();
}
Expand Down
10 changes: 6 additions & 4 deletions src/scripts/summary-slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const SummarySlide = (function () {
* Updates the provided summary slide with current values.
*
* @param {$} $summarySlide Summary slide that will be updated
* @param {Boolean} [noXAPI] If true, will not trigger xAPI events.
*/
SummarySlide.prototype.updateSummarySlide = function (slideNumber, noJump) {
SummarySlide.prototype.updateSummarySlide = function (slideNumber, noJump, noXAPI) {
var that = this;
// Validate update.
var isValidUpdate = (this.cp.editor === undefined) && (this.$summarySlide !== undefined) && (slideNumber >= this.cp.slides.length - 1);
Expand All @@ -39,7 +40,7 @@ const SummarySlide = (function () {

// Get scores and updated html for summary slide
var slideScores = that.cp.getSlideScores(noJump);
var htmlText = that.outputScoreStats(slideScores);
var htmlText = that.outputScoreStats(slideScores, noXAPI);
$(htmlText).appendTo(that.$summarySlide);

if (!isExportSlide) {
Expand Down Expand Up @@ -146,9 +147,10 @@ const SummarySlide = (function () {
* Gets html for summary slide.
*
* @param slideScores Scores for all pages
* @param {Boolean} [noXAPI] If true, will not trigger xAPI events.
* @returns {string} html
*/
SummarySlide.prototype.outputScoreStats = function (slideScores) {
SummarySlide.prototype.outputScoreStats = function (slideScores, noXAPI) {
var self = this;
if (slideScores === undefined) {
this.$summarySlide.addClass('h5p-summary-only-export');
Expand Down Expand Up @@ -189,7 +191,7 @@ const SummarySlide = (function () {
}

// this.cp.ignoreResize is true when printing; do not xAPI submit on print.
if (!this.cp.isSolutionMode && !this.cp.ignoreResize) {
if (!this.cp.isSolutionMode && !this.cp.ignoreResize && !noXAPI) {
that.cp.triggerXAPICompleted(totalScore, totalMaxScore);
}
var shareResultContainer = (that.cp.enableTwitterShare || that.cp.enableFacebookShare || that.cp.enableGoogleShare) ? '<span class="h5p-show-results-text">' + that.cp.l10n.shareResult + '</span>' : '';
Expand Down