Skip to content

Commit

Permalink
Adding setting to always commit total_time, listeners for commit requ…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
jcputney committed Aug 14, 2020
1 parent e9fee3c commit 4582d73
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
17 changes: 13 additions & 4 deletions dist/scorm-again.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/scorm-again.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/scorm-again.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scorm-again",
"version": "1.3.6",
"version": "1.4.0",
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
"main": "dist/scorm-again.min.js",
"directories": {
Expand Down
9 changes: 8 additions & 1 deletion src/BaseAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class BaseAPI {
autoProgress: false,
logLevel: global_constants.LOG_LEVEL_ERROR,
selfReportSessionTime: false,
alwaysSendTotalTime: false,
responseHandler: function(xhr) {
let result;
if (typeof xhr !== 'undefined') {
Expand Down Expand Up @@ -1065,7 +1066,13 @@ export default class BaseAPI {
errorCode: 0,
};
} else {
return process(url, params, this.settings, this.error_codes);
const result = process(url, params, this.settings, this.error_codes);
if (result.errorCode === 0) {
this.processListeners('CommitSuccess');
} else {
this.processListeners('CommitError');
}
return result;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Scorm12API.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,17 @@ export default class Scorm12API extends BaseAPI {
}
}

const commitObject = this.renderCommitCMI(terminateCommit);
const commitObject = this.renderCommitCMI(terminateCommit ||
this.settings.alwaysSendTotalTime);

if (this.settings.lmsCommitUrl) {
if (this.apiLogLevel === global_constants.LOG_LEVEL_DEBUG) {
console.debug('Commit (terminated: ' +
(terminateCommit ? 'yes' : 'no') + '): ');
console.debug(commitObject);
}
return this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit);
return this.processHttpRequest(this.settings.lmsCommitUrl, commitObject,
terminateCommit);
} else {
console.log('Commit (terminated: ' +
(terminateCommit ? 'yes' : 'no') + '): ');
Expand Down
5 changes: 3 additions & 2 deletions src/Scorm2004API.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ export default class Scorm2004API extends BaseAPI {
navRequest = true;
}

const commitObject = this.renderCommitCMI(terminateCommit);
const commitObject = this.renderCommitCMI(terminateCommit ||
this.settings.alwaysSendTotalTime);

if (this.settings.lmsCommitUrl) {
if (this.apiLogLevel === global_constants.LOG_LEVEL_DEBUG) {
Expand All @@ -561,7 +562,7 @@ export default class Scorm2004API extends BaseAPI {
// check if this is a sequencing call, and then call the necessary JS
{
if (navRequest && result.navRequest !== undefined &&
result.navRequest !== '') {
result.navRequest !== '') {
Function(`"use strict";(() => { ${result.navRequest} })()`)();
}
}
Expand Down

0 comments on commit 4582d73

Please sign in to comment.