scorm-again 2.6.2 → 2.6.4
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/dist/aicc.js +41 -25
- 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 +41 -25
- 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 +70 -45
- 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 +38 -23
- 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 +60 -39
- 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 +70 -45
- 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 +38 -23
- 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 +60 -39
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/index.d.ts +24 -3
- package/package.json +1 -1
- package/src/BaseAPI.ts +57 -35
- package/src/Scorm12API.ts +3 -2
- package/src/Scorm2004API.ts +31 -24
- package/src/cmi/aicc/attempts.ts +3 -3
- package/src/cmi/aicc/core.ts +30 -12
- package/src/cmi/aicc/evaluation.ts +1 -1
- package/src/cmi/aicc/student_data.ts +1 -1
- package/src/cmi/aicc/student_demographics.ts +13 -13
- package/src/cmi/aicc/student_preferences.ts +1 -1
- package/src/cmi/aicc/tries.ts +3 -3
- package/src/cmi/aicc/validation.ts +1 -1
- package/src/cmi/common/array.ts +1 -1
- package/src/cmi/common/score.ts +3 -3
- package/src/cmi/common/validation.ts +2 -2
- package/src/cmi/scorm12/cmi.ts +12 -4
- package/src/cmi/scorm12/interactions.ts +27 -11
- package/src/cmi/scorm12/objectives.ts +4 -4
- package/src/cmi/scorm12/student_data.ts +12 -4
- package/src/cmi/scorm12/student_preference.ts +3 -1
- package/src/cmi/scorm12/validation.ts +5 -3
- package/src/cmi/scorm2004/adl.ts +21 -7
- package/src/cmi/scorm2004/cmi.ts +45 -15
- package/src/cmi/scorm2004/comments.ts +11 -5
- package/src/cmi/scorm2004/interactions.ts +25 -23
- package/src/cmi/scorm2004/learner_preference.ts +3 -1
- package/src/cmi/scorm2004/objectives.ts +5 -5
- package/src/cmi/scorm2004/score.ts +3 -3
- package/src/cmi/scorm2004/validation.ts +2 -2
- package/src/constants/regex.ts +8 -1
- package/src/exceptions/aicc_exceptions.ts +4 -4
- package/src/exceptions/scorm12_exceptions.ts +4 -4
- package/src/exceptions/scorm2004_exceptions.ts +4 -4
- package/src/utilities.ts +3 -3
- package/test/Scorm12API.spec.ts +45 -0
- package/test/Scorm2004API.spec.ts +43 -0
- package/tsconfig.json +1 -0
package/dist/esm/scorm-again.js
CHANGED
|
@@ -32,11 +32,12 @@ var AICCValidationError = (function (_super) {
|
|
|
32
32
|
(0,tslib_es6.__extends)(AICCValidationError, _super);
|
|
33
33
|
function AICCValidationError(errorCode) {
|
|
34
34
|
var _this = this;
|
|
35
|
+
var _a, _b, _c, _d;
|
|
35
36
|
if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
|
|
36
|
-
_this = _super.call(this, errorCode, aicc_errors[String(errorCode)].basicMessage, aicc_errors[String(errorCode)].detailMessage) || this;
|
|
37
|
+
_this = _super.call(this, errorCode, ((_a = aicc_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown rror", (_b = aicc_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
_this = _super.call(this, 101, aicc_errors["101"].basicMessage, aicc_errors["101"].detailMessage) || this;
|
|
40
|
+
_this = _super.call(this, 101, ((_c = aicc_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) || "General error", (_d = aicc_errors["101"]) === null || _d === void 0 ? void 0 : _d.detailMessage) || this;
|
|
40
41
|
}
|
|
41
42
|
return _this;
|
|
42
43
|
}
|
|
@@ -1410,6 +1411,10 @@ var BaseAPI = (function () {
|
|
|
1410
1411
|
: this._error_codes.GENERAL;
|
|
1411
1412
|
for (var idx = 0; idx < structure.length; idx++) {
|
|
1412
1413
|
var attribute = structure[idx];
|
|
1414
|
+
if (!attribute) {
|
|
1415
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
1416
|
+
return api_constants.global_constants.SCORM_FALSE;
|
|
1417
|
+
}
|
|
1413
1418
|
if (idx === structure.length - 1) {
|
|
1414
1419
|
if (scorm2004 && attribute.substring(0, 8) === "{target=") {
|
|
1415
1420
|
if (this.isInitialized()) {
|
|
@@ -1440,7 +1445,7 @@ var BaseAPI = (function () {
|
|
|
1440
1445
|
break;
|
|
1441
1446
|
}
|
|
1442
1447
|
if (refObject instanceof array.CMIArray) {
|
|
1443
|
-
var index = parseInt(structure[idx + 1], 10);
|
|
1448
|
+
var index = parseInt(structure[idx + 1] || "0", 10);
|
|
1444
1449
|
if (!isNaN(index)) {
|
|
1445
1450
|
var item = refObject.childArray[index];
|
|
1446
1451
|
if (item) {
|
|
@@ -1484,6 +1489,10 @@ var BaseAPI = (function () {
|
|
|
1484
1489
|
: this._error_codes.GENERAL;
|
|
1485
1490
|
for (var idx = 0; idx < structure.length; idx++) {
|
|
1486
1491
|
attribute = structure[idx];
|
|
1492
|
+
if (!attribute) {
|
|
1493
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1487
1496
|
if (!scorm2004) {
|
|
1488
1497
|
if (idx === structure.length - 1) {
|
|
1489
1498
|
if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
@@ -1509,7 +1518,7 @@ var BaseAPI = (function () {
|
|
|
1509
1518
|
break;
|
|
1510
1519
|
}
|
|
1511
1520
|
if (refObject instanceof array.CMIArray) {
|
|
1512
|
-
var index = parseInt(structure[idx + 1], 10);
|
|
1521
|
+
var index = parseInt(structure[idx + 1] || "", 10);
|
|
1513
1522
|
if (!isNaN(index)) {
|
|
1514
1523
|
var item = refObject.childArray[index];
|
|
1515
1524
|
if (item) {
|
|
@@ -1547,17 +1556,18 @@ var BaseAPI = (function () {
|
|
|
1547
1556
|
return this.currentState === api_constants.global_constants.STATE_TERMINATED;
|
|
1548
1557
|
};
|
|
1549
1558
|
BaseAPI.prototype.on = function (listenerName, callback) {
|
|
1559
|
+
var _a, _c;
|
|
1550
1560
|
if (!callback)
|
|
1551
1561
|
return;
|
|
1552
1562
|
var listenerFunctions = listenerName.split(" ");
|
|
1553
1563
|
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
1554
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1555
|
-
if (listenerSplit.length === 0)
|
|
1564
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1565
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
1556
1566
|
return;
|
|
1557
1567
|
var functionName = listenerSplit[0];
|
|
1558
1568
|
var CMIElement = null;
|
|
1559
1569
|
if (listenerSplit.length > 1) {
|
|
1560
|
-
CMIElement =
|
|
1570
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1561
1571
|
}
|
|
1562
1572
|
this.listenerArray.push({
|
|
1563
1573
|
functionName: functionName,
|
|
@@ -1568,17 +1578,18 @@ var BaseAPI = (function () {
|
|
|
1568
1578
|
}
|
|
1569
1579
|
};
|
|
1570
1580
|
BaseAPI.prototype.off = function (listenerName, callback) {
|
|
1581
|
+
var _a, _c;
|
|
1571
1582
|
if (!callback)
|
|
1572
1583
|
return;
|
|
1573
1584
|
var listenerFunctions = listenerName.split(" ");
|
|
1574
1585
|
var _loop_1 = function (i) {
|
|
1575
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1576
|
-
if (listenerSplit.length === 0)
|
|
1586
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1587
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
1577
1588
|
return { value: void 0 };
|
|
1578
1589
|
var functionName = listenerSplit[0];
|
|
1579
1590
|
var CMIElement = null;
|
|
1580
1591
|
if (listenerSplit.length > 1) {
|
|
1581
|
-
CMIElement =
|
|
1592
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1582
1593
|
}
|
|
1583
1594
|
var removeIndex = this_1.listenerArray.findIndex(function (obj) {
|
|
1584
1595
|
return obj.functionName === functionName &&
|
|
@@ -1598,15 +1609,16 @@ var BaseAPI = (function () {
|
|
|
1598
1609
|
}
|
|
1599
1610
|
};
|
|
1600
1611
|
BaseAPI.prototype.clear = function (listenerName) {
|
|
1612
|
+
var _a, _c;
|
|
1601
1613
|
var listenerFunctions = listenerName.split(" ");
|
|
1602
1614
|
var _loop_2 = function (i) {
|
|
1603
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1604
|
-
if (listenerSplit.length === 0)
|
|
1615
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1616
|
+
if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
|
|
1605
1617
|
return { value: void 0 };
|
|
1606
1618
|
var functionName = listenerSplit[0];
|
|
1607
1619
|
var CMIElement = null;
|
|
1608
1620
|
if (listenerSplit.length > 1) {
|
|
1609
|
-
CMIElement =
|
|
1621
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1610
1622
|
}
|
|
1611
1623
|
this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
|
|
1612
1624
|
return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
|
|
@@ -1789,7 +1801,7 @@ var BaseAPI = (function () {
|
|
|
1789
1801
|
}];
|
|
1790
1802
|
}
|
|
1791
1803
|
process = function (url, params, settings) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
1792
|
-
var response, e_1;
|
|
1804
|
+
var response, e_1, message;
|
|
1793
1805
|
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1794
1806
|
switch (_a.label) {
|
|
1795
1807
|
case 0:
|
|
@@ -1801,7 +1813,8 @@ var BaseAPI = (function () {
|
|
|
1801
1813
|
return [2, this.transformResponse(response)];
|
|
1802
1814
|
case 2:
|
|
1803
1815
|
e_1 = _a.sent();
|
|
1804
|
-
|
|
1816
|
+
message = e_1 instanceof Error ? e_1.message : String(e_1);
|
|
1817
|
+
this.apiLog("processHttpRequest", message, enums.LogLevelEnum.ERROR);
|
|
1805
1818
|
api.processListeners("CommitError");
|
|
1806
1819
|
return [2, genericError];
|
|
1807
1820
|
case 3: return [2];
|
|
@@ -2087,14 +2100,16 @@ var Scorm12Impl = (function (_super) {
|
|
|
2087
2100
|
Scorm12Impl.prototype.validateCorrectResponse = function (_CMIElement, _value) {
|
|
2088
2101
|
};
|
|
2089
2102
|
Scorm12Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
|
|
2103
|
+
var _a, _b;
|
|
2090
2104
|
var basicMessage = "No Error";
|
|
2091
2105
|
var detailMessage = "No Error";
|
|
2092
2106
|
errorNumber = String(errorNumber);
|
|
2093
2107
|
if (_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) {
|
|
2094
2108
|
basicMessage =
|
|
2095
|
-
_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].basicMessage
|
|
2109
|
+
((_a = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
|
|
2110
|
+
"General Error";
|
|
2096
2111
|
detailMessage =
|
|
2097
|
-
_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].detailMessage;
|
|
2112
|
+
((_b = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) || "";
|
|
2098
2113
|
}
|
|
2099
2114
|
return detail ? detailMessage : basicMessage;
|
|
2100
2115
|
};
|
|
@@ -2251,11 +2266,12 @@ var Scorm2004ValidationError = (function (_super) {
|
|
|
2251
2266
|
(0,tslib_es6.__extends)(Scorm2004ValidationError, _super);
|
|
2252
2267
|
function Scorm2004ValidationError(errorCode) {
|
|
2253
2268
|
var _this = this;
|
|
2269
|
+
var _a, _b, _c, _d;
|
|
2254
2270
|
if ({}.hasOwnProperty.call(scorm2004_errors, String(errorCode))) {
|
|
2255
|
-
_this = _super.call(this, errorCode, scorm2004_errors[String(errorCode)].basicMessage, scorm2004_errors[String(errorCode)].detailMessage) || this;
|
|
2271
|
+
_this = _super.call(this, errorCode, ((_a = scorm2004_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown error", (_b = scorm2004_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
|
|
2256
2272
|
}
|
|
2257
2273
|
else {
|
|
2258
|
-
_this = _super.call(this, 101, scorm2004_errors["101"].basicMessage, scorm2004_errors["101"].detailMessage) || this;
|
|
2274
|
+
_this = _super.call(this, 101, ((_c = scorm2004_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) || "General error", (_d = scorm2004_errors["101"]) === null || _d === void 0 ? void 0 : _d.detailMessage) || this;
|
|
2259
2275
|
}
|
|
2260
2276
|
return _this;
|
|
2261
2277
|
}
|
|
@@ -2671,6 +2687,7 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2671
2687
|
return this._learner_response;
|
|
2672
2688
|
},
|
|
2673
2689
|
set: function (learner_response) {
|
|
2690
|
+
var _a, _b, _c, _d;
|
|
2674
2691
|
if (this.initialized && (this._type === "" || this._id === "")) {
|
|
2675
2692
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED);
|
|
2676
2693
|
}
|
|
@@ -2688,14 +2705,14 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2688
2705
|
var formatRegex = new RegExp(response_type.format);
|
|
2689
2706
|
for (var i = 0; i < nodes.length; i++) {
|
|
2690
2707
|
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
|
|
2691
|
-
var values = nodes[i].split(response_type.delimiter2);
|
|
2692
|
-
if (values.length === 2) {
|
|
2693
|
-
if (!values[0].match(formatRegex)) {
|
|
2708
|
+
var values = (_a = nodes[i]) === null || _a === void 0 ? void 0 : _a.split(response_type.delimiter2);
|
|
2709
|
+
if ((values === null || values === void 0 ? void 0 : values.length) === 2) {
|
|
2710
|
+
if (!((_b = values[0]) === null || _b === void 0 ? void 0 : _b.match(formatRegex))) {
|
|
2694
2711
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2695
2712
|
}
|
|
2696
2713
|
else {
|
|
2697
2714
|
if (!response_type.format2 ||
|
|
2698
|
-
!values[1].match(new RegExp(response_type.format2))) {
|
|
2715
|
+
!((_c = values[1]) === null || _c === void 0 ? void 0 : _c.match(new RegExp(response_type.format2)))) {
|
|
2699
2716
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2700
2717
|
}
|
|
2701
2718
|
}
|
|
@@ -2705,7 +2722,7 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2705
2722
|
}
|
|
2706
2723
|
}
|
|
2707
2724
|
else {
|
|
2708
|
-
if (!nodes[i].match(formatRegex)) {
|
|
2725
|
+
if (!((_d = nodes[i]) === null || _d === void 0 ? void 0 : _d.match(formatRegex))) {
|
|
2709
2726
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2710
2727
|
}
|
|
2711
2728
|
else {
|
|
@@ -4183,7 +4200,8 @@ var ADLNavRequestValid = (function (_super) {
|
|
|
4183
4200
|
}
|
|
4184
4201
|
for (var key in choice) {
|
|
4185
4202
|
if ({}.hasOwnProperty.call(choice, key)) {
|
|
4186
|
-
if (
|
|
4203
|
+
if (choice[key] !== undefined &&
|
|
4204
|
+
check2004ValidFormat(choice[key], regex.scorm2004_regex.NAVBoolean) &&
|
|
4187
4205
|
check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
|
|
4188
4206
|
this._choice[key] =
|
|
4189
4207
|
enums.NAVBoolean[choice[key]];
|
|
@@ -4207,7 +4225,8 @@ var ADLNavRequestValid = (function (_super) {
|
|
|
4207
4225
|
}
|
|
4208
4226
|
for (var key in jump) {
|
|
4209
4227
|
if ({}.hasOwnProperty.call(jump, key)) {
|
|
4210
|
-
if (
|
|
4228
|
+
if (jump[key] !== undefined &&
|
|
4229
|
+
check2004ValidFormat(jump[key], regex.scorm2004_regex.NAVBoolean) &&
|
|
4211
4230
|
check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
|
|
4212
4231
|
this._jump[key] = enums.NAVBoolean[jump[key]];
|
|
4213
4232
|
}
|
|
@@ -4360,19 +4379,19 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4360
4379
|
});
|
|
4361
4380
|
};
|
|
4362
4381
|
Scorm2004Impl.prototype.lmsGetValue = function (CMIElement) {
|
|
4363
|
-
var _a;
|
|
4382
|
+
var _a, _b;
|
|
4364
4383
|
var adlNavRequestRegex = "^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=\\S{0,}([a-zA-Z0-9-_]+)}$";
|
|
4365
4384
|
if ((0,utilities.stringMatches)(CMIElement, adlNavRequestRegex)) {
|
|
4366
4385
|
var matches = CMIElement.match(adlNavRequestRegex);
|
|
4367
4386
|
if (matches) {
|
|
4368
4387
|
var request = matches[1];
|
|
4369
|
-
var target = matches[2].replace("{target=", "").replace("}", "");
|
|
4370
|
-
if (request === "choice" || request === "jump") {
|
|
4388
|
+
var target = (_a = matches[2]) === null || _a === void 0 ? void 0 : _a.replace("{target=", "").replace("}", "");
|
|
4389
|
+
if (target && (request === "choice" || request === "jump")) {
|
|
4371
4390
|
if (this.settings.scoItemIdValidator) {
|
|
4372
4391
|
return String(this.settings.scoItemIdValidator(target));
|
|
4373
4392
|
}
|
|
4374
4393
|
if (this.settings.scoItemIds) {
|
|
4375
|
-
return String((
|
|
4394
|
+
return String((_b = this.settings.scoItemIds) === null || _b === void 0 ? void 0 : _b.includes(target));
|
|
4376
4395
|
}
|
|
4377
4396
|
return String(request);
|
|
4378
4397
|
}
|
|
@@ -4526,8 +4545,9 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4526
4545
|
var interaction_count = interaction.correct_responses._count;
|
|
4527
4546
|
this.checkDuplicateChoiceResponse(interaction, value);
|
|
4528
4547
|
var response_type = CorrectResponses[interaction.type];
|
|
4529
|
-
if (typeof response_type
|
|
4530
|
-
|
|
4548
|
+
if (typeof response_type !== "undefined" &&
|
|
4549
|
+
(typeof response_type.limit === "undefined" ||
|
|
4550
|
+
interaction_count <= response_type.limit)) {
|
|
4531
4551
|
this.checkValidResponseType(response_type, value, interaction.type);
|
|
4532
4552
|
if ((this.lastErrorCode === "0" &&
|
|
4533
4553
|
(!response_type.duplicate ||
|
|
@@ -4548,14 +4568,17 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4548
4568
|
return this._commonGetCMIValue("GetValue", true, CMIElement);
|
|
4549
4569
|
};
|
|
4550
4570
|
Scorm2004Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
|
|
4571
|
+
var _a, _b;
|
|
4551
4572
|
var basicMessage = "";
|
|
4552
4573
|
var detailMessage = "";
|
|
4553
4574
|
errorNumber = String(errorNumber);
|
|
4554
4575
|
if (api_constants.scorm2004_constants.error_descriptions[errorNumber]) {
|
|
4555
4576
|
basicMessage =
|
|
4556
|
-
api_constants.scorm2004_constants.error_descriptions[errorNumber].basicMessage
|
|
4577
|
+
((_a = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
|
|
4578
|
+
"Unknown Error";
|
|
4557
4579
|
detailMessage =
|
|
4558
|
-
api_constants.scorm2004_constants.error_descriptions[errorNumber].detailMessage
|
|
4580
|
+
((_b = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) ||
|
|
4581
|
+
"";
|
|
4559
4582
|
}
|
|
4560
4583
|
return detail ? detailMessage : basicMessage;
|
|
4561
4584
|
};
|
|
@@ -4571,7 +4594,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4571
4594
|
};
|
|
4572
4595
|
Scorm2004Impl.prototype.checkCorrectResponseValue = function (interaction_type, nodes, value) {
|
|
4573
4596
|
var response = CorrectResponses[interaction_type];
|
|
4574
|
-
var formatRegex = new RegExp(response.format);
|
|
4597
|
+
var formatRegex = new RegExp((response === null || response === void 0 ? void 0 : response.format) || ".*");
|
|
4575
4598
|
for (var i = 0; i < nodes.length && this.lastErrorCode === "0"; i++) {
|
|
4576
4599
|
if (interaction_type.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")) {
|
|
4577
4600
|
nodes[i] = this.removeCorrectResponsePrefixes(nodes[i]);
|
|
@@ -4607,7 +4630,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4607
4630
|
}
|
|
4608
4631
|
}
|
|
4609
4632
|
else {
|
|
4610
|
-
if (nodes[i] !== "" && response.unique) {
|
|
4633
|
+
if (nodes[i] !== "" && (response === null || response === void 0 ? void 0 : response.unique)) {
|
|
4611
4634
|
for (var j = 0; j < i && this.lastErrorCode === "0"; j++) {
|
|
4612
4635
|
if (nodes[i] === nodes[j]) {
|
|
4613
4636
|
this.throwSCORMError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
@@ -4620,6 +4643,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4620
4643
|
}
|
|
4621
4644
|
};
|
|
4622
4645
|
Scorm2004Impl.prototype.removeCorrectResponsePrefixes = function (node) {
|
|
4646
|
+
var _a;
|
|
4623
4647
|
var seenOrder = false;
|
|
4624
4648
|
var seenCase = false;
|
|
4625
4649
|
var seenLang = false;
|
|
@@ -4657,7 +4681,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4657
4681
|
seenOrder = true;
|
|
4658
4682
|
break;
|
|
4659
4683
|
}
|
|
4660
|
-
node = node.substring(matches[1].length);
|
|
4684
|
+
node = node.substring(((_a = matches[1]) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
4661
4685
|
matches = node.match(prefixRegex);
|
|
4662
4686
|
}
|
|
4663
4687
|
return node;
|
|
@@ -5059,8 +5083,8 @@ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmpty
|
|
|
5059
5083
|
function checkValidRange(value, rangePattern, errorCode, errorClass) {
|
|
5060
5084
|
var ranges = rangePattern.split("#");
|
|
5061
5085
|
value = value * 1.0;
|
|
5062
|
-
if (value >= ranges[0]) {
|
|
5063
|
-
if (ranges[1] === "*" || value <= ranges[1]) {
|
|
5086
|
+
if (ranges[0] && value >= ranges[0]) {
|
|
5087
|
+
if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
|
|
5064
5088
|
return true;
|
|
5065
5089
|
}
|
|
5066
5090
|
else {
|
|
@@ -6519,7 +6543,7 @@ var scorm12_regex = {
|
|
|
6519
6543
|
CMISInteger: "^-?([0-9]+)$",
|
|
6520
6544
|
CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
|
|
6521
6545
|
CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
|
|
6522
|
-
CMIFeedback: "
|
|
6546
|
+
CMIFeedback: "^.*$",
|
|
6523
6547
|
CMIIndex: "[._](\\d+).",
|
|
6524
6548
|
CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
|
|
6525
6549
|
CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
|
|
@@ -6655,11 +6679,12 @@ var Scorm12ValidationError = (function (_super) {
|
|
|
6655
6679
|
(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(Scorm12ValidationError, _super);
|
|
6656
6680
|
function Scorm12ValidationError(errorCode) {
|
|
6657
6681
|
var _this = this;
|
|
6682
|
+
var _a, _b, _c, _d, _e;
|
|
6658
6683
|
if ({}.hasOwnProperty.call(scorm12_errors, String(errorCode))) {
|
|
6659
|
-
_this = _super.call(this, errorCode, scorm12_errors[String(errorCode)].basicMessage, scorm12_errors[String(errorCode)].detailMessage) || this;
|
|
6684
|
+
_this = _super.call(this, errorCode, ((_a = scorm12_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown error", (_b = scorm12_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
|
|
6660
6685
|
}
|
|
6661
6686
|
else {
|
|
6662
|
-
_this = _super.call(this, 101, scorm12_errors["101"].basicMessage, scorm12_errors["101"].detailMessage) || this;
|
|
6687
|
+
_this = _super.call(this, 101, (_d = (_c = scorm12_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) !== null && _d !== void 0 ? _d : "General error", (_e = scorm12_errors["101"]) === null || _e === void 0 ? void 0 : _e.detailMessage) || this;
|
|
6663
6688
|
}
|
|
6664
6689
|
return _this;
|
|
6665
6690
|
}
|
|
@@ -6729,7 +6754,7 @@ function getSecondsAsISODuration(seconds) {
|
|
|
6729
6754
|
var duration = "P";
|
|
6730
6755
|
var remainder = seconds;
|
|
6731
6756
|
for (var designationsKey in designations) {
|
|
6732
|
-
var current_seconds = designations[designationsKey];
|
|
6757
|
+
var current_seconds = designations[designationsKey] || 1;
|
|
6733
6758
|
var value = Math.floor(remainder / current_seconds);
|
|
6734
6759
|
remainder = remainder % current_seconds;
|
|
6735
6760
|
if (countDecimals(remainder) > 2) {
|
|
@@ -6836,7 +6861,7 @@ function unflatten(data) {
|
|
|
6836
6861
|
var m = regex.exec(p);
|
|
6837
6862
|
while (m) {
|
|
6838
6863
|
cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
|
|
6839
|
-
prop = m[2] || m[1];
|
|
6864
|
+
prop = m[2] || m[1] || "";
|
|
6840
6865
|
m = regex.exec(p);
|
|
6841
6866
|
}
|
|
6842
6867
|
cur[prop] = data[p];
|
|
@@ -6848,7 +6873,7 @@ function countDecimals(num) {
|
|
|
6848
6873
|
if (Math.floor(num) === num || String(num).indexOf(".") < 0)
|
|
6849
6874
|
return 0;
|
|
6850
6875
|
var parts = num.toString().split(".")[1];
|
|
6851
|
-
return parts.length || 0;
|
|
6876
|
+
return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
|
|
6852
6877
|
}
|
|
6853
6878
|
function formatMessage(functionName, message, CMIElement) {
|
|
6854
6879
|
var baseLength = 20;
|