scorm-again 3.0.4 → 3.0.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.
@@ -1418,7 +1418,19 @@ class CMIValueAccessService {
1418
1418
  if (!scorm2004) {
1419
1419
  if (isFinalAttribute) {
1420
1420
  if (typeof attribute === "undefined" || !this.context.checkObjectHasProperty(refObject, attribute)) {
1421
- this.context.throwSCORMError(CMIElement, invalidErrorCode, invalidErrorMessage);
1421
+ if (attribute === "_children") {
1422
+ this.context.throwSCORMError(
1423
+ CMIElement,
1424
+ getErrorCode(this.context.errorCodes, "CHILDREN_ERROR")
1425
+ );
1426
+ } else if (attribute === "_count") {
1427
+ this.context.throwSCORMError(
1428
+ CMIElement,
1429
+ getErrorCode(this.context.errorCodes, "COUNT_ERROR")
1430
+ );
1431
+ } else {
1432
+ this.context.throwSCORMError(CMIElement, invalidErrorCode, invalidErrorMessage);
1433
+ }
1422
1434
  return { error: true };
1423
1435
  }
1424
1436
  }
@@ -3254,7 +3266,8 @@ class BaseAPI {
3254
3266
  if (errorCode === 143) returnValue = global_constants.SCORM_FALSE;
3255
3267
  } else {
3256
3268
  const result = this.storeData(false);
3257
- if ((result.errorCode ?? 0) > 0) {
3269
+ const errorCode = result.errorCode ?? 0;
3270
+ if (errorCode > 0) {
3258
3271
  if (result.errorMessage) {
3259
3272
  this.apiLog(
3260
3273
  "commit",
@@ -3269,12 +3282,12 @@ class BaseAPI {
3269
3282
  LogLevelEnum.DEBUG
3270
3283
  );
3271
3284
  }
3272
- this.throwSCORMError("api", result.errorCode);
3285
+ this.throwSCORMError("api", errorCode);
3273
3286
  }
3274
3287
  const resultValue = result?.result ?? global_constants.SCORM_FALSE;
3275
3288
  returnValue = typeof resultValue === "boolean" ? String(resultValue) : resultValue;
3276
3289
  this.apiLog(callbackName, " Result: " + returnValue, LogLevelEnum.DEBUG, "HttpRequest");
3277
- if (checkTerminated) this.lastErrorCode = "0";
3290
+ if (checkTerminated && errorCode === 0) this.lastErrorCode = "0";
3278
3291
  this.processListeners(callbackName);
3279
3292
  if (this.settings.enableOfflineSupport && this._offlineStorageService && this._offlineStorageService.isDeviceOnline() && this._courseId) {
3280
3293
  this._offlineStorageService.hasPendingOfflineData(this._courseId).then((hasPendingData) => {