scorm-again 2.4.0 → 2.5.0
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.
- package/README.md +23 -23
- package/dist/aicc.js +65 -41
- package/dist/aicc.js.map +1 -1
- package/dist/aicc.min.js +1 -1
- package/dist/aicc.min.js.map +1 -1
- package/dist/esm/aicc.js +65 -41
- package/dist/esm/aicc.js.map +1 -1
- package/dist/esm/aicc.min.js +1 -1
- package/dist/esm/aicc.min.js.map +1 -1
- package/dist/esm/scorm-again.js +78 -48
- package/dist/esm/scorm-again.js.map +1 -1
- package/dist/esm/scorm-again.min.js +1 -1
- package/dist/esm/scorm-again.min.js.map +1 -1
- package/dist/esm/scorm12.js +65 -41
- package/dist/esm/scorm12.js.map +1 -1
- package/dist/esm/scorm12.min.js +1 -1
- package/dist/esm/scorm12.min.js.map +1 -1
- package/dist/esm/scorm2004.js +78 -48
- package/dist/esm/scorm2004.js.map +1 -1
- package/dist/esm/scorm2004.min.js +1 -1
- package/dist/esm/scorm2004.min.js.map +1 -1
- package/dist/scorm-again.js +78 -48
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +1 -1
- package/dist/scorm-again.min.js.map +1 -1
- package/dist/scorm12.js +65 -41
- package/dist/scorm12.js.map +1 -1
- package/dist/scorm12.min.js +1 -1
- package/dist/scorm12.min.js.map +1 -1
- package/dist/scorm2004.js +78 -48
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/package.json +4 -4
- package/src/AICC.ts +2 -2
- package/src/BaseAPI.ts +28 -66
- package/src/Scorm12API.ts +3 -3
- package/src/Scorm2004API.ts +11 -7
- package/src/cmi/aicc/attempts.ts +7 -7
- package/src/cmi/aicc/cmi.ts +4 -4
- package/src/cmi/aicc/core.ts +1 -1
- package/src/cmi/aicc/evaluation.ts +1 -1
- package/src/cmi/aicc/student_data.ts +2 -2
- package/src/cmi/aicc/student_preferences.ts +2 -2
- package/src/cmi/aicc/tries.ts +7 -7
- package/src/cmi/scorm12/cmi.ts +1 -1
- package/src/cmi/scorm12/interactions.ts +1 -1
- package/src/cmi/scorm2004/adl.ts +2 -2
- package/src/cmi/scorm2004/cmi.ts +1 -1
- package/src/cmi/scorm2004/interactions.ts +1 -1
- package/src/cmi/scorm2004/objectives.ts +1 -1
- package/src/cmi/scorm2004/score.ts +1 -1
- package/src/constants/api_constants.ts +0 -10
- package/src/constants/default_settings.ts +25 -8
- package/src/constants/enums.ts +9 -0
- package/src/constants/regex.ts +1 -1
- package/src/exceptions.ts +1 -5
- package/src/types/api_types.ts +26 -3
- package/test/Scorm12API.spec.ts +101 -1
- package/test/types/api_types.spec.ts +38 -45
- package/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -89,29 +89,29 @@ the `window` object, because that's where modules are supposed to look.
|
|
|
89
89
|
|
|
90
90
|
The APIs include several settings to customize the functionality of each API:
|
|
91
91
|
|
|
92
|
-
| Setting | Default |
|
|
93
|
-
|
|
94
|
-
| `autocommit` | false |
|
|
95
|
-
| `autocommitSeconds` | 60 |
|
|
96
|
-
| `asyncCommit` | false |
|
|
97
|
-
| `sendFullCommit` | true |
|
|
98
|
-
| `lmsCommitUrl` | false |
|
|
99
|
-
| `dataCommitFormat` | `json` |
|
|
100
|
-
| `commitRequestDataType` | 'application/json;charset=UTF-8' |
|
|
101
|
-
| `renderCommonCommitFields` | false |
|
|
102
|
-
| `autoProgress` | false |
|
|
103
|
-
| `logLevel` | 4 |
|
|
104
|
-
| `mastery_override` | false |
|
|
105
|
-
| `selfReportSessionTime` | false |
|
|
106
|
-
| `alwaysSendTotalTime` | false |
|
|
107
|
-
| `fetchMode` | 'cors' |
|
|
108
|
-
| `xhrWithCredentials` | false |
|
|
109
|
-
| `xhrHeaders` | {} |
|
|
110
|
-
| `responseHandler` | function |
|
|
111
|
-
| `requestHandler` | function |
|
|
112
|
-
| `onLogMessage` | function |
|
|
113
|
-
| `scoItemIds` | [] |
|
|
114
|
-
| `scoItemIdValidator` | false |
|
|
92
|
+
| Setting | Default | Values | Description |
|
|
93
|
+
|----------------------------|:--------------------------------:|:-----------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
94
|
+
| `autocommit` | false | true/false | Determines whether the API schedules an autocommit to the LMS after setting a value. |
|
|
95
|
+
| `autocommitSeconds` | 60 | int | Number of seconds to wait before autocommiting. Timer is restarted if another value is set. |
|
|
96
|
+
| `asyncCommit` | false | true/false | Determines whether the API should send the request to the `lmsCommitUrl` asynchronously. |
|
|
97
|
+
| `sendFullCommit` | true | true/false | Determines whether the API sends the full CMI object as part of the commit, or of it only sends the fields that actually contains values. |
|
|
98
|
+
| `lmsCommitUrl` | false | url | The URL endpoint of the LMS where data should be sent upon commit. If no value is provided, modules will run as usual, but all method calls will be logged to the console. |
|
|
99
|
+
| `dataCommitFormat` | `json` | `json`, `flattened`, `params` | `json` will send a JSON object to the lmsCommitUrl in the format of <br>`{'cmi': {'core': {...}}`<br><br> `flattened` will send the data in the format <br>`{'cmi.core.exit': 'suspend', 'cmi.core.mode': 'normal'...}`<br><br> `params` will send the data as <br>`?cmi.core.exit=suspend&cmi.core.mode=normal...` |
|
|
100
|
+
| `commitRequestDataType` | 'application/json;charset=UTF-8' | string | This setting is provided in case your LMS expects a different content type or character set. |
|
|
101
|
+
| `renderCommonCommitFields` | false | true/false | Determines whether the API should render the common fields in the commit object. Common fields are `successStatus`, `completionStatus`, `totalTimeSeconds`, `score`, and `runtimeData`. The `runtimeData` field contains the render CMI object. This allows for easier processing on the LMS. |
|
|
102
|
+
| `autoProgress` | false | true/false | In case Sequencing is being used, you can tell the API to automatically throw the `SequenceNext` event. |
|
|
103
|
+
| `logLevel` | 4 | number \| string \| LogLevelEnum<br><br>`1` => DEBUG<br>`2` => INFO<br>`3` => WARN<br>`4` => ERROR<br>`5` => NONE | By default, the APIs only log error messages. |
|
|
104
|
+
| `mastery_override` | false | true/false | (SCORM 1.2) Used to override a module's `cmi.core.lesson_status` so that a pass/fail is determined based on a mastery score and the user's raw score, rather than using whatever status is provided by the module. An example of this would be if a module is published using a `Complete/Incomplete` final status, but the LMS always wants to receive a `Passed/Failed` for quizzes, then we can use this setting to override the given final status. |
|
|
105
|
+
| `selfReportSessionTime` | false | true/false | Should the API override the default `session_time` reported by the module? Useful when modules don't properly report time. |
|
|
106
|
+
| `alwaysSendTotalTime` | false | true/false | Should the API always send `total_time` when committing to the LMS |
|
|
107
|
+
| `fetchMode` | 'cors' | 'cors', 'no-cors', 'same-origin', 'navigate' | The fetch mode to use when sending requests to the LMS. |
|
|
108
|
+
| `xhrWithCredentials` | false | true/false | Sets the withCredentials flag on the request to the LMS |
|
|
109
|
+
| `xhrHeaders` | {} | Object | This allows setting of additional headers on the request to the LMS where the key should be the header name and the value is the value of the header you want to send |
|
|
110
|
+
| `responseHandler` | function | | A function to properly transform the response from the LMS to the correct format. The APIs expect the result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }` |
|
|
111
|
+
| `requestHandler` | function | | A function to transform the commit object before sending it to `lmsCommitUrl`. By default it's the identity function (no transformation). |
|
|
112
|
+
| `onLogMessage` | function | | A function to be called whenever a message is logged. Defaults to console.{error,warn,info,debug,log} |
|
|
113
|
+
| `scoItemIds` | [] | string[] | A list of valid SCO IDs to be used for choice/jump sequence validation. |
|
|
114
|
+
| `scoItemIdValidator` | false | false / function | A function to be called during choice/jump sequence checks to determine if a SCO ID is valid. Could be used to call an API to check validity. |
|
|
115
115
|
|
|
116
116
|
## Settings Function Examples
|
|
117
117
|
|
package/dist/aicc.js
CHANGED
|
@@ -23,9 +23,12 @@ var error_codes = __webpack_require__(797);
|
|
|
23
23
|
var api_constants = __webpack_require__(340);
|
|
24
24
|
// EXTERNAL MODULE: ./src/utilities.ts
|
|
25
25
|
var utilities = __webpack_require__(864);
|
|
26
|
+
// EXTERNAL MODULE: ./src/constants/enums.ts
|
|
27
|
+
var enums = __webpack_require__(56);
|
|
26
28
|
;// ./src/constants/default_settings.ts
|
|
27
29
|
|
|
28
30
|
|
|
31
|
+
|
|
29
32
|
var DefaultSettings = {
|
|
30
33
|
autocommit: false,
|
|
31
34
|
autocommitSeconds: 10,
|
|
@@ -35,7 +38,7 @@ var DefaultSettings = {
|
|
|
35
38
|
dataCommitFormat: "json",
|
|
36
39
|
commitRequestDataType: "application/json;charset=UTF-8",
|
|
37
40
|
autoProgress: false,
|
|
38
|
-
logLevel:
|
|
41
|
+
logLevel: enums/* LogLevelEnum */.Mb.ERROR,
|
|
39
42
|
selfReportSessionTime: false,
|
|
40
43
|
alwaysSendTotalTime: false,
|
|
41
44
|
renderCommonCommitFields: false,
|
|
@@ -45,15 +48,18 @@ var DefaultSettings = {
|
|
|
45
48
|
fetchMode: "cors",
|
|
46
49
|
responseHandler: function (response) {
|
|
47
50
|
return (0,tslib_es6/* __awaiter */.sH)(this, void 0, void 0, function () {
|
|
48
|
-
var
|
|
49
|
-
return (0,tslib_es6/* __generator */.YH)(this, function (
|
|
50
|
-
switch (
|
|
51
|
+
var responseText, httpResult;
|
|
52
|
+
return (0,tslib_es6/* __generator */.YH)(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
51
54
|
case 0:
|
|
52
55
|
if (!(typeof response !== "undefined")) return [3, 2];
|
|
53
|
-
_b = (_a = JSON).parse;
|
|
54
56
|
return [4, response.text()];
|
|
55
57
|
case 1:
|
|
56
|
-
|
|
58
|
+
responseText = _a.sent();
|
|
59
|
+
httpResult = null;
|
|
60
|
+
if (responseText) {
|
|
61
|
+
httpResult = JSON.parse(responseText);
|
|
62
|
+
}
|
|
57
63
|
if (httpResult === null ||
|
|
58
64
|
!{}.hasOwnProperty.call(httpResult, "result")) {
|
|
59
65
|
if (response.status === 200) {
|
|
@@ -79,7 +85,7 @@ var DefaultSettings = {
|
|
|
79
85
|
: 101,
|
|
80
86
|
}];
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
_a.label = 2;
|
|
83
89
|
case 2: return [2, {
|
|
84
90
|
result: api_constants/* default */.A.global.SCORM_FALSE,
|
|
85
91
|
errorCode: 101,
|
|
@@ -93,16 +99,28 @@ var DefaultSettings = {
|
|
|
93
99
|
},
|
|
94
100
|
onLogMessage: function (messageLevel, logMessage) {
|
|
95
101
|
switch (messageLevel) {
|
|
96
|
-
case
|
|
102
|
+
case "4":
|
|
103
|
+
case 4:
|
|
104
|
+
case "ERROR":
|
|
105
|
+
case enums/* LogLevelEnum */.Mb.ERROR:
|
|
97
106
|
console.error(logMessage);
|
|
98
107
|
break;
|
|
99
|
-
case
|
|
108
|
+
case "3":
|
|
109
|
+
case 3:
|
|
110
|
+
case "WARN":
|
|
111
|
+
case enums/* LogLevelEnum */.Mb.WARN:
|
|
100
112
|
console.warn(logMessage);
|
|
101
113
|
break;
|
|
102
|
-
case
|
|
114
|
+
case "2":
|
|
115
|
+
case 2:
|
|
116
|
+
case "INFO":
|
|
117
|
+
case enums/* LogLevelEnum */.Mb.INFO:
|
|
103
118
|
console.info(logMessage);
|
|
104
119
|
break;
|
|
105
|
-
case
|
|
120
|
+
case "1":
|
|
121
|
+
case 1:
|
|
122
|
+
case "DEBUG":
|
|
123
|
+
case enums/* LogLevelEnum */.Mb.DEBUG:
|
|
106
124
|
if (console.debug) {
|
|
107
125
|
console.debug(logMessage);
|
|
108
126
|
}
|
|
@@ -155,6 +173,7 @@ var ScheduledCommit = (function () {
|
|
|
155
173
|
|
|
156
174
|
|
|
157
175
|
|
|
176
|
+
|
|
158
177
|
var BaseAPI = (function () {
|
|
159
178
|
function BaseAPI(error_codes, settings) {
|
|
160
179
|
var _newTarget = this.constructor;
|
|
@@ -171,6 +190,9 @@ var BaseAPI = (function () {
|
|
|
171
190
|
}
|
|
172
191
|
this.apiLogLevel = this.settings.logLevel;
|
|
173
192
|
this.selfReportSessionTime = this.settings.selfReportSessionTime;
|
|
193
|
+
if (this.apiLogLevel === undefined) {
|
|
194
|
+
this.apiLogLevel = enums/* LogLevelEnum */.Mb.NONE;
|
|
195
|
+
}
|
|
174
196
|
}
|
|
175
197
|
BaseAPI.prototype.commonReset = function (settings) {
|
|
176
198
|
this.settings = (0,tslib_es6/* __assign */.Cl)((0,tslib_es6/* __assign */.Cl)({}, this.settings), settings);
|
|
@@ -195,7 +217,7 @@ var BaseAPI = (function () {
|
|
|
195
217
|
returnValue = api_constants/* default */.A.global.SCORM_TRUE;
|
|
196
218
|
this.processListeners(callbackName);
|
|
197
219
|
}
|
|
198
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
220
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
199
221
|
this.clearSCORMError(returnValue);
|
|
200
222
|
return returnValue;
|
|
201
223
|
};
|
|
@@ -247,7 +269,7 @@ var BaseAPI = (function () {
|
|
|
247
269
|
this.processListeners(callbackName);
|
|
248
270
|
_a.label = 2;
|
|
249
271
|
case 2:
|
|
250
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
272
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
251
273
|
this.clearSCORMError(returnValue);
|
|
252
274
|
return [2, returnValue];
|
|
253
275
|
}
|
|
@@ -267,7 +289,7 @@ var BaseAPI = (function () {
|
|
|
267
289
|
}
|
|
268
290
|
this.processListeners(callbackName, CMIElement);
|
|
269
291
|
}
|
|
270
|
-
this.apiLog(callbackName, ": returned: " + returnValue,
|
|
292
|
+
this.apiLog(callbackName, ": returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO, CMIElement);
|
|
271
293
|
if (returnValue === undefined) {
|
|
272
294
|
return "";
|
|
273
295
|
}
|
|
@@ -298,7 +320,7 @@ var BaseAPI = (function () {
|
|
|
298
320
|
this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
|
|
299
321
|
}
|
|
300
322
|
}
|
|
301
|
-
this.apiLog(callbackName, ": " + value + ": result: " + returnValue,
|
|
323
|
+
this.apiLog(callbackName, ": " + value + ": result: " + returnValue, enums/* LogLevelEnum */.Mb.INFO, CMIElement);
|
|
302
324
|
this.clearSCORMError(returnValue);
|
|
303
325
|
return returnValue;
|
|
304
326
|
};
|
|
@@ -309,7 +331,6 @@ var BaseAPI = (function () {
|
|
|
309
331
|
return (0,tslib_es6/* __generator */.YH)(this, function (_a) {
|
|
310
332
|
switch (_a.label) {
|
|
311
333
|
case 0:
|
|
312
|
-
console.log("commit");
|
|
313
334
|
this.clearScheduledCommit();
|
|
314
335
|
returnValue = api_constants/* default */.A.global.SCORM_FALSE;
|
|
315
336
|
if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
|
|
@@ -323,13 +344,13 @@ var BaseAPI = (function () {
|
|
|
323
344
|
typeof result !== "undefined" && result.result
|
|
324
345
|
? result.result
|
|
325
346
|
: api_constants/* default */.A.global.SCORM_FALSE;
|
|
326
|
-
this.apiLog(callbackName, " Result: " + returnValue,
|
|
347
|
+
this.apiLog(callbackName, " Result: " + returnValue, enums/* LogLevelEnum */.Mb.DEBUG, "HttpRequest");
|
|
327
348
|
if (checkTerminated)
|
|
328
349
|
this.lastErrorCode = "0";
|
|
329
350
|
this.processListeners(callbackName);
|
|
330
351
|
_a.label = 2;
|
|
331
352
|
case 2:
|
|
332
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
353
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
333
354
|
this.clearSCORMError(returnValue);
|
|
334
355
|
return [2, returnValue];
|
|
335
356
|
}
|
|
@@ -339,7 +360,7 @@ var BaseAPI = (function () {
|
|
|
339
360
|
BaseAPI.prototype.getLastError = function (callbackName) {
|
|
340
361
|
var returnValue = String(this.lastErrorCode);
|
|
341
362
|
this.processListeners(callbackName);
|
|
342
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
363
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
343
364
|
return returnValue;
|
|
344
365
|
};
|
|
345
366
|
BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
|
|
@@ -348,7 +369,7 @@ var BaseAPI = (function () {
|
|
|
348
369
|
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
|
|
349
370
|
this.processListeners(callbackName);
|
|
350
371
|
}
|
|
351
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
372
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
352
373
|
return returnValue;
|
|
353
374
|
};
|
|
354
375
|
BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
|
|
@@ -357,7 +378,7 @@ var BaseAPI = (function () {
|
|
|
357
378
|
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
|
|
358
379
|
this.processListeners(callbackName);
|
|
359
380
|
}
|
|
360
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
381
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums/* LogLevelEnum */.Mb.INFO);
|
|
361
382
|
return returnValue;
|
|
362
383
|
};
|
|
363
384
|
BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
|
|
@@ -451,7 +472,7 @@ var BaseAPI = (function () {
|
|
|
451
472
|
}
|
|
452
473
|
}
|
|
453
474
|
if (returnValue === api_constants/* default */.A.global.SCORM_FALSE) {
|
|
454
|
-
this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value),
|
|
475
|
+
this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), enums/* LogLevelEnum */.Mb.WARN);
|
|
455
476
|
}
|
|
456
477
|
return returnValue;
|
|
457
478
|
};
|
|
@@ -549,7 +570,7 @@ var BaseAPI = (function () {
|
|
|
549
570
|
CMIElement: CMIElement,
|
|
550
571
|
callback: callback,
|
|
551
572
|
});
|
|
552
|
-
this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length),
|
|
573
|
+
this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), enums/* LogLevelEnum */.Mb.INFO, functionName);
|
|
553
574
|
}
|
|
554
575
|
};
|
|
555
576
|
BaseAPI.prototype.off = function (listenerName, callback) {
|
|
@@ -572,7 +593,7 @@ var BaseAPI = (function () {
|
|
|
572
593
|
});
|
|
573
594
|
if (removeIndex !== -1) {
|
|
574
595
|
this_1.listenerArray.splice(removeIndex, 1);
|
|
575
|
-
this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length),
|
|
596
|
+
this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), enums/* LogLevelEnum */.Mb.INFO, functionName);
|
|
576
597
|
}
|
|
577
598
|
};
|
|
578
599
|
var this_1 = this;
|
|
@@ -605,7 +626,7 @@ var BaseAPI = (function () {
|
|
|
605
626
|
}
|
|
606
627
|
};
|
|
607
628
|
BaseAPI.prototype.processListeners = function (functionName, CMIElement, value) {
|
|
608
|
-
this.apiLog(functionName, value,
|
|
629
|
+
this.apiLog(functionName, value, enums/* LogLevelEnum */.Mb.INFO, CMIElement);
|
|
609
630
|
for (var i = 0; i < this.listenerArray.length; i++) {
|
|
610
631
|
var listener = this.listenerArray[i];
|
|
611
632
|
var functionsMatch = listener.functionName === functionName;
|
|
@@ -621,7 +642,7 @@ var BaseAPI = (function () {
|
|
|
621
642
|
CMIElementsMatch = listener.CMIElement === CMIElement;
|
|
622
643
|
}
|
|
623
644
|
if (functionsMatch && (!listenerHasCMIElement || CMIElementsMatch)) {
|
|
624
|
-
this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName),
|
|
645
|
+
this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), enums/* LogLevelEnum */.Mb.INFO, CMIElement);
|
|
625
646
|
listener.callback(CMIElement, value);
|
|
626
647
|
}
|
|
627
648
|
}
|
|
@@ -630,7 +651,7 @@ var BaseAPI = (function () {
|
|
|
630
651
|
if (!message) {
|
|
631
652
|
message = this.getLmsErrorMessageDetails(errorNumber);
|
|
632
653
|
}
|
|
633
|
-
this.apiLog("throwSCORMError", errorNumber + ": " + message,
|
|
654
|
+
this.apiLog("throwSCORMError", errorNumber + ": " + message, enums/* LogLevelEnum */.Mb.ERROR);
|
|
634
655
|
this.lastErrorCode = String(errorNumber);
|
|
635
656
|
};
|
|
636
657
|
BaseAPI.prototype.clearSCORMError = function (success) {
|
|
@@ -704,6 +725,7 @@ var BaseAPI = (function () {
|
|
|
704
725
|
});
|
|
705
726
|
};
|
|
706
727
|
BaseAPI.prototype.loadFromJSON = function (json, CMIElement) {
|
|
728
|
+
if (CMIElement === void 0) { CMIElement = ""; }
|
|
707
729
|
if (!this.isNotInitialized()) {
|
|
708
730
|
console.error("loadFromJSON can only be called before the call to lmsInitialize.");
|
|
709
731
|
return;
|
|
@@ -780,7 +802,7 @@ var BaseAPI = (function () {
|
|
|
780
802
|
return [2, this.transformResponse(response)];
|
|
781
803
|
case 2:
|
|
782
804
|
e_1 = _a.sent();
|
|
783
|
-
this.apiLog("processHttpRequest", e_1,
|
|
805
|
+
this.apiLog("processHttpRequest", e_1, enums/* LogLevelEnum */.Mb.ERROR);
|
|
784
806
|
api.processListeners("CommitError");
|
|
785
807
|
return [2, genericError];
|
|
786
808
|
case 3: return [2];
|
|
@@ -796,14 +818,14 @@ var BaseAPI = (function () {
|
|
|
796
818
|
BaseAPI.prototype.scheduleCommit = function (when, callback) {
|
|
797
819
|
if (!this._timeout) {
|
|
798
820
|
this._timeout = new ScheduledCommit(this, when, callback);
|
|
799
|
-
this.apiLog("scheduleCommit", "scheduled",
|
|
821
|
+
this.apiLog("scheduleCommit", "scheduled", enums/* LogLevelEnum */.Mb.DEBUG, "");
|
|
800
822
|
}
|
|
801
823
|
};
|
|
802
824
|
BaseAPI.prototype.clearScheduledCommit = function () {
|
|
803
825
|
if (this._timeout) {
|
|
804
826
|
this._timeout.cancel();
|
|
805
827
|
this._timeout = undefined;
|
|
806
|
-
this.apiLog("clearScheduledCommit", "cleared",
|
|
828
|
+
this.apiLog("clearScheduledCommit", "cleared", enums/* LogLevelEnum */.Mb.DEBUG, "");
|
|
807
829
|
}
|
|
808
830
|
};
|
|
809
831
|
BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
|
|
@@ -832,7 +854,7 @@ var BaseAPI = (function () {
|
|
|
832
854
|
var commitObject = this.settings.renderCommonCommitFields
|
|
833
855
|
? this.renderCommitObject(shouldTerminateCommit)
|
|
834
856
|
: this.renderCommitCMI(shouldTerminateCommit);
|
|
835
|
-
if (
|
|
857
|
+
if ([enums/* LogLevelEnum */.Mb.DEBUG, "1", 1, "DEBUG"].includes(this.apiLogLevel)) {
|
|
836
858
|
console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
|
|
837
859
|
console.debug(commitObject);
|
|
838
860
|
}
|
|
@@ -2529,11 +2551,6 @@ var global = {
|
|
|
2529
2551
|
STATE_NOT_INITIALIZED: 0,
|
|
2530
2552
|
STATE_INITIALIZED: 1,
|
|
2531
2553
|
STATE_TERMINATED: 2,
|
|
2532
|
-
LOG_LEVEL_DEBUG: 1,
|
|
2533
|
-
LOG_LEVEL_INFO: 2,
|
|
2534
|
-
LOG_LEVEL_WARNING: 3,
|
|
2535
|
-
LOG_LEVEL_ERROR: 4,
|
|
2536
|
-
LOG_LEVEL_NONE: 5,
|
|
2537
2554
|
};
|
|
2538
2555
|
var scorm12 = {
|
|
2539
2556
|
cmi_children: "core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",
|
|
@@ -2736,6 +2753,7 @@ var APIConstants = {
|
|
|
2736
2753
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2737
2754
|
|
|
2738
2755
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2756
|
+
/* harmony export */ Mb: function() { return /* binding */ LogLevelEnum; },
|
|
2739
2757
|
/* harmony export */ YE: function() { return /* binding */ SuccessStatus; },
|
|
2740
2758
|
/* harmony export */ lC: function() { return /* binding */ CompletionStatus; }
|
|
2741
2759
|
/* harmony export */ });
|
|
@@ -2758,6 +2776,15 @@ var CompletionStatus;
|
|
|
2758
2776
|
CompletionStatus["incomplete"] = "incomplete";
|
|
2759
2777
|
CompletionStatus["unknown"] = "unknown";
|
|
2760
2778
|
})(CompletionStatus || (CompletionStatus = {}));
|
|
2779
|
+
var LogLevelEnum;
|
|
2780
|
+
(function (LogLevelEnum) {
|
|
2781
|
+
LogLevelEnum[LogLevelEnum["_"] = 0] = "_";
|
|
2782
|
+
LogLevelEnum[LogLevelEnum["DEBUG"] = 1] = "DEBUG";
|
|
2783
|
+
LogLevelEnum[LogLevelEnum["INFO"] = 2] = "INFO";
|
|
2784
|
+
LogLevelEnum[LogLevelEnum["WARN"] = 3] = "WARN";
|
|
2785
|
+
LogLevelEnum[LogLevelEnum["ERROR"] = 4] = "ERROR";
|
|
2786
|
+
LogLevelEnum[LogLevelEnum["NONE"] = 5] = "NONE";
|
|
2787
|
+
})(LogLevelEnum || (LogLevelEnum = {}));
|
|
2761
2788
|
|
|
2762
2789
|
|
|
2763
2790
|
/***/ }),
|
|
@@ -2866,7 +2893,7 @@ var scorm2004 = {
|
|
|
2866
2893
|
CMIExit: "^(time-out|suspend|logout|normal)$",
|
|
2867
2894
|
CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
|
|
2868
2895
|
CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
|
|
2869
|
-
NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|_none_|(\\{target
|
|
2896
|
+
NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",
|
|
2870
2897
|
NAVBoolean: "^(unknown|true|false$)",
|
|
2871
2898
|
NAVTarget: "^{target=\\S{0,}[a-zA-Z0-9-_]+}$",
|
|
2872
2899
|
scaled_range: "-1#1",
|
|
@@ -2917,9 +2944,6 @@ var BaseScormValidationError = (function (_super) {
|
|
|
2917
2944
|
enumerable: false,
|
|
2918
2945
|
configurable: true
|
|
2919
2946
|
});
|
|
2920
|
-
BaseScormValidationError.prototype.setMessage = function (message) {
|
|
2921
|
-
this.message = message;
|
|
2922
|
-
};
|
|
2923
2947
|
return BaseScormValidationError;
|
|
2924
2948
|
}(Error));
|
|
2925
2949
|
|
|
@@ -2928,7 +2952,7 @@ var ValidationError = (function (_super) {
|
|
|
2928
2952
|
function ValidationError(errorCode, errorMessage, detailedMessage) {
|
|
2929
2953
|
var _this = _super.call(this, errorCode) || this;
|
|
2930
2954
|
_this._detailedMessage = "";
|
|
2931
|
-
_this.
|
|
2955
|
+
_this.message = errorMessage;
|
|
2932
2956
|
_this._errorMessage = errorMessage;
|
|
2933
2957
|
if (detailedMessage) {
|
|
2934
2958
|
_this._detailedMessage = detailedMessage;
|