scorm-again 3.0.0 → 3.0.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.
- package/dist/esm/scorm-again.js +43 -6
- package/dist/esm/scorm-again.min.js +1 -1
- package/dist/esm/scorm2004.js +43 -6
- package/dist/esm/scorm2004.min.js +1 -1
- package/dist/scorm-again.js +43 -6
- package/dist/scorm-again.min.js +1 -1
- package/dist/scorm2004.js +43 -6
- package/dist/scorm2004.min.js +1 -1
- package/dist/types/Scorm2004API.d.ts +1 -0
- package/dist/types/cmi/scorm2004/sequencing/handlers/termination_handler.d.ts +2 -2
- package/package.json +30 -26
package/dist/esm/scorm-again.js
CHANGED
|
@@ -24392,12 +24392,7 @@ class Scorm2004API extends BaseAPI {
|
|
|
24392
24392
|
* @return {string} "true" or "false"
|
|
24393
24393
|
*/
|
|
24394
24394
|
lmsSetValue(CMIElement, value) {
|
|
24395
|
-
|
|
24396
|
-
try {
|
|
24397
|
-
oldValue = this.getCMIValue(CMIElement);
|
|
24398
|
-
} catch (error) {
|
|
24399
|
-
oldValue = null;
|
|
24400
|
-
}
|
|
24395
|
+
const oldValue = this._peekCMIValue(CMIElement);
|
|
24401
24396
|
const result = this.setValue("SetValue", "Commit", true, CMIElement, value);
|
|
24402
24397
|
if (result === global_constants.SCORM_TRUE && this._sequencingService) {
|
|
24403
24398
|
try {
|
|
@@ -24529,6 +24524,48 @@ class Scorm2004API extends BaseAPI {
|
|
|
24529
24524
|
}
|
|
24530
24525
|
this._responseValidator.validateCorrectResponse(CMIElement, interaction, value);
|
|
24531
24526
|
}
|
|
24527
|
+
/**
|
|
24528
|
+
* Silently peeks at a CMI value without triggering error logging or
|
|
24529
|
+
* mutating lastErrorCode. Returns null if the element doesn't exist.
|
|
24530
|
+
* Used internally to capture old values before SetValue overwrites them.
|
|
24531
|
+
*
|
|
24532
|
+
* @param {string} CMIElement - dot-delimited CMI path (e.g. "cmi.interactions.0.id")
|
|
24533
|
+
* @return {*} the current value, or null if the path doesn't resolve
|
|
24534
|
+
*/
|
|
24535
|
+
_peekCMIValue(CMIElement) {
|
|
24536
|
+
if (!CMIElement || typeof CMIElement !== "string") {
|
|
24537
|
+
return null;
|
|
24538
|
+
}
|
|
24539
|
+
const segments = CMIElement.split(".");
|
|
24540
|
+
let refObject = this;
|
|
24541
|
+
for (let i = 0; i < segments.length; i++) {
|
|
24542
|
+
const attribute = segments[i];
|
|
24543
|
+
if (refObject == null) {
|
|
24544
|
+
return null;
|
|
24545
|
+
}
|
|
24546
|
+
try {
|
|
24547
|
+
refObject = refObject[attribute];
|
|
24548
|
+
} catch {
|
|
24549
|
+
return null;
|
|
24550
|
+
}
|
|
24551
|
+
if (refObject instanceof CMIArray) {
|
|
24552
|
+
const nextIndex = i + 1;
|
|
24553
|
+
if (nextIndex >= segments.length) {
|
|
24554
|
+
return refObject;
|
|
24555
|
+
}
|
|
24556
|
+
const nextSegment = segments[nextIndex];
|
|
24557
|
+
const index = Number(nextSegment);
|
|
24558
|
+
if (!Number.isNaN(index) && Number.isInteger(index) && index >= 0) {
|
|
24559
|
+
if (index >= refObject.childArray.length) {
|
|
24560
|
+
return null;
|
|
24561
|
+
}
|
|
24562
|
+
refObject = refObject.childArray[index];
|
|
24563
|
+
i++;
|
|
24564
|
+
}
|
|
24565
|
+
}
|
|
24566
|
+
}
|
|
24567
|
+
return refObject ?? null;
|
|
24568
|
+
}
|
|
24532
24569
|
/**
|
|
24533
24570
|
* Gets a value from the CMI Object
|
|
24534
24571
|
* @param {string} CMIElement
|