scorm-again 2.3.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +2 -1
  2. package/dist/aicc.js +3165 -2799
  3. package/dist/aicc.js.map +1 -1
  4. package/dist/aicc.min.js +1 -1
  5. package/dist/aicc.min.js.map +1 -1
  6. package/dist/esm/aicc.js +4573 -0
  7. package/dist/esm/aicc.js.map +1 -0
  8. package/dist/esm/aicc.min.js +2 -0
  9. package/dist/esm/aicc.min.js.map +1 -0
  10. package/dist/esm/scorm-again.js +6959 -0
  11. package/dist/esm/scorm-again.js.map +1 -0
  12. package/dist/esm/scorm-again.min.js +2 -0
  13. package/dist/esm/scorm-again.min.js.map +1 -0
  14. package/dist/esm/scorm12.js +3641 -0
  15. package/dist/esm/scorm12.js.map +1 -0
  16. package/dist/esm/scorm12.min.js +2 -0
  17. package/dist/esm/scorm12.min.js.map +1 -0
  18. package/dist/esm/scorm2004.js +4635 -0
  19. package/dist/esm/scorm2004.js.map +1 -0
  20. package/dist/esm/scorm2004.min.js +2 -0
  21. package/dist/esm/scorm2004.min.js.map +1 -0
  22. package/dist/scorm-again.js +4506 -4086
  23. package/dist/scorm-again.js.map +1 -1
  24. package/dist/scorm-again.min.js +1 -1
  25. package/dist/scorm-again.min.js.map +1 -1
  26. package/dist/scorm12.js +3079 -2757
  27. package/dist/scorm12.js.map +1 -1
  28. package/dist/scorm12.min.js +1 -1
  29. package/dist/scorm12.min.js.map +1 -1
  30. package/dist/scorm2004.js +2434 -2221
  31. package/dist/scorm2004.js.map +1 -1
  32. package/dist/scorm2004.min.js +1 -1
  33. package/dist/scorm2004.min.js.map +1 -1
  34. package/index.d.ts +69 -4
  35. package/package.json +11 -8
  36. package/src/AICC.ts +7 -5
  37. package/src/BaseAPI.ts +39 -22
  38. package/src/Scorm12API.ts +27 -32
  39. package/src/Scorm2004API.ts +16 -21
  40. package/src/ScormAgain.ts +9 -0
  41. package/src/cmi/aicc/attempts.ts +7 -7
  42. package/src/cmi/aicc/cmi.ts +4 -4
  43. package/src/cmi/aicc/core.ts +1 -1
  44. package/src/cmi/aicc/evaluation.ts +1 -1
  45. package/src/cmi/aicc/student_data.ts +2 -2
  46. package/src/cmi/aicc/student_preferences.ts +2 -2
  47. package/src/cmi/aicc/tries.ts +7 -7
  48. package/src/cmi/scorm12/cmi.ts +1 -1
  49. package/src/cmi/scorm12/interactions.ts +1 -1
  50. package/src/cmi/scorm2004/adl.ts +2 -2
  51. package/src/cmi/scorm2004/cmi.ts +1 -1
  52. package/src/cmi/scorm2004/interactions.ts +1 -1
  53. package/src/cmi/scorm2004/objectives.ts +1 -1
  54. package/src/cmi/scorm2004/score.ts +1 -1
  55. package/src/constants/default_settings.ts +6 -1
  56. package/src/types/api_types.ts +1 -0
  57. package/test/AICC.spec.ts +2 -2
  58. package/test/Scorm12API.spec.ts +174 -3
  59. package/test/Scorm2004API.spec.ts +18 -18
  60. package/tsconfig.json +1 -0
  61. package/webpack.config.js +38 -15
  62. package/src/exports/aicc.js +0 -3
  63. package/src/exports/scorm-again.js +0 -7
  64. package/src/exports/scorm12.js +0 -3
  65. package/src/exports/scorm2004.js +0 -3
  66. package/src/utilities/debounce.ts +0 -31
  67. package/test/utilities/debounce.spec.ts +0 -56
package/index.d.ts CHANGED
@@ -1,5 +1,70 @@
1
- import Scorm2004API from "./src/Scorm2004API.ts";
2
- import Scorm12API from "./src/Scorm12API.ts";
3
- import AICC from "./src/AICC.ts";
1
+ import { Scorm12Impl } from "./src/Scorm12API";
2
+ import { CMI as Scorm12CMI } from "./src/cmi/scorm12/cmi";
3
+ import { NAV as Scorm12NAV } from "./src/cmi/scorm12/nav";
4
+ import { CMI as Scorm2004CMI } from "./src/cmi/scorm2004/cmi";
5
+ import { ADL as Scorm2004ADL } from "./src/cmi/scorm2004/adl";
6
+ import { Settings } from "./src/types/api_types";
7
+ import { Scorm2004Impl } from "./src/Scorm2004API";
8
+ import { AICCImpl } from "./src/AICC";
4
9
 
5
- export { Scorm2004API, Scorm12API, AICC };
10
+ declare class Scorm12API extends Scorm12Impl {
11
+ constructor(settings?: Settings);
12
+
13
+ cmi: Scorm12CMI;
14
+ nav: Scorm12NAV;
15
+ LMSInitialize: () => string;
16
+ LMSFinish: () => string;
17
+ LMSGetValue: (CMIElement: string) => string;
18
+ LMSSetValue: (CMIElement: string, value: any) => string;
19
+ LMSCommit: () => string;
20
+ LMSGetLastError: () => string;
21
+ LMSGetErrorString: (CMIErrorCode: string) => string;
22
+ LMSGetDiagnostic: (CMIErrorCode: string) => string;
23
+
24
+ /**
25
+ * Called when the API needs to be reset
26
+ */
27
+ reset(settings?: Settings): void;
28
+ }
29
+
30
+ declare class Scorm2004API extends Scorm2004Impl {
31
+ constructor(settings?: Settings);
32
+
33
+ cmi: Scorm2004CMI;
34
+ adl: Scorm2004ADL;
35
+ Initialize: () => string;
36
+ Terminate: () => string;
37
+ GetValue: (CMIElement: string) => string;
38
+ SetValue: (CMIElement: string, value: any) => string;
39
+ Commit: () => string;
40
+ GetLastError: () => string;
41
+ GetErrorString: (CMIErrorCode: string) => string;
42
+ GetDiagnostic: (CMIErrorCode: string) => string;
43
+
44
+ /**
45
+ * Called when the API needs to be reset
46
+ */
47
+ reset(settings?: Settings): void;
48
+ }
49
+
50
+ declare class AICC extends AICCImpl {
51
+ constructor(settings?: Settings);
52
+
53
+ cmi: Scorm12CMI;
54
+ nav: Scorm12NAV;
55
+ LMSInitialize: () => string;
56
+ LMSFinish: () => string;
57
+ LMSGetValue: (CMIElement: string) => string;
58
+ LMSSetValue: (CMIElement: string, value: any) => string;
59
+ LMSCommit: () => string;
60
+ LMSGetLastError: () => string;
61
+ LMSGetErrorString: (CMIErrorCode: string) => string;
62
+ LMSGetDiagnostic: (CMIErrorCode: string) => string;
63
+
64
+ /**
65
+ * Called when the API needs to be reset
66
+ */
67
+ reset(settings?: Settings): void;
68
+ }
69
+
70
+ export { Scorm12API, Scorm2004API, AICC, Settings };
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "scorm-again",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
5
- "main": "index.d.ts",
5
+ "main": "dist/scorm-again.js",
6
+ "types": "index.d.ts",
7
+ "module": "dist/esm/scorm-again.js",
6
8
  "type": "module",
7
9
  "browser": {
8
10
  "electron": false
@@ -21,11 +23,11 @@
21
23
  },
22
24
  "devDependencies": {
23
25
  "@babel/cli": "^7.25.9",
24
- "@babel/core": "^7.25.9",
26
+ "@babel/core": "^7.26.0",
25
27
  "@babel/eslint-parser": "^7.25.9",
26
- "@babel/node": "^7.25.9",
27
- "@babel/preset-env": "^7.25.9",
28
- "@babel/preset-typescript": "^7.25.9",
28
+ "@babel/node": "^7.26.0",
29
+ "@babel/preset-env": "^7.26.0",
30
+ "@babel/preset-typescript": "^7.26.0",
29
31
  "@eslint/eslintrc": "^3.1.0",
30
32
  "@eslint/js": "^9.13.0",
31
33
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
@@ -66,7 +68,7 @@
66
68
  "scripts": {
67
69
  "test": "./node_modules/.bin/mocha --import=tsx --bdd --recursive --reporter list",
68
70
  "test:coverage": "./node_modules/.bin/c8 ./node_modules/.bin/mocha --import=tsx --recursive --timeout=10000 --exit --reporter json --reporter-option output=test-results.json",
69
- "compile": "./node_modules/.bin/webpack --bail --config webpack.config.js",
71
+ "compile": "./node_modules/.bin/webpack --bail --config webpack.config.js --mode production",
70
72
  "fix": "./node_modules/.bin/eslint ./src --fix",
71
73
  "prettier": "./node_modules/.bin/prettier --write src/**/*.ts test/**/*.ts src/*.ts test/*.ts"
72
74
  },
@@ -97,7 +99,8 @@
97
99
  "test/**/*.*",
98
100
  "src/exports/*.*",
99
101
  "src/interfaces/*.*",
100
- "src/types/*.*"
102
+ "src/types/*.*",
103
+ "src/ScormAgain.ts"
101
104
  ],
102
105
  "extension": [
103
106
  ".ts"
package/src/AICC.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Scorm12API from "./Scorm12API";
1
+ import { Scorm12Impl } from "./Scorm12API";
2
2
  import { CMI } from "./cmi/aicc/cmi";
3
3
 
4
4
  import { BaseCMI } from "./cmi/common/base_cmi";
@@ -13,7 +13,7 @@ import { stringMatches } from "./utilities";
13
13
  /**
14
14
  * The AICC API class
15
15
  */
16
- export default class AICC extends Scorm12API {
16
+ class AICCImpl extends Scorm12Impl {
17
17
  /**
18
18
  * Constructor to create AICC API object
19
19
  * @param {Settings} settings
@@ -33,7 +33,7 @@ export default class AICC extends Scorm12API {
33
33
  * @param {boolean} foundFirstIndex
34
34
  * @return {BaseCMI | null}
35
35
  */
36
- getChildElement(
36
+ override getChildElement(
37
37
  CMIElement: string,
38
38
  value: any,
39
39
  foundFirstIndex: boolean,
@@ -62,11 +62,13 @@ export default class AICC extends Scorm12API {
62
62
  /**
63
63
  * Replace the whole API with another
64
64
  *
65
- * @param {AICC} newAPI
65
+ * @param {AICCImpl} newAPI
66
66
  */
67
- replaceWithAnotherScormAPI(newAPI: AICC) {
67
+ override replaceWithAnotherScormAPI(newAPI: AICCImpl) {
68
68
  // Data Model
69
69
  this.cmi = newAPI.cmi;
70
70
  this.nav = newAPI.nav;
71
71
  }
72
72
  }
73
+
74
+ export { AICCImpl };
package/src/BaseAPI.ts CHANGED
@@ -4,10 +4,9 @@ import ErrorCodes, { ErrorCode } from "./constants/error_codes";
4
4
  import APIConstants from "./constants/api_constants";
5
5
  import { formatMessage, stringMatches, unflatten } from "./utilities";
6
6
  import { BaseCMI } from "./cmi/common/base_cmi";
7
- import { debounce } from "./utilities/debounce";
8
7
  import {
9
- RefObject,
10
8
  CommitObject,
9
+ RefObject,
11
10
  ResultObject,
12
11
  Settings,
13
12
  } from "./types/api_types";
@@ -360,7 +359,7 @@ export default abstract class BaseAPI implements IBaseAPI {
360
359
  // If we didn't have any errors while setting the data, go ahead and
361
360
  // schedule a commit, if autocommit is turned on
362
361
  if (String(this.lastErrorCode) === "0") {
363
- if (this.settings.autocommit && !this._timeout) {
362
+ if (this.settings.autocommit) {
364
363
  this.scheduleCommit(
365
364
  this.settings.autocommitSeconds * 1000,
366
365
  commitCallback,
@@ -389,6 +388,7 @@ export default abstract class BaseAPI implements IBaseAPI {
389
388
  callbackName: string,
390
389
  checkTerminated: boolean = false,
391
390
  ): Promise<string> {
391
+ console.log("commit");
392
392
  this.clearScheduledCommit();
393
393
 
394
394
  let returnValue = APIConstants.global.SCORM_FALSE;
@@ -1067,7 +1067,7 @@ export default abstract class BaseAPI implements IBaseAPI {
1067
1067
  * @param {RefObject} json
1068
1068
  * @param {string} CMIElement
1069
1069
  */
1070
- loadFromJSON(json: RefObject, CMIElement: string) {
1070
+ loadFromJSON(json: RefObject, CMIElement: string = "") {
1071
1071
  if (!this.isNotInitialized()) {
1072
1072
  console.error(
1073
1073
  "loadFromJSON can only be called before the call to lmsInitialize.",
@@ -1174,17 +1174,7 @@ export default abstract class BaseAPI implements IBaseAPI {
1174
1174
  }
1175
1175
  };
1176
1176
 
1177
- if (this.settings.asyncCommit) {
1178
- const debouncedProcess = debounce(process, 500, immediate);
1179
- debouncedProcess(url, params, this.settings);
1180
-
1181
- return {
1182
- result: APIConstants.global.SCORM_TRUE,
1183
- errorCode: 0,
1184
- };
1185
- } else {
1186
- return await process(url, params, this.settings);
1187
- }
1177
+ return await process(url, params, this.settings);
1188
1178
  }
1189
1179
 
1190
1180
  /**
@@ -1194,13 +1184,15 @@ export default abstract class BaseAPI implements IBaseAPI {
1194
1184
  * @param {string} callback - the name of the commit event callback
1195
1185
  */
1196
1186
  scheduleCommit(when: number, callback: string) {
1197
- this._timeout = new ScheduledCommit(this, when, callback);
1198
- this.apiLog(
1199
- "scheduleCommit",
1200
- "scheduled",
1201
- APIConstants.global.LOG_LEVEL_DEBUG,
1202
- "",
1203
- );
1187
+ if (!this._timeout) {
1188
+ this._timeout = new ScheduledCommit(this, when, callback);
1189
+ this.apiLog(
1190
+ "scheduleCommit",
1191
+ "scheduled",
1192
+ APIConstants.global.LOG_LEVEL_DEBUG,
1193
+ "",
1194
+ );
1195
+ }
1204
1196
  }
1205
1197
 
1206
1198
  /**
@@ -1262,6 +1254,30 @@ export default abstract class BaseAPI implements IBaseAPI {
1262
1254
  return returnValue;
1263
1255
  }
1264
1256
 
1257
+ /**
1258
+ * Builds the commit object to be sent to the LMS
1259
+ * @param {boolean} terminateCommit
1260
+ * @return {CommitObject|RefObject|Array}
1261
+ * @private
1262
+ */
1263
+ protected getCommitObject(
1264
+ terminateCommit: boolean,
1265
+ ): CommitObject | RefObject | Array<any> {
1266
+ const shouldTerminateCommit =
1267
+ terminateCommit || this.settings.alwaysSendTotalTime;
1268
+ const commitObject = this.settings.renderCommonCommitFields
1269
+ ? this.renderCommitObject(shouldTerminateCommit)
1270
+ : this.renderCommitCMI(shouldTerminateCommit);
1271
+
1272
+ if (this.apiLogLevel === APIConstants.global.LOG_LEVEL_DEBUG) {
1273
+ console.debug(
1274
+ "Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ",
1275
+ );
1276
+ console.debug(commitObject);
1277
+ }
1278
+ return commitObject;
1279
+ }
1280
+
1265
1281
  /**
1266
1282
  * Perform the fetch request to the LMS
1267
1283
  * @param {string} url
@@ -1275,6 +1291,7 @@ export default abstract class BaseAPI implements IBaseAPI {
1275
1291
  ): Promise<Response> {
1276
1292
  return fetch(url, {
1277
1293
  method: "POST",
1294
+ mode: this.settings.fetchMode,
1278
1295
  body: params instanceof Array ? params.join("&") : JSON.stringify(params),
1279
1296
  headers: {
1280
1297
  ...this.settings.xhrHeaders,
package/src/Scorm12API.ts CHANGED
@@ -1,4 +1,3 @@
1
- import BaseAPI from "./BaseAPI";
2
1
  import { CMI } from "./cmi/scorm12/cmi";
3
2
  import * as Utilities from "./utilities";
4
3
  import { stringMatches } from "./utilities";
@@ -22,11 +21,12 @@ import {
22
21
  } from "./types/api_types";
23
22
  import Regex from "./constants/regex";
24
23
  import { CompletionStatus, SuccessStatus } from "./constants/enums";
24
+ import BaseAPI from "./BaseAPI";
25
25
 
26
26
  /**
27
27
  * API class for SCORM 1.2
28
28
  */
29
- export default class Scorm12API extends BaseAPI {
29
+ class Scorm12Impl extends BaseAPI {
30
30
  /**
31
31
  * Constructor for SCORM 1.2 API
32
32
  * @param {object} settings
@@ -56,17 +56,17 @@ export default class Scorm12API extends BaseAPI {
56
56
 
57
57
  public statusSetByModule = false;
58
58
 
59
- public cmi: CMI;
60
- public nav: NAV;
59
+ cmi: CMI;
60
+ nav: NAV;
61
61
 
62
- public LMSInitialize: () => string;
63
- public LMSFinish: () => string;
64
- public LMSGetValue: (CMIElement: string) => string;
65
- public LMSSetValue: (CMIElement: string, value: any) => string;
66
- public LMSCommit: () => string;
67
- public LMSGetLastError: () => string;
68
- public LMSGetErrorString: (CMIErrorCode: string) => string;
69
- public LMSGetDiagnostic: (CMIErrorCode: string) => string;
62
+ LMSInitialize: () => string;
63
+ LMSFinish: () => string;
64
+ LMSGetValue: (CMIElement: string) => string;
65
+ LMSSetValue: (CMIElement: string, value: any) => string;
66
+ LMSCommit: () => string;
67
+ LMSGetLastError: () => string;
68
+ LMSGetErrorString: (CMIErrorCode: string) => string;
69
+ LMSGetDiagnostic: (CMIErrorCode: string) => string;
70
70
 
71
71
  /**
72
72
  * Called when the API needs to be reset
@@ -157,9 +157,13 @@ export default class Scorm12API extends BaseAPI {
157
157
  * @return {string} bool
158
158
  */
159
159
  lmsCommit(): string {
160
- (async () => {
161
- await this.commit("LMSCommit", false);
162
- })();
160
+ if (this.settings.asyncCommit) {
161
+ this.scheduleCommit(500, "LMSCommit");
162
+ } else {
163
+ (async () => {
164
+ await this.commit("LMSCommit", false);
165
+ })();
166
+ }
163
167
  return APIConstants.global.SCORM_TRUE;
164
168
  }
165
169
 
@@ -199,7 +203,7 @@ export default class Scorm12API extends BaseAPI {
199
203
  * @param {*} value
200
204
  * @return {string}
201
205
  */
202
- setCMIValue(CMIElement: string, value: any): string {
206
+ override setCMIValue(CMIElement: string, value: any): string {
203
207
  return this._commonSetCMIValue("LMSSetValue", false, CMIElement, value);
204
208
  }
205
209
 
@@ -209,7 +213,7 @@ export default class Scorm12API extends BaseAPI {
209
213
  * @param {string} CMIElement
210
214
  * @return {*}
211
215
  */
212
- getCMIValue(CMIElement: string): any {
216
+ override getCMIValue(CMIElement: string): any {
213
217
  return this._commonGetCMIValue("getCMIValue", false, CMIElement);
214
218
  }
215
219
 
@@ -268,7 +272,7 @@ export default class Scorm12API extends BaseAPI {
268
272
  * @param {boolean} detail
269
273
  * @return {string}
270
274
  */
271
- getLmsErrorMessageDetails(
275
+ override getLmsErrorMessageDetails(
272
276
  errorNumber: number | string,
273
277
  detail: boolean,
274
278
  ): string {
@@ -290,9 +294,9 @@ export default class Scorm12API extends BaseAPI {
290
294
  /**
291
295
  * Replace the whole API with another
292
296
  *
293
- * @param {Scorm12API} newAPI
297
+ * @param {Scorm12Impl} newAPI
294
298
  */
295
- replaceWithAnotherScormAPI(newAPI: Scorm12API) {
299
+ replaceWithAnotherScormAPI(newAPI: Scorm12Impl) {
296
300
  // Data Model
297
301
  this.cmi = newAPI.cmi;
298
302
  }
@@ -424,18 +428,7 @@ export default class Scorm12API extends BaseAPI {
424
428
  }
425
429
  }
426
430
 
427
- const shouldTerminateCommit =
428
- terminateCommit || this.settings.alwaysSendTotalTime;
429
- const commitObject = this.settings.renderCommonCommitFields
430
- ? this.renderCommitObject(shouldTerminateCommit)
431
- : this.renderCommitCMI(shouldTerminateCommit);
432
-
433
- if (this.apiLogLevel === APIConstants.global.LOG_LEVEL_DEBUG) {
434
- console.debug(
435
- "Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ",
436
- );
437
- console.debug(commitObject);
438
- }
431
+ const commitObject = this.getCommitObject(terminateCommit);
439
432
  if (typeof this.settings.lmsCommitUrl === "string") {
440
433
  return await this.processHttpRequest(
441
434
  this.settings.lmsCommitUrl,
@@ -450,3 +443,5 @@ export default class Scorm12API extends BaseAPI {
450
443
  }
451
444
  }
452
445
  }
446
+
447
+ export { Scorm12Impl };
@@ -30,7 +30,7 @@ import { CompletionStatus, SuccessStatus } from "./constants/enums";
30
30
  /**
31
31
  * API class for SCORM 2004
32
32
  */
33
- export default class Scorm2004API extends BaseAPI {
33
+ class Scorm2004Impl extends BaseAPI {
34
34
  private _version: string = "1.0";
35
35
 
36
36
  /**
@@ -180,9 +180,13 @@ export default class Scorm2004API extends BaseAPI {
180
180
  * @return {string} bool
181
181
  */
182
182
  lmsCommit(): string {
183
- (async () => {
184
- await this.commit("Commit");
185
- })();
183
+ if (this.settings.asyncCommit) {
184
+ this.scheduleCommit(500, "LMSCommit");
185
+ } else {
186
+ (async () => {
187
+ await this.commit("LMSCommit", false);
188
+ })();
189
+ }
186
190
  return APIConstants.global.SCORM_TRUE;
187
191
  }
188
192
 
@@ -222,7 +226,7 @@ export default class Scorm2004API extends BaseAPI {
222
226
  * @param {any} value
223
227
  * @return {string}
224
228
  */
225
- setCMIValue(CMIElement: string, value: any): string {
229
+ override setCMIValue(CMIElement: string, value: any): string {
226
230
  return this._commonSetCMIValue("SetValue", true, CMIElement, value);
227
231
  }
228
232
 
@@ -407,7 +411,7 @@ export default class Scorm2004API extends BaseAPI {
407
411
  * @param {string} CMIElement
408
412
  * @return {*}
409
413
  */
410
- getCMIValue(CMIElement: string): any {
414
+ override getCMIValue(CMIElement: string): any {
411
415
  return this._commonGetCMIValue("GetValue", true, CMIElement);
412
416
  }
413
417
 
@@ -418,7 +422,7 @@ export default class Scorm2004API extends BaseAPI {
418
422
  * @param {boolean} detail
419
423
  * @return {string}
420
424
  */
421
- getLmsErrorMessageDetails(
425
+ override getLmsErrorMessageDetails(
422
426
  errorNumber: string | number,
423
427
  detail: boolean,
424
428
  ): string {
@@ -581,9 +585,9 @@ export default class Scorm2004API extends BaseAPI {
581
585
 
582
586
  /**
583
587
  * Replace the whole API with another
584
- * @param {Scorm2004API} newAPI
588
+ * @param {Scorm2004Impl} newAPI
585
589
  */
586
- replaceWithAnotherScormAPI(newAPI: Scorm2004API) {
590
+ replaceWithAnotherScormAPI(newAPI: Scorm2004Impl) {
587
591
  // Data Model
588
592
  this.cmi = newAPI.cmi;
589
593
  this.adl = newAPI.adl;
@@ -718,18 +722,7 @@ export default class Scorm2004API extends BaseAPI {
718
722
  navRequest = true;
719
723
  }
720
724
 
721
- const shouldTerminateCommit =
722
- terminateCommit || this.settings.alwaysSendTotalTime;
723
- const commitObject = this.settings.renderCommonCommitFields
724
- ? this.renderCommitObject(shouldTerminateCommit)
725
- : this.renderCommitCMI(shouldTerminateCommit);
726
-
727
- if (this.apiLogLevel === APIConstants.global.LOG_LEVEL_DEBUG) {
728
- console.debug(
729
- "Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ",
730
- );
731
- console.debug(commitObject);
732
- }
725
+ const commitObject = this.getCommitObject(terminateCommit);
733
726
  if (typeof this.settings.lmsCommitUrl === "string") {
734
727
  const result = await this.processHttpRequest(
735
728
  this.settings.lmsCommitUrl,
@@ -756,3 +749,5 @@ export default class Scorm2004API extends BaseAPI {
756
749
  }
757
750
  }
758
751
  }
752
+
753
+ export { Scorm2004Impl };
@@ -0,0 +1,9 @@
1
+ import { AICCImpl } from "./AICC";
2
+ import { Scorm12Impl } from "./Scorm12API";
3
+ import { Scorm2004Impl } from "./Scorm2004API";
4
+
5
+ const Scorm12API = Scorm12Impl;
6
+ const Scorm2004API = Scorm2004Impl;
7
+ const AICC = AICCImpl;
8
+
9
+ export { Scorm12API, Scorm2004API, AICC };
@@ -1,11 +1,11 @@
1
- import {BaseCMI} from "../common/base_cmi";
2
- import {CMIScore} from "../common/score";
1
+ import { BaseCMI } from "../common/base_cmi";
2
+ import { CMIScore } from "../common/score";
3
3
  import APIConstants from "../../constants/api_constants";
4
4
  import Regex from "../../constants/regex";
5
5
  import ErrorCodes from "../../constants/error_codes";
6
- import {AICCValidationError} from "../../exceptions";
7
- import {checkAICCValidFormat} from "./validation";
8
- import {CMIArray} from "../common/array";
6
+ import { AICCValidationError } from "../../exceptions";
7
+ import { checkAICCValidFormat } from "./validation";
8
+ import { CMIArray } from "../common/array";
9
9
 
10
10
  /**
11
11
  * Class for cmi.student_data.attempt_records array
@@ -45,7 +45,7 @@ export class CMIAttemptRecordsObject extends BaseCMI {
45
45
  /**
46
46
  * Called when the API has been initialized after the CMI has been created
47
47
  */
48
- initialize() {
48
+ override initialize() {
49
49
  super.initialize();
50
50
  this.score?.initialize();
51
51
  }
@@ -91,4 +91,4 @@ export class CMIAttemptRecordsObject extends BaseCMI {
91
91
  delete this.jsonString;
92
92
  return result;
93
93
  }
94
- }
94
+ }
@@ -29,8 +29,8 @@ export class CMI extends Scorm12CMI.CMI {
29
29
  this.paths = new CMIPaths();
30
30
  }
31
31
 
32
- public student_data: AICCCMIStudentData;
33
- public student_preference: AICCStudentPreferences;
32
+ public override student_data: AICCCMIStudentData;
33
+ public override student_preference: AICCStudentPreferences;
34
34
  public student_demographics: CMIStudentDemographics;
35
35
  public evaluation: CMIEvaluation;
36
36
  public paths: CMIPaths;
@@ -38,7 +38,7 @@ export class CMI extends Scorm12CMI.CMI {
38
38
  /**
39
39
  * Called when the API has been initialized after the CMI has been created
40
40
  */
41
- initialize() {
41
+ override initialize() {
42
42
  super.initialize();
43
43
  this.student_preference?.initialize();
44
44
  this.student_data?.initialize();
@@ -65,7 +65,7 @@ export class CMI extends Scorm12CMI.CMI {
65
65
  * }
66
66
  * }
67
67
  */
68
- toJSON(): {
68
+ override toJSON(): {
69
69
  suspend_data: string;
70
70
  launch_data: string;
71
71
  comments: string;
@@ -32,7 +32,7 @@ export class CMICore extends BaseCMI {
32
32
  /**
33
33
  * Called when the API has been initialized after the CMI has been created
34
34
  */
35
- initialize() {
35
+ override initialize() {
36
36
  super.initialize();
37
37
  this.score?.initialize();
38
38
  }
@@ -23,7 +23,7 @@ export class CMIEvaluation extends BaseCMI {
23
23
  /**
24
24
  * Called when the API has been initialized after the CMI has been created
25
25
  */
26
- initialize() {
26
+ override initialize() {
27
27
  super.initialize();
28
28
  this.comments?.initialize();
29
29
  }
@@ -24,7 +24,7 @@ export class AICCCMIStudentData extends CMIStudentData {
24
24
  /**
25
25
  * Called when the API has been initialized after the CMI has been created
26
26
  */
27
- initialize() {
27
+ override initialize() {
28
28
  super.initialize();
29
29
  this.tries?.initialize();
30
30
  this.attempt_records?.initialize();
@@ -65,7 +65,7 @@ export class AICCCMIStudentData extends CMIStudentData {
65
65
  * }
66
66
  * }
67
67
  */
68
- toJSON(): {
68
+ override toJSON(): {
69
69
  mastery_score: string;
70
70
  max_time_allowed: string;
71
71
  time_limit_action: string;
@@ -27,7 +27,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
27
27
  /**
28
28
  * Called when the API has been initialized after the CMI has been created
29
29
  */
30
- initialize() {
30
+ override initialize() {
31
31
  super.initialize();
32
32
  this.windows?.initialize();
33
33
  }
@@ -145,7 +145,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
145
145
  * }
146
146
  * }
147
147
  */
148
- toJSON(): {
148
+ override toJSON(): {
149
149
  audio: string;
150
150
  language: string;
151
151
  lesson_type: string;
@@ -1,11 +1,11 @@
1
- import {CMIArray} from "../common/array";
1
+ import { CMIArray } from "../common/array";
2
2
  import APIConstants from "../../constants/api_constants";
3
- import {BaseCMI} from "../common/base_cmi";
4
- import {CMIScore} from "../common/score";
3
+ import { BaseCMI } from "../common/base_cmi";
4
+ import { CMIScore } from "../common/score";
5
5
  import Regex from "../../constants/regex";
6
6
  import ErrorCodes from "../../constants/error_codes";
7
- import {AICCValidationError} from "../../exceptions";
8
- import {checkAICCValidFormat} from "./validation";
7
+ import { AICCValidationError } from "../../exceptions";
8
+ import { checkAICCValidFormat } from "./validation";
9
9
 
10
10
  /**
11
11
  * Class representing the AICC cmi.student_data.tries object
@@ -45,7 +45,7 @@ export class CMITriesObject extends BaseCMI {
45
45
  /**
46
46
  * Called when the API has been initialized after the CMI has been created
47
47
  */
48
- initialize() {
48
+ override initialize() {
49
49
  super.initialize();
50
50
  this.score?.initialize();
51
51
  }
@@ -113,4 +113,4 @@ export class CMITriesObject extends BaseCMI {
113
113
  delete this.jsonString;
114
114
  return result;
115
115
  }
116
- }
116
+ }
@@ -52,7 +52,7 @@ export class CMI extends BaseRootCMI {
52
52
  /**
53
53
  * Called when the API has been initialized after the CMI has been created
54
54
  */
55
- initialize() {
55
+ override initialize() {
56
56
  super.initialize();
57
57
  this.core?.initialize();
58
58
  this.objectives?.initialize();
@@ -51,7 +51,7 @@ export class CMIInteractionsObject extends BaseCMI {
51
51
  /**
52
52
  * Called when the API has been initialized after the CMI has been created
53
53
  */
54
- initialize() {
54
+ override initialize() {
55
55
  super.initialize();
56
56
  this.objectives?.initialize();
57
57
  this.correct_responses?.initialize();