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/scorm-again.js
CHANGED
|
@@ -34,11 +34,12 @@ var AICCValidationError = (function (_super) {
|
|
|
34
34
|
(0,tslib_es6.__extends)(AICCValidationError, _super);
|
|
35
35
|
function AICCValidationError(errorCode) {
|
|
36
36
|
var _this = this;
|
|
37
|
+
var _a, _b, _c, _d;
|
|
37
38
|
if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
|
|
38
|
-
_this = _super.call(this, errorCode, aicc_errors[String(errorCode)].basicMessage, aicc_errors[String(errorCode)].detailMessage) || this;
|
|
39
|
+
_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;
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
|
-
_this = _super.call(this, 101, aicc_errors["101"].basicMessage, aicc_errors["101"].detailMessage) || this;
|
|
42
|
+
_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;
|
|
42
43
|
}
|
|
43
44
|
return _this;
|
|
44
45
|
}
|
|
@@ -1412,6 +1413,10 @@ var BaseAPI = (function () {
|
|
|
1412
1413
|
: this._error_codes.GENERAL;
|
|
1413
1414
|
for (var idx = 0; idx < structure.length; idx++) {
|
|
1414
1415
|
var attribute = structure[idx];
|
|
1416
|
+
if (!attribute) {
|
|
1417
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
1418
|
+
return api_constants.global_constants.SCORM_FALSE;
|
|
1419
|
+
}
|
|
1415
1420
|
if (idx === structure.length - 1) {
|
|
1416
1421
|
if (scorm2004 && attribute.substring(0, 8) === "{target=") {
|
|
1417
1422
|
if (this.isInitialized()) {
|
|
@@ -1442,7 +1447,7 @@ var BaseAPI = (function () {
|
|
|
1442
1447
|
break;
|
|
1443
1448
|
}
|
|
1444
1449
|
if (refObject instanceof array.CMIArray) {
|
|
1445
|
-
var index = parseInt(structure[idx + 1], 10);
|
|
1450
|
+
var index = parseInt(structure[idx + 1] || "0", 10);
|
|
1446
1451
|
if (!isNaN(index)) {
|
|
1447
1452
|
var item = refObject.childArray[index];
|
|
1448
1453
|
if (item) {
|
|
@@ -1486,6 +1491,10 @@ var BaseAPI = (function () {
|
|
|
1486
1491
|
: this._error_codes.GENERAL;
|
|
1487
1492
|
for (var idx = 0; idx < structure.length; idx++) {
|
|
1488
1493
|
attribute = structure[idx];
|
|
1494
|
+
if (!attribute) {
|
|
1495
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1489
1498
|
if (!scorm2004) {
|
|
1490
1499
|
if (idx === structure.length - 1) {
|
|
1491
1500
|
if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
@@ -1511,7 +1520,7 @@ var BaseAPI = (function () {
|
|
|
1511
1520
|
break;
|
|
1512
1521
|
}
|
|
1513
1522
|
if (refObject instanceof array.CMIArray) {
|
|
1514
|
-
var index = parseInt(structure[idx + 1], 10);
|
|
1523
|
+
var index = parseInt(structure[idx + 1] || "", 10);
|
|
1515
1524
|
if (!isNaN(index)) {
|
|
1516
1525
|
var item = refObject.childArray[index];
|
|
1517
1526
|
if (item) {
|
|
@@ -1549,17 +1558,18 @@ var BaseAPI = (function () {
|
|
|
1549
1558
|
return this.currentState === api_constants.global_constants.STATE_TERMINATED;
|
|
1550
1559
|
};
|
|
1551
1560
|
BaseAPI.prototype.on = function (listenerName, callback) {
|
|
1561
|
+
var _a, _c;
|
|
1552
1562
|
if (!callback)
|
|
1553
1563
|
return;
|
|
1554
1564
|
var listenerFunctions = listenerName.split(" ");
|
|
1555
1565
|
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
1556
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1557
|
-
if (listenerSplit.length === 0)
|
|
1566
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1567
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
1558
1568
|
return;
|
|
1559
1569
|
var functionName = listenerSplit[0];
|
|
1560
1570
|
var CMIElement = null;
|
|
1561
1571
|
if (listenerSplit.length > 1) {
|
|
1562
|
-
CMIElement =
|
|
1572
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1563
1573
|
}
|
|
1564
1574
|
this.listenerArray.push({
|
|
1565
1575
|
functionName: functionName,
|
|
@@ -1570,17 +1580,18 @@ var BaseAPI = (function () {
|
|
|
1570
1580
|
}
|
|
1571
1581
|
};
|
|
1572
1582
|
BaseAPI.prototype.off = function (listenerName, callback) {
|
|
1583
|
+
var _a, _c;
|
|
1573
1584
|
if (!callback)
|
|
1574
1585
|
return;
|
|
1575
1586
|
var listenerFunctions = listenerName.split(" ");
|
|
1576
1587
|
var _loop_1 = function (i) {
|
|
1577
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1578
|
-
if (listenerSplit.length === 0)
|
|
1588
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1589
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
1579
1590
|
return { value: void 0 };
|
|
1580
1591
|
var functionName = listenerSplit[0];
|
|
1581
1592
|
var CMIElement = null;
|
|
1582
1593
|
if (listenerSplit.length > 1) {
|
|
1583
|
-
CMIElement =
|
|
1594
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1584
1595
|
}
|
|
1585
1596
|
var removeIndex = this_1.listenerArray.findIndex(function (obj) {
|
|
1586
1597
|
return obj.functionName === functionName &&
|
|
@@ -1600,15 +1611,16 @@ var BaseAPI = (function () {
|
|
|
1600
1611
|
}
|
|
1601
1612
|
};
|
|
1602
1613
|
BaseAPI.prototype.clear = function (listenerName) {
|
|
1614
|
+
var _a, _c;
|
|
1603
1615
|
var listenerFunctions = listenerName.split(" ");
|
|
1604
1616
|
var _loop_2 = function (i) {
|
|
1605
|
-
var listenerSplit = listenerFunctions[i].split(".");
|
|
1606
|
-
if (listenerSplit.length === 0)
|
|
1617
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1618
|
+
if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
|
|
1607
1619
|
return { value: void 0 };
|
|
1608
1620
|
var functionName = listenerSplit[0];
|
|
1609
1621
|
var CMIElement = null;
|
|
1610
1622
|
if (listenerSplit.length > 1) {
|
|
1611
|
-
CMIElement =
|
|
1623
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1612
1624
|
}
|
|
1613
1625
|
this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
|
|
1614
1626
|
return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
|
|
@@ -1791,7 +1803,7 @@ var BaseAPI = (function () {
|
|
|
1791
1803
|
}];
|
|
1792
1804
|
}
|
|
1793
1805
|
process = function (url, params, settings) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
1794
|
-
var response, e_1;
|
|
1806
|
+
var response, e_1, message;
|
|
1795
1807
|
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1796
1808
|
switch (_a.label) {
|
|
1797
1809
|
case 0:
|
|
@@ -1803,7 +1815,8 @@ var BaseAPI = (function () {
|
|
|
1803
1815
|
return [2, this.transformResponse(response)];
|
|
1804
1816
|
case 2:
|
|
1805
1817
|
e_1 = _a.sent();
|
|
1806
|
-
|
|
1818
|
+
message = e_1 instanceof Error ? e_1.message : String(e_1);
|
|
1819
|
+
this.apiLog("processHttpRequest", message, enums.LogLevelEnum.ERROR);
|
|
1807
1820
|
api.processListeners("CommitError");
|
|
1808
1821
|
return [2, genericError];
|
|
1809
1822
|
case 3: return [2];
|
|
@@ -2089,14 +2102,16 @@ var Scorm12Impl = (function (_super) {
|
|
|
2089
2102
|
Scorm12Impl.prototype.validateCorrectResponse = function (_CMIElement, _value) {
|
|
2090
2103
|
};
|
|
2091
2104
|
Scorm12Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
|
|
2105
|
+
var _a, _b;
|
|
2092
2106
|
var basicMessage = "No Error";
|
|
2093
2107
|
var detailMessage = "No Error";
|
|
2094
2108
|
errorNumber = String(errorNumber);
|
|
2095
2109
|
if (_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) {
|
|
2096
2110
|
basicMessage =
|
|
2097
|
-
_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].basicMessage
|
|
2111
|
+
((_a = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
|
|
2112
|
+
"General Error";
|
|
2098
2113
|
detailMessage =
|
|
2099
|
-
_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].detailMessage;
|
|
2114
|
+
((_b = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) || "";
|
|
2100
2115
|
}
|
|
2101
2116
|
return detail ? detailMessage : basicMessage;
|
|
2102
2117
|
};
|
|
@@ -2253,11 +2268,12 @@ var Scorm2004ValidationError = (function (_super) {
|
|
|
2253
2268
|
(0,tslib_es6.__extends)(Scorm2004ValidationError, _super);
|
|
2254
2269
|
function Scorm2004ValidationError(errorCode) {
|
|
2255
2270
|
var _this = this;
|
|
2271
|
+
var _a, _b, _c, _d;
|
|
2256
2272
|
if ({}.hasOwnProperty.call(scorm2004_errors, String(errorCode))) {
|
|
2257
|
-
_this = _super.call(this, errorCode, scorm2004_errors[String(errorCode)].basicMessage, scorm2004_errors[String(errorCode)].detailMessage) || this;
|
|
2273
|
+
_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;
|
|
2258
2274
|
}
|
|
2259
2275
|
else {
|
|
2260
|
-
_this = _super.call(this, 101, scorm2004_errors["101"].basicMessage, scorm2004_errors["101"].detailMessage) || this;
|
|
2276
|
+
_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;
|
|
2261
2277
|
}
|
|
2262
2278
|
return _this;
|
|
2263
2279
|
}
|
|
@@ -2673,6 +2689,7 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2673
2689
|
return this._learner_response;
|
|
2674
2690
|
},
|
|
2675
2691
|
set: function (learner_response) {
|
|
2692
|
+
var _a, _b, _c, _d;
|
|
2676
2693
|
if (this.initialized && (this._type === "" || this._id === "")) {
|
|
2677
2694
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED);
|
|
2678
2695
|
}
|
|
@@ -2690,14 +2707,14 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2690
2707
|
var formatRegex = new RegExp(response_type.format);
|
|
2691
2708
|
for (var i = 0; i < nodes.length; i++) {
|
|
2692
2709
|
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
|
|
2693
|
-
var values = nodes[i].split(response_type.delimiter2);
|
|
2694
|
-
if (values.length === 2) {
|
|
2695
|
-
if (!values[0].match(formatRegex)) {
|
|
2710
|
+
var values = (_a = nodes[i]) === null || _a === void 0 ? void 0 : _a.split(response_type.delimiter2);
|
|
2711
|
+
if ((values === null || values === void 0 ? void 0 : values.length) === 2) {
|
|
2712
|
+
if (!((_b = values[0]) === null || _b === void 0 ? void 0 : _b.match(formatRegex))) {
|
|
2696
2713
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2697
2714
|
}
|
|
2698
2715
|
else {
|
|
2699
2716
|
if (!response_type.format2 ||
|
|
2700
|
-
!values[1].match(new RegExp(response_type.format2))) {
|
|
2717
|
+
!((_c = values[1]) === null || _c === void 0 ? void 0 : _c.match(new RegExp(response_type.format2)))) {
|
|
2701
2718
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2702
2719
|
}
|
|
2703
2720
|
}
|
|
@@ -2707,7 +2724,7 @@ var CMIInteractionsObject = (function (_super) {
|
|
|
2707
2724
|
}
|
|
2708
2725
|
}
|
|
2709
2726
|
else {
|
|
2710
|
-
if (!nodes[i].match(formatRegex)) {
|
|
2727
|
+
if (!((_d = nodes[i]) === null || _d === void 0 ? void 0 : _d.match(formatRegex))) {
|
|
2711
2728
|
throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
2712
2729
|
}
|
|
2713
2730
|
else {
|
|
@@ -4185,7 +4202,8 @@ var ADLNavRequestValid = (function (_super) {
|
|
|
4185
4202
|
}
|
|
4186
4203
|
for (var key in choice) {
|
|
4187
4204
|
if ({}.hasOwnProperty.call(choice, key)) {
|
|
4188
|
-
if (
|
|
4205
|
+
if (choice[key] !== undefined &&
|
|
4206
|
+
check2004ValidFormat(choice[key], regex.scorm2004_regex.NAVBoolean) &&
|
|
4189
4207
|
check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
|
|
4190
4208
|
this._choice[key] =
|
|
4191
4209
|
enums.NAVBoolean[choice[key]];
|
|
@@ -4209,7 +4227,8 @@ var ADLNavRequestValid = (function (_super) {
|
|
|
4209
4227
|
}
|
|
4210
4228
|
for (var key in jump) {
|
|
4211
4229
|
if ({}.hasOwnProperty.call(jump, key)) {
|
|
4212
|
-
if (
|
|
4230
|
+
if (jump[key] !== undefined &&
|
|
4231
|
+
check2004ValidFormat(jump[key], regex.scorm2004_regex.NAVBoolean) &&
|
|
4213
4232
|
check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
|
|
4214
4233
|
this._jump[key] = enums.NAVBoolean[jump[key]];
|
|
4215
4234
|
}
|
|
@@ -4362,19 +4381,19 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4362
4381
|
});
|
|
4363
4382
|
};
|
|
4364
4383
|
Scorm2004Impl.prototype.lmsGetValue = function (CMIElement) {
|
|
4365
|
-
var _a;
|
|
4384
|
+
var _a, _b;
|
|
4366
4385
|
var adlNavRequestRegex = "^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=\\S{0,}([a-zA-Z0-9-_]+)}$";
|
|
4367
4386
|
if ((0,utilities.stringMatches)(CMIElement, adlNavRequestRegex)) {
|
|
4368
4387
|
var matches = CMIElement.match(adlNavRequestRegex);
|
|
4369
4388
|
if (matches) {
|
|
4370
4389
|
var request = matches[1];
|
|
4371
|
-
var target = matches[2].replace("{target=", "").replace("}", "");
|
|
4372
|
-
if (request === "choice" || request === "jump") {
|
|
4390
|
+
var target = (_a = matches[2]) === null || _a === void 0 ? void 0 : _a.replace("{target=", "").replace("}", "");
|
|
4391
|
+
if (target && (request === "choice" || request === "jump")) {
|
|
4373
4392
|
if (this.settings.scoItemIdValidator) {
|
|
4374
4393
|
return String(this.settings.scoItemIdValidator(target));
|
|
4375
4394
|
}
|
|
4376
4395
|
if (this.settings.scoItemIds) {
|
|
4377
|
-
return String((
|
|
4396
|
+
return String((_b = this.settings.scoItemIds) === null || _b === void 0 ? void 0 : _b.includes(target));
|
|
4378
4397
|
}
|
|
4379
4398
|
return String(request);
|
|
4380
4399
|
}
|
|
@@ -4528,8 +4547,9 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4528
4547
|
var interaction_count = interaction.correct_responses._count;
|
|
4529
4548
|
this.checkDuplicateChoiceResponse(interaction, value);
|
|
4530
4549
|
var response_type = CorrectResponses[interaction.type];
|
|
4531
|
-
if (typeof response_type
|
|
4532
|
-
|
|
4550
|
+
if (typeof response_type !== "undefined" &&
|
|
4551
|
+
(typeof response_type.limit === "undefined" ||
|
|
4552
|
+
interaction_count <= response_type.limit)) {
|
|
4533
4553
|
this.checkValidResponseType(response_type, value, interaction.type);
|
|
4534
4554
|
if ((this.lastErrorCode === "0" &&
|
|
4535
4555
|
(!response_type.duplicate ||
|
|
@@ -4550,14 +4570,17 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4550
4570
|
return this._commonGetCMIValue("GetValue", true, CMIElement);
|
|
4551
4571
|
};
|
|
4552
4572
|
Scorm2004Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
|
|
4573
|
+
var _a, _b;
|
|
4553
4574
|
var basicMessage = "";
|
|
4554
4575
|
var detailMessage = "";
|
|
4555
4576
|
errorNumber = String(errorNumber);
|
|
4556
4577
|
if (api_constants.scorm2004_constants.error_descriptions[errorNumber]) {
|
|
4557
4578
|
basicMessage =
|
|
4558
|
-
api_constants.scorm2004_constants.error_descriptions[errorNumber].basicMessage
|
|
4579
|
+
((_a = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
|
|
4580
|
+
"Unknown Error";
|
|
4559
4581
|
detailMessage =
|
|
4560
|
-
api_constants.scorm2004_constants.error_descriptions[errorNumber].detailMessage
|
|
4582
|
+
((_b = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) ||
|
|
4583
|
+
"";
|
|
4561
4584
|
}
|
|
4562
4585
|
return detail ? detailMessage : basicMessage;
|
|
4563
4586
|
};
|
|
@@ -4573,7 +4596,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4573
4596
|
};
|
|
4574
4597
|
Scorm2004Impl.prototype.checkCorrectResponseValue = function (interaction_type, nodes, value) {
|
|
4575
4598
|
var response = CorrectResponses[interaction_type];
|
|
4576
|
-
var formatRegex = new RegExp(response.format);
|
|
4599
|
+
var formatRegex = new RegExp((response === null || response === void 0 ? void 0 : response.format) || ".*");
|
|
4577
4600
|
for (var i = 0; i < nodes.length && this.lastErrorCode === "0"; i++) {
|
|
4578
4601
|
if (interaction_type.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")) {
|
|
4579
4602
|
nodes[i] = this.removeCorrectResponsePrefixes(nodes[i]);
|
|
@@ -4609,7 +4632,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4609
4632
|
}
|
|
4610
4633
|
}
|
|
4611
4634
|
else {
|
|
4612
|
-
if (nodes[i] !== "" && response.unique) {
|
|
4635
|
+
if (nodes[i] !== "" && (response === null || response === void 0 ? void 0 : response.unique)) {
|
|
4613
4636
|
for (var j = 0; j < i && this.lastErrorCode === "0"; j++) {
|
|
4614
4637
|
if (nodes[i] === nodes[j]) {
|
|
4615
4638
|
this.throwSCORMError(error_codes.scorm2004_errors.TYPE_MISMATCH);
|
|
@@ -4622,6 +4645,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4622
4645
|
}
|
|
4623
4646
|
};
|
|
4624
4647
|
Scorm2004Impl.prototype.removeCorrectResponsePrefixes = function (node) {
|
|
4648
|
+
var _a;
|
|
4625
4649
|
var seenOrder = false;
|
|
4626
4650
|
var seenCase = false;
|
|
4627
4651
|
var seenLang = false;
|
|
@@ -4659,7 +4683,7 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4659
4683
|
seenOrder = true;
|
|
4660
4684
|
break;
|
|
4661
4685
|
}
|
|
4662
|
-
node = node.substring(matches[1].length);
|
|
4686
|
+
node = node.substring(((_a = matches[1]) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
4663
4687
|
matches = node.match(prefixRegex);
|
|
4664
4688
|
}
|
|
4665
4689
|
return node;
|
|
@@ -5061,8 +5085,8 @@ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmpty
|
|
|
5061
5085
|
function checkValidRange(value, rangePattern, errorCode, errorClass) {
|
|
5062
5086
|
var ranges = rangePattern.split("#");
|
|
5063
5087
|
value = value * 1.0;
|
|
5064
|
-
if (value >= ranges[0]) {
|
|
5065
|
-
if (ranges[1] === "*" || value <= ranges[1]) {
|
|
5088
|
+
if (ranges[0] && value >= ranges[0]) {
|
|
5089
|
+
if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
|
|
5066
5090
|
return true;
|
|
5067
5091
|
}
|
|
5068
5092
|
else {
|
|
@@ -6521,7 +6545,7 @@ var scorm12_regex = {
|
|
|
6521
6545
|
CMISInteger: "^-?([0-9]+)$",
|
|
6522
6546
|
CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
|
|
6523
6547
|
CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
|
|
6524
|
-
CMIFeedback: "
|
|
6548
|
+
CMIFeedback: "^.*$",
|
|
6525
6549
|
CMIIndex: "[._](\\d+).",
|
|
6526
6550
|
CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
|
|
6527
6551
|
CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
|
|
@@ -6657,11 +6681,12 @@ var Scorm12ValidationError = (function (_super) {
|
|
|
6657
6681
|
(0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(Scorm12ValidationError, _super);
|
|
6658
6682
|
function Scorm12ValidationError(errorCode) {
|
|
6659
6683
|
var _this = this;
|
|
6684
|
+
var _a, _b, _c, _d, _e;
|
|
6660
6685
|
if ({}.hasOwnProperty.call(scorm12_errors, String(errorCode))) {
|
|
6661
|
-
_this = _super.call(this, errorCode, scorm12_errors[String(errorCode)].basicMessage, scorm12_errors[String(errorCode)].detailMessage) || this;
|
|
6686
|
+
_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;
|
|
6662
6687
|
}
|
|
6663
6688
|
else {
|
|
6664
|
-
_this = _super.call(this, 101, scorm12_errors["101"].basicMessage, scorm12_errors["101"].detailMessage) || this;
|
|
6689
|
+
_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;
|
|
6665
6690
|
}
|
|
6666
6691
|
return _this;
|
|
6667
6692
|
}
|
|
@@ -6731,7 +6756,7 @@ function getSecondsAsISODuration(seconds) {
|
|
|
6731
6756
|
var duration = "P";
|
|
6732
6757
|
var remainder = seconds;
|
|
6733
6758
|
for (var designationsKey in designations) {
|
|
6734
|
-
var current_seconds = designations[designationsKey];
|
|
6759
|
+
var current_seconds = designations[designationsKey] || 1;
|
|
6735
6760
|
var value = Math.floor(remainder / current_seconds);
|
|
6736
6761
|
remainder = remainder % current_seconds;
|
|
6737
6762
|
if (countDecimals(remainder) > 2) {
|
|
@@ -6838,7 +6863,7 @@ function unflatten(data) {
|
|
|
6838
6863
|
var m = regex.exec(p);
|
|
6839
6864
|
while (m) {
|
|
6840
6865
|
cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
|
|
6841
|
-
prop = m[2] || m[1];
|
|
6866
|
+
prop = m[2] || m[1] || "";
|
|
6842
6867
|
m = regex.exec(p);
|
|
6843
6868
|
}
|
|
6844
6869
|
cur[prop] = data[p];
|
|
@@ -6850,7 +6875,7 @@ function countDecimals(num) {
|
|
|
6850
6875
|
if (Math.floor(num) === num || String(num).indexOf(".") < 0)
|
|
6851
6876
|
return 0;
|
|
6852
6877
|
var parts = num.toString().split(".")[1];
|
|
6853
|
-
return parts.length || 0;
|
|
6878
|
+
return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
|
|
6854
6879
|
}
|
|
6855
6880
|
function formatMessage(functionName, message, CMIElement) {
|
|
6856
6881
|
var baseLength = 20;
|