scorm-again 2.0.0 → 2.2.0

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.
Files changed (77) hide show
  1. package/.github/workflows/stale.yml +14 -0
  2. package/.run/{Mocha Unit Tests.run.xml → Mocha Unit Tests (watch).run.xml } +1 -1
  3. package/.run/Template Mocha.run.xml +17 -0
  4. package/README.md +180 -72
  5. package/dist/aicc.js +1520 -1149
  6. package/dist/aicc.js.map +1 -1
  7. package/dist/aicc.min.js +1 -1
  8. package/dist/aicc.min.js.map +1 -1
  9. package/dist/scorm-again.js +2812 -2205
  10. package/dist/scorm-again.js.map +1 -1
  11. package/dist/scorm-again.min.js +1 -1
  12. package/dist/scorm-again.min.js.map +1 -1
  13. package/dist/scorm12.js +1129 -842
  14. package/dist/scorm12.js.map +1 -1
  15. package/dist/scorm12.min.js +1 -1
  16. package/dist/scorm12.min.js.map +1 -1
  17. package/dist/scorm2004.js +1921 -1564
  18. package/dist/scorm2004.js.map +1 -1
  19. package/dist/scorm2004.min.js +1 -1
  20. package/dist/scorm2004.min.js.map +1 -1
  21. package/package.json +20 -17
  22. package/src/AICC.ts +15 -17
  23. package/src/BaseAPI.ts +283 -420
  24. package/src/Scorm12API.ts +133 -41
  25. package/src/Scorm2004API.ts +224 -120
  26. package/src/cmi/aicc/attempts.ts +94 -0
  27. package/src/cmi/aicc/cmi.ts +100 -0
  28. package/src/cmi/aicc/core.ts +360 -0
  29. package/src/cmi/aicc/evaluation.ts +157 -0
  30. package/src/cmi/aicc/paths.ts +180 -0
  31. package/src/cmi/aicc/student_data.ts +86 -0
  32. package/src/cmi/aicc/student_demographics.ts +367 -0
  33. package/src/cmi/aicc/student_preferences.ts +176 -0
  34. package/src/cmi/aicc/tries.ts +116 -0
  35. package/src/cmi/aicc/validation.ts +25 -0
  36. package/src/cmi/common/array.ts +77 -0
  37. package/src/cmi/common/base_cmi.ts +46 -0
  38. package/src/cmi/common/score.ts +203 -0
  39. package/src/cmi/common/validation.ts +60 -0
  40. package/src/cmi/scorm12/cmi.ts +224 -0
  41. package/src/cmi/scorm12/interactions.ts +368 -0
  42. package/src/cmi/scorm12/nav.ts +54 -0
  43. package/src/cmi/scorm12/objectives.ts +112 -0
  44. package/src/cmi/scorm12/student_data.ts +130 -0
  45. package/src/cmi/scorm12/student_preference.ts +158 -0
  46. package/src/cmi/scorm12/validation.ts +48 -0
  47. package/src/cmi/scorm2004/adl.ts +272 -0
  48. package/src/cmi/scorm2004/cmi.ts +599 -0
  49. package/src/cmi/scorm2004/comments.ts +163 -0
  50. package/src/cmi/scorm2004/interactions.ts +466 -0
  51. package/src/cmi/scorm2004/learner_preference.ts +152 -0
  52. package/src/cmi/scorm2004/objectives.ts +212 -0
  53. package/src/cmi/scorm2004/score.ts +78 -0
  54. package/src/cmi/scorm2004/validation.ts +42 -0
  55. package/src/constants/default_settings.ts +82 -0
  56. package/src/constants/enums.ts +17 -0
  57. package/src/constants/regex.ts +2 -2
  58. package/src/constants/response_constants.ts +2 -0
  59. package/src/exceptions.ts +22 -1
  60. package/src/helpers/scheduled_commit.ts +42 -0
  61. package/src/interfaces/IBaseAPI.ts +35 -0
  62. package/src/types/api_types.ts +50 -0
  63. package/src/utilities/debounce.ts +31 -0
  64. package/src/utilities.ts +56 -0
  65. package/test/AICC.spec.ts +11 -1
  66. package/test/Scorm12API.spec.ts +372 -9
  67. package/test/Scorm2004API.spec.ts +558 -2
  68. package/test/cmi/aicc_cmi.spec.ts +188 -11
  69. package/test/cmi/scorm12_cmi.spec.ts +5 -5
  70. package/test/cmi/scorm2004_cmi.spec.ts +8 -8
  71. package/test/cmi_helpers.ts +1 -1
  72. package/test/types/api_types.spec.ts +126 -0
  73. package/test/utilities/debounce.spec.ts +56 -0
  74. package/src/cmi/aicc_cmi.ts +0 -1248
  75. package/src/cmi/common.ts +0 -411
  76. package/src/cmi/scorm12_cmi.ts +0 -1426
  77. package/src/cmi/scorm2004_cmi.ts +0 -1874
package/dist/aicc.js CHANGED
@@ -381,9 +381,88 @@ function __disposeResources(env) {
381
381
  __disposeResources,
382
382
  });
383
383
 
384
- ;// ./src/constants/api_constants.ts
384
+ ;// ./src/cmi/common/base_cmi.ts
385
+
386
+ var BaseCMI = (function () {
387
+ function BaseCMI() {
388
+ this.jsonString = false;
389
+ this._initialized = false;
390
+ }
391
+ Object.defineProperty(BaseCMI.prototype, "initialized", {
392
+ get: function () {
393
+ return this._initialized;
394
+ },
395
+ enumerable: false,
396
+ configurable: true
397
+ });
398
+ Object.defineProperty(BaseCMI.prototype, "start_time", {
399
+ get: function () {
400
+ return this._start_time;
401
+ },
402
+ enumerable: false,
403
+ configurable: true
404
+ });
405
+ BaseCMI.prototype.initialize = function () {
406
+ this._initialized = true;
407
+ };
408
+ BaseCMI.prototype.setStartTime = function () {
409
+ this._start_time = new Date().getTime();
410
+ };
411
+ return BaseCMI;
412
+ }());
413
+
414
+ var BaseRootCMI = (function (_super) {
415
+ __extends(BaseRootCMI, _super);
416
+ function BaseRootCMI() {
417
+ return _super !== null && _super.apply(this, arguments) || this;
418
+ }
419
+ return BaseRootCMI;
420
+ }(BaseCMI));
421
+
422
+
423
+ ;// ./src/constants/error_codes.ts
385
424
 
386
425
  var global = {
426
+ GENERAL: 101,
427
+ INITIALIZATION_FAILED: 101,
428
+ INITIALIZED: 101,
429
+ TERMINATED: 101,
430
+ TERMINATION_FAILURE: 101,
431
+ TERMINATION_BEFORE_INIT: 101,
432
+ MULTIPLE_TERMINATION: 101,
433
+ RETRIEVE_BEFORE_INIT: 101,
434
+ RETRIEVE_AFTER_TERM: 101,
435
+ STORE_BEFORE_INIT: 101,
436
+ STORE_AFTER_TERM: 101,
437
+ COMMIT_BEFORE_INIT: 101,
438
+ COMMIT_AFTER_TERM: 101,
439
+ ARGUMENT_ERROR: 101,
440
+ CHILDREN_ERROR: 101,
441
+ COUNT_ERROR: 101,
442
+ GENERAL_GET_FAILURE: 101,
443
+ GENERAL_SET_FAILURE: 101,
444
+ GENERAL_COMMIT_FAILURE: 101,
445
+ UNDEFINED_DATA_MODEL: 101,
446
+ UNIMPLEMENTED_ELEMENT: 101,
447
+ VALUE_NOT_INITIALIZED: 101,
448
+ INVALID_SET_VALUE: 101,
449
+ READ_ONLY_ELEMENT: 101,
450
+ WRITE_ONLY_ELEMENT: 101,
451
+ TYPE_MISMATCH: 101,
452
+ VALUE_OUT_OF_RANGE: 101,
453
+ DEPENDENCY_NOT_ESTABLISHED: 101,
454
+ };
455
+ var scorm12 = __assign(__assign({}, global), { RETRIEVE_BEFORE_INIT: 301, STORE_BEFORE_INIT: 301, COMMIT_BEFORE_INIT: 301, ARGUMENT_ERROR: 201, CHILDREN_ERROR: 202, COUNT_ERROR: 203, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 401, VALUE_NOT_INITIALIZED: 301, INVALID_SET_VALUE: 402, READ_ONLY_ELEMENT: 403, WRITE_ONLY_ELEMENT: 404, TYPE_MISMATCH: 405, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
456
+ var scorm2004 = __assign(__assign({}, global), { INITIALIZATION_FAILED: 102, INITIALIZED: 103, TERMINATED: 104, TERMINATION_FAILURE: 111, TERMINATION_BEFORE_INIT: 112, MULTIPLE_TERMINATIONS: 113, RETRIEVE_BEFORE_INIT: 122, RETRIEVE_AFTER_TERM: 123, STORE_BEFORE_INIT: 132, STORE_AFTER_TERM: 133, COMMIT_BEFORE_INIT: 142, COMMIT_AFTER_TERM: 143, ARGUMENT_ERROR: 201, GENERAL_GET_FAILURE: 301, GENERAL_SET_FAILURE: 351, GENERAL_COMMIT_FAILURE: 391, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 402, VALUE_NOT_INITIALIZED: 403, READ_ONLY_ELEMENT: 404, WRITE_ONLY_ELEMENT: 405, TYPE_MISMATCH: 406, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
457
+ var ErrorCodes = {
458
+ scorm12: scorm12,
459
+ scorm2004: scorm2004,
460
+ };
461
+ /* harmony default export */ var error_codes = (ErrorCodes);
462
+
463
+ ;// ./src/constants/api_constants.ts
464
+
465
+ var api_constants_global = {
387
466
  SCORM_TRUE: "true",
388
467
  SCORM_FALSE: "false",
389
468
  STATE_NOT_INITIALIZED: 0,
@@ -395,7 +474,7 @@ var global = {
395
474
  LOG_LEVEL_ERROR: 4,
396
475
  LOG_LEVEL_NONE: 5,
397
476
  };
398
- var scorm12 = {
477
+ var api_constants_scorm12 = {
399
478
  cmi_children: "core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",
400
479
  core_children: "student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time",
401
480
  score_children: "raw,min,max",
@@ -456,7 +535,7 @@ var scorm12 = {
456
535
  },
457
536
  },
458
537
  };
459
- var aicc = __assign(__assign({}, scorm12), {
538
+ var aicc = __assign(__assign({}, api_constants_scorm12), {
460
539
  cmi_children: "core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions,evaluation",
461
540
  student_preference_children: "audio,language,lesson_type,speed,text,text_color,text_location,text_size,video,windows",
462
541
  student_data_children: "attempt_number,tries,mastery_score,max_time_allowed,time_limit_action",
@@ -465,7 +544,7 @@ var aicc = __assign(__assign({}, scorm12), {
465
544
  attempt_records_children: "score,lesson_status",
466
545
  paths_children: "location_id,date,time,status,why_left,time_in_element",
467
546
  });
468
- var scorm2004 = {
547
+ var api_constants_scorm2004 = {
469
548
  cmi_children: "_version,comments_from_learner,comments_from_lms,completion_status,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time",
470
549
  comments_children: "comment,timestamp,location",
471
550
  score_children: "max,raw,scaled,min",
@@ -582,132 +661,19 @@ var scorm2004 = {
582
661
  },
583
662
  };
584
663
  var APIConstants = {
585
- global: global,
586
- scorm12: scorm12,
664
+ global: api_constants_global,
665
+ scorm12: api_constants_scorm12,
587
666
  aicc: aicc,
588
- scorm2004: scorm2004,
667
+ scorm2004: api_constants_scorm2004,
589
668
  };
590
669
  /* harmony default export */ var api_constants = (APIConstants);
591
670
 
592
- ;// ./src/constants/error_codes.ts
593
-
594
- var error_codes_global = {
595
- GENERAL: 101,
596
- INITIALIZATION_FAILED: 101,
597
- INITIALIZED: 101,
598
- TERMINATED: 101,
599
- TERMINATION_FAILURE: 101,
600
- TERMINATION_BEFORE_INIT: 101,
601
- MULTIPLE_TERMINATION: 101,
602
- RETRIEVE_BEFORE_INIT: 101,
603
- RETRIEVE_AFTER_TERM: 101,
604
- STORE_BEFORE_INIT: 101,
605
- STORE_AFTER_TERM: 101,
606
- COMMIT_BEFORE_INIT: 101,
607
- COMMIT_AFTER_TERM: 101,
608
- ARGUMENT_ERROR: 101,
609
- CHILDREN_ERROR: 101,
610
- COUNT_ERROR: 101,
611
- GENERAL_GET_FAILURE: 101,
612
- GENERAL_SET_FAILURE: 101,
613
- GENERAL_COMMIT_FAILURE: 101,
614
- UNDEFINED_DATA_MODEL: 101,
615
- UNIMPLEMENTED_ELEMENT: 101,
616
- VALUE_NOT_INITIALIZED: 101,
617
- INVALID_SET_VALUE: 101,
618
- READ_ONLY_ELEMENT: 101,
619
- WRITE_ONLY_ELEMENT: 101,
620
- TYPE_MISMATCH: 101,
621
- VALUE_OUT_OF_RANGE: 101,
622
- DEPENDENCY_NOT_ESTABLISHED: 101,
623
- };
624
- var error_codes_scorm12 = __assign(__assign({}, error_codes_global), { RETRIEVE_BEFORE_INIT: 301, STORE_BEFORE_INIT: 301, COMMIT_BEFORE_INIT: 301, ARGUMENT_ERROR: 201, CHILDREN_ERROR: 202, COUNT_ERROR: 203, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 401, VALUE_NOT_INITIALIZED: 301, INVALID_SET_VALUE: 402, READ_ONLY_ELEMENT: 403, WRITE_ONLY_ELEMENT: 404, TYPE_MISMATCH: 405, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
625
- var error_codes_scorm2004 = __assign(__assign({}, error_codes_global), { INITIALIZATION_FAILED: 102, INITIALIZED: 103, TERMINATED: 104, TERMINATION_FAILURE: 111, TERMINATION_BEFORE_INIT: 112, MULTIPLE_TERMINATIONS: 113, RETRIEVE_BEFORE_INIT: 122, RETRIEVE_AFTER_TERM: 123, STORE_BEFORE_INIT: 132, STORE_AFTER_TERM: 133, COMMIT_BEFORE_INIT: 142, COMMIT_AFTER_TERM: 143, ARGUMENT_ERROR: 201, GENERAL_GET_FAILURE: 301, GENERAL_SET_FAILURE: 351, GENERAL_COMMIT_FAILURE: 391, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 402, VALUE_NOT_INITIALIZED: 403, READ_ONLY_ELEMENT: 404, WRITE_ONLY_ELEMENT: 405, TYPE_MISMATCH: 406, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
626
- var ErrorCodes = {
627
- scorm12: error_codes_scorm12,
628
- scorm2004: error_codes_scorm2004,
629
- };
630
- /* harmony default export */ var error_codes = (ErrorCodes);
631
-
632
- ;// ./src/constants/regex.ts
633
-
634
- var regex_scorm12 = {
635
- CMIString256: "^.{0,255}$",
636
- CMIString4096: "^.{0,4096}$",
637
- CMITime: "^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",
638
- CMITimespan: "^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",
639
- CMIInteger: "^\\d+$",
640
- CMISInteger: "^-?([0-9]+)$",
641
- CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
642
- CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
643
- CMIFeedback: "^.{0,255}$",
644
- CMIIndex: "[._](\\d+).",
645
- CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
646
- CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
647
- CMIExit: "^(time-out|suspend|logout|)$",
648
- CMIType: "^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$",
649
- CMIResult: "^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$",
650
- NAVEvent: "^(previous|continue)$",
651
- score_range: "0#100",
652
- audio_range: "-1#100",
653
- speed_range: "-100#100",
654
- weighting_range: "-100#100",
655
- text_range: "-1#1",
656
- };
657
- var regex_aicc = __assign(__assign({}, regex_scorm12), {
658
- CMIIdentifier: "^\\w{1,255}$",
659
- });
660
- var regex_scorm2004 = {
661
- CMIString200: "^[\\u0000-\\uFFFF]{0,200}$",
662
- CMIString250: "^[\\u0000-\\uFFFF]{0,250}$",
663
- CMIString1000: "^[\\u0000-\\uFFFF]{0,1000}$",
664
- CMIString4000: "^[\\u0000-\\uFFFF]{0,4000}$",
665
- CMIString64000: "^[\\u0000-\\uFFFF]{0,64000}$",
666
- CMILang: "^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",
667
- CMILangString250: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",
668
- CMILangcr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",
669
- CMILangString250cr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",
670
- CMILangString4000: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",
671
- CMITime: "^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$",
672
- CMITimespan: "^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$",
673
- CMIInteger: "^\\d+$",
674
- CMISInteger: "^-?([0-9]+)$",
675
- CMIDecimal: "^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",
676
- CMIIdentifier: "^\\S{1,250}[a-zA-Z0-9]$",
677
- CMIShortIdentifier: "^[\\w\\.\\-\\_]{1,250}$",
678
- CMILongIdentifier: "^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",
679
- CMIFeedback: "^.*$",
680
- CMIIndex: "[._](\\d+).",
681
- CMIIndexStore: ".N(\\d+).",
682
- CMICStatus: "^(completed|incomplete|not attempted|unknown)$",
683
- CMISStatus: "^(passed|failed|unknown)$",
684
- CMIExit: "^(time-out|suspend|logout|normal)$",
685
- CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
686
- CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
687
- NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|{target=\\S{0,200}[a-zA-Z0-9]}choice|jump)$",
688
- NAVBoolean: "^(unknown|true|false$)",
689
- NAVTarget: "^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$",
690
- scaled_range: "-1#1",
691
- audio_range: "0#*",
692
- speed_range: "0#*",
693
- text_range: "-1#1",
694
- progress_range: "0#1",
695
- };
696
- var Regex = {
697
- aicc: regex_aicc,
698
- scorm12: regex_scorm12,
699
- scorm2004: regex_scorm2004,
700
- };
701
- /* harmony default export */ var regex = (Regex);
702
-
703
- ;// ./src/cmi/common.ts
704
-
705
-
671
+ ;// ./src/exceptions.ts
706
672
 
707
673
 
708
- var scorm12_constants = api_constants.scorm12;
709
- var scorm12_regex = regex.scorm12;
710
- var scorm12_error_codes = error_codes.scorm12;
674
+ var scorm12_errors = api_constants.scorm12.error_descriptions;
675
+ var aicc_errors = api_constants.aicc.error_descriptions;
676
+ var scorm2004_errors = api_constants.scorm2004.error_descriptions;
711
677
  var BaseScormValidationError = (function (_super) {
712
678
  __extends(BaseScormValidationError, _super);
713
679
  function BaseScormValidationError(errorCode) {
@@ -729,246 +695,28 @@ var BaseScormValidationError = (function (_super) {
729
695
  return BaseScormValidationError;
730
696
  }(Error));
731
697
 
732
- var BaseScorm12ValidationError = (function (_super) {
733
- __extends(BaseScorm12ValidationError, _super);
734
- function BaseScorm12ValidationError(errorCode) {
735
- var _this = _super.call(this, errorCode) || this;
736
- _this.name = "Scorm12ValidationError";
737
- return _this;
738
- }
739
- return BaseScorm12ValidationError;
740
- }(BaseScormValidationError));
741
-
742
- var BaseScorm2004ValidationError = (function (_super) {
743
- __extends(BaseScorm2004ValidationError, _super);
744
- function BaseScorm2004ValidationError(errorCode) {
698
+ var ValidationError = (function (_super) {
699
+ __extends(ValidationError, _super);
700
+ function ValidationError(errorCode, errorMessage, detailedMessage) {
745
701
  var _this = _super.call(this, errorCode) || this;
746
- _this.name = "Scorm2004ValidationError";
747
- return _this;
748
- }
749
- return BaseScorm2004ValidationError;
750
- }(BaseScormValidationError));
751
-
752
- function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
753
- var formatRegex = new RegExp(regexPattern);
754
- var matches = value.match(formatRegex);
755
- if (allowEmptyString && value === "") {
756
- return true;
757
- }
758
- if (value === undefined || !matches || matches[0] === "") {
759
- throw new errorClass(errorCode);
760
- }
761
- return true;
762
- }
763
- function checkValidRange(value, rangePattern, errorCode, errorClass) {
764
- var ranges = rangePattern.split("#");
765
- value = value * 1.0;
766
- if (value >= ranges[0]) {
767
- if (ranges[1] === "*" || value <= ranges[1]) {
768
- return true;
769
- }
770
- else {
771
- throw new errorClass(errorCode);
702
+ _this._detailedMessage = "";
703
+ _this.setMessage(errorMessage);
704
+ _this._errorMessage = errorMessage;
705
+ if (detailedMessage) {
706
+ _this._detailedMessage = detailedMessage;
772
707
  }
708
+ return _this;
773
709
  }
774
- else {
775
- throw new errorClass(errorCode);
776
- }
777
- }
778
- var BaseCMI = (function () {
779
- function BaseCMI() {
780
- this.jsonString = false;
781
- this._initialized = false;
782
- }
783
- Object.defineProperty(BaseCMI.prototype, "initialized", {
710
+ Object.defineProperty(ValidationError.prototype, "errorMessage", {
784
711
  get: function () {
785
- return this._initialized;
712
+ return this._errorMessage;
786
713
  },
787
714
  enumerable: false,
788
715
  configurable: true
789
716
  });
790
- Object.defineProperty(BaseCMI.prototype, "start_time", {
717
+ Object.defineProperty(ValidationError.prototype, "detailedMessage", {
791
718
  get: function () {
792
- return this._start_time;
793
- },
794
- enumerable: false,
795
- configurable: true
796
- });
797
- BaseCMI.prototype.initialize = function () {
798
- this._initialized = true;
799
- };
800
- BaseCMI.prototype.setStartTime = function () {
801
- this._start_time = new Date().getTime();
802
- };
803
- return BaseCMI;
804
- }());
805
-
806
- var BaseRootCMI = (function (_super) {
807
- __extends(BaseRootCMI, _super);
808
- function BaseRootCMI() {
809
- return _super !== null && _super.apply(this, arguments) || this;
810
- }
811
- return BaseRootCMI;
812
- }(BaseCMI));
813
-
814
- var CMIScore = (function (_super) {
815
- __extends(CMIScore, _super);
816
- function CMIScore(params) {
817
- var _this = _super.call(this) || this;
818
- _this._raw = "";
819
- _this._min = "";
820
- _this.__children = params.score_children || scorm12_constants.score_children;
821
- _this.__score_range = !params.score_range
822
- ? false
823
- : scorm12_regex.score_range;
824
- _this._max = params.max || params.max === "" ? params.max : "100";
825
- _this.__invalid_error_code =
826
- params.invalidErrorCode || scorm12_error_codes.INVALID_SET_VALUE;
827
- _this.__invalid_type_code =
828
- params.invalidTypeCode || scorm12_error_codes.TYPE_MISMATCH;
829
- _this.__invalid_range_code =
830
- params.invalidRangeCode || scorm12_error_codes.VALUE_OUT_OF_RANGE;
831
- _this.__decimal_regex = params.decimalRegex || scorm12_regex.CMIDecimal;
832
- _this.__error_class = params.errorClass;
833
- return _this;
834
- }
835
- Object.defineProperty(CMIScore.prototype, "_children", {
836
- get: function () {
837
- return this.__children;
838
- },
839
- set: function (_children) {
840
- throw new this.__error_class(this.__invalid_error_code);
841
- },
842
- enumerable: false,
843
- configurable: true
844
- });
845
- Object.defineProperty(CMIScore.prototype, "raw", {
846
- get: function () {
847
- return this._raw;
848
- },
849
- set: function (raw) {
850
- if (checkValidFormat(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
851
- (!this.__score_range ||
852
- checkValidRange(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
853
- this._raw = raw;
854
- }
855
- },
856
- enumerable: false,
857
- configurable: true
858
- });
859
- Object.defineProperty(CMIScore.prototype, "min", {
860
- get: function () {
861
- return this._min;
862
- },
863
- set: function (min) {
864
- if (checkValidFormat(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
865
- (!this.__score_range ||
866
- checkValidRange(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
867
- this._min = min;
868
- }
869
- },
870
- enumerable: false,
871
- configurable: true
872
- });
873
- Object.defineProperty(CMIScore.prototype, "max", {
874
- get: function () {
875
- return this._max;
876
- },
877
- set: function (max) {
878
- if (checkValidFormat(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
879
- (!this.__score_range ||
880
- checkValidRange(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
881
- this._max = max;
882
- }
883
- },
884
- enumerable: false,
885
- configurable: true
886
- });
887
- CMIScore.prototype.toJSON = function () {
888
- this.jsonString = true;
889
- var result = {
890
- raw: this.raw,
891
- min: this.min,
892
- max: this.max,
893
- };
894
- delete this.jsonString;
895
- return result;
896
- };
897
- return CMIScore;
898
- }(BaseCMI));
899
-
900
- var CMIArray = (function (_super) {
901
- __extends(CMIArray, _super);
902
- function CMIArray(params) {
903
- var _this = _super.call(this) || this;
904
- _this.__children = params.children;
905
- _this._errorCode = params.errorCode || scorm12_error_codes.GENERAL;
906
- _this._errorClass = params.errorClass || BaseScorm12ValidationError;
907
- _this.childArray = [];
908
- return _this;
909
- }
910
- Object.defineProperty(CMIArray.prototype, "_children", {
911
- get: function () {
912
- return this.__children;
913
- },
914
- set: function (_children) {
915
- throw new this._errorClass(this._errorCode);
916
- },
917
- enumerable: false,
918
- configurable: true
919
- });
920
- Object.defineProperty(CMIArray.prototype, "_count", {
921
- get: function () {
922
- return this.childArray.length;
923
- },
924
- set: function (_count) {
925
- throw new this._errorClass(this._errorCode);
926
- },
927
- enumerable: false,
928
- configurable: true
929
- });
930
- CMIArray.prototype.toJSON = function () {
931
- this.jsonString = true;
932
- var result = {};
933
- for (var i = 0; i < this.childArray.length; i++) {
934
- result[i + ""] = this.childArray[i];
935
- }
936
- delete this.jsonString;
937
- return result;
938
- };
939
- return CMIArray;
940
- }(BaseCMI));
941
-
942
-
943
- ;// ./src/exceptions.ts
944
-
945
-
946
-
947
- var scorm12_errors = api_constants.scorm12.error_descriptions;
948
- var aicc_errors = api_constants.aicc.error_descriptions;
949
- var scorm2004_errors = api_constants.scorm2004.error_descriptions;
950
- var ValidationError = (function (_super) {
951
- __extends(ValidationError, _super);
952
- function ValidationError(errorCode, errorMessage, detailedMessage) {
953
- var _this = _super.call(this, errorCode) || this;
954
- _this._detailedMessage = "";
955
- _this.setMessage(errorMessage);
956
- _this._errorMessage = errorMessage;
957
- if (detailedMessage) {
958
- _this._detailedMessage = detailedMessage;
959
- }
960
- return _this;
961
- }
962
- Object.defineProperty(ValidationError.prototype, "errorMessage", {
963
- get: function () {
964
- return this._errorMessage;
965
- },
966
- enumerable: false,
967
- configurable: true
968
- });
969
- Object.defineProperty(ValidationError.prototype, "detailedMessage", {
970
- get: function () {
971
- return this._detailedMessage;
719
+ return this._detailedMessage;
972
720
  },
973
721
  enumerable: false,
974
722
  configurable: true
@@ -1022,6 +770,55 @@ var Scorm2004ValidationError = (function (_super) {
1022
770
  }(ValidationError));
1023
771
 
1024
772
 
773
+ ;// ./src/cmi/common/array.ts
774
+
775
+
776
+
777
+
778
+ var scorm12_error_codes = error_codes.scorm12;
779
+ var CMIArray = (function (_super) {
780
+ __extends(CMIArray, _super);
781
+ function CMIArray(params) {
782
+ var _this = _super.call(this) || this;
783
+ _this.__children = params.children;
784
+ _this._errorCode = params.errorCode || scorm12_error_codes.GENERAL;
785
+ _this._errorClass = params.errorClass || BaseScormValidationError;
786
+ _this.childArray = [];
787
+ return _this;
788
+ }
789
+ Object.defineProperty(CMIArray.prototype, "_children", {
790
+ get: function () {
791
+ return this.__children;
792
+ },
793
+ set: function (_children) {
794
+ throw new this._errorClass(this._errorCode);
795
+ },
796
+ enumerable: false,
797
+ configurable: true
798
+ });
799
+ Object.defineProperty(CMIArray.prototype, "_count", {
800
+ get: function () {
801
+ return this.childArray.length;
802
+ },
803
+ set: function (_count) {
804
+ throw new this._errorClass(this._errorCode);
805
+ },
806
+ enumerable: false,
807
+ configurable: true
808
+ });
809
+ CMIArray.prototype.toJSON = function () {
810
+ this.jsonString = true;
811
+ var result = {};
812
+ for (var i = 0; i < this.childArray.length; i++) {
813
+ result[i + ""] = this.childArray[i];
814
+ }
815
+ delete this.jsonString;
816
+ return result;
817
+ };
818
+ return CMIArray;
819
+ }(BaseCMI));
820
+
821
+
1025
822
  ;// ./src/utilities.ts
1026
823
  var SECONDS_PER_SECOND = 1.0;
1027
824
  var SECONDS_PER_MINUTE = 60;
@@ -1182,16 +979,33 @@ function countDecimals(num) {
1182
979
  var parts = num.toString().split(".")[1];
1183
980
  return parts.length || 0;
1184
981
  }
982
+ function formatMessage(functionName, message, CMIElement) {
983
+ var baseLength = 20;
984
+ var messageString = "";
985
+ messageString += functionName;
986
+ var fillChars = baseLength - messageString.length;
987
+ for (var i = 0; i < fillChars; i++) {
988
+ messageString += " ";
989
+ }
990
+ messageString += ": ";
991
+ if (CMIElement) {
992
+ var CMIElementBaseLength = 70;
993
+ messageString += CMIElement;
994
+ fillChars = CMIElementBaseLength - messageString.length;
995
+ for (var j = 0; j < fillChars; j++) {
996
+ messageString += " ";
997
+ }
998
+ }
999
+ if (message) {
1000
+ messageString += message;
1001
+ }
1002
+ return messageString;
1003
+ }
1004
+ function stringMatches(str, tester) {
1005
+ return (str === null || str === void 0 ? void 0 : str.match(tester)) !== null;
1006
+ }
1185
1007
 
1186
- ;// ./src/BaseAPI.ts
1187
-
1188
-
1189
-
1190
-
1191
-
1192
-
1193
- var global_constants = api_constants.global;
1194
- var BaseAPI_scorm12_error_codes = error_codes.scorm12;
1008
+ ;// ./src/utilities/debounce.ts
1195
1009
  function debounce(func, wait, immediate) {
1196
1010
  if (immediate === void 0) { immediate = false; }
1197
1011
  var timeout;
@@ -1214,43 +1028,48 @@ function debounce(func, wait, immediate) {
1214
1028
  func.apply(context, args);
1215
1029
  };
1216
1030
  }
1031
+
1032
+ ;// ./src/constants/default_settings.ts
1033
+
1034
+
1217
1035
  var DefaultSettings = {
1218
1036
  autocommit: false,
1219
1037
  autocommitSeconds: 10,
1220
1038
  asyncCommit: false,
1221
- sendBeaconCommit: false,
1039
+ sendFullCommit: true,
1222
1040
  lmsCommitUrl: false,
1223
1041
  dataCommitFormat: "json",
1224
1042
  commitRequestDataType: "application/json;charset=UTF-8",
1225
1043
  autoProgress: false,
1226
- logLevel: global_constants.LOG_LEVEL_ERROR,
1044
+ logLevel: api_constants.global.LOG_LEVEL_ERROR,
1227
1045
  selfReportSessionTime: false,
1228
1046
  alwaysSendTotalTime: false,
1047
+ renderCommonCommitFields: false,
1229
1048
  strict_errors: true,
1230
1049
  xhrHeaders: {},
1231
1050
  xhrWithCredentials: false,
1232
1051
  responseHandler: function (response) {
1233
1052
  return __awaiter(this, void 0, void 0, function () {
1234
- var httpResult, _a, _c;
1235
- return __generator(this, function (_e) {
1236
- switch (_e.label) {
1053
+ var httpResult, _a, _b;
1054
+ return __generator(this, function (_c) {
1055
+ switch (_c.label) {
1237
1056
  case 0:
1238
1057
  if (!(typeof response !== "undefined")) return [3, 2];
1239
- _c = (_a = JSON).parse;
1058
+ _b = (_a = JSON).parse;
1240
1059
  return [4, response.text()];
1241
1060
  case 1:
1242
- httpResult = _c.apply(_a, [_e.sent()]);
1061
+ httpResult = _b.apply(_a, [_c.sent()]);
1243
1062
  if (httpResult === null ||
1244
1063
  !{}.hasOwnProperty.call(httpResult, "result")) {
1245
1064
  if (response.status === 200) {
1246
1065
  return [2, {
1247
- result: global_constants.SCORM_TRUE,
1066
+ result: api_constants.global.SCORM_TRUE,
1248
1067
  errorCode: 0,
1249
1068
  }];
1250
1069
  }
1251
1070
  else {
1252
1071
  return [2, {
1253
- result: global_constants.SCORM_FALSE,
1072
+ result: api_constants.global.SCORM_FALSE,
1254
1073
  errorCode: 101,
1255
1074
  }];
1256
1075
  }
@@ -1260,14 +1079,14 @@ var DefaultSettings = {
1260
1079
  result: httpResult.result,
1261
1080
  errorCode: httpResult.errorCode
1262
1081
  ? httpResult.errorCode
1263
- : httpResult.result === global_constants.SCORM_TRUE
1082
+ : httpResult.result === api_constants.global.SCORM_TRUE
1264
1083
  ? 0
1265
1084
  : 101,
1266
1085
  }];
1267
1086
  }
1268
- _e.label = 2;
1087
+ _c.label = 2;
1269
1088
  case 2: return [2, {
1270
- result: global_constants.SCORM_FALSE,
1089
+ result: api_constants.global.SCORM_FALSE,
1271
1090
  errorCode: 101,
1272
1091
  }];
1273
1092
  }
@@ -1279,16 +1098,16 @@ var DefaultSettings = {
1279
1098
  },
1280
1099
  onLogMessage: function (messageLevel, logMessage) {
1281
1100
  switch (messageLevel) {
1282
- case global_constants.LOG_LEVEL_ERROR:
1101
+ case api_constants.global.LOG_LEVEL_ERROR:
1283
1102
  console.error(logMessage);
1284
1103
  break;
1285
- case global_constants.LOG_LEVEL_WARNING:
1104
+ case api_constants.global.LOG_LEVEL_WARNING:
1286
1105
  console.warn(logMessage);
1287
1106
  break;
1288
- case global_constants.LOG_LEVEL_INFO:
1107
+ case api_constants.global.LOG_LEVEL_INFO:
1289
1108
  console.info(logMessage);
1290
1109
  break;
1291
- case global_constants.LOG_LEVEL_DEBUG:
1110
+ case api_constants.global.LOG_LEVEL_DEBUG:
1292
1111
  if (console.debug) {
1293
1112
  console.debug(logMessage);
1294
1113
  }
@@ -1298,26 +1117,75 @@ var DefaultSettings = {
1298
1117
  break;
1299
1118
  }
1300
1119
  },
1120
+ scoItemIds: [],
1121
+ scoItemIdValidator: false,
1301
1122
  };
1302
- var BaseAPI = (function () {
1303
- function BaseAPI(error_codes, settings) {
1304
- var _newTarget = this.constructor;
1305
- this._settings = DefaultSettings;
1306
- if (_newTarget === BaseAPI) {
1307
- throw new TypeError("Cannot construct BaseAPI instances directly");
1308
- }
1309
- this.currentState = global_constants.STATE_NOT_INITIALIZED;
1310
- this.lastErrorCode = "0";
1311
- this.listenerArray = [];
1312
- this._error_codes = error_codes;
1313
- if (settings) {
1314
- this.settings = settings;
1315
- }
1316
- this.apiLogLevel = this.settings.logLevel;
1317
- this.selfReportSessionTime = this.settings.selfReportSessionTime;
1123
+
1124
+ ;// ./src/helpers/scheduled_commit.ts
1125
+
1126
+ var ScheduledCommit = (function () {
1127
+ function ScheduledCommit(API, when, callback) {
1128
+ this._cancelled = false;
1129
+ this._API = API;
1130
+ this._timeout = setTimeout(this.wrapper.bind(this), when);
1131
+ this._callback = callback;
1318
1132
  }
1319
- BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
1320
- var returnValue = global_constants.SCORM_FALSE;
1133
+ ScheduledCommit.prototype.cancel = function () {
1134
+ this._cancelled = true;
1135
+ if (this._timeout) {
1136
+ clearTimeout(this._timeout);
1137
+ }
1138
+ };
1139
+ ScheduledCommit.prototype.wrapper = function () {
1140
+ var _this = this;
1141
+ if (!this._cancelled) {
1142
+ (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
1143
+ switch (_a.label) {
1144
+ case 0: return [4, this._API.commit(this._callback)];
1145
+ case 1: return [2, _a.sent()];
1146
+ }
1147
+ }); }); })();
1148
+ }
1149
+ };
1150
+ return ScheduledCommit;
1151
+ }());
1152
+
1153
+
1154
+ ;// ./src/BaseAPI.ts
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+
1164
+ var BaseAPI = (function () {
1165
+ function BaseAPI(error_codes, settings) {
1166
+ var _newTarget = this.constructor;
1167
+ this._settings = DefaultSettings;
1168
+ if (_newTarget === BaseAPI) {
1169
+ throw new TypeError("Cannot construct BaseAPI instances directly");
1170
+ }
1171
+ this.currentState = api_constants.global.STATE_NOT_INITIALIZED;
1172
+ this.lastErrorCode = "0";
1173
+ this.listenerArray = [];
1174
+ this._error_codes = error_codes;
1175
+ if (settings) {
1176
+ this.settings = settings;
1177
+ }
1178
+ this.apiLogLevel = this.settings.logLevel;
1179
+ this.selfReportSessionTime = this.settings.selfReportSessionTime;
1180
+ }
1181
+ BaseAPI.prototype.commonReset = function (settings) {
1182
+ this.settings = __assign(__assign({}, this.settings), settings);
1183
+ this.currentState = api_constants.global.STATE_NOT_INITIALIZED;
1184
+ this.lastErrorCode = "0";
1185
+ this.listenerArray = [];
1186
+ };
1187
+ BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
1188
+ var returnValue = api_constants.global.SCORM_FALSE;
1321
1189
  if (this.isInitialized()) {
1322
1190
  this.throwSCORMError(this._error_codes.INITIALIZED, initializeMessage);
1323
1191
  }
@@ -1328,15 +1196,21 @@ var BaseAPI = (function () {
1328
1196
  if (this.selfReportSessionTime) {
1329
1197
  this.cmi.setStartTime();
1330
1198
  }
1331
- this.currentState = global_constants.STATE_INITIALIZED;
1199
+ this.currentState = api_constants.global.STATE_INITIALIZED;
1332
1200
  this.lastErrorCode = "0";
1333
- returnValue = global_constants.SCORM_TRUE;
1201
+ returnValue = api_constants.global.SCORM_TRUE;
1334
1202
  this.processListeners(callbackName);
1335
1203
  }
1336
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1204
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1337
1205
  this.clearSCORMError(returnValue);
1338
1206
  return returnValue;
1339
1207
  };
1208
+ BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
1209
+ logMessage = formatMessage(functionName, logMessage, CMIElement);
1210
+ if (messageLevel >= this.apiLogLevel) {
1211
+ this.settings.onLogMessage(messageLevel, logMessage);
1212
+ }
1213
+ };
1340
1214
  Object.defineProperty(BaseAPI.prototype, "error_codes", {
1341
1215
  get: function () {
1342
1216
  return this._error_codes;
@@ -1355,25 +1229,36 @@ var BaseAPI = (function () {
1355
1229
  configurable: true
1356
1230
  });
1357
1231
  BaseAPI.prototype.terminate = function (callbackName, checkTerminated) {
1358
- var returnValue = global_constants.SCORM_FALSE;
1359
- if (this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) {
1360
- this.currentState = global_constants.STATE_TERMINATED;
1361
- var result = this.storeData(true);
1362
- if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
1363
- this.throwSCORMError(result.errorCode);
1364
- }
1365
- returnValue =
1366
- typeof result !== "undefined" && result.result
1367
- ? result.result
1368
- : global_constants.SCORM_FALSE;
1369
- if (checkTerminated)
1370
- this.lastErrorCode = "0";
1371
- returnValue = global_constants.SCORM_TRUE;
1372
- this.processListeners(callbackName);
1373
- }
1374
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1375
- this.clearSCORMError(returnValue);
1376
- return returnValue;
1232
+ return __awaiter(this, void 0, void 0, function () {
1233
+ var returnValue, result;
1234
+ return __generator(this, function (_a) {
1235
+ switch (_a.label) {
1236
+ case 0:
1237
+ returnValue = api_constants.global.SCORM_FALSE;
1238
+ if (!this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) return [3, 2];
1239
+ this.currentState = api_constants.global.STATE_TERMINATED;
1240
+ return [4, this.storeData(true)];
1241
+ case 1:
1242
+ result = _a.sent();
1243
+ if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
1244
+ this.throwSCORMError(result.errorCode);
1245
+ }
1246
+ returnValue =
1247
+ typeof result !== "undefined" && result.result
1248
+ ? result.result
1249
+ : api_constants.global.SCORM_FALSE;
1250
+ if (checkTerminated)
1251
+ this.lastErrorCode = "0";
1252
+ returnValue = api_constants.global.SCORM_TRUE;
1253
+ this.processListeners(callbackName);
1254
+ _a.label = 2;
1255
+ case 2:
1256
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1257
+ this.clearSCORMError(returnValue);
1258
+ return [2, returnValue];
1259
+ }
1260
+ });
1261
+ });
1377
1262
  };
1378
1263
  BaseAPI.prototype.getValue = function (callbackName, checkTerminated, CMIElement) {
1379
1264
  var returnValue = "";
@@ -1388,7 +1273,10 @@ var BaseAPI = (function () {
1388
1273
  }
1389
1274
  this.processListeners(callbackName, CMIElement);
1390
1275
  }
1391
- this.apiLog(callbackName, ": returned: " + returnValue, global_constants.LOG_LEVEL_INFO, CMIElement);
1276
+ this.apiLog(callbackName, ": returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1277
+ if (returnValue === undefined) {
1278
+ return "";
1279
+ }
1392
1280
  this.clearSCORMError(returnValue);
1393
1281
  return returnValue;
1394
1282
  };
@@ -1396,7 +1284,7 @@ var BaseAPI = (function () {
1396
1284
  if (value !== undefined) {
1397
1285
  value = String(value);
1398
1286
  }
1399
- var returnValue = global_constants.SCORM_FALSE;
1287
+ var returnValue = api_constants.global.SCORM_FALSE;
1400
1288
  if (this.checkState(checkTerminated, this._error_codes.STORE_BEFORE_INIT, this._error_codes.STORE_AFTER_TERM)) {
1401
1289
  if (checkTerminated)
1402
1290
  this.lastErrorCode = "0";
@@ -1409,43 +1297,54 @@ var BaseAPI = (function () {
1409
1297
  this.processListeners(callbackName, CMIElement, value);
1410
1298
  }
1411
1299
  if (returnValue === undefined) {
1412
- returnValue = global_constants.SCORM_FALSE;
1300
+ returnValue = api_constants.global.SCORM_FALSE;
1413
1301
  }
1414
1302
  if (String(this.lastErrorCode) === "0") {
1415
1303
  if (this.settings.autocommit && !this._timeout) {
1416
1304
  this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
1417
1305
  }
1418
1306
  }
1419
- this.apiLog(callbackName, ": " + value + ": result: " + returnValue, global_constants.LOG_LEVEL_INFO, CMIElement);
1307
+ this.apiLog(callbackName, ": " + value + ": result: " + returnValue, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1420
1308
  this.clearSCORMError(returnValue);
1421
1309
  return returnValue;
1422
1310
  };
1423
- BaseAPI.prototype.commit = function (callbackName, checkTerminated) {
1424
- if (checkTerminated === void 0) { checkTerminated = false; }
1425
- this.clearScheduledCommit();
1426
- var returnValue = global_constants.SCORM_FALSE;
1427
- if (this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) {
1428
- var result = this.storeData(false);
1429
- if (result.errorCode && result.errorCode > 0) {
1430
- this.throwSCORMError(result.errorCode);
1431
- }
1432
- returnValue =
1433
- typeof result !== "undefined" && result.result
1434
- ? result.result
1435
- : global_constants.SCORM_FALSE;
1436
- this.apiLog(callbackName, " Result: " + returnValue, global_constants.LOG_LEVEL_DEBUG, "HttpRequest");
1437
- if (checkTerminated)
1438
- this.lastErrorCode = "0";
1439
- this.processListeners(callbackName);
1440
- }
1441
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1442
- this.clearSCORMError(returnValue);
1443
- return returnValue;
1311
+ BaseAPI.prototype.commit = function (callbackName_1) {
1312
+ return __awaiter(this, arguments, void 0, function (callbackName, checkTerminated) {
1313
+ var returnValue, result;
1314
+ if (checkTerminated === void 0) { checkTerminated = false; }
1315
+ return __generator(this, function (_a) {
1316
+ switch (_a.label) {
1317
+ case 0:
1318
+ this.clearScheduledCommit();
1319
+ returnValue = api_constants.global.SCORM_FALSE;
1320
+ if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
1321
+ return [4, this.storeData(false)];
1322
+ case 1:
1323
+ result = _a.sent();
1324
+ if (result.errorCode && result.errorCode > 0) {
1325
+ this.throwSCORMError(result.errorCode);
1326
+ }
1327
+ returnValue =
1328
+ typeof result !== "undefined" && result.result
1329
+ ? result.result
1330
+ : api_constants.global.SCORM_FALSE;
1331
+ this.apiLog(callbackName, " Result: " + returnValue, api_constants.global.LOG_LEVEL_DEBUG, "HttpRequest");
1332
+ if (checkTerminated)
1333
+ this.lastErrorCode = "0";
1334
+ this.processListeners(callbackName);
1335
+ _a.label = 2;
1336
+ case 2:
1337
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1338
+ this.clearSCORMError(returnValue);
1339
+ return [2, returnValue];
1340
+ }
1341
+ });
1342
+ });
1444
1343
  };
1445
1344
  BaseAPI.prototype.getLastError = function (callbackName) {
1446
1345
  var returnValue = String(this.lastErrorCode);
1447
1346
  this.processListeners(callbackName);
1448
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1347
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1449
1348
  return returnValue;
1450
1349
  };
1451
1350
  BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
@@ -1454,7 +1353,7 @@ var BaseAPI = (function () {
1454
1353
  returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
1455
1354
  this.processListeners(callbackName);
1456
1355
  }
1457
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1356
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1458
1357
  return returnValue;
1459
1358
  };
1460
1359
  BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
@@ -1463,7 +1362,7 @@ var BaseAPI = (function () {
1463
1362
  returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
1464
1363
  this.processListeners(callbackName);
1465
1364
  }
1466
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1365
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1467
1366
  return returnValue;
1468
1367
  };
1469
1368
  BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
@@ -1477,42 +1376,6 @@ var BaseAPI = (function () {
1477
1376
  }
1478
1377
  return true;
1479
1378
  };
1480
- BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
1481
- logMessage = this.formatMessage(functionName, logMessage, CMIElement);
1482
- if (messageLevel >= this.apiLogLevel) {
1483
- this.settings.onLogMessage(messageLevel, logMessage);
1484
- }
1485
- };
1486
- BaseAPI.prototype.formatMessage = function (functionName, message, CMIElement) {
1487
- var baseLength = 20;
1488
- var messageString = "";
1489
- messageString += functionName;
1490
- var fillChars = baseLength - messageString.length;
1491
- for (var i = 0; i < fillChars; i++) {
1492
- messageString += " ";
1493
- }
1494
- messageString += ": ";
1495
- if (CMIElement) {
1496
- var CMIElementBaseLength = 70;
1497
- messageString += CMIElement;
1498
- fillChars = CMIElementBaseLength - messageString.length;
1499
- for (var j = 0; j < fillChars; j++) {
1500
- messageString += " ";
1501
- }
1502
- }
1503
- if (message) {
1504
- messageString += message;
1505
- }
1506
- return messageString;
1507
- };
1508
- BaseAPI.prototype.stringMatches = function (str, tester) {
1509
- return (str === null || str === void 0 ? void 0 : str.match(tester)) !== null;
1510
- };
1511
- BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
1512
- return (Object.hasOwnProperty.call(refObject, attribute) ||
1513
- Object.getOwnPropertyDescriptor(Object.getPrototypeOf(refObject), attribute) != null ||
1514
- attribute in refObject);
1515
- };
1516
1379
  BaseAPI.prototype.getLmsErrorMessageDetails = function (_errorNumber, _detail) {
1517
1380
  if (_detail === void 0) { _detail = false; }
1518
1381
  throw new Error("The getLmsErrorMessageDetails method has not been implemented");
@@ -1525,11 +1388,11 @@ var BaseAPI = (function () {
1525
1388
  };
1526
1389
  BaseAPI.prototype._commonSetCMIValue = function (methodName, scorm2004, CMIElement, value) {
1527
1390
  if (!CMIElement || CMIElement === "") {
1528
- return global_constants.SCORM_FALSE;
1391
+ return api_constants.global.SCORM_FALSE;
1529
1392
  }
1530
1393
  var structure = CMIElement.split(".");
1531
1394
  var refObject = this;
1532
- var returnValue = global_constants.SCORM_FALSE;
1395
+ var returnValue = api_constants.global.SCORM_FALSE;
1533
1396
  var foundFirstIndex = false;
1534
1397
  var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
1535
1398
  var invalidErrorCode = scorm2004
@@ -1538,22 +1401,25 @@ var BaseAPI = (function () {
1538
1401
  for (var idx = 0; idx < structure.length; idx++) {
1539
1402
  var attribute = structure[idx];
1540
1403
  if (idx === structure.length - 1) {
1541
- if (scorm2004 &&
1542
- attribute.substring(0, 8) === "{target=" &&
1543
- typeof refObject._isTargetValid == "function") {
1544
- this.throwSCORMError(this._error_codes.READ_ONLY_ELEMENT);
1404
+ if (scorm2004 && attribute.substring(0, 8) === "{target=") {
1405
+ if (this.isInitialized()) {
1406
+ this.throwSCORMError(this._error_codes.READ_ONLY_ELEMENT);
1407
+ }
1408
+ else {
1409
+ refObject = __assign(__assign({}, refObject), { attribute: value });
1410
+ }
1545
1411
  }
1546
1412
  else if (!this._checkObjectHasProperty(refObject, attribute)) {
1547
1413
  this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1548
1414
  }
1549
1415
  else {
1550
- if (this.isInitialized() &&
1551
- this.stringMatches(CMIElement, "\\.correct_responses\\.\\d+")) {
1416
+ if (stringMatches(CMIElement, "\\.correct_responses\\.\\d+") &&
1417
+ this.isInitialized()) {
1552
1418
  this.validateCorrectResponse(CMIElement, value);
1553
1419
  }
1554
1420
  if (!scorm2004 || this.lastErrorCode === "0") {
1555
1421
  refObject[attribute] = value;
1556
- returnValue = global_constants.SCORM_TRUE;
1422
+ returnValue = api_constants.global.SCORM_TRUE;
1557
1423
  }
1558
1424
  }
1559
1425
  }
@@ -1589,8 +1455,8 @@ var BaseAPI = (function () {
1589
1455
  }
1590
1456
  }
1591
1457
  }
1592
- if (returnValue === global_constants.SCORM_FALSE) {
1593
- this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), global_constants.LOG_LEVEL_WARNING);
1458
+ if (returnValue === api_constants.global.SCORM_FALSE) {
1459
+ this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), api_constants.global.LOG_LEVEL_WARNING);
1594
1460
  }
1595
1461
  return returnValue;
1596
1462
  };
@@ -1650,10 +1516,10 @@ var BaseAPI = (function () {
1650
1516
  if (refObject === null || refObject === undefined) {
1651
1517
  if (!scorm2004) {
1652
1518
  if (attribute === "_children") {
1653
- this.throwSCORMError(BaseAPI_scorm12_error_codes.CHILDREN_ERROR);
1519
+ this.throwSCORMError(error_codes.scorm12.CHILDREN_ERROR);
1654
1520
  }
1655
1521
  else if (attribute === "_count") {
1656
- this.throwSCORMError(BaseAPI_scorm12_error_codes.COUNT_ERROR);
1522
+ this.throwSCORMError(error_codes.scorm12.COUNT_ERROR);
1657
1523
  }
1658
1524
  }
1659
1525
  }
@@ -1662,13 +1528,13 @@ var BaseAPI = (function () {
1662
1528
  }
1663
1529
  };
1664
1530
  BaseAPI.prototype.isInitialized = function () {
1665
- return this.currentState === global_constants.STATE_INITIALIZED;
1531
+ return this.currentState === api_constants.global.STATE_INITIALIZED;
1666
1532
  };
1667
1533
  BaseAPI.prototype.isNotInitialized = function () {
1668
- return this.currentState === global_constants.STATE_NOT_INITIALIZED;
1534
+ return this.currentState === api_constants.global.STATE_NOT_INITIALIZED;
1669
1535
  };
1670
1536
  BaseAPI.prototype.isTerminated = function () {
1671
- return this.currentState === global_constants.STATE_TERMINATED;
1537
+ return this.currentState === api_constants.global.STATE_TERMINATED;
1672
1538
  };
1673
1539
  BaseAPI.prototype.on = function (listenerName, callback) {
1674
1540
  if (!callback)
@@ -1688,7 +1554,7 @@ var BaseAPI = (function () {
1688
1554
  CMIElement: CMIElement,
1689
1555
  callback: callback,
1690
1556
  });
1691
- this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), global_constants.LOG_LEVEL_INFO, functionName);
1557
+ this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), api_constants.global.LOG_LEVEL_INFO, functionName);
1692
1558
  }
1693
1559
  };
1694
1560
  BaseAPI.prototype.off = function (listenerName, callback) {
@@ -1711,7 +1577,7 @@ var BaseAPI = (function () {
1711
1577
  });
1712
1578
  if (removeIndex !== -1) {
1713
1579
  this_1.listenerArray.splice(removeIndex, 1);
1714
- this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), global_constants.LOG_LEVEL_INFO, functionName);
1580
+ this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), api_constants.global.LOG_LEVEL_INFO, functionName);
1715
1581
  }
1716
1582
  };
1717
1583
  var this_1 = this;
@@ -1744,7 +1610,7 @@ var BaseAPI = (function () {
1744
1610
  }
1745
1611
  };
1746
1612
  BaseAPI.prototype.processListeners = function (functionName, CMIElement, value) {
1747
- this.apiLog(functionName, value, global_constants.LOG_LEVEL_INFO, CMIElement);
1613
+ this.apiLog(functionName, value, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1748
1614
  for (var i = 0; i < this.listenerArray.length; i++) {
1749
1615
  var listener = this.listenerArray[i];
1750
1616
  var functionsMatch = listener.functionName === functionName;
@@ -1760,7 +1626,7 @@ var BaseAPI = (function () {
1760
1626
  CMIElementsMatch = listener.CMIElement === CMIElement;
1761
1627
  }
1762
1628
  if (functionsMatch && (!listenerHasCMIElement || CMIElementsMatch)) {
1763
- this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), global_constants.LOG_LEVEL_INFO, CMIElement);
1629
+ this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), api_constants.global.LOG_LEVEL_INFO, CMIElement);
1764
1630
  listener.callback(CMIElement, value);
1765
1631
  }
1766
1632
  }
@@ -1769,16 +1635,19 @@ var BaseAPI = (function () {
1769
1635
  if (!message) {
1770
1636
  message = this.getLmsErrorMessageDetails(errorNumber);
1771
1637
  }
1772
- this.apiLog("throwSCORMError", errorNumber + ": " + message, global_constants.LOG_LEVEL_ERROR);
1638
+ this.apiLog("throwSCORMError", errorNumber + ": " + message, api_constants.global.LOG_LEVEL_ERROR);
1773
1639
  this.lastErrorCode = String(errorNumber);
1774
1640
  };
1775
1641
  BaseAPI.prototype.clearSCORMError = function (success) {
1776
- if (success !== undefined && success !== global_constants.SCORM_FALSE) {
1642
+ if (success !== undefined && success !== api_constants.global.SCORM_FALSE) {
1777
1643
  this.lastErrorCode = "0";
1778
1644
  }
1779
1645
  };
1780
1646
  BaseAPI.prototype.loadFromFlattenedJSON = function (json, CMIElement) {
1781
1647
  var _this = this;
1648
+ if (!CMIElement) {
1649
+ CMIElement = "";
1650
+ }
1782
1651
  if (!this.isNotInitialized()) {
1783
1652
  console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.");
1784
1653
  return;
@@ -1866,87 +1735,96 @@ var BaseAPI = (function () {
1866
1735
  };
1867
1736
  BaseAPI.prototype.renderCMIToJSONString = function () {
1868
1737
  var cmi = this.cmi;
1869
- return JSON.stringify({ cmi: cmi });
1738
+ if (this.settings.sendFullCommit) {
1739
+ return JSON.stringify({ cmi: cmi });
1740
+ }
1741
+ return JSON.stringify({ cmi: cmi }, function (k, v) { return (v === undefined ? null : v); }, 2);
1870
1742
  };
1871
1743
  BaseAPI.prototype.renderCMIToJSONObject = function () {
1872
1744
  return JSON.parse(this.renderCMIToJSONString());
1873
1745
  };
1874
- BaseAPI.prototype.processHttpRequest = function (url, params, immediate) {
1875
- var _this = this;
1876
- if (immediate === void 0) { immediate = false; }
1877
- var api = this;
1878
- var genericError = {
1879
- result: global_constants.SCORM_FALSE,
1880
- errorCode: this.error_codes.GENERAL,
1881
- };
1882
- var process = function (url, params, settings) { return __awaiter(_this, void 0, void 0, function () {
1883
- var response, result, _a, e_1;
1884
- return __generator(this, function (_c) {
1885
- switch (_c.label) {
1746
+ BaseAPI.prototype.processHttpRequest = function (url_1, params_1) {
1747
+ return __awaiter(this, arguments, void 0, function (url, params, immediate) {
1748
+ var api, genericError, process, debouncedProcess;
1749
+ var _this = this;
1750
+ if (immediate === void 0) { immediate = false; }
1751
+ return __generator(this, function (_a) {
1752
+ switch (_a.label) {
1886
1753
  case 0:
1887
- _c.trys.push([0, 6, , 7]);
1888
- params = settings.requestHandler(params);
1889
- return [4, fetch(url, {
1890
- method: "POST",
1891
- body: params instanceof Array ? params.join("&") : JSON.stringify(params),
1892
- headers: __assign(__assign({}, settings.xhrHeaders), { "Content-Type": settings.commitRequestDataType }),
1893
- credentials: settings.xhrWithCredentials ? "include" : undefined,
1894
- keepalive: true,
1895
- })];
1896
- case 1:
1897
- response = _c.sent();
1898
- if (!(typeof settings.responseHandler === "function")) return [3, 3];
1899
- return [4, settings.responseHandler(response)];
1900
- case 2:
1901
- _a = _c.sent();
1902
- return [3, 5];
1903
- case 3: return [4, response.json()];
1904
- case 4:
1905
- _a = _c.sent();
1906
- _c.label = 5;
1907
- case 5:
1908
- result = _a;
1909
- if (response.status >= 200 &&
1910
- response.status <= 299 &&
1911
- (result.result === true ||
1912
- result.result === global_constants.SCORM_TRUE)) {
1913
- api.processListeners("CommitSuccess");
1914
- }
1915
- else {
1916
- api.processListeners("CommitError");
1754
+ api = this;
1755
+ genericError = {
1756
+ result: api_constants.global.SCORM_FALSE,
1757
+ errorCode: this.error_codes.GENERAL,
1758
+ };
1759
+ if (immediate) {
1760
+ this.performFetch(url, params).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
1761
+ return __generator(this, function (_a) {
1762
+ switch (_a.label) {
1763
+ case 0: return [4, this.transformResponse(response)];
1764
+ case 1:
1765
+ _a.sent();
1766
+ return [2];
1767
+ }
1768
+ });
1769
+ }); });
1770
+ return [2, {
1771
+ result: api_constants.global.SCORM_TRUE,
1772
+ errorCode: 0,
1773
+ }];
1917
1774
  }
1918
- return [2, result];
1919
- case 6:
1920
- e_1 = _c.sent();
1921
- this.apiLog("processHttpRequest", e_1, global_constants.LOG_LEVEL_ERROR);
1922
- api.processListeners("CommitError");
1923
- return [2, genericError];
1924
- case 7: return [2];
1775
+ process = function (url, params, settings) { return __awaiter(_this, void 0, void 0, function () {
1776
+ var response, e_1;
1777
+ return __generator(this, function (_a) {
1778
+ switch (_a.label) {
1779
+ case 0:
1780
+ _a.trys.push([0, 2, , 3]);
1781
+ params = settings.requestHandler(params);
1782
+ return [4, this.performFetch(url, params)];
1783
+ case 1:
1784
+ response = _a.sent();
1785
+ return [2, this.transformResponse(response)];
1786
+ case 2:
1787
+ e_1 = _a.sent();
1788
+ this.apiLog("processHttpRequest", e_1, api_constants.global.LOG_LEVEL_ERROR);
1789
+ api.processListeners("CommitError");
1790
+ return [2, genericError];
1791
+ case 3: return [2];
1792
+ }
1793
+ });
1794
+ }); };
1795
+ if (!this.settings.asyncCommit) return [3, 1];
1796
+ debouncedProcess = debounce(process, 500, immediate);
1797
+ debouncedProcess(url, params, this.settings);
1798
+ return [2, {
1799
+ result: api_constants.global.SCORM_TRUE,
1800
+ errorCode: 0,
1801
+ }];
1802
+ case 1: return [4, process(url, params, this.settings)];
1803
+ case 2: return [2, _a.sent()];
1925
1804
  }
1926
1805
  });
1927
- }); };
1928
- var debouncedProcess = debounce(process, 500, immediate);
1929
- debouncedProcess(url, params, this.settings);
1930
- return {
1931
- result: global_constants.SCORM_TRUE,
1932
- errorCode: 0,
1933
- };
1806
+ });
1934
1807
  };
1935
1808
  BaseAPI.prototype.scheduleCommit = function (when, callback) {
1936
1809
  this._timeout = new ScheduledCommit(this, when, callback);
1937
- this.apiLog("scheduleCommit", "scheduled", global_constants.LOG_LEVEL_DEBUG, "");
1810
+ this.apiLog("scheduleCommit", "scheduled", api_constants.global.LOG_LEVEL_DEBUG, "");
1938
1811
  };
1939
1812
  BaseAPI.prototype.clearScheduledCommit = function () {
1940
1813
  if (this._timeout) {
1941
1814
  this._timeout.cancel();
1942
1815
  this._timeout = undefined;
1943
- this.apiLog("clearScheduledCommit", "cleared", global_constants.LOG_LEVEL_DEBUG, "");
1816
+ this.apiLog("clearScheduledCommit", "cleared", api_constants.global.LOG_LEVEL_DEBUG, "");
1944
1817
  }
1945
1818
  };
1819
+ BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
1820
+ return (Object.hasOwnProperty.call(refObject, attribute) ||
1821
+ Object.getOwnPropertyDescriptor(Object.getPrototypeOf(refObject), attribute) != null ||
1822
+ attribute in refObject);
1823
+ };
1946
1824
  BaseAPI.prototype.handleValueAccessException = function (e, returnValue) {
1947
1825
  if (e instanceof ValidationError) {
1948
1826
  this.lastErrorCode = String(e.errorCode);
1949
- returnValue = global_constants.SCORM_FALSE;
1827
+ returnValue = api_constants.global.SCORM_FALSE;
1950
1828
  }
1951
1829
  else {
1952
1830
  if (e instanceof Error && e.message) {
@@ -1959,182 +1837,282 @@ var BaseAPI = (function () {
1959
1837
  }
1960
1838
  return returnValue;
1961
1839
  };
1962
- return BaseAPI;
1963
- }());
1964
- /* harmony default export */ var src_BaseAPI = (BaseAPI);
1965
- var ScheduledCommit = (function () {
1966
- function ScheduledCommit(API, when, callback) {
1967
- this._cancelled = false;
1968
- this._API = API;
1969
- this._timeout = setTimeout(this.wrapper.bind(this), when);
1970
- this._callback = callback;
1971
- }
1972
- ScheduledCommit.prototype.cancel = function () {
1973
- this._cancelled = true;
1974
- if (this._timeout) {
1975
- clearTimeout(this._timeout);
1976
- }
1840
+ BaseAPI.prototype.performFetch = function (url, params) {
1841
+ return __awaiter(this, void 0, void 0, function () {
1842
+ return __generator(this, function (_a) {
1843
+ return [2, fetch(url, {
1844
+ method: "POST",
1845
+ body: params instanceof Array ? params.join("&") : JSON.stringify(params),
1846
+ headers: __assign(__assign({}, this.settings.xhrHeaders), { "Content-Type": this.settings.commitRequestDataType }),
1847
+ credentials: this.settings.xhrWithCredentials ? "include" : undefined,
1848
+ keepalive: true,
1849
+ })];
1850
+ });
1851
+ });
1977
1852
  };
1978
- ScheduledCommit.prototype.wrapper = function () {
1979
- if (!this._cancelled) {
1980
- this._API.commit(this._callback);
1981
- }
1853
+ BaseAPI.prototype.transformResponse = function (response) {
1854
+ return __awaiter(this, void 0, void 0, function () {
1855
+ var result, _a;
1856
+ return __generator(this, function (_c) {
1857
+ switch (_c.label) {
1858
+ case 0:
1859
+ if (!(typeof this.settings.responseHandler === "function")) return [3, 2];
1860
+ return [4, this.settings.responseHandler(response)];
1861
+ case 1:
1862
+ _a = _c.sent();
1863
+ return [3, 4];
1864
+ case 2: return [4, response.json()];
1865
+ case 3:
1866
+ _a = _c.sent();
1867
+ _c.label = 4;
1868
+ case 4:
1869
+ result = _a;
1870
+ if (response.status >= 200 &&
1871
+ response.status <= 299 &&
1872
+ (result.result === true ||
1873
+ result.result === api_constants.global.SCORM_TRUE)) {
1874
+ this.processListeners("CommitSuccess");
1875
+ }
1876
+ else {
1877
+ this.processListeners("CommitError");
1878
+ }
1879
+ return [2, result];
1880
+ }
1881
+ });
1882
+ });
1982
1883
  };
1983
- return ScheduledCommit;
1884
+ return BaseAPI;
1984
1885
  }());
1886
+ /* harmony default export */ var src_BaseAPI = (BaseAPI);
1985
1887
 
1986
- ;// ./src/cmi/scorm12_cmi.ts
1987
-
1988
-
1989
-
1990
-
1991
-
1888
+ ;// ./src/constants/regex.ts
1992
1889
 
1890
+ var regex_scorm12 = {
1891
+ CMIString256: "^.{0,255}$",
1892
+ CMIString4096: "^.{0,4096}$",
1893
+ CMITime: "^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",
1894
+ CMITimespan: "^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",
1895
+ CMIInteger: "^\\d+$",
1896
+ CMISInteger: "^-?([0-9]+)$",
1897
+ CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
1898
+ CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
1899
+ CMIFeedback: "^.{0,255}$",
1900
+ CMIIndex: "[._](\\d+).",
1901
+ CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
1902
+ CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
1903
+ CMIExit: "^(time-out|suspend|logout|)$",
1904
+ CMIType: "^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$",
1905
+ CMIResult: "^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$",
1906
+ NAVEvent: "^(previous|continue)$",
1907
+ score_range: "0#100",
1908
+ audio_range: "-1#100",
1909
+ speed_range: "-100#100",
1910
+ weighting_range: "-100#100",
1911
+ text_range: "-1#1",
1912
+ };
1913
+ var regex_aicc = __assign(__assign({}, regex_scorm12), {
1914
+ CMIIdentifier: "^\\w{1,255}$",
1915
+ });
1916
+ var regex_scorm2004 = {
1917
+ CMIString200: "^[\\u0000-\\uFFFF]{0,200}$",
1918
+ CMIString250: "^[\\u0000-\\uFFFF]{0,250}$",
1919
+ CMIString1000: "^[\\u0000-\\uFFFF]{0,1000}$",
1920
+ CMIString4000: "^[\\u0000-\\uFFFF]{0,4000}$",
1921
+ CMIString64000: "^[\\u0000-\\uFFFF]{0,64000}$",
1922
+ CMILang: "^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",
1923
+ CMILangString250: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",
1924
+ CMILangcr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",
1925
+ CMILangString250cr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",
1926
+ CMILangString4000: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",
1927
+ CMITime: "^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$",
1928
+ CMITimespan: "^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$",
1929
+ CMIInteger: "^\\d+$",
1930
+ CMISInteger: "^-?([0-9]+)$",
1931
+ CMIDecimal: "^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",
1932
+ CMIIdentifier: "^\\S{1,250}[a-zA-Z0-9]$",
1933
+ CMIShortIdentifier: "^[\\w\\.\\-\\_]{1,250}$",
1934
+ CMILongIdentifier: "^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",
1935
+ CMIFeedback: "^.*$",
1936
+ CMIIndex: "[._](\\d+).",
1937
+ CMIIndexStore: ".N(\\d+).",
1938
+ CMICStatus: "^(completed|incomplete|not attempted|unknown)$",
1939
+ CMISStatus: "^(passed|failed|unknown)$",
1940
+ CMIExit: "^(time-out|suspend|logout|normal)$",
1941
+ CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
1942
+ CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
1943
+ NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|_none_|(\\{target=\\S{0,}[a-zA-Z0-9-_]+})?choice|(\\{target=\\S{0,}[a-zA-Z0-9-_]+})?jump)$",
1944
+ NAVBoolean: "^(unknown|true|false$)",
1945
+ NAVTarget: "^{target=\\S{0,}[a-zA-Z0-9-_]+}$",
1946
+ scaled_range: "-1#1",
1947
+ audio_range: "0#*",
1948
+ speed_range: "0#*",
1949
+ text_range: "-1#1",
1950
+ progress_range: "0#1",
1951
+ };
1952
+ var Regex = {
1953
+ aicc: regex_aicc,
1954
+ scorm12: regex_scorm12,
1955
+ scorm2004: regex_scorm2004,
1956
+ };
1957
+ /* harmony default export */ var regex = (Regex);
1993
1958
 
1994
- var scorm12_cmi_scorm12_constants = api_constants.scorm12;
1995
- var scorm12_cmi_scorm12_regex = regex.scorm12;
1996
- var scorm12_cmi_scorm12_error_codes = error_codes.scorm12;
1997
- function check12ValidFormat(value, regexPattern, allowEmptyString) {
1998
- return checkValidFormat(value, regexPattern, scorm12_cmi_scorm12_error_codes.TYPE_MISMATCH, Scorm12ValidationError, allowEmptyString);
1999
- }
2000
- function check12ValidRange(value, rangePattern, allowEmptyString) {
2001
- if (!allowEmptyString && value === "") {
2002
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.VALUE_OUT_OF_RANGE);
1959
+ ;// ./src/cmi/common/validation.ts
1960
+ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
1961
+ if (typeof value !== "string") {
1962
+ return false;
2003
1963
  }
2004
- return checkValidRange(value, rangePattern, scorm12_cmi_scorm12_error_codes.VALUE_OUT_OF_RANGE, Scorm12ValidationError);
2005
- }
2006
- var CMI = (function (_super) {
2007
- __extends(CMI, _super);
2008
- function CMI(cmi_children, student_data, initialized) {
2009
- var _this = _super.call(this) || this;
2010
- _this.__children = "";
2011
- _this.__version = "3.4";
2012
- _this._launch_data = "";
2013
- _this._comments = "";
2014
- _this._comments_from_lms = "";
2015
- if (initialized)
2016
- _this.initialize();
2017
- _this.__children = cmi_children
2018
- ? cmi_children
2019
- : scorm12_cmi_scorm12_constants.cmi_children;
2020
- _this.core = new CMICore();
2021
- _this.objectives = new CMIObjectives();
2022
- _this.student_data = student_data ? student_data : new CMIStudentData();
2023
- _this.student_preference = new CMIStudentPreference();
2024
- _this.interactions = new CMIInteractions();
1964
+ var formatRegex = new RegExp(regexPattern);
1965
+ var matches = value.match(formatRegex);
1966
+ if (allowEmptyString && value === "") {
1967
+ return true;
1968
+ }
1969
+ if (value === undefined || !matches || matches[0] === "") {
1970
+ throw new errorClass(errorCode);
1971
+ }
1972
+ return true;
1973
+ }
1974
+ function checkValidRange(value, rangePattern, errorCode, errorClass) {
1975
+ var ranges = rangePattern.split("#");
1976
+ value = value * 1.0;
1977
+ if (value >= ranges[0]) {
1978
+ if (ranges[1] === "*" || value <= ranges[1]) {
1979
+ return true;
1980
+ }
1981
+ else {
1982
+ throw new errorClass(errorCode);
1983
+ }
1984
+ }
1985
+ else {
1986
+ throw new errorClass(errorCode);
1987
+ }
1988
+ }
1989
+
1990
+ ;// ./src/cmi/scorm12/validation.ts
1991
+
1992
+
1993
+
1994
+ function check12ValidFormat(value, regexPattern, allowEmptyString) {
1995
+ return checkValidFormat(value, regexPattern, error_codes.scorm12.TYPE_MISMATCH, Scorm12ValidationError, allowEmptyString);
1996
+ }
1997
+ function check12ValidRange(value, rangePattern, allowEmptyString) {
1998
+ if (!allowEmptyString && value === "") {
1999
+ throw new Scorm12ValidationError(error_codes.scorm12.VALUE_OUT_OF_RANGE);
2000
+ }
2001
+ return checkValidRange(value, rangePattern, error_codes.scorm12.VALUE_OUT_OF_RANGE, Scorm12ValidationError);
2002
+ }
2003
+
2004
+ ;// ./src/cmi/common/score.ts
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+
2011
+ var scorm12_constants = api_constants.scorm12;
2012
+ var scorm12_regex = regex.scorm12;
2013
+ var score_scorm12_error_codes = error_codes.scorm12;
2014
+ var CMIScore = (function (_super) {
2015
+ __extends(CMIScore, _super);
2016
+ function CMIScore(params) {
2017
+ var _this = _super.call(this) || this;
2018
+ _this._raw = "";
2019
+ _this._min = "";
2020
+ _this.__children = params.score_children || scorm12_constants.score_children;
2021
+ _this.__score_range = !params.score_range
2022
+ ? false
2023
+ : scorm12_regex.score_range;
2024
+ _this._max = params.max || params.max === "" ? params.max : "100";
2025
+ _this.__invalid_error_code =
2026
+ params.invalidErrorCode || score_scorm12_error_codes.INVALID_SET_VALUE;
2027
+ _this.__invalid_type_code =
2028
+ params.invalidTypeCode || score_scorm12_error_codes.TYPE_MISMATCH;
2029
+ _this.__invalid_range_code =
2030
+ params.invalidRangeCode || score_scorm12_error_codes.VALUE_OUT_OF_RANGE;
2031
+ _this.__decimal_regex = params.decimalRegex || scorm12_regex.CMIDecimal;
2032
+ _this.__error_class = params.errorClass;
2025
2033
  return _this;
2026
2034
  }
2027
- CMI.prototype.initialize = function () {
2028
- var _a, _b, _c, _d, _e;
2029
- _super.prototype.initialize.call(this);
2030
- (_a = this.core) === null || _a === void 0 ? void 0 : _a.initialize();
2031
- (_b = this.objectives) === null || _b === void 0 ? void 0 : _b.initialize();
2032
- (_c = this.student_data) === null || _c === void 0 ? void 0 : _c.initialize();
2033
- (_d = this.student_preference) === null || _d === void 0 ? void 0 : _d.initialize();
2034
- (_e = this.interactions) === null || _e === void 0 ? void 0 : _e.initialize();
2035
- };
2036
- CMI.prototype.toJSON = function () {
2037
- this.jsonString = true;
2038
- var result = {
2039
- suspend_data: this.suspend_data,
2040
- launch_data: this.launch_data,
2041
- comments: this.comments,
2042
- comments_from_lms: this.comments_from_lms,
2043
- core: this.core,
2044
- objectives: this.objectives,
2045
- student_data: this.student_data,
2046
- student_preference: this.student_preference,
2047
- interactions: this.interactions,
2048
- };
2049
- delete this.jsonString;
2050
- return result;
2051
- };
2052
- Object.defineProperty(CMI.prototype, "_version", {
2053
- get: function () {
2054
- return this.__version;
2055
- },
2056
- set: function (_version) {
2057
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2058
- },
2059
- enumerable: false,
2060
- configurable: true
2061
- });
2062
- Object.defineProperty(CMI.prototype, "_children", {
2035
+ Object.defineProperty(CMIScore.prototype, "_children", {
2063
2036
  get: function () {
2064
2037
  return this.__children;
2065
2038
  },
2066
2039
  set: function (_children) {
2067
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2068
- },
2069
- enumerable: false,
2070
- configurable: true
2071
- });
2072
- Object.defineProperty(CMI.prototype, "suspend_data", {
2073
- get: function () {
2074
- var _a;
2075
- return (_a = this.core) === null || _a === void 0 ? void 0 : _a.suspend_data;
2076
- },
2077
- set: function (suspend_data) {
2078
- if (this.core) {
2079
- this.core.suspend_data = suspend_data;
2080
- }
2040
+ throw new this.__error_class(this.__invalid_error_code);
2081
2041
  },
2082
2042
  enumerable: false,
2083
2043
  configurable: true
2084
2044
  });
2085
- Object.defineProperty(CMI.prototype, "launch_data", {
2045
+ Object.defineProperty(CMIScore.prototype, "raw", {
2086
2046
  get: function () {
2087
- return this._launch_data;
2047
+ return this._raw;
2088
2048
  },
2089
- set: function (launch_data) {
2090
- if (this.initialized) {
2091
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2092
- }
2093
- else {
2094
- this._launch_data = launch_data;
2049
+ set: function (raw) {
2050
+ if (checkValidFormat(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2051
+ (!this.__score_range ||
2052
+ checkValidRange(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2053
+ this._raw = raw;
2095
2054
  }
2096
2055
  },
2097
2056
  enumerable: false,
2098
2057
  configurable: true
2099
2058
  });
2100
- Object.defineProperty(CMI.prototype, "comments", {
2059
+ Object.defineProperty(CMIScore.prototype, "min", {
2101
2060
  get: function () {
2102
- return this._comments;
2061
+ return this._min;
2103
2062
  },
2104
- set: function (comments) {
2105
- if (check12ValidFormat(comments, scorm12_cmi_scorm12_regex.CMIString4096, true)) {
2106
- this._comments = comments;
2063
+ set: function (min) {
2064
+ if (checkValidFormat(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2065
+ (!this.__score_range ||
2066
+ checkValidRange(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2067
+ this._min = min;
2107
2068
  }
2108
2069
  },
2109
2070
  enumerable: false,
2110
2071
  configurable: true
2111
2072
  });
2112
- Object.defineProperty(CMI.prototype, "comments_from_lms", {
2073
+ Object.defineProperty(CMIScore.prototype, "max", {
2113
2074
  get: function () {
2114
- return this._comments_from_lms;
2075
+ return this._max;
2115
2076
  },
2116
- set: function (comments_from_lms) {
2117
- if (this.initialized) {
2118
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2119
- }
2120
- else {
2121
- this._comments_from_lms = comments_from_lms;
2077
+ set: function (max) {
2078
+ if (checkValidFormat(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2079
+ (!this.__score_range ||
2080
+ checkValidRange(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2081
+ this._max = max;
2122
2082
  }
2123
2083
  },
2124
2084
  enumerable: false,
2125
2085
  configurable: true
2126
2086
  });
2127
- CMI.prototype.getCurrentTotalTime = function () {
2128
- return this.core.getCurrentTotalTime(this.start_time);
2087
+ CMIScore.prototype.toJSON = function () {
2088
+ this.jsonString = true;
2089
+ var result = {
2090
+ raw: this.raw,
2091
+ min: this.min,
2092
+ max: this.max,
2093
+ };
2094
+ delete this.jsonString;
2095
+ return result;
2129
2096
  };
2130
- return CMI;
2131
- }(BaseRootCMI));
2097
+ return CMIScore;
2098
+ }(BaseCMI));
2099
+
2100
+
2101
+ ;// ./src/cmi/aicc/core.ts
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+
2108
+
2109
+
2132
2110
 
2133
2111
  var CMICore = (function (_super) {
2134
2112
  __extends(CMICore, _super);
2135
2113
  function CMICore() {
2136
2114
  var _this = _super.call(this) || this;
2137
- _this.__children = scorm12_cmi_scorm12_constants.core_children;
2115
+ _this.__children = api_constants.scorm12.core_children;
2138
2116
  _this._student_id = "";
2139
2117
  _this._student_name = "";
2140
2118
  _this._lesson_location = "";
@@ -2147,11 +2125,11 @@ var CMICore = (function (_super) {
2147
2125
  _this._session_time = "00:00:00";
2148
2126
  _this._suspend_data = "";
2149
2127
  _this.score = new CMIScore({
2150
- score_children: scorm12_cmi_scorm12_constants.score_children,
2151
- score_range: scorm12_cmi_scorm12_regex.score_range,
2152
- invalidErrorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2153
- invalidTypeCode: scorm12_cmi_scorm12_error_codes.TYPE_MISMATCH,
2154
- invalidRangeCode: scorm12_cmi_scorm12_error_codes.VALUE_OUT_OF_RANGE,
2128
+ score_children: api_constants.scorm12.score_children,
2129
+ score_range: regex.scorm12.score_range,
2130
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
2131
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
2132
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
2155
2133
  errorClass: Scorm12ValidationError,
2156
2134
  });
2157
2135
  return _this;
@@ -2166,7 +2144,7 @@ var CMICore = (function (_super) {
2166
2144
  return this.__children;
2167
2145
  },
2168
2146
  set: function (_children) {
2169
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2147
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2170
2148
  },
2171
2149
  enumerable: false,
2172
2150
  configurable: true
@@ -2177,7 +2155,7 @@ var CMICore = (function (_super) {
2177
2155
  },
2178
2156
  set: function (student_id) {
2179
2157
  if (this.initialized) {
2180
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2158
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2181
2159
  }
2182
2160
  else {
2183
2161
  this._student_id = student_id;
@@ -2192,7 +2170,7 @@ var CMICore = (function (_super) {
2192
2170
  },
2193
2171
  set: function (student_name) {
2194
2172
  if (this.initialized) {
2195
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2173
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2196
2174
  }
2197
2175
  else {
2198
2176
  this._student_name = student_name;
@@ -2206,7 +2184,7 @@ var CMICore = (function (_super) {
2206
2184
  return this._lesson_location;
2207
2185
  },
2208
2186
  set: function (lesson_location) {
2209
- if (check12ValidFormat(lesson_location, scorm12_cmi_scorm12_regex.CMIString256, true)) {
2187
+ if (check12ValidFormat(lesson_location, regex.scorm12.CMIString256, true)) {
2210
2188
  this._lesson_location = lesson_location;
2211
2189
  }
2212
2190
  },
@@ -2219,7 +2197,7 @@ var CMICore = (function (_super) {
2219
2197
  },
2220
2198
  set: function (credit) {
2221
2199
  if (this.initialized) {
2222
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2200
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2223
2201
  }
2224
2202
  else {
2225
2203
  this._credit = credit;
@@ -2234,12 +2212,12 @@ var CMICore = (function (_super) {
2234
2212
  },
2235
2213
  set: function (lesson_status) {
2236
2214
  if (this.initialized) {
2237
- if (check12ValidFormat(lesson_status, scorm12_cmi_scorm12_regex.CMIStatus)) {
2215
+ if (check12ValidFormat(lesson_status, regex.scorm12.CMIStatus)) {
2238
2216
  this._lesson_status = lesson_status;
2239
2217
  }
2240
2218
  }
2241
2219
  else {
2242
- if (check12ValidFormat(lesson_status, scorm12_cmi_scorm12_regex.CMIStatus2)) {
2220
+ if (check12ValidFormat(lesson_status, regex.scorm12.CMIStatus2)) {
2243
2221
  this._lesson_status = lesson_status;
2244
2222
  }
2245
2223
  }
@@ -2253,7 +2231,7 @@ var CMICore = (function (_super) {
2253
2231
  },
2254
2232
  set: function (entry) {
2255
2233
  if (this.initialized) {
2256
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2234
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2257
2235
  }
2258
2236
  else {
2259
2237
  this._entry = entry;
@@ -2268,7 +2246,7 @@ var CMICore = (function (_super) {
2268
2246
  },
2269
2247
  set: function (total_time) {
2270
2248
  if (this.initialized) {
2271
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2249
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2272
2250
  }
2273
2251
  else {
2274
2252
  this._total_time = total_time;
@@ -2283,7 +2261,7 @@ var CMICore = (function (_super) {
2283
2261
  },
2284
2262
  set: function (lesson_mode) {
2285
2263
  if (this.initialized) {
2286
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2264
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2287
2265
  }
2288
2266
  else {
2289
2267
  this._lesson_mode = lesson_mode;
@@ -2295,12 +2273,12 @@ var CMICore = (function (_super) {
2295
2273
  Object.defineProperty(CMICore.prototype, "exit", {
2296
2274
  get: function () {
2297
2275
  if (!this.jsonString) {
2298
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2276
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2299
2277
  }
2300
2278
  return this._exit;
2301
2279
  },
2302
2280
  set: function (exit) {
2303
- if (check12ValidFormat(exit, scorm12_cmi_scorm12_regex.CMIExit, true)) {
2281
+ if (check12ValidFormat(exit, regex.scorm12.CMIExit, true)) {
2304
2282
  this._exit = exit;
2305
2283
  }
2306
2284
  },
@@ -2310,12 +2288,12 @@ var CMICore = (function (_super) {
2310
2288
  Object.defineProperty(CMICore.prototype, "session_time", {
2311
2289
  get: function () {
2312
2290
  if (!this.jsonString) {
2313
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2291
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2314
2292
  }
2315
2293
  return this._session_time;
2316
2294
  },
2317
2295
  set: function (session_time) {
2318
- if (check12ValidFormat(session_time, scorm12_cmi_scorm12_regex.CMITimespan)) {
2296
+ if (check12ValidFormat(session_time, regex.scorm12.CMITimespan)) {
2319
2297
  this._session_time = session_time;
2320
2298
  }
2321
2299
  },
@@ -2327,7 +2305,7 @@ var CMICore = (function (_super) {
2327
2305
  return this._suspend_data;
2328
2306
  },
2329
2307
  set: function (suspend_data) {
2330
- if (check12ValidFormat(suspend_data, scorm12_cmi_scorm12_regex.CMIString4096, true)) {
2308
+ if (check12ValidFormat(suspend_data, regex.scorm12.CMIString4096, true)) {
2331
2309
  this._suspend_data = suspend_data;
2332
2310
  }
2333
2311
  },
@@ -2341,7 +2319,7 @@ var CMICore = (function (_super) {
2341
2319
  var seconds = new Date().getTime() - startTime;
2342
2320
  sessionTime = getSecondsAsHHMMSS(seconds / 1000);
2343
2321
  }
2344
- return addHHMMSSTimeStrings(this._total_time, sessionTime, new RegExp(scorm12_cmi_scorm12_regex.CMITimespan));
2322
+ return addHHMMSSTimeStrings(this._total_time, sessionTime, new RegExp(regex.scorm12.CMITimespan));
2345
2323
  };
2346
2324
  CMICore.prototype.toJSON = function () {
2347
2325
  this.jsonString = true;
@@ -2363,18 +2341,89 @@ var CMICore = (function (_super) {
2363
2341
  return CMICore;
2364
2342
  }(BaseCMI));
2365
2343
 
2344
+
2345
+ ;// ./src/cmi/scorm12/objectives.ts
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2366
2355
  var CMIObjectives = (function (_super) {
2367
2356
  __extends(CMIObjectives, _super);
2368
2357
  function CMIObjectives() {
2369
2358
  return _super.call(this, {
2370
- children: scorm12_cmi_scorm12_constants.objectives_children,
2371
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2359
+ children: api_constants.scorm12.objectives_children,
2360
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2372
2361
  errorClass: Scorm12ValidationError,
2373
2362
  }) || this;
2374
2363
  }
2375
2364
  return CMIObjectives;
2376
2365
  }(CMIArray));
2377
2366
 
2367
+ var CMIObjectivesObject = (function (_super) {
2368
+ __extends(CMIObjectivesObject, _super);
2369
+ function CMIObjectivesObject() {
2370
+ var _this = _super.call(this) || this;
2371
+ _this._id = "";
2372
+ _this._status = "";
2373
+ _this.score = new CMIScore({
2374
+ score_children: api_constants.scorm12.score_children,
2375
+ score_range: regex.scorm12.score_range,
2376
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
2377
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
2378
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
2379
+ errorClass: Scorm12ValidationError,
2380
+ });
2381
+ return _this;
2382
+ }
2383
+ Object.defineProperty(CMIObjectivesObject.prototype, "id", {
2384
+ get: function () {
2385
+ return this._id;
2386
+ },
2387
+ set: function (id) {
2388
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2389
+ this._id = id;
2390
+ }
2391
+ },
2392
+ enumerable: false,
2393
+ configurable: true
2394
+ });
2395
+ Object.defineProperty(CMIObjectivesObject.prototype, "status", {
2396
+ get: function () {
2397
+ return this._status;
2398
+ },
2399
+ set: function (status) {
2400
+ if (check12ValidFormat(status, regex.scorm12.CMIStatus2)) {
2401
+ this._status = status;
2402
+ }
2403
+ },
2404
+ enumerable: false,
2405
+ configurable: true
2406
+ });
2407
+ CMIObjectivesObject.prototype.toJSON = function () {
2408
+ this.jsonString = true;
2409
+ var result = {
2410
+ id: this.id,
2411
+ status: this.status,
2412
+ score: this.score,
2413
+ };
2414
+ delete this.jsonString;
2415
+ return result;
2416
+ };
2417
+ return CMIObjectivesObject;
2418
+ }(BaseCMI));
2419
+
2420
+
2421
+ ;// ./src/cmi/scorm12/student_data.ts
2422
+
2423
+
2424
+
2425
+
2426
+
2378
2427
  var CMIStudentData = (function (_super) {
2379
2428
  __extends(CMIStudentData, _super);
2380
2429
  function CMIStudentData(student_data_children) {
@@ -2384,7 +2433,7 @@ var CMIStudentData = (function (_super) {
2384
2433
  _this._time_limit_action = "";
2385
2434
  _this.__children = student_data_children
2386
2435
  ? student_data_children
2387
- : scorm12_cmi_scorm12_constants.student_data_children;
2436
+ : api_constants.scorm12.student_data_children;
2388
2437
  return _this;
2389
2438
  }
2390
2439
  Object.defineProperty(CMIStudentData.prototype, "_children", {
@@ -2392,7 +2441,7 @@ var CMIStudentData = (function (_super) {
2392
2441
  return this.__children;
2393
2442
  },
2394
2443
  set: function (_children) {
2395
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2444
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2396
2445
  },
2397
2446
  enumerable: false,
2398
2447
  configurable: true
@@ -2403,7 +2452,7 @@ var CMIStudentData = (function (_super) {
2403
2452
  },
2404
2453
  set: function (mastery_score) {
2405
2454
  if (this.initialized) {
2406
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2455
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2407
2456
  }
2408
2457
  else {
2409
2458
  this._mastery_score = mastery_score;
@@ -2418,7 +2467,7 @@ var CMIStudentData = (function (_super) {
2418
2467
  },
2419
2468
  set: function (max_time_allowed) {
2420
2469
  if (this.initialized) {
2421
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2470
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2422
2471
  }
2423
2472
  else {
2424
2473
  this._max_time_allowed = max_time_allowed;
@@ -2433,7 +2482,7 @@ var CMIStudentData = (function (_super) {
2433
2482
  },
2434
2483
  set: function (time_limit_action) {
2435
2484
  if (this.initialized) {
2436
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2485
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2437
2486
  }
2438
2487
  else {
2439
2488
  this._time_limit_action = time_limit_action;
@@ -2455,6 +2504,15 @@ var CMIStudentData = (function (_super) {
2455
2504
  return CMIStudentData;
2456
2505
  }(BaseCMI));
2457
2506
 
2507
+
2508
+ ;// ./src/cmi/scorm12/student_preference.ts
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2458
2516
  var CMIStudentPreference = (function (_super) {
2459
2517
  __extends(CMIStudentPreference, _super);
2460
2518
  function CMIStudentPreference(student_preference_children) {
@@ -2465,7 +2523,7 @@ var CMIStudentPreference = (function (_super) {
2465
2523
  _this._text = "";
2466
2524
  _this.__children = student_preference_children
2467
2525
  ? student_preference_children
2468
- : scorm12_cmi_scorm12_constants.student_preference_children;
2526
+ : api_constants.scorm12.student_preference_children;
2469
2527
  return _this;
2470
2528
  }
2471
2529
  Object.defineProperty(CMIStudentPreference.prototype, "_children", {
@@ -2473,7 +2531,7 @@ var CMIStudentPreference = (function (_super) {
2473
2531
  return this.__children;
2474
2532
  },
2475
2533
  set: function (_children) {
2476
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2534
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2477
2535
  },
2478
2536
  enumerable: false,
2479
2537
  configurable: true
@@ -2483,8 +2541,8 @@ var CMIStudentPreference = (function (_super) {
2483
2541
  return this._audio;
2484
2542
  },
2485
2543
  set: function (audio) {
2486
- if (check12ValidFormat(audio, scorm12_cmi_scorm12_regex.CMISInteger) &&
2487
- check12ValidRange(audio, scorm12_cmi_scorm12_regex.audio_range)) {
2544
+ if (check12ValidFormat(audio, regex.scorm12.CMISInteger) &&
2545
+ check12ValidRange(audio, regex.scorm12.audio_range)) {
2488
2546
  this._audio = audio;
2489
2547
  }
2490
2548
  },
@@ -2496,7 +2554,7 @@ var CMIStudentPreference = (function (_super) {
2496
2554
  return this._language;
2497
2555
  },
2498
2556
  set: function (language) {
2499
- if (check12ValidFormat(language, scorm12_cmi_scorm12_regex.CMIString256)) {
2557
+ if (check12ValidFormat(language, regex.scorm12.CMIString256)) {
2500
2558
  this._language = language;
2501
2559
  }
2502
2560
  },
@@ -2508,8 +2566,8 @@ var CMIStudentPreference = (function (_super) {
2508
2566
  return this._speed;
2509
2567
  },
2510
2568
  set: function (speed) {
2511
- if (check12ValidFormat(speed, scorm12_cmi_scorm12_regex.CMISInteger) &&
2512
- check12ValidRange(speed, scorm12_cmi_scorm12_regex.speed_range)) {
2569
+ if (check12ValidFormat(speed, regex.scorm12.CMISInteger) &&
2570
+ check12ValidRange(speed, regex.scorm12.speed_range)) {
2513
2571
  this._speed = speed;
2514
2572
  }
2515
2573
  },
@@ -2521,8 +2579,8 @@ var CMIStudentPreference = (function (_super) {
2521
2579
  return this._text;
2522
2580
  },
2523
2581
  set: function (text) {
2524
- if (check12ValidFormat(text, scorm12_cmi_scorm12_regex.CMISInteger) &&
2525
- check12ValidRange(text, scorm12_cmi_scorm12_regex.text_range)) {
2582
+ if (check12ValidFormat(text, regex.scorm12.CMISInteger) &&
2583
+ check12ValidRange(text, regex.scorm12.text_range)) {
2526
2584
  this._text = text;
2527
2585
  }
2528
2586
  },
@@ -2543,12 +2601,22 @@ var CMIStudentPreference = (function (_super) {
2543
2601
  return CMIStudentPreference;
2544
2602
  }(BaseCMI));
2545
2603
 
2604
+
2605
+ ;// ./src/cmi/scorm12/interactions.ts
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2613
+
2546
2614
  var CMIInteractions = (function (_super) {
2547
2615
  __extends(CMIInteractions, _super);
2548
2616
  function CMIInteractions() {
2549
2617
  return _super.call(this, {
2550
- children: scorm12_cmi_scorm12_constants.interactions_children,
2551
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2618
+ children: api_constants.scorm12.interactions_children,
2619
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2552
2620
  errorClass: Scorm12ValidationError,
2553
2621
  }) || this;
2554
2622
  }
@@ -2567,14 +2635,14 @@ var CMIInteractionsObject = (function (_super) {
2567
2635
  _this._result = "";
2568
2636
  _this._latency = "";
2569
2637
  _this.objectives = new CMIArray({
2570
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2638
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2571
2639
  errorClass: Scorm12ValidationError,
2572
- children: scorm12_cmi_scorm12_constants.objectives_children,
2640
+ children: api_constants.scorm12.objectives_children,
2573
2641
  });
2574
2642
  _this.correct_responses = new CMIArray({
2575
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2643
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2576
2644
  errorClass: Scorm12ValidationError,
2577
- children: scorm12_cmi_scorm12_constants.correct_responses_children,
2645
+ children: api_constants.scorm12.correct_responses_children,
2578
2646
  });
2579
2647
  return _this;
2580
2648
  }
@@ -2587,12 +2655,12 @@ var CMIInteractionsObject = (function (_super) {
2587
2655
  Object.defineProperty(CMIInteractionsObject.prototype, "id", {
2588
2656
  get: function () {
2589
2657
  if (!this.jsonString) {
2590
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2658
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2591
2659
  }
2592
2660
  return this._id;
2593
2661
  },
2594
2662
  set: function (id) {
2595
- if (check12ValidFormat(id, scorm12_cmi_scorm12_regex.CMIIdentifier)) {
2663
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2596
2664
  this._id = id;
2597
2665
  }
2598
2666
  },
@@ -2602,12 +2670,12 @@ var CMIInteractionsObject = (function (_super) {
2602
2670
  Object.defineProperty(CMIInteractionsObject.prototype, "time", {
2603
2671
  get: function () {
2604
2672
  if (!this.jsonString) {
2605
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2673
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2606
2674
  }
2607
2675
  return this._time;
2608
2676
  },
2609
2677
  set: function (time) {
2610
- if (check12ValidFormat(time, scorm12_cmi_scorm12_regex.CMITime)) {
2678
+ if (check12ValidFormat(time, regex.scorm12.CMITime)) {
2611
2679
  this._time = time;
2612
2680
  }
2613
2681
  },
@@ -2617,12 +2685,12 @@ var CMIInteractionsObject = (function (_super) {
2617
2685
  Object.defineProperty(CMIInteractionsObject.prototype, "type", {
2618
2686
  get: function () {
2619
2687
  if (!this.jsonString) {
2620
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2688
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2621
2689
  }
2622
2690
  return this._type;
2623
2691
  },
2624
2692
  set: function (type) {
2625
- if (check12ValidFormat(type, scorm12_cmi_scorm12_regex.CMIType)) {
2693
+ if (check12ValidFormat(type, regex.scorm12.CMIType)) {
2626
2694
  this._type = type;
2627
2695
  }
2628
2696
  },
@@ -2632,13 +2700,13 @@ var CMIInteractionsObject = (function (_super) {
2632
2700
  Object.defineProperty(CMIInteractionsObject.prototype, "weighting", {
2633
2701
  get: function () {
2634
2702
  if (!this.jsonString) {
2635
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2703
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2636
2704
  }
2637
2705
  return this._weighting;
2638
2706
  },
2639
2707
  set: function (weighting) {
2640
- if (check12ValidFormat(weighting, scorm12_cmi_scorm12_regex.CMIDecimal) &&
2641
- check12ValidRange(weighting, scorm12_cmi_scorm12_regex.weighting_range)) {
2708
+ if (check12ValidFormat(weighting, regex.scorm12.CMIDecimal) &&
2709
+ check12ValidRange(weighting, regex.scorm12.weighting_range)) {
2642
2710
  this._weighting = weighting;
2643
2711
  }
2644
2712
  },
@@ -2648,12 +2716,12 @@ var CMIInteractionsObject = (function (_super) {
2648
2716
  Object.defineProperty(CMIInteractionsObject.prototype, "student_response", {
2649
2717
  get: function () {
2650
2718
  if (!this.jsonString) {
2651
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2719
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2652
2720
  }
2653
2721
  return this._student_response;
2654
2722
  },
2655
2723
  set: function (student_response) {
2656
- if (check12ValidFormat(student_response, scorm12_cmi_scorm12_regex.CMIFeedback, true)) {
2724
+ if (check12ValidFormat(student_response, regex.scorm12.CMIFeedback, true)) {
2657
2725
  this._student_response = student_response;
2658
2726
  }
2659
2727
  },
@@ -2663,12 +2731,12 @@ var CMIInteractionsObject = (function (_super) {
2663
2731
  Object.defineProperty(CMIInteractionsObject.prototype, "result", {
2664
2732
  get: function () {
2665
2733
  if (!this.jsonString) {
2666
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2734
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2667
2735
  }
2668
2736
  return this._result;
2669
2737
  },
2670
2738
  set: function (result) {
2671
- if (check12ValidFormat(result, scorm12_cmi_scorm12_regex.CMIResult)) {
2739
+ if (check12ValidFormat(result, regex.scorm12.CMIResult)) {
2672
2740
  this._result = result;
2673
2741
  }
2674
2742
  },
@@ -2678,12 +2746,12 @@ var CMIInteractionsObject = (function (_super) {
2678
2746
  Object.defineProperty(CMIInteractionsObject.prototype, "latency", {
2679
2747
  get: function () {
2680
2748
  if (!this.jsonString) {
2681
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2749
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2682
2750
  }
2683
2751
  return this._latency;
2684
2752
  },
2685
2753
  set: function (latency) {
2686
- if (check12ValidFormat(latency, scorm12_cmi_scorm12_regex.CMITimespan)) {
2754
+ if (check12ValidFormat(latency, regex.scorm12.CMITimespan)) {
2687
2755
  this._latency = latency;
2688
2756
  }
2689
2757
  },
@@ -2709,59 +2777,6 @@ var CMIInteractionsObject = (function (_super) {
2709
2777
  return CMIInteractionsObject;
2710
2778
  }(BaseCMI));
2711
2779
 
2712
- var CMIObjectivesObject = (function (_super) {
2713
- __extends(CMIObjectivesObject, _super);
2714
- function CMIObjectivesObject() {
2715
- var _this = _super.call(this) || this;
2716
- _this._id = "";
2717
- _this._status = "";
2718
- _this.score = new CMIScore({
2719
- score_children: scorm12_cmi_scorm12_constants.score_children,
2720
- score_range: scorm12_cmi_scorm12_regex.score_range,
2721
- invalidErrorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2722
- invalidTypeCode: scorm12_cmi_scorm12_error_codes.TYPE_MISMATCH,
2723
- invalidRangeCode: scorm12_cmi_scorm12_error_codes.VALUE_OUT_OF_RANGE,
2724
- errorClass: Scorm12ValidationError,
2725
- });
2726
- return _this;
2727
- }
2728
- Object.defineProperty(CMIObjectivesObject.prototype, "id", {
2729
- get: function () {
2730
- return this._id;
2731
- },
2732
- set: function (id) {
2733
- if (check12ValidFormat(id, scorm12_cmi_scorm12_regex.CMIIdentifier)) {
2734
- this._id = id;
2735
- }
2736
- },
2737
- enumerable: false,
2738
- configurable: true
2739
- });
2740
- Object.defineProperty(CMIObjectivesObject.prototype, "status", {
2741
- get: function () {
2742
- return this._status;
2743
- },
2744
- set: function (status) {
2745
- if (check12ValidFormat(status, scorm12_cmi_scorm12_regex.CMIStatus2)) {
2746
- this._status = status;
2747
- }
2748
- },
2749
- enumerable: false,
2750
- configurable: true
2751
- });
2752
- CMIObjectivesObject.prototype.toJSON = function () {
2753
- this.jsonString = true;
2754
- var result = {
2755
- id: this.id,
2756
- status: this.status,
2757
- score: this.score,
2758
- };
2759
- delete this.jsonString;
2760
- return result;
2761
- };
2762
- return CMIObjectivesObject;
2763
- }(BaseCMI));
2764
-
2765
2780
  var CMIInteractionsObjectivesObject = (function (_super) {
2766
2781
  __extends(CMIInteractionsObjectivesObject, _super);
2767
2782
  function CMIInteractionsObjectivesObject() {
@@ -2774,7 +2789,7 @@ var CMIInteractionsObjectivesObject = (function (_super) {
2774
2789
  return this._id;
2775
2790
  },
2776
2791
  set: function (id) {
2777
- if (check12ValidFormat(id, scorm12_cmi_scorm12_regex.CMIIdentifier)) {
2792
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2778
2793
  this._id = id;
2779
2794
  }
2780
2795
  },
@@ -2802,12 +2817,12 @@ var CMIInteractionsCorrectResponsesObject = (function (_super) {
2802
2817
  Object.defineProperty(CMIInteractionsCorrectResponsesObject.prototype, "pattern", {
2803
2818
  get: function () {
2804
2819
  if (!this.jsonString) {
2805
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2820
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2806
2821
  }
2807
2822
  return this._pattern;
2808
2823
  },
2809
2824
  set: function (pattern) {
2810
- if (check12ValidFormat(pattern, scorm12_cmi_scorm12_regex.CMIFeedback, true)) {
2825
+ if (check12ValidFormat(pattern, regex.scorm12.CMIFeedback, true)) {
2811
2826
  this._pattern = pattern;
2812
2827
  }
2813
2828
  },
@@ -2825,6 +2840,153 @@ var CMIInteractionsCorrectResponsesObject = (function (_super) {
2825
2840
  return CMIInteractionsCorrectResponsesObject;
2826
2841
  }(BaseCMI));
2827
2842
 
2843
+
2844
+ ;// ./src/cmi/scorm12/cmi.ts
2845
+
2846
+
2847
+
2848
+
2849
+
2850
+
2851
+
2852
+
2853
+
2854
+
2855
+
2856
+
2857
+ var CMI = (function (_super) {
2858
+ __extends(CMI, _super);
2859
+ function CMI(cmi_children, student_data, initialized) {
2860
+ var _this = _super.call(this) || this;
2861
+ _this.__children = "";
2862
+ _this.__version = "3.4";
2863
+ _this._launch_data = "";
2864
+ _this._comments = "";
2865
+ _this._comments_from_lms = "";
2866
+ if (initialized)
2867
+ _this.initialize();
2868
+ _this.__children = cmi_children
2869
+ ? cmi_children
2870
+ : api_constants.scorm12.cmi_children;
2871
+ _this.core = new CMICore();
2872
+ _this.objectives = new CMIObjectives();
2873
+ _this.student_data = student_data ? student_data : new CMIStudentData();
2874
+ _this.student_preference = new CMIStudentPreference();
2875
+ _this.interactions = new CMIInteractions();
2876
+ return _this;
2877
+ }
2878
+ CMI.prototype.initialize = function () {
2879
+ var _a, _b, _c, _d, _e;
2880
+ _super.prototype.initialize.call(this);
2881
+ (_a = this.core) === null || _a === void 0 ? void 0 : _a.initialize();
2882
+ (_b = this.objectives) === null || _b === void 0 ? void 0 : _b.initialize();
2883
+ (_c = this.student_data) === null || _c === void 0 ? void 0 : _c.initialize();
2884
+ (_d = this.student_preference) === null || _d === void 0 ? void 0 : _d.initialize();
2885
+ (_e = this.interactions) === null || _e === void 0 ? void 0 : _e.initialize();
2886
+ };
2887
+ CMI.prototype.toJSON = function () {
2888
+ this.jsonString = true;
2889
+ var result = {
2890
+ suspend_data: this.suspend_data,
2891
+ launch_data: this.launch_data,
2892
+ comments: this.comments,
2893
+ comments_from_lms: this.comments_from_lms,
2894
+ core: this.core,
2895
+ objectives: this.objectives,
2896
+ student_data: this.student_data,
2897
+ student_preference: this.student_preference,
2898
+ interactions: this.interactions,
2899
+ };
2900
+ delete this.jsonString;
2901
+ return result;
2902
+ };
2903
+ Object.defineProperty(CMI.prototype, "_version", {
2904
+ get: function () {
2905
+ return this.__version;
2906
+ },
2907
+ set: function (_version) {
2908
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2909
+ },
2910
+ enumerable: false,
2911
+ configurable: true
2912
+ });
2913
+ Object.defineProperty(CMI.prototype, "_children", {
2914
+ get: function () {
2915
+ return this.__children;
2916
+ },
2917
+ set: function (_children) {
2918
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2919
+ },
2920
+ enumerable: false,
2921
+ configurable: true
2922
+ });
2923
+ Object.defineProperty(CMI.prototype, "suspend_data", {
2924
+ get: function () {
2925
+ var _a;
2926
+ return (_a = this.core) === null || _a === void 0 ? void 0 : _a.suspend_data;
2927
+ },
2928
+ set: function (suspend_data) {
2929
+ if (this.core) {
2930
+ this.core.suspend_data = suspend_data;
2931
+ }
2932
+ },
2933
+ enumerable: false,
2934
+ configurable: true
2935
+ });
2936
+ Object.defineProperty(CMI.prototype, "launch_data", {
2937
+ get: function () {
2938
+ return this._launch_data;
2939
+ },
2940
+ set: function (launch_data) {
2941
+ if (this.initialized) {
2942
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2943
+ }
2944
+ else {
2945
+ this._launch_data = launch_data;
2946
+ }
2947
+ },
2948
+ enumerable: false,
2949
+ configurable: true
2950
+ });
2951
+ Object.defineProperty(CMI.prototype, "comments", {
2952
+ get: function () {
2953
+ return this._comments;
2954
+ },
2955
+ set: function (comments) {
2956
+ if (check12ValidFormat(comments, regex.scorm12.CMIString4096, true)) {
2957
+ this._comments = comments;
2958
+ }
2959
+ },
2960
+ enumerable: false,
2961
+ configurable: true
2962
+ });
2963
+ Object.defineProperty(CMI.prototype, "comments_from_lms", {
2964
+ get: function () {
2965
+ return this._comments_from_lms;
2966
+ },
2967
+ set: function (comments_from_lms) {
2968
+ if (this.initialized) {
2969
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2970
+ }
2971
+ else {
2972
+ this._comments_from_lms = comments_from_lms;
2973
+ }
2974
+ },
2975
+ enumerable: false,
2976
+ configurable: true
2977
+ });
2978
+ CMI.prototype.getCurrentTotalTime = function () {
2979
+ return this.core.getCurrentTotalTime(this.start_time);
2980
+ };
2981
+ return CMI;
2982
+ }(BaseRootCMI));
2983
+
2984
+
2985
+ ;// ./src/cmi/scorm12/nav.ts
2986
+
2987
+
2988
+
2989
+
2828
2990
  var NAV = (function (_super) {
2829
2991
  __extends(NAV, _super);
2830
2992
  function NAV() {
@@ -2837,7 +2999,7 @@ var NAV = (function (_super) {
2837
2999
  return this._event;
2838
3000
  },
2839
3001
  set: function (event) {
2840
- if (check12ValidFormat(event, scorm12_cmi_scorm12_regex.NAVEvent)) {
3002
+ if (check12ValidFormat(event, regex.scorm12.NAVEvent)) {
2841
3003
  this._event = event;
2842
3004
  }
2843
3005
  },
@@ -2856,6 +3018,26 @@ var NAV = (function (_super) {
2856
3018
  }(BaseCMI));
2857
3019
 
2858
3020
 
3021
+ ;// ./src/constants/enums.ts
3022
+ var NAVBoolean;
3023
+ (function (NAVBoolean) {
3024
+ NAVBoolean["unknown"] = "unknown";
3025
+ NAVBoolean["true"] = "true";
3026
+ NAVBoolean["false"] = "false";
3027
+ })(NAVBoolean || (NAVBoolean = {}));
3028
+ var SuccessStatus;
3029
+ (function (SuccessStatus) {
3030
+ SuccessStatus["passed"] = "passed";
3031
+ SuccessStatus["failed"] = "failed";
3032
+ SuccessStatus["unknown"] = "unknown";
3033
+ })(SuccessStatus || (SuccessStatus = {}));
3034
+ var CompletionStatus;
3035
+ (function (CompletionStatus) {
3036
+ CompletionStatus["completed"] = "completed";
3037
+ CompletionStatus["incomplete"] = "incomplete";
3038
+ CompletionStatus["unknown"] = "unknown";
3039
+ })(CompletionStatus || (CompletionStatus = {}));
3040
+
2859
3041
  ;// ./src/Scorm12API.ts
2860
3042
 
2861
3043
 
@@ -2863,9 +3045,12 @@ var NAV = (function (_super) {
2863
3045
 
2864
3046
 
2865
3047
 
2866
- var Scorm12API_scorm12_constants = api_constants.scorm12;
2867
- var Scorm12API_global_constants = api_constants.global;
2868
- var Scorm12API_scorm12_error_codes = error_codes.scorm12;
3048
+
3049
+
3050
+
3051
+
3052
+
3053
+
2869
3054
  var Scorm12API = (function (_super) {
2870
3055
  __extends(Scorm12API, _super);
2871
3056
  function Scorm12API(settings) {
@@ -2875,7 +3060,8 @@ var Scorm12API = (function (_super) {
2875
3060
  settings.mastery_override = false;
2876
3061
  }
2877
3062
  }
2878
- _this = _super.call(this, Scorm12API_scorm12_error_codes, settings) || this;
3063
+ _this = _super.call(this, error_codes.scorm12, settings) || this;
3064
+ _this.statusSetByModule = false;
2879
3065
  _this.cmi = new CMI();
2880
3066
  _this.nav = new NAV();
2881
3067
  _this.LMSInitialize = _this.lmsInitialize;
@@ -2888,35 +3074,83 @@ var Scorm12API = (function (_super) {
2888
3074
  _this.LMSGetDiagnostic = _this.lmsGetDiagnostic;
2889
3075
  return _this;
2890
3076
  }
3077
+ Scorm12API.prototype.reset = function (settings) {
3078
+ this.commonReset(settings);
3079
+ this.cmi = new CMI();
3080
+ this.nav = new NAV();
3081
+ };
2891
3082
  Scorm12API.prototype.lmsInitialize = function () {
2892
3083
  this.cmi.initialize();
3084
+ if (this.cmi.core.lesson_status) {
3085
+ this.statusSetByModule = true;
3086
+ }
3087
+ else {
3088
+ this.cmi.core.lesson_status = "not attempted";
3089
+ }
2893
3090
  return this.initialize("LMSInitialize", "LMS was already initialized!", "LMS is already finished!");
2894
3091
  };
2895
3092
  Scorm12API.prototype.lmsFinish = function () {
2896
- var result = this.terminate("LMSFinish", true);
2897
- if (result === Scorm12API_global_constants.SCORM_TRUE) {
2898
- if (this.nav.event !== "") {
2899
- if (this.nav.event === "continue") {
2900
- this.processListeners("SequenceNext");
3093
+ var _this = this;
3094
+ (function () { return __awaiter(_this, void 0, void 0, function () {
3095
+ return __generator(this, function (_a) {
3096
+ switch (_a.label) {
3097
+ case 0: return [4, this.internalFinish()];
3098
+ case 1:
3099
+ _a.sent();
3100
+ return [2];
2901
3101
  }
2902
- else {
2903
- this.processListeners("SequencePrevious");
3102
+ });
3103
+ }); })();
3104
+ return api_constants.global.SCORM_TRUE;
3105
+ };
3106
+ Scorm12API.prototype.internalFinish = function () {
3107
+ return __awaiter(this, void 0, void 0, function () {
3108
+ var result;
3109
+ return __generator(this, function (_a) {
3110
+ switch (_a.label) {
3111
+ case 0: return [4, this.terminate("LMSFinish", true)];
3112
+ case 1:
3113
+ result = _a.sent();
3114
+ if (result === api_constants.global.SCORM_TRUE) {
3115
+ if (this.nav.event !== "") {
3116
+ if (this.nav.event === "continue") {
3117
+ this.processListeners("SequenceNext");
3118
+ }
3119
+ else {
3120
+ this.processListeners("SequencePrevious");
3121
+ }
3122
+ }
3123
+ else if (this.settings.autoProgress) {
3124
+ this.processListeners("SequenceNext");
3125
+ }
3126
+ }
3127
+ return [2, result];
2904
3128
  }
2905
- }
2906
- else if (this.settings.autoProgress) {
2907
- this.processListeners("SequenceNext");
2908
- }
2909
- }
2910
- return result;
3129
+ });
3130
+ });
2911
3131
  };
2912
3132
  Scorm12API.prototype.lmsGetValue = function (CMIElement) {
2913
3133
  return this.getValue("LMSGetValue", false, CMIElement);
2914
3134
  };
2915
3135
  Scorm12API.prototype.lmsSetValue = function (CMIElement, value) {
3136
+ if (CMIElement === "cmi.core.lesson_status") {
3137
+ this.statusSetByModule = true;
3138
+ }
2916
3139
  return this.setValue("LMSSetValue", "LMSCommit", false, CMIElement, value);
2917
3140
  };
2918
3141
  Scorm12API.prototype.lmsCommit = function () {
2919
- return this.commit("LMSCommit", false);
3142
+ var _this = this;
3143
+ (function () { return __awaiter(_this, void 0, void 0, function () {
3144
+ return __generator(this, function (_a) {
3145
+ switch (_a.label) {
3146
+ case 0: return [4, this.commit("LMSCommit", false)];
3147
+ case 1:
3148
+ _a.sent();
3149
+ return [2];
3150
+ }
3151
+ });
3152
+ }); })();
3153
+ return api_constants.global.SCORM_TRUE;
2920
3154
  };
2921
3155
  Scorm12API.prototype.lmsGetLastError = function () {
2922
3156
  return this.getLastError("LMSGetLastError");
@@ -2934,19 +3168,19 @@ var Scorm12API = (function (_super) {
2934
3168
  return this._commonGetCMIValue("getCMIValue", false, CMIElement);
2935
3169
  };
2936
3170
  Scorm12API.prototype.getChildElement = function (CMIElement, _value, foundFirstIndex) {
2937
- if (this.stringMatches(CMIElement, "cmi\\.objectives\\.\\d+")) {
3171
+ if (stringMatches(CMIElement, "cmi\\.objectives\\.\\d+")) {
2938
3172
  return new CMIObjectivesObject();
2939
3173
  }
2940
3174
  else if (foundFirstIndex &&
2941
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")) {
3175
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")) {
2942
3176
  return new CMIInteractionsCorrectResponsesObject();
2943
3177
  }
2944
3178
  else if (foundFirstIndex &&
2945
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
3179
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
2946
3180
  return new CMIInteractionsObjectivesObject();
2947
3181
  }
2948
3182
  else if (!foundFirstIndex &&
2949
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
3183
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
2950
3184
  return new CMIInteractionsObject();
2951
3185
  }
2952
3186
  return null;
@@ -2957,11 +3191,11 @@ var Scorm12API = (function (_super) {
2957
3191
  var basicMessage = "No Error";
2958
3192
  var detailMessage = "No Error";
2959
3193
  errorNumber = String(errorNumber);
2960
- if (Scorm12API_scorm12_constants.error_descriptions[errorNumber]) {
3194
+ if (api_constants.scorm12.error_descriptions[errorNumber]) {
2961
3195
  basicMessage =
2962
- Scorm12API_scorm12_constants.error_descriptions[errorNumber].basicMessage;
3196
+ api_constants.scorm12.error_descriptions[errorNumber].basicMessage;
2963
3197
  detailMessage =
2964
- Scorm12API_scorm12_constants.error_descriptions[errorNumber].detailMessage;
3198
+ api_constants.scorm12.error_descriptions[errorNumber].detailMessage;
2965
3199
  }
2966
3200
  return detail ? detailMessage : basicMessage;
2967
3201
  };
@@ -2990,112 +3224,124 @@ var Scorm12API = (function (_super) {
2990
3224
  return cmiExport;
2991
3225
  }
2992
3226
  };
2993
- Scorm12API.prototype.storeData = function (terminateCommit) {
2994
- var _a, _b, _c;
2995
- if (terminateCommit) {
2996
- var originalStatus = this.cmi.core.lesson_status;
2997
- if (originalStatus === "not attempted") {
2998
- this.cmi.core.lesson_status = "completed";
2999
- }
3000
- if (this.cmi.core.lesson_mode === "normal") {
3001
- if (this.cmi.core.credit === "credit") {
3002
- if (this.settings.mastery_override &&
3003
- this.cmi.student_data.mastery_score !== "" &&
3004
- this.cmi.core.score.raw !== "") {
3005
- if (parseFloat(this.cmi.core.score.raw) >=
3006
- parseFloat(this.cmi.student_data.mastery_score)) {
3007
- this.cmi.core.lesson_status = "passed";
3008
- }
3009
- else {
3010
- this.cmi.core.lesson_status = "failed";
3011
- }
3012
- }
3013
- }
3014
- }
3015
- else if (this.cmi.core.lesson_mode === "browse") {
3016
- if ((((_c = (_b = (_a = this.startingData) === null || _a === void 0 ? void 0 : _a.cmi) === null || _b === void 0 ? void 0 : _b.core) === null || _c === void 0 ? void 0 : _c.lesson_status) || "") === "" &&
3017
- originalStatus === "not attempted") {
3018
- this.cmi.core.lesson_status = "browsed";
3019
- }
3227
+ Scorm12API.prototype.renderCommitObject = function (terminateCommit) {
3228
+ var cmiExport = this.renderCommitCMI(terminateCommit);
3229
+ var totalTimeHHMMSS = this.cmi.getCurrentTotalTime();
3230
+ var totalTimeSeconds = getTimeAsSeconds(totalTimeHHMMSS, regex.scorm12.CMITimespan);
3231
+ var lessonStatus = this.cmi.core.lesson_status;
3232
+ var completionStatus = CompletionStatus.unknown;
3233
+ var successStatus = SuccessStatus.unknown;
3234
+ if (lessonStatus) {
3235
+ completionStatus =
3236
+ lessonStatus === "completed" || lessonStatus === "passed"
3237
+ ? CompletionStatus.completed
3238
+ : CompletionStatus.incomplete;
3239
+ if (lessonStatus === "passed") {
3240
+ successStatus = SuccessStatus.passed;
3241
+ }
3242
+ else if (lessonStatus === "failed") {
3243
+ successStatus = SuccessStatus.failed;
3020
3244
  }
3021
3245
  }
3022
- var commitObject = this.renderCommitCMI(terminateCommit || this.settings.alwaysSendTotalTime);
3023
- if (this.apiLogLevel === Scorm12API_global_constants.LOG_LEVEL_DEBUG) {
3024
- console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
3025
- console.debug(commitObject);
3026
- }
3027
- if (typeof this.settings.lmsCommitUrl === "string") {
3028
- return this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit);
3246
+ var score = this.cmi.core.score;
3247
+ var scoreObject = null;
3248
+ if (score) {
3249
+ scoreObject = {};
3250
+ if (!Number.isNaN(Number.parseFloat(score.raw))) {
3251
+ scoreObject.raw = Number.parseFloat(score.raw);
3252
+ }
3253
+ if (!Number.isNaN(Number.parseFloat(score.min))) {
3254
+ scoreObject.min = Number.parseFloat(score.min);
3255
+ }
3256
+ if (!Number.isNaN(Number.parseFloat(score.max))) {
3257
+ scoreObject.max = Number.parseFloat(score.max);
3258
+ }
3029
3259
  }
3030
- else {
3031
- return {
3032
- result: Scorm12API_global_constants.SCORM_TRUE,
3033
- errorCode: 0,
3034
- };
3260
+ var commitObject = {
3261
+ successStatus: successStatus,
3262
+ completionStatus: completionStatus,
3263
+ runtimeData: cmiExport,
3264
+ totalTimeSeconds: totalTimeSeconds,
3265
+ };
3266
+ if (scoreObject) {
3267
+ commitObject.score = scoreObject;
3035
3268
  }
3269
+ return commitObject;
3036
3270
  };
3037
- return Scorm12API;
3038
- }(src_BaseAPI));
3039
- /* harmony default export */ var src_Scorm12API = (Scorm12API);
3040
-
3041
- ;// ./src/cmi/aicc_cmi.ts
3042
-
3043
-
3044
-
3045
-
3046
-
3047
-
3048
-
3049
- var aicc_constants = api_constants.aicc;
3050
- var aicc_regex = regex.aicc;
3051
- var aicc_error_codes = error_codes.scorm12;
3052
- function checkAICCValidFormat(value, regexPattern, allowEmptyString) {
3271
+ Scorm12API.prototype.storeData = function (terminateCommit) {
3272
+ return __awaiter(this, void 0, void 0, function () {
3273
+ var originalStatus, shouldTerminateCommit, commitObject;
3274
+ var _a, _b, _c;
3275
+ return __generator(this, function (_d) {
3276
+ switch (_d.label) {
3277
+ case 0:
3278
+ if (terminateCommit) {
3279
+ originalStatus = this.cmi.core.lesson_status;
3280
+ if (!this.cmi.core.lesson_status ||
3281
+ (!this.statusSetByModule &&
3282
+ this.cmi.core.lesson_status === "not attempted")) {
3283
+ this.cmi.core.lesson_status = "completed";
3284
+ }
3285
+ if (this.cmi.core.lesson_mode === "normal") {
3286
+ if (this.cmi.core.credit === "credit") {
3287
+ if (this.settings.mastery_override &&
3288
+ this.cmi.student_data.mastery_score !== "" &&
3289
+ this.cmi.core.score.raw !== "") {
3290
+ this.cmi.core.lesson_status =
3291
+ parseFloat(this.cmi.core.score.raw) >=
3292
+ parseFloat(this.cmi.student_data.mastery_score)
3293
+ ? "passed"
3294
+ : "failed";
3295
+ }
3296
+ }
3297
+ }
3298
+ else if (this.cmi.core.lesson_mode === "browse") {
3299
+ if ((((_c = (_b = (_a = this.startingData) === null || _a === void 0 ? void 0 : _a.cmi) === null || _b === void 0 ? void 0 : _b.core) === null || _c === void 0 ? void 0 : _c.lesson_status) || "") === "" &&
3300
+ originalStatus === "not attempted") {
3301
+ this.cmi.core.lesson_status = "browsed";
3302
+ }
3303
+ }
3304
+ }
3305
+ shouldTerminateCommit = terminateCommit || this.settings.alwaysSendTotalTime;
3306
+ commitObject = this.settings.renderCommonCommitFields
3307
+ ? this.renderCommitObject(shouldTerminateCommit)
3308
+ : this.renderCommitCMI(shouldTerminateCommit);
3309
+ if (this.apiLogLevel === api_constants.global.LOG_LEVEL_DEBUG) {
3310
+ console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
3311
+ console.debug(commitObject);
3312
+ }
3313
+ if (!(typeof this.settings.lmsCommitUrl === "string")) return [3, 2];
3314
+ return [4, this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit)];
3315
+ case 1: return [2, _d.sent()];
3316
+ case 2: return [2, {
3317
+ result: api_constants.global.SCORM_TRUE,
3318
+ errorCode: 0,
3319
+ }];
3320
+ }
3321
+ });
3322
+ });
3323
+ };
3324
+ return Scorm12API;
3325
+ }(src_BaseAPI));
3326
+ /* harmony default export */ var src_Scorm12API = (Scorm12API);
3327
+
3328
+ ;// ./src/cmi/aicc/validation.ts
3329
+
3330
+
3331
+
3332
+ var aicc_error_codes = error_codes.scorm12;
3333
+ function checkAICCValidFormat(value, regexPattern, allowEmptyString) {
3053
3334
  return checkValidFormat(value, regexPattern, aicc_error_codes.TYPE_MISMATCH, AICCValidationError, allowEmptyString);
3054
3335
  }
3055
- var aicc_cmi_CMI = (function (_super) {
3056
- __extends(CMI, _super);
3057
- function CMI(initialized) {
3058
- if (initialized === void 0) { initialized = false; }
3059
- var _this = _super.call(this, aicc_constants.cmi_children) || this;
3060
- if (initialized)
3061
- _this.initialize();
3062
- _this.student_preference = new AICCStudentPreferences();
3063
- _this.student_data = new AICCCMIStudentData();
3064
- _this.student_demographics = new CMIStudentDemographics();
3065
- _this.evaluation = new CMIEvaluation();
3066
- _this.paths = new CMIPaths();
3067
- return _this;
3068
- }
3069
- CMI.prototype.initialize = function () {
3070
- var _a, _b, _c, _d, _e;
3071
- _super.prototype.initialize.call(this);
3072
- (_a = this.student_preference) === null || _a === void 0 ? void 0 : _a.initialize();
3073
- (_b = this.student_data) === null || _b === void 0 ? void 0 : _b.initialize();
3074
- (_c = this.student_demographics) === null || _c === void 0 ? void 0 : _c.initialize();
3075
- (_d = this.evaluation) === null || _d === void 0 ? void 0 : _d.initialize();
3076
- (_e = this.paths) === null || _e === void 0 ? void 0 : _e.initialize();
3077
- };
3078
- CMI.prototype.toJSON = function () {
3079
- this.jsonString = true;
3080
- var result = {
3081
- suspend_data: this.suspend_data,
3082
- launch_data: this.launch_data,
3083
- comments: this.comments,
3084
- comments_from_lms: this.comments_from_lms,
3085
- core: this.core,
3086
- objectives: this.objectives,
3087
- student_data: this.student_data,
3088
- student_preference: this.student_preference,
3089
- student_demographics: this.student_demographics,
3090
- interactions: this.interactions,
3091
- evaluation: this.evaluation,
3092
- paths: this.paths,
3093
- };
3094
- delete this.jsonString;
3095
- return result;
3096
- };
3097
- return CMI;
3098
- }(CMI));
3336
+
3337
+ ;// ./src/cmi/aicc/evaluation.ts
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+
3099
3345
 
3100
3346
  var CMIEvaluation = (function (_super) {
3101
3347
  __extends(CMIEvaluation, _super);
@@ -3119,28 +3365,97 @@ var CMIEvaluation = (function (_super) {
3119
3365
  };
3120
3366
  return CMIEvaluation;
3121
3367
  }(BaseCMI));
3368
+
3122
3369
  var CMIEvaluationComments = (function (_super) {
3123
3370
  __extends(CMIEvaluationComments, _super);
3124
3371
  function CMIEvaluationComments() {
3125
3372
  return _super.call(this, {
3126
- children: aicc_constants.comments_children,
3127
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
3373
+ children: api_constants.aicc.comments_children,
3374
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
3128
3375
  errorClass: AICCValidationError,
3129
3376
  }) || this;
3130
3377
  }
3131
3378
  return CMIEvaluationComments;
3132
3379
  }(CMIArray));
3380
+ var CMIEvaluationCommentsObject = (function (_super) {
3381
+ __extends(CMIEvaluationCommentsObject, _super);
3382
+ function CMIEvaluationCommentsObject() {
3383
+ var _this = _super.call(this) || this;
3384
+ _this._content = "";
3385
+ _this._location = "";
3386
+ _this._time = "";
3387
+ return _this;
3388
+ }
3389
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "content", {
3390
+ get: function () {
3391
+ return this._content;
3392
+ },
3393
+ set: function (content) {
3394
+ if (checkAICCValidFormat(content, regex.aicc.CMIString256)) {
3395
+ this._content = content;
3396
+ }
3397
+ },
3398
+ enumerable: false,
3399
+ configurable: true
3400
+ });
3401
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "location", {
3402
+ get: function () {
3403
+ return this._location;
3404
+ },
3405
+ set: function (location) {
3406
+ if (checkAICCValidFormat(location, regex.aicc.CMIString256)) {
3407
+ this._location = location;
3408
+ }
3409
+ },
3410
+ enumerable: false,
3411
+ configurable: true
3412
+ });
3413
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "time", {
3414
+ get: function () {
3415
+ return this._time;
3416
+ },
3417
+ set: function (time) {
3418
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3419
+ this._time = time;
3420
+ }
3421
+ },
3422
+ enumerable: false,
3423
+ configurable: true
3424
+ });
3425
+ CMIEvaluationCommentsObject.prototype.toJSON = function () {
3426
+ this.jsonString = true;
3427
+ var result = {
3428
+ content: this.content,
3429
+ location: this.location,
3430
+ time: this.time,
3431
+ };
3432
+ delete this.jsonString;
3433
+ return result;
3434
+ };
3435
+ return CMIEvaluationCommentsObject;
3436
+ }(BaseCMI));
3437
+
3438
+
3439
+ ;// ./src/cmi/aicc/student_preferences.ts
3440
+
3441
+
3442
+
3443
+
3444
+
3445
+
3446
+
3447
+
3133
3448
  var AICCStudentPreferences = (function (_super) {
3134
3449
  __extends(AICCStudentPreferences, _super);
3135
3450
  function AICCStudentPreferences() {
3136
- var _this = _super.call(this, aicc_constants.student_preference_children) || this;
3451
+ var _this = _super.call(this, api_constants.aicc.student_preference_children) || this;
3137
3452
  _this._lesson_type = "";
3138
3453
  _this._text_color = "";
3139
3454
  _this._text_location = "";
3140
3455
  _this._text_size = "";
3141
3456
  _this._video = "";
3142
3457
  _this.windows = new CMIArray({
3143
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
3458
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
3144
3459
  errorClass: AICCValidationError,
3145
3460
  children: "",
3146
3461
  });
@@ -3156,7 +3471,7 @@ var AICCStudentPreferences = (function (_super) {
3156
3471
  return this._lesson_type;
3157
3472
  },
3158
3473
  set: function (lesson_type) {
3159
- if (checkAICCValidFormat(lesson_type, aicc_regex.CMIString256)) {
3474
+ if (checkAICCValidFormat(lesson_type, regex.aicc.CMIString256)) {
3160
3475
  this._lesson_type = lesson_type;
3161
3476
  }
3162
3477
  },
@@ -3168,7 +3483,7 @@ var AICCStudentPreferences = (function (_super) {
3168
3483
  return this._text_color;
3169
3484
  },
3170
3485
  set: function (text_color) {
3171
- if (checkAICCValidFormat(text_color, aicc_regex.CMIString256)) {
3486
+ if (checkAICCValidFormat(text_color, regex.aicc.CMIString256)) {
3172
3487
  this._text_color = text_color;
3173
3488
  }
3174
3489
  },
@@ -3180,7 +3495,7 @@ var AICCStudentPreferences = (function (_super) {
3180
3495
  return this._text_location;
3181
3496
  },
3182
3497
  set: function (text_location) {
3183
- if (checkAICCValidFormat(text_location, aicc_regex.CMIString256)) {
3498
+ if (checkAICCValidFormat(text_location, regex.aicc.CMIString256)) {
3184
3499
  this._text_location = text_location;
3185
3500
  }
3186
3501
  },
@@ -3192,7 +3507,7 @@ var AICCStudentPreferences = (function (_super) {
3192
3507
  return this._text_size;
3193
3508
  },
3194
3509
  set: function (text_size) {
3195
- if (checkAICCValidFormat(text_size, aicc_regex.CMIString256)) {
3510
+ if (checkAICCValidFormat(text_size, regex.aicc.CMIString256)) {
3196
3511
  this._text_size = text_size;
3197
3512
  }
3198
3513
  },
@@ -3204,7 +3519,7 @@ var AICCStudentPreferences = (function (_super) {
3204
3519
  return this._video;
3205
3520
  },
3206
3521
  set: function (video) {
3207
- if (checkAICCValidFormat(video, aicc_regex.CMIString256)) {
3522
+ if (checkAICCValidFormat(video, regex.aicc.CMIString256)) {
3208
3523
  this._video = video;
3209
3524
  }
3210
3525
  },
@@ -3230,52 +3545,19 @@ var AICCStudentPreferences = (function (_super) {
3230
3545
  };
3231
3546
  return AICCStudentPreferences;
3232
3547
  }(CMIStudentPreference));
3233
- var AICCCMIStudentData = (function (_super) {
3234
- __extends(AICCCMIStudentData, _super);
3235
- function AICCCMIStudentData() {
3236
- var _this = _super.call(this, aicc_constants.student_data_children) || this;
3237
- _this._tries_during_lesson = "";
3238
- _this.tries = new CMITries();
3239
- return _this;
3240
- }
3241
- AICCCMIStudentData.prototype.initialize = function () {
3242
- var _a;
3243
- _super.prototype.initialize.call(this);
3244
- (_a = this.tries) === null || _a === void 0 ? void 0 : _a.initialize();
3245
- };
3246
- Object.defineProperty(AICCCMIStudentData.prototype, "tries_during_lesson", {
3247
- get: function () {
3248
- return this._tries_during_lesson;
3249
- },
3250
- set: function (tries_during_lesson) {
3251
- if (this.initialized) {
3252
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3253
- }
3254
- else {
3255
- this._tries_during_lesson = tries_during_lesson;
3256
- }
3257
- },
3258
- enumerable: false,
3259
- configurable: true
3260
- });
3261
- AICCCMIStudentData.prototype.toJSON = function () {
3262
- this.jsonString = true;
3263
- var result = {
3264
- mastery_score: this.mastery_score,
3265
- max_time_allowed: this.max_time_allowed,
3266
- time_limit_action: this.time_limit_action,
3267
- tries: this.tries,
3268
- };
3269
- delete this.jsonString;
3270
- return result;
3271
- };
3272
- return AICCCMIStudentData;
3273
- }(CMIStudentData));
3548
+
3549
+
3550
+ ;// ./src/cmi/aicc/student_demographics.ts
3551
+
3552
+
3553
+
3554
+
3555
+
3274
3556
  var CMIStudentDemographics = (function (_super) {
3275
3557
  __extends(CMIStudentDemographics, _super);
3276
3558
  function CMIStudentDemographics() {
3277
3559
  var _this = _super.call(this) || this;
3278
- _this.__children = aicc_constants.student_demographics_children;
3560
+ _this.__children = api_constants.aicc.student_demographics_children;
3279
3561
  _this._city = "";
3280
3562
  _this._class = "";
3281
3563
  _this._company = "";
@@ -3304,7 +3586,7 @@ var CMIStudentDemographics = (function (_super) {
3304
3586
  },
3305
3587
  set: function (city) {
3306
3588
  if (this.initialized) {
3307
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3589
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3308
3590
  }
3309
3591
  else {
3310
3592
  this._city = city;
@@ -3319,7 +3601,7 @@ var CMIStudentDemographics = (function (_super) {
3319
3601
  },
3320
3602
  set: function (clazz) {
3321
3603
  if (this.initialized) {
3322
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3604
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3323
3605
  }
3324
3606
  else {
3325
3607
  this._class = clazz;
@@ -3334,7 +3616,7 @@ var CMIStudentDemographics = (function (_super) {
3334
3616
  },
3335
3617
  set: function (company) {
3336
3618
  if (this.initialized) {
3337
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3619
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3338
3620
  }
3339
3621
  else {
3340
3622
  this._company = company;
@@ -3349,7 +3631,7 @@ var CMIStudentDemographics = (function (_super) {
3349
3631
  },
3350
3632
  set: function (country) {
3351
3633
  if (this.initialized) {
3352
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3634
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3353
3635
  }
3354
3636
  else {
3355
3637
  this._country = country;
@@ -3364,7 +3646,7 @@ var CMIStudentDemographics = (function (_super) {
3364
3646
  },
3365
3647
  set: function (experience) {
3366
3648
  if (this.initialized) {
3367
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3649
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3368
3650
  }
3369
3651
  else {
3370
3652
  this._experience = experience;
@@ -3379,7 +3661,7 @@ var CMIStudentDemographics = (function (_super) {
3379
3661
  },
3380
3662
  set: function (familiar_name) {
3381
3663
  if (this.initialized) {
3382
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3664
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3383
3665
  }
3384
3666
  else {
3385
3667
  this._familiar_name = familiar_name;
@@ -3394,7 +3676,7 @@ var CMIStudentDemographics = (function (_super) {
3394
3676
  },
3395
3677
  set: function (instructor_name) {
3396
3678
  if (this.initialized) {
3397
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3679
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3398
3680
  }
3399
3681
  else {
3400
3682
  this._instructor_name = instructor_name;
@@ -3409,7 +3691,7 @@ var CMIStudentDemographics = (function (_super) {
3409
3691
  },
3410
3692
  set: function (title) {
3411
3693
  if (this.initialized) {
3412
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3694
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3413
3695
  }
3414
3696
  else {
3415
3697
  this._title = title;
@@ -3424,7 +3706,7 @@ var CMIStudentDemographics = (function (_super) {
3424
3706
  },
3425
3707
  set: function (native_language) {
3426
3708
  if (this.initialized) {
3427
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3709
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3428
3710
  }
3429
3711
  else {
3430
3712
  this._native_language = native_language;
@@ -3439,7 +3721,7 @@ var CMIStudentDemographics = (function (_super) {
3439
3721
  },
3440
3722
  set: function (state) {
3441
3723
  if (this.initialized) {
3442
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3724
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3443
3725
  }
3444
3726
  else {
3445
3727
  this._state = state;
@@ -3454,7 +3736,7 @@ var CMIStudentDemographics = (function (_super) {
3454
3736
  },
3455
3737
  set: function (street_address) {
3456
3738
  if (this.initialized) {
3457
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3739
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3458
3740
  }
3459
3741
  else {
3460
3742
  this._street_address = street_address;
@@ -3469,7 +3751,7 @@ var CMIStudentDemographics = (function (_super) {
3469
3751
  },
3470
3752
  set: function (telephone) {
3471
3753
  if (this.initialized) {
3472
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3754
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3473
3755
  }
3474
3756
  else {
3475
3757
  this._telephone = telephone;
@@ -3484,7 +3766,7 @@ var CMIStudentDemographics = (function (_super) {
3484
3766
  },
3485
3767
  set: function (years_experience) {
3486
3768
  if (this.initialized) {
3487
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3769
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3488
3770
  }
3489
3771
  else {
3490
3772
  this._years_experience = years_experience;
@@ -3516,121 +3798,22 @@ var CMIStudentDemographics = (function (_super) {
3516
3798
  return CMIStudentDemographics;
3517
3799
  }(BaseCMI));
3518
3800
 
3519
- var CMIPaths = (function (_super) {
3520
- __extends(CMIPaths, _super);
3521
- function CMIPaths() {
3522
- return _super.call(this, {
3523
- children: aicc_constants.paths_children,
3524
- }) || this;
3525
- }
3526
- return CMIPaths;
3527
- }(CMIArray));
3528
3801
 
3529
- var CMIPathsObject = (function (_super) {
3530
- __extends(CMIPathsObject, _super);
3531
- function CMIPathsObject() {
3532
- var _this = _super.call(this) || this;
3533
- _this._location_id = "";
3534
- _this._date = "";
3535
- _this._time = "";
3536
- _this._status = "";
3537
- _this._why_left = "";
3538
- _this._time_in_element = "";
3539
- return _this;
3540
- }
3541
- Object.defineProperty(CMIPathsObject.prototype, "location_id", {
3542
- get: function () {
3543
- return this._location_id;
3544
- },
3545
- set: function (location_id) {
3546
- if (checkAICCValidFormat(location_id, aicc_regex.CMIString256)) {
3547
- this._location_id = location_id;
3548
- }
3549
- },
3550
- enumerable: false,
3551
- configurable: true
3552
- });
3553
- Object.defineProperty(CMIPathsObject.prototype, "date", {
3554
- get: function () {
3555
- return this._date;
3556
- },
3557
- set: function (date) {
3558
- if (checkAICCValidFormat(date, aicc_regex.CMIString256)) {
3559
- this._date = date;
3560
- }
3561
- },
3562
- enumerable: false,
3563
- configurable: true
3564
- });
3565
- Object.defineProperty(CMIPathsObject.prototype, "time", {
3566
- get: function () {
3567
- return this._time;
3568
- },
3569
- set: function (time) {
3570
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
3571
- this._time = time;
3572
- }
3573
- },
3574
- enumerable: false,
3575
- configurable: true
3576
- });
3577
- Object.defineProperty(CMIPathsObject.prototype, "status", {
3578
- get: function () {
3579
- return this._status;
3580
- },
3581
- set: function (status) {
3582
- if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
3583
- this._status = status;
3584
- }
3585
- },
3586
- enumerable: false,
3587
- configurable: true
3588
- });
3589
- Object.defineProperty(CMIPathsObject.prototype, "why_left", {
3590
- get: function () {
3591
- return this._why_left;
3592
- },
3593
- set: function (why_left) {
3594
- if (checkAICCValidFormat(why_left, aicc_regex.CMIString256)) {
3595
- this._why_left = why_left;
3596
- }
3597
- },
3598
- enumerable: false,
3599
- configurable: true
3600
- });
3601
- Object.defineProperty(CMIPathsObject.prototype, "time_in_element", {
3602
- get: function () {
3603
- return this._time_in_element;
3604
- },
3605
- set: function (time_in_element) {
3606
- if (checkAICCValidFormat(time_in_element, aicc_regex.CMITime)) {
3607
- this._time_in_element = time_in_element;
3608
- }
3609
- },
3610
- enumerable: false,
3611
- configurable: true
3612
- });
3613
- CMIPathsObject.prototype.toJSON = function () {
3614
- this.jsonString = true;
3615
- var result = {
3616
- location_id: this.location_id,
3617
- date: this.date,
3618
- time: this.time,
3619
- status: this.status,
3620
- why_left: this.why_left,
3621
- time_in_element: this.time_in_element,
3622
- };
3623
- delete this.jsonString;
3624
- return result;
3625
- };
3626
- return CMIPathsObject;
3627
- }(BaseCMI));
3802
+ ;// ./src/cmi/aicc/tries.ts
3803
+
3804
+
3805
+
3806
+
3807
+
3808
+
3809
+
3810
+
3628
3811
 
3629
3812
  var CMITries = (function (_super) {
3630
3813
  __extends(CMITries, _super);
3631
3814
  function CMITries() {
3632
3815
  return _super.call(this, {
3633
- children: aicc_constants.tries_children,
3816
+ children: api_constants.aicc.tries_children,
3634
3817
  }) || this;
3635
3818
  }
3636
3819
  return CMITries;
@@ -3643,11 +3826,11 @@ var CMITriesObject = (function (_super) {
3643
3826
  _this._status = "";
3644
3827
  _this._time = "";
3645
3828
  _this.score = new CMIScore({
3646
- score_children: aicc_constants.score_children,
3647
- score_range: aicc_regex.score_range,
3648
- invalidErrorCode: aicc_error_codes.INVALID_SET_VALUE,
3649
- invalidTypeCode: aicc_error_codes.TYPE_MISMATCH,
3650
- invalidRangeCode: aicc_error_codes.VALUE_OUT_OF_RANGE,
3829
+ score_children: api_constants.aicc.score_children,
3830
+ score_range: regex.aicc.score_range,
3831
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
3832
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
3833
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
3651
3834
  errorClass: AICCValidationError,
3652
3835
  });
3653
3836
  return _this;
@@ -3662,7 +3845,7 @@ var CMITriesObject = (function (_super) {
3662
3845
  return this._status;
3663
3846
  },
3664
3847
  set: function (status) {
3665
- if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
3848
+ if (checkAICCValidFormat(status, regex.aicc.CMIStatus2)) {
3666
3849
  this._status = status;
3667
3850
  }
3668
3851
  },
@@ -3674,7 +3857,7 @@ var CMITriesObject = (function (_super) {
3674
3857
  return this._time;
3675
3858
  },
3676
3859
  set: function (time) {
3677
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
3860
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3678
3861
  this._time = time;
3679
3862
  }
3680
3863
  },
@@ -3694,11 +3877,22 @@ var CMITriesObject = (function (_super) {
3694
3877
  return CMITriesObject;
3695
3878
  }(BaseCMI));
3696
3879
 
3880
+
3881
+ ;// ./src/cmi/aicc/attempts.ts
3882
+
3883
+
3884
+
3885
+
3886
+
3887
+
3888
+
3889
+
3890
+
3697
3891
  var CMIAttemptRecords = (function (_super) {
3698
3892
  __extends(CMIAttemptRecords, _super);
3699
3893
  function CMIAttemptRecords() {
3700
3894
  return _super.call(this, {
3701
- children: aicc_constants.attempt_records_children,
3895
+ children: api_constants.aicc.attempt_records_children,
3702
3896
  }) || this;
3703
3897
  }
3704
3898
  return CMIAttemptRecords;
@@ -3710,11 +3904,11 @@ var CMIAttemptRecordsObject = (function (_super) {
3710
3904
  var _this = _super.call(this) || this;
3711
3905
  _this._lesson_status = "";
3712
3906
  _this.score = new CMIScore({
3713
- score_children: aicc_constants.score_children,
3714
- score_range: aicc_regex.score_range,
3715
- invalidErrorCode: aicc_error_codes.INVALID_SET_VALUE,
3716
- invalidTypeCode: aicc_error_codes.TYPE_MISMATCH,
3717
- invalidRangeCode: aicc_error_codes.VALUE_OUT_OF_RANGE,
3907
+ score_children: api_constants.aicc.score_children,
3908
+ score_range: regex.aicc.score_range,
3909
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
3910
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
3911
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
3718
3912
  errorClass: AICCValidationError,
3719
3913
  });
3720
3914
  return _this;
@@ -3729,7 +3923,7 @@ var CMIAttemptRecordsObject = (function (_super) {
3729
3923
  return this._lesson_status;
3730
3924
  },
3731
3925
  set: function (lesson_status) {
3732
- if (checkAICCValidFormat(lesson_status, aicc_regex.CMIStatus2)) {
3926
+ if (checkAICCValidFormat(lesson_status, regex.aicc.CMIStatus2)) {
3733
3927
  this._lesson_status = lesson_status;
3734
3928
  }
3735
3929
  },
@@ -3748,90 +3942,267 @@ var CMIAttemptRecordsObject = (function (_super) {
3748
3942
  return CMIAttemptRecordsObject;
3749
3943
  }(BaseCMI));
3750
3944
 
3751
- var CMIEvaluationCommentsObject = (function (_super) {
3752
- __extends(CMIEvaluationCommentsObject, _super);
3753
- function CMIEvaluationCommentsObject() {
3945
+
3946
+ ;// ./src/cmi/aicc/student_data.ts
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+ var AICCCMIStudentData = (function (_super) {
3955
+ __extends(AICCCMIStudentData, _super);
3956
+ function AICCCMIStudentData() {
3957
+ var _this = _super.call(this, api_constants.aicc.student_data_children) || this;
3958
+ _this._tries_during_lesson = "";
3959
+ _this.tries = new CMITries();
3960
+ _this.attempt_records = new CMIAttemptRecords();
3961
+ return _this;
3962
+ }
3963
+ AICCCMIStudentData.prototype.initialize = function () {
3964
+ var _a, _b;
3965
+ _super.prototype.initialize.call(this);
3966
+ (_a = this.tries) === null || _a === void 0 ? void 0 : _a.initialize();
3967
+ (_b = this.attempt_records) === null || _b === void 0 ? void 0 : _b.initialize();
3968
+ };
3969
+ Object.defineProperty(AICCCMIStudentData.prototype, "tries_during_lesson", {
3970
+ get: function () {
3971
+ return this._tries_during_lesson;
3972
+ },
3973
+ set: function (tries_during_lesson) {
3974
+ if (this.initialized) {
3975
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3976
+ }
3977
+ else {
3978
+ this._tries_during_lesson = tries_during_lesson;
3979
+ }
3980
+ },
3981
+ enumerable: false,
3982
+ configurable: true
3983
+ });
3984
+ AICCCMIStudentData.prototype.toJSON = function () {
3985
+ this.jsonString = true;
3986
+ var result = {
3987
+ mastery_score: this.mastery_score,
3988
+ max_time_allowed: this.max_time_allowed,
3989
+ time_limit_action: this.time_limit_action,
3990
+ tries: this.tries,
3991
+ attempt_records: this.attempt_records,
3992
+ };
3993
+ delete this.jsonString;
3994
+ return result;
3995
+ };
3996
+ return AICCCMIStudentData;
3997
+ }(CMIStudentData));
3998
+
3999
+
4000
+ ;// ./src/cmi/aicc/paths.ts
4001
+
4002
+
4003
+
4004
+
4005
+
4006
+
4007
+ var CMIPaths = (function (_super) {
4008
+ __extends(CMIPaths, _super);
4009
+ function CMIPaths() {
4010
+ return _super.call(this, {
4011
+ children: api_constants.aicc.paths_children,
4012
+ }) || this;
4013
+ }
4014
+ return CMIPaths;
4015
+ }(CMIArray));
4016
+
4017
+ var CMIPathsObject = (function (_super) {
4018
+ __extends(CMIPathsObject, _super);
4019
+ function CMIPathsObject() {
3754
4020
  var _this = _super.call(this) || this;
3755
- _this._content = "";
3756
- _this._location = "";
4021
+ _this._location_id = "";
4022
+ _this._date = "";
3757
4023
  _this._time = "";
4024
+ _this._status = "";
4025
+ _this._why_left = "";
4026
+ _this._time_in_element = "";
3758
4027
  return _this;
3759
4028
  }
3760
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "content", {
4029
+ Object.defineProperty(CMIPathsObject.prototype, "location_id", {
3761
4030
  get: function () {
3762
- return this._content;
4031
+ return this._location_id;
3763
4032
  },
3764
- set: function (content) {
3765
- if (checkAICCValidFormat(content, aicc_regex.CMIString256)) {
3766
- this._content = content;
4033
+ set: function (location_id) {
4034
+ if (checkAICCValidFormat(location_id, regex.aicc.CMIString256)) {
4035
+ this._location_id = location_id;
3767
4036
  }
3768
4037
  },
3769
4038
  enumerable: false,
3770
4039
  configurable: true
3771
4040
  });
3772
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "location", {
4041
+ Object.defineProperty(CMIPathsObject.prototype, "date", {
3773
4042
  get: function () {
3774
- return this._location;
4043
+ return this._date;
3775
4044
  },
3776
- set: function (location) {
3777
- if (checkAICCValidFormat(location, aicc_regex.CMIString256)) {
3778
- this._location = location;
4045
+ set: function (date) {
4046
+ if (checkAICCValidFormat(date, regex.aicc.CMIString256)) {
4047
+ this._date = date;
3779
4048
  }
3780
4049
  },
3781
4050
  enumerable: false,
3782
4051
  configurable: true
3783
4052
  });
3784
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "time", {
4053
+ Object.defineProperty(CMIPathsObject.prototype, "time", {
3785
4054
  get: function () {
3786
4055
  return this._time;
3787
4056
  },
3788
4057
  set: function (time) {
3789
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
4058
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3790
4059
  this._time = time;
3791
4060
  }
3792
4061
  },
3793
4062
  enumerable: false,
3794
4063
  configurable: true
3795
4064
  });
3796
- CMIEvaluationCommentsObject.prototype.toJSON = function () {
4065
+ Object.defineProperty(CMIPathsObject.prototype, "status", {
4066
+ get: function () {
4067
+ return this._status;
4068
+ },
4069
+ set: function (status) {
4070
+ if (checkAICCValidFormat(status, regex.aicc.CMIStatus2)) {
4071
+ this._status = status;
4072
+ }
4073
+ },
4074
+ enumerable: false,
4075
+ configurable: true
4076
+ });
4077
+ Object.defineProperty(CMIPathsObject.prototype, "why_left", {
4078
+ get: function () {
4079
+ return this._why_left;
4080
+ },
4081
+ set: function (why_left) {
4082
+ if (checkAICCValidFormat(why_left, regex.aicc.CMIString256)) {
4083
+ this._why_left = why_left;
4084
+ }
4085
+ },
4086
+ enumerable: false,
4087
+ configurable: true
4088
+ });
4089
+ Object.defineProperty(CMIPathsObject.prototype, "time_in_element", {
4090
+ get: function () {
4091
+ return this._time_in_element;
4092
+ },
4093
+ set: function (time_in_element) {
4094
+ if (checkAICCValidFormat(time_in_element, regex.aicc.CMITime)) {
4095
+ this._time_in_element = time_in_element;
4096
+ }
4097
+ },
4098
+ enumerable: false,
4099
+ configurable: true
4100
+ });
4101
+ CMIPathsObject.prototype.toJSON = function () {
3797
4102
  this.jsonString = true;
3798
4103
  var result = {
3799
- content: this.content,
3800
- location: this.location,
4104
+ location_id: this.location_id,
4105
+ date: this.date,
3801
4106
  time: this.time,
4107
+ status: this.status,
4108
+ why_left: this.why_left,
4109
+ time_in_element: this.time_in_element,
3802
4110
  };
3803
4111
  delete this.jsonString;
3804
4112
  return result;
3805
4113
  };
3806
- return CMIEvaluationCommentsObject;
4114
+ return CMIPathsObject;
3807
4115
  }(BaseCMI));
3808
4116
 
3809
4117
 
4118
+ ;// ./src/cmi/aicc/cmi.ts
4119
+
4120
+
4121
+
4122
+
4123
+
4124
+
4125
+
4126
+
4127
+ var cmi_CMI = (function (_super) {
4128
+ __extends(CMI, _super);
4129
+ function CMI(initialized) {
4130
+ if (initialized === void 0) { initialized = false; }
4131
+ var _this = _super.call(this, api_constants.aicc.cmi_children) || this;
4132
+ if (initialized)
4133
+ _this.initialize();
4134
+ _this.student_preference = new AICCStudentPreferences();
4135
+ _this.student_data = new AICCCMIStudentData();
4136
+ _this.student_demographics = new CMIStudentDemographics();
4137
+ _this.evaluation = new CMIEvaluation();
4138
+ _this.paths = new CMIPaths();
4139
+ return _this;
4140
+ }
4141
+ CMI.prototype.initialize = function () {
4142
+ var _a, _b, _c, _d, _e;
4143
+ _super.prototype.initialize.call(this);
4144
+ (_a = this.student_preference) === null || _a === void 0 ? void 0 : _a.initialize();
4145
+ (_b = this.student_data) === null || _b === void 0 ? void 0 : _b.initialize();
4146
+ (_c = this.student_demographics) === null || _c === void 0 ? void 0 : _c.initialize();
4147
+ (_d = this.evaluation) === null || _d === void 0 ? void 0 : _d.initialize();
4148
+ (_e = this.paths) === null || _e === void 0 ? void 0 : _e.initialize();
4149
+ };
4150
+ CMI.prototype.toJSON = function () {
4151
+ this.jsonString = true;
4152
+ var result = {
4153
+ suspend_data: this.suspend_data,
4154
+ launch_data: this.launch_data,
4155
+ comments: this.comments,
4156
+ comments_from_lms: this.comments_from_lms,
4157
+ core: this.core,
4158
+ objectives: this.objectives,
4159
+ student_data: this.student_data,
4160
+ student_preference: this.student_preference,
4161
+ student_demographics: this.student_demographics,
4162
+ interactions: this.interactions,
4163
+ evaluation: this.evaluation,
4164
+ paths: this.paths,
4165
+ };
4166
+ delete this.jsonString;
4167
+ return result;
4168
+ };
4169
+ return CMI;
4170
+ }(CMI));
4171
+
4172
+
3810
4173
  ;// ./src/AICC.ts
3811
4174
 
3812
4175
 
3813
4176
 
3814
4177
 
4178
+
4179
+
4180
+
4181
+
4182
+
3815
4183
  var AICC = (function (_super) {
3816
4184
  __extends(AICC, _super);
3817
4185
  function AICC(settings) {
3818
4186
  var _this = _super.call(this, settings) || this;
3819
- _this.cmi = new aicc_cmi_CMI();
4187
+ _this.cmi = new cmi_CMI();
3820
4188
  _this.nav = new NAV();
3821
4189
  return _this;
3822
4190
  }
3823
4191
  AICC.prototype.getChildElement = function (CMIElement, value, foundFirstIndex) {
3824
4192
  var newChild = _super.prototype.getChildElement.call(this, CMIElement, value, foundFirstIndex);
3825
4193
  if (!newChild) {
3826
- if (this.stringMatches(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")) {
4194
+ if (stringMatches(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")) {
3827
4195
  newChild = new CMIEvaluationCommentsObject();
3828
4196
  }
3829
- else if (this.stringMatches(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")) {
4197
+ else if (stringMatches(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")) {
3830
4198
  newChild = new CMITriesObject();
3831
4199
  }
3832
- else if (this.stringMatches(CMIElement, "cmi\\.student_data\\.attempt_records\\.\\d+")) {
4200
+ else if (stringMatches(CMIElement, "cmi\\.student_data\\.attempt_records\\.\\d+")) {
3833
4201
  newChild = new CMIAttemptRecordsObject();
3834
4202
  }
4203
+ else if (stringMatches(CMIElement, "cmi\\.paths\\.\\d+")) {
4204
+ newChild = new CMIPathsObject();
4205
+ }
3835
4206
  }
3836
4207
  return newChild;
3837
4208
  };