@didask/scol-r 2.2.3 → 2.2.5
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/lib/SCORMAdapter.js +23 -16
- package/package.json +1 -1
package/lib/SCORMAdapter.js
CHANGED
|
@@ -3,31 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SCORMAdapter = void 0;
|
|
4
4
|
var SCORMAdapter = /** @class */ (function () {
|
|
5
5
|
function SCORMAdapter(errorCallback) {
|
|
6
|
+
var _this = this;
|
|
6
7
|
if (errorCallback === void 0) { errorCallback = function () { }; }
|
|
7
8
|
this._ignorableErrorCodes = [
|
|
8
|
-
{ code: 0,
|
|
9
|
+
{ code: 0, getShouldBeIgnored: function () { return true; } },
|
|
9
10
|
{
|
|
10
11
|
code: 403,
|
|
11
|
-
|
|
12
|
-
return this._isSCORM2004;
|
|
13
|
-
},
|
|
12
|
+
getShouldBeIgnored: function () { return _this._isSCORM2004; },
|
|
14
13
|
},
|
|
15
14
|
{
|
|
16
15
|
code: 401,
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
getShouldBeIgnored: function () {
|
|
17
|
+
return !_this._isSCORM2004 &&
|
|
18
|
+
_this._lastRequest &&
|
|
19
|
+
_this._lastRequest.method === "get" &&
|
|
20
|
+
_this._lastRequest.key === "cmi.objectives._children";
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
{
|
|
25
24
|
code: 402,
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
getShouldBeIgnored: function () {
|
|
26
|
+
return _this._isSCORM2004 &&
|
|
27
|
+
_this._lastRequest &&
|
|
28
|
+
_this._lastRequest.method === "get" &&
|
|
29
|
+
_this._lastRequest.key === "cmi.objectives._children";
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
code: 351,
|
|
34
|
+
getShouldBeIgnored: function () {
|
|
35
|
+
return _this._lastRequest.method === "set" &&
|
|
36
|
+
new RegExp("^cmi.objectives.\\d+.id$").test(_this._lastRequest.key) &&
|
|
37
|
+
!!_this.LMSGetValue(_this._lastRequest.key);
|
|
31
38
|
},
|
|
32
39
|
},
|
|
33
40
|
];
|
|
@@ -124,8 +131,8 @@ var SCORMAdapter = /** @class */ (function () {
|
|
|
124
131
|
var lastErrorString = this.LMSGetErrorString(lastErrorCode);
|
|
125
132
|
var lastErrorDiagnostic = this.LMSGetDiagnostic(lastErrorCode);
|
|
126
133
|
if (!this._ignorableErrorCodes.some(function (_a) {
|
|
127
|
-
var code = _a.code,
|
|
128
|
-
return code === lastErrorCode &&
|
|
134
|
+
var code = _a.code, getShouldBeIgnored = _a.getShouldBeIgnored;
|
|
135
|
+
return code === lastErrorCode && getShouldBeIgnored();
|
|
129
136
|
})) {
|
|
130
137
|
console.warn(functionName, "An error occured on the SCORM API: code " + lastErrorCode + ", message: " + lastErrorString, lastErrorDiagnostic);
|
|
131
138
|
this._errorCallback(lastErrorString, lastErrorDiagnostic && lastErrorDiagnostic != lastErrorCode
|