scorm-again 2.0.0 → 2.1.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 +171 -72
  5. package/dist/aicc.js +1441 -1140
  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 +2703 -2212
  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 +1069 -852
  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 +1861 -1571
  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 +10 -6
  22. package/src/AICC.ts +15 -17
  23. package/src/BaseAPI.ts +268 -417
  24. package/src/Scorm12API.ts +65 -38
  25. package/src/Scorm2004API.ts +151 -117
  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 +81 -0
  56. package/src/constants/enums.ts +5 -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 +32 -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 +262 -9
  67. package/test/Scorm2004API.spec.ts +488 -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,16 +1028,20 @@ 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,
1229
1047
  strict_errors: true,
@@ -1231,26 +1049,26 @@ var DefaultSettings = {
1231
1049
  xhrWithCredentials: false,
1232
1050
  responseHandler: function (response) {
1233
1051
  return __awaiter(this, void 0, void 0, function () {
1234
- var httpResult, _a, _c;
1235
- return __generator(this, function (_e) {
1236
- switch (_e.label) {
1052
+ var httpResult, _a, _b;
1053
+ return __generator(this, function (_c) {
1054
+ switch (_c.label) {
1237
1055
  case 0:
1238
1056
  if (!(typeof response !== "undefined")) return [3, 2];
1239
- _c = (_a = JSON).parse;
1057
+ _b = (_a = JSON).parse;
1240
1058
  return [4, response.text()];
1241
1059
  case 1:
1242
- httpResult = _c.apply(_a, [_e.sent()]);
1060
+ httpResult = _b.apply(_a, [_c.sent()]);
1243
1061
  if (httpResult === null ||
1244
1062
  !{}.hasOwnProperty.call(httpResult, "result")) {
1245
1063
  if (response.status === 200) {
1246
1064
  return [2, {
1247
- result: global_constants.SCORM_TRUE,
1065
+ result: api_constants.global.SCORM_TRUE,
1248
1066
  errorCode: 0,
1249
1067
  }];
1250
1068
  }
1251
1069
  else {
1252
1070
  return [2, {
1253
- result: global_constants.SCORM_FALSE,
1071
+ result: api_constants.global.SCORM_FALSE,
1254
1072
  errorCode: 101,
1255
1073
  }];
1256
1074
  }
@@ -1260,14 +1078,14 @@ var DefaultSettings = {
1260
1078
  result: httpResult.result,
1261
1079
  errorCode: httpResult.errorCode
1262
1080
  ? httpResult.errorCode
1263
- : httpResult.result === global_constants.SCORM_TRUE
1081
+ : httpResult.result === api_constants.global.SCORM_TRUE
1264
1082
  ? 0
1265
1083
  : 101,
1266
1084
  }];
1267
1085
  }
1268
- _e.label = 2;
1086
+ _c.label = 2;
1269
1087
  case 2: return [2, {
1270
- result: global_constants.SCORM_FALSE,
1088
+ result: api_constants.global.SCORM_FALSE,
1271
1089
  errorCode: 101,
1272
1090
  }];
1273
1091
  }
@@ -1279,16 +1097,16 @@ var DefaultSettings = {
1279
1097
  },
1280
1098
  onLogMessage: function (messageLevel, logMessage) {
1281
1099
  switch (messageLevel) {
1282
- case global_constants.LOG_LEVEL_ERROR:
1100
+ case api_constants.global.LOG_LEVEL_ERROR:
1283
1101
  console.error(logMessage);
1284
1102
  break;
1285
- case global_constants.LOG_LEVEL_WARNING:
1103
+ case api_constants.global.LOG_LEVEL_WARNING:
1286
1104
  console.warn(logMessage);
1287
1105
  break;
1288
- case global_constants.LOG_LEVEL_INFO:
1106
+ case api_constants.global.LOG_LEVEL_INFO:
1289
1107
  console.info(logMessage);
1290
1108
  break;
1291
- case global_constants.LOG_LEVEL_DEBUG:
1109
+ case api_constants.global.LOG_LEVEL_DEBUG:
1292
1110
  if (console.debug) {
1293
1111
  console.debug(logMessage);
1294
1112
  }
@@ -1298,26 +1116,75 @@ var DefaultSettings = {
1298
1116
  break;
1299
1117
  }
1300
1118
  },
1119
+ scoItemIds: [],
1120
+ scoItemIdValidator: false,
1301
1121
  };
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;
1122
+
1123
+ ;// ./src/helpers/scheduled_commit.ts
1124
+
1125
+ var ScheduledCommit = (function () {
1126
+ function ScheduledCommit(API, when, callback) {
1127
+ this._cancelled = false;
1128
+ this._API = API;
1129
+ this._timeout = setTimeout(this.wrapper.bind(this), when);
1130
+ this._callback = callback;
1318
1131
  }
1319
- BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
1320
- var returnValue = global_constants.SCORM_FALSE;
1132
+ ScheduledCommit.prototype.cancel = function () {
1133
+ this._cancelled = true;
1134
+ if (this._timeout) {
1135
+ clearTimeout(this._timeout);
1136
+ }
1137
+ };
1138
+ ScheduledCommit.prototype.wrapper = function () {
1139
+ var _this = this;
1140
+ if (!this._cancelled) {
1141
+ (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
1142
+ switch (_a.label) {
1143
+ case 0: return [4, this._API.commit(this._callback)];
1144
+ case 1: return [2, _a.sent()];
1145
+ }
1146
+ }); }); })();
1147
+ }
1148
+ };
1149
+ return ScheduledCommit;
1150
+ }());
1151
+
1152
+
1153
+ ;// ./src/BaseAPI.ts
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+ var BaseAPI = (function () {
1164
+ function BaseAPI(error_codes, settings) {
1165
+ var _newTarget = this.constructor;
1166
+ this._settings = DefaultSettings;
1167
+ if (_newTarget === BaseAPI) {
1168
+ throw new TypeError("Cannot construct BaseAPI instances directly");
1169
+ }
1170
+ this.currentState = api_constants.global.STATE_NOT_INITIALIZED;
1171
+ this.lastErrorCode = "0";
1172
+ this.listenerArray = [];
1173
+ this._error_codes = error_codes;
1174
+ if (settings) {
1175
+ this.settings = settings;
1176
+ }
1177
+ this.apiLogLevel = this.settings.logLevel;
1178
+ this.selfReportSessionTime = this.settings.selfReportSessionTime;
1179
+ }
1180
+ BaseAPI.prototype.commonReset = function (settings) {
1181
+ this.settings = __assign(__assign({}, this.settings), settings);
1182
+ this.currentState = api_constants.global.STATE_NOT_INITIALIZED;
1183
+ this.lastErrorCode = "0";
1184
+ this.listenerArray = [];
1185
+ };
1186
+ BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
1187
+ var returnValue = api_constants.global.SCORM_FALSE;
1321
1188
  if (this.isInitialized()) {
1322
1189
  this.throwSCORMError(this._error_codes.INITIALIZED, initializeMessage);
1323
1190
  }
@@ -1328,15 +1195,21 @@ var BaseAPI = (function () {
1328
1195
  if (this.selfReportSessionTime) {
1329
1196
  this.cmi.setStartTime();
1330
1197
  }
1331
- this.currentState = global_constants.STATE_INITIALIZED;
1198
+ this.currentState = api_constants.global.STATE_INITIALIZED;
1332
1199
  this.lastErrorCode = "0";
1333
- returnValue = global_constants.SCORM_TRUE;
1200
+ returnValue = api_constants.global.SCORM_TRUE;
1334
1201
  this.processListeners(callbackName);
1335
1202
  }
1336
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1203
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1337
1204
  this.clearSCORMError(returnValue);
1338
1205
  return returnValue;
1339
1206
  };
1207
+ BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
1208
+ logMessage = formatMessage(functionName, logMessage, CMIElement);
1209
+ if (messageLevel >= this.apiLogLevel) {
1210
+ this.settings.onLogMessage(messageLevel, logMessage);
1211
+ }
1212
+ };
1340
1213
  Object.defineProperty(BaseAPI.prototype, "error_codes", {
1341
1214
  get: function () {
1342
1215
  return this._error_codes;
@@ -1355,25 +1228,36 @@ var BaseAPI = (function () {
1355
1228
  configurable: true
1356
1229
  });
1357
1230
  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;
1231
+ return __awaiter(this, void 0, void 0, function () {
1232
+ var returnValue, result;
1233
+ return __generator(this, function (_a) {
1234
+ switch (_a.label) {
1235
+ case 0:
1236
+ returnValue = api_constants.global.SCORM_FALSE;
1237
+ if (!this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) return [3, 2];
1238
+ this.currentState = api_constants.global.STATE_TERMINATED;
1239
+ return [4, this.storeData(true)];
1240
+ case 1:
1241
+ result = _a.sent();
1242
+ if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
1243
+ this.throwSCORMError(result.errorCode);
1244
+ }
1245
+ returnValue =
1246
+ typeof result !== "undefined" && result.result
1247
+ ? result.result
1248
+ : api_constants.global.SCORM_FALSE;
1249
+ if (checkTerminated)
1250
+ this.lastErrorCode = "0";
1251
+ returnValue = api_constants.global.SCORM_TRUE;
1252
+ this.processListeners(callbackName);
1253
+ _a.label = 2;
1254
+ case 2:
1255
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1256
+ this.clearSCORMError(returnValue);
1257
+ return [2, returnValue];
1258
+ }
1259
+ });
1260
+ });
1377
1261
  };
1378
1262
  BaseAPI.prototype.getValue = function (callbackName, checkTerminated, CMIElement) {
1379
1263
  var returnValue = "";
@@ -1388,7 +1272,10 @@ var BaseAPI = (function () {
1388
1272
  }
1389
1273
  this.processListeners(callbackName, CMIElement);
1390
1274
  }
1391
- this.apiLog(callbackName, ": returned: " + returnValue, global_constants.LOG_LEVEL_INFO, CMIElement);
1275
+ this.apiLog(callbackName, ": returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1276
+ if (returnValue === undefined) {
1277
+ return "";
1278
+ }
1392
1279
  this.clearSCORMError(returnValue);
1393
1280
  return returnValue;
1394
1281
  };
@@ -1396,7 +1283,7 @@ var BaseAPI = (function () {
1396
1283
  if (value !== undefined) {
1397
1284
  value = String(value);
1398
1285
  }
1399
- var returnValue = global_constants.SCORM_FALSE;
1286
+ var returnValue = api_constants.global.SCORM_FALSE;
1400
1287
  if (this.checkState(checkTerminated, this._error_codes.STORE_BEFORE_INIT, this._error_codes.STORE_AFTER_TERM)) {
1401
1288
  if (checkTerminated)
1402
1289
  this.lastErrorCode = "0";
@@ -1409,43 +1296,54 @@ var BaseAPI = (function () {
1409
1296
  this.processListeners(callbackName, CMIElement, value);
1410
1297
  }
1411
1298
  if (returnValue === undefined) {
1412
- returnValue = global_constants.SCORM_FALSE;
1299
+ returnValue = api_constants.global.SCORM_FALSE;
1413
1300
  }
1414
1301
  if (String(this.lastErrorCode) === "0") {
1415
1302
  if (this.settings.autocommit && !this._timeout) {
1416
1303
  this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
1417
1304
  }
1418
1305
  }
1419
- this.apiLog(callbackName, ": " + value + ": result: " + returnValue, global_constants.LOG_LEVEL_INFO, CMIElement);
1306
+ this.apiLog(callbackName, ": " + value + ": result: " + returnValue, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1420
1307
  this.clearSCORMError(returnValue);
1421
1308
  return returnValue;
1422
1309
  };
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;
1310
+ BaseAPI.prototype.commit = function (callbackName_1) {
1311
+ return __awaiter(this, arguments, void 0, function (callbackName, checkTerminated) {
1312
+ var returnValue, result;
1313
+ if (checkTerminated === void 0) { checkTerminated = false; }
1314
+ return __generator(this, function (_a) {
1315
+ switch (_a.label) {
1316
+ case 0:
1317
+ this.clearScheduledCommit();
1318
+ returnValue = api_constants.global.SCORM_FALSE;
1319
+ if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
1320
+ return [4, this.storeData(false)];
1321
+ case 1:
1322
+ result = _a.sent();
1323
+ if (result.errorCode && result.errorCode > 0) {
1324
+ this.throwSCORMError(result.errorCode);
1325
+ }
1326
+ returnValue =
1327
+ typeof result !== "undefined" && result.result
1328
+ ? result.result
1329
+ : api_constants.global.SCORM_FALSE;
1330
+ this.apiLog(callbackName, " Result: " + returnValue, api_constants.global.LOG_LEVEL_DEBUG, "HttpRequest");
1331
+ if (checkTerminated)
1332
+ this.lastErrorCode = "0";
1333
+ this.processListeners(callbackName);
1334
+ _a.label = 2;
1335
+ case 2:
1336
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1337
+ this.clearSCORMError(returnValue);
1338
+ return [2, returnValue];
1339
+ }
1340
+ });
1341
+ });
1444
1342
  };
1445
1343
  BaseAPI.prototype.getLastError = function (callbackName) {
1446
1344
  var returnValue = String(this.lastErrorCode);
1447
1345
  this.processListeners(callbackName);
1448
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1346
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1449
1347
  return returnValue;
1450
1348
  };
1451
1349
  BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
@@ -1454,7 +1352,7 @@ var BaseAPI = (function () {
1454
1352
  returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
1455
1353
  this.processListeners(callbackName);
1456
1354
  }
1457
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1355
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1458
1356
  return returnValue;
1459
1357
  };
1460
1358
  BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
@@ -1463,7 +1361,7 @@ var BaseAPI = (function () {
1463
1361
  returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
1464
1362
  this.processListeners(callbackName);
1465
1363
  }
1466
- this.apiLog(callbackName, "returned: " + returnValue, global_constants.LOG_LEVEL_INFO);
1364
+ this.apiLog(callbackName, "returned: " + returnValue, api_constants.global.LOG_LEVEL_INFO);
1467
1365
  return returnValue;
1468
1366
  };
1469
1367
  BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
@@ -1477,42 +1375,6 @@ var BaseAPI = (function () {
1477
1375
  }
1478
1376
  return true;
1479
1377
  };
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
1378
  BaseAPI.prototype.getLmsErrorMessageDetails = function (_errorNumber, _detail) {
1517
1379
  if (_detail === void 0) { _detail = false; }
1518
1380
  throw new Error("The getLmsErrorMessageDetails method has not been implemented");
@@ -1525,11 +1387,11 @@ var BaseAPI = (function () {
1525
1387
  };
1526
1388
  BaseAPI.prototype._commonSetCMIValue = function (methodName, scorm2004, CMIElement, value) {
1527
1389
  if (!CMIElement || CMIElement === "") {
1528
- return global_constants.SCORM_FALSE;
1390
+ return api_constants.global.SCORM_FALSE;
1529
1391
  }
1530
1392
  var structure = CMIElement.split(".");
1531
1393
  var refObject = this;
1532
- var returnValue = global_constants.SCORM_FALSE;
1394
+ var returnValue = api_constants.global.SCORM_FALSE;
1533
1395
  var foundFirstIndex = false;
1534
1396
  var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
1535
1397
  var invalidErrorCode = scorm2004
@@ -1538,22 +1400,25 @@ var BaseAPI = (function () {
1538
1400
  for (var idx = 0; idx < structure.length; idx++) {
1539
1401
  var attribute = structure[idx];
1540
1402
  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);
1403
+ if (scorm2004 && attribute.substring(0, 8) === "{target=") {
1404
+ if (this.isInitialized()) {
1405
+ this.throwSCORMError(this._error_codes.READ_ONLY_ELEMENT);
1406
+ }
1407
+ else {
1408
+ refObject = __assign(__assign({}, refObject), { attribute: value });
1409
+ }
1545
1410
  }
1546
1411
  else if (!this._checkObjectHasProperty(refObject, attribute)) {
1547
1412
  this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1548
1413
  }
1549
1414
  else {
1550
- if (this.isInitialized() &&
1551
- this.stringMatches(CMIElement, "\\.correct_responses\\.\\d+")) {
1415
+ if (stringMatches(CMIElement, "\\.correct_responses\\.\\d+") &&
1416
+ this.isInitialized()) {
1552
1417
  this.validateCorrectResponse(CMIElement, value);
1553
1418
  }
1554
1419
  if (!scorm2004 || this.lastErrorCode === "0") {
1555
1420
  refObject[attribute] = value;
1556
- returnValue = global_constants.SCORM_TRUE;
1421
+ returnValue = api_constants.global.SCORM_TRUE;
1557
1422
  }
1558
1423
  }
1559
1424
  }
@@ -1589,8 +1454,8 @@ var BaseAPI = (function () {
1589
1454
  }
1590
1455
  }
1591
1456
  }
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);
1457
+ if (returnValue === api_constants.global.SCORM_FALSE) {
1458
+ this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), api_constants.global.LOG_LEVEL_WARNING);
1594
1459
  }
1595
1460
  return returnValue;
1596
1461
  };
@@ -1650,10 +1515,10 @@ var BaseAPI = (function () {
1650
1515
  if (refObject === null || refObject === undefined) {
1651
1516
  if (!scorm2004) {
1652
1517
  if (attribute === "_children") {
1653
- this.throwSCORMError(BaseAPI_scorm12_error_codes.CHILDREN_ERROR);
1518
+ this.throwSCORMError(error_codes.scorm12.CHILDREN_ERROR);
1654
1519
  }
1655
1520
  else if (attribute === "_count") {
1656
- this.throwSCORMError(BaseAPI_scorm12_error_codes.COUNT_ERROR);
1521
+ this.throwSCORMError(error_codes.scorm12.COUNT_ERROR);
1657
1522
  }
1658
1523
  }
1659
1524
  }
@@ -1662,13 +1527,13 @@ var BaseAPI = (function () {
1662
1527
  }
1663
1528
  };
1664
1529
  BaseAPI.prototype.isInitialized = function () {
1665
- return this.currentState === global_constants.STATE_INITIALIZED;
1530
+ return this.currentState === api_constants.global.STATE_INITIALIZED;
1666
1531
  };
1667
1532
  BaseAPI.prototype.isNotInitialized = function () {
1668
- return this.currentState === global_constants.STATE_NOT_INITIALIZED;
1533
+ return this.currentState === api_constants.global.STATE_NOT_INITIALIZED;
1669
1534
  };
1670
1535
  BaseAPI.prototype.isTerminated = function () {
1671
- return this.currentState === global_constants.STATE_TERMINATED;
1536
+ return this.currentState === api_constants.global.STATE_TERMINATED;
1672
1537
  };
1673
1538
  BaseAPI.prototype.on = function (listenerName, callback) {
1674
1539
  if (!callback)
@@ -1688,7 +1553,7 @@ var BaseAPI = (function () {
1688
1553
  CMIElement: CMIElement,
1689
1554
  callback: callback,
1690
1555
  });
1691
- this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), global_constants.LOG_LEVEL_INFO, functionName);
1556
+ this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), api_constants.global.LOG_LEVEL_INFO, functionName);
1692
1557
  }
1693
1558
  };
1694
1559
  BaseAPI.prototype.off = function (listenerName, callback) {
@@ -1711,7 +1576,7 @@ var BaseAPI = (function () {
1711
1576
  });
1712
1577
  if (removeIndex !== -1) {
1713
1578
  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);
1579
+ this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), api_constants.global.LOG_LEVEL_INFO, functionName);
1715
1580
  }
1716
1581
  };
1717
1582
  var this_1 = this;
@@ -1744,7 +1609,7 @@ var BaseAPI = (function () {
1744
1609
  }
1745
1610
  };
1746
1611
  BaseAPI.prototype.processListeners = function (functionName, CMIElement, value) {
1747
- this.apiLog(functionName, value, global_constants.LOG_LEVEL_INFO, CMIElement);
1612
+ this.apiLog(functionName, value, api_constants.global.LOG_LEVEL_INFO, CMIElement);
1748
1613
  for (var i = 0; i < this.listenerArray.length; i++) {
1749
1614
  var listener = this.listenerArray[i];
1750
1615
  var functionsMatch = listener.functionName === functionName;
@@ -1760,7 +1625,7 @@ var BaseAPI = (function () {
1760
1625
  CMIElementsMatch = listener.CMIElement === CMIElement;
1761
1626
  }
1762
1627
  if (functionsMatch && (!listenerHasCMIElement || CMIElementsMatch)) {
1763
- this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), global_constants.LOG_LEVEL_INFO, CMIElement);
1628
+ this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), api_constants.global.LOG_LEVEL_INFO, CMIElement);
1764
1629
  listener.callback(CMIElement, value);
1765
1630
  }
1766
1631
  }
@@ -1769,16 +1634,19 @@ var BaseAPI = (function () {
1769
1634
  if (!message) {
1770
1635
  message = this.getLmsErrorMessageDetails(errorNumber);
1771
1636
  }
1772
- this.apiLog("throwSCORMError", errorNumber + ": " + message, global_constants.LOG_LEVEL_ERROR);
1637
+ this.apiLog("throwSCORMError", errorNumber + ": " + message, api_constants.global.LOG_LEVEL_ERROR);
1773
1638
  this.lastErrorCode = String(errorNumber);
1774
1639
  };
1775
1640
  BaseAPI.prototype.clearSCORMError = function (success) {
1776
- if (success !== undefined && success !== global_constants.SCORM_FALSE) {
1641
+ if (success !== undefined && success !== api_constants.global.SCORM_FALSE) {
1777
1642
  this.lastErrorCode = "0";
1778
1643
  }
1779
1644
  };
1780
1645
  BaseAPI.prototype.loadFromFlattenedJSON = function (json, CMIElement) {
1781
1646
  var _this = this;
1647
+ if (!CMIElement) {
1648
+ CMIElement = "";
1649
+ }
1782
1650
  if (!this.isNotInitialized()) {
1783
1651
  console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.");
1784
1652
  return;
@@ -1866,87 +1734,96 @@ var BaseAPI = (function () {
1866
1734
  };
1867
1735
  BaseAPI.prototype.renderCMIToJSONString = function () {
1868
1736
  var cmi = this.cmi;
1869
- return JSON.stringify({ cmi: cmi });
1737
+ if (this.settings.sendFullCommit) {
1738
+ return JSON.stringify({ cmi: cmi });
1739
+ }
1740
+ return JSON.stringify({ cmi: cmi }, function (k, v) { return (v === undefined ? null : v); }, 2);
1870
1741
  };
1871
1742
  BaseAPI.prototype.renderCMIToJSONObject = function () {
1872
1743
  return JSON.parse(this.renderCMIToJSONString());
1873
1744
  };
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) {
1745
+ BaseAPI.prototype.processHttpRequest = function (url_1, params_1) {
1746
+ return __awaiter(this, arguments, void 0, function (url, params, immediate) {
1747
+ var api, genericError, process, debouncedProcess;
1748
+ var _this = this;
1749
+ if (immediate === void 0) { immediate = false; }
1750
+ return __generator(this, function (_a) {
1751
+ switch (_a.label) {
1886
1752
  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");
1753
+ api = this;
1754
+ genericError = {
1755
+ result: api_constants.global.SCORM_FALSE,
1756
+ errorCode: this.error_codes.GENERAL,
1757
+ };
1758
+ if (immediate) {
1759
+ this.performFetch(url, params).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
1760
+ return __generator(this, function (_a) {
1761
+ switch (_a.label) {
1762
+ case 0: return [4, this.transformResponse(response)];
1763
+ case 1:
1764
+ _a.sent();
1765
+ return [2];
1766
+ }
1767
+ });
1768
+ }); });
1769
+ return [2, {
1770
+ result: api_constants.global.SCORM_TRUE,
1771
+ errorCode: 0,
1772
+ }];
1917
1773
  }
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];
1774
+ process = function (url, params, settings) { return __awaiter(_this, void 0, void 0, function () {
1775
+ var response, e_1;
1776
+ return __generator(this, function (_a) {
1777
+ switch (_a.label) {
1778
+ case 0:
1779
+ _a.trys.push([0, 2, , 3]);
1780
+ params = settings.requestHandler(params);
1781
+ return [4, this.performFetch(url, params)];
1782
+ case 1:
1783
+ response = _a.sent();
1784
+ return [2, this.transformResponse(response)];
1785
+ case 2:
1786
+ e_1 = _a.sent();
1787
+ this.apiLog("processHttpRequest", e_1, api_constants.global.LOG_LEVEL_ERROR);
1788
+ api.processListeners("CommitError");
1789
+ return [2, genericError];
1790
+ case 3: return [2];
1791
+ }
1792
+ });
1793
+ }); };
1794
+ if (!this.settings.asyncCommit) return [3, 1];
1795
+ debouncedProcess = debounce(process, 500, immediate);
1796
+ debouncedProcess(url, params, this.settings);
1797
+ return [2, {
1798
+ result: api_constants.global.SCORM_TRUE,
1799
+ errorCode: 0,
1800
+ }];
1801
+ case 1: return [4, process(url, params, this.settings)];
1802
+ case 2: return [2, _a.sent()];
1925
1803
  }
1926
1804
  });
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
- };
1805
+ });
1934
1806
  };
1935
1807
  BaseAPI.prototype.scheduleCommit = function (when, callback) {
1936
1808
  this._timeout = new ScheduledCommit(this, when, callback);
1937
- this.apiLog("scheduleCommit", "scheduled", global_constants.LOG_LEVEL_DEBUG, "");
1809
+ this.apiLog("scheduleCommit", "scheduled", api_constants.global.LOG_LEVEL_DEBUG, "");
1938
1810
  };
1939
1811
  BaseAPI.prototype.clearScheduledCommit = function () {
1940
1812
  if (this._timeout) {
1941
1813
  this._timeout.cancel();
1942
1814
  this._timeout = undefined;
1943
- this.apiLog("clearScheduledCommit", "cleared", global_constants.LOG_LEVEL_DEBUG, "");
1815
+ this.apiLog("clearScheduledCommit", "cleared", api_constants.global.LOG_LEVEL_DEBUG, "");
1944
1816
  }
1945
1817
  };
1818
+ BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
1819
+ return (Object.hasOwnProperty.call(refObject, attribute) ||
1820
+ Object.getOwnPropertyDescriptor(Object.getPrototypeOf(refObject), attribute) != null ||
1821
+ attribute in refObject);
1822
+ };
1946
1823
  BaseAPI.prototype.handleValueAccessException = function (e, returnValue) {
1947
1824
  if (e instanceof ValidationError) {
1948
1825
  this.lastErrorCode = String(e.errorCode);
1949
- returnValue = global_constants.SCORM_FALSE;
1826
+ returnValue = api_constants.global.SCORM_FALSE;
1950
1827
  }
1951
1828
  else {
1952
1829
  if (e instanceof Error && e.message) {
@@ -1959,182 +1836,282 @@ var BaseAPI = (function () {
1959
1836
  }
1960
1837
  return returnValue;
1961
1838
  };
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
- }
1839
+ BaseAPI.prototype.performFetch = function (url, params) {
1840
+ return __awaiter(this, void 0, void 0, function () {
1841
+ return __generator(this, function (_a) {
1842
+ return [2, fetch(url, {
1843
+ method: "POST",
1844
+ body: params instanceof Array ? params.join("&") : JSON.stringify(params),
1845
+ headers: __assign(__assign({}, this.settings.xhrHeaders), { "Content-Type": this.settings.commitRequestDataType }),
1846
+ credentials: this.settings.xhrWithCredentials ? "include" : undefined,
1847
+ keepalive: true,
1848
+ })];
1849
+ });
1850
+ });
1977
1851
  };
1978
- ScheduledCommit.prototype.wrapper = function () {
1979
- if (!this._cancelled) {
1980
- this._API.commit(this._callback);
1981
- }
1852
+ BaseAPI.prototype.transformResponse = function (response) {
1853
+ return __awaiter(this, void 0, void 0, function () {
1854
+ var result, _a;
1855
+ return __generator(this, function (_c) {
1856
+ switch (_c.label) {
1857
+ case 0:
1858
+ if (!(typeof this.settings.responseHandler === "function")) return [3, 2];
1859
+ return [4, this.settings.responseHandler(response)];
1860
+ case 1:
1861
+ _a = _c.sent();
1862
+ return [3, 4];
1863
+ case 2: return [4, response.json()];
1864
+ case 3:
1865
+ _a = _c.sent();
1866
+ _c.label = 4;
1867
+ case 4:
1868
+ result = _a;
1869
+ if (response.status >= 200 &&
1870
+ response.status <= 299 &&
1871
+ (result.result === true ||
1872
+ result.result === api_constants.global.SCORM_TRUE)) {
1873
+ this.processListeners("CommitSuccess");
1874
+ }
1875
+ else {
1876
+ this.processListeners("CommitError");
1877
+ }
1878
+ return [2, result];
1879
+ }
1880
+ });
1881
+ });
1982
1882
  };
1983
- return ScheduledCommit;
1883
+ return BaseAPI;
1984
1884
  }());
1885
+ /* harmony default export */ var src_BaseAPI = (BaseAPI);
1985
1886
 
1986
- ;// ./src/cmi/scorm12_cmi.ts
1987
-
1988
-
1989
-
1990
-
1991
-
1887
+ ;// ./src/constants/regex.ts
1992
1888
 
1889
+ var regex_scorm12 = {
1890
+ CMIString256: "^.{0,255}$",
1891
+ CMIString4096: "^.{0,4096}$",
1892
+ CMITime: "^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",
1893
+ CMITimespan: "^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",
1894
+ CMIInteger: "^\\d+$",
1895
+ CMISInteger: "^-?([0-9]+)$",
1896
+ CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
1897
+ CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
1898
+ CMIFeedback: "^.{0,255}$",
1899
+ CMIIndex: "[._](\\d+).",
1900
+ CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
1901
+ CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
1902
+ CMIExit: "^(time-out|suspend|logout|)$",
1903
+ CMIType: "^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$",
1904
+ CMIResult: "^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$",
1905
+ NAVEvent: "^(previous|continue)$",
1906
+ score_range: "0#100",
1907
+ audio_range: "-1#100",
1908
+ speed_range: "-100#100",
1909
+ weighting_range: "-100#100",
1910
+ text_range: "-1#1",
1911
+ };
1912
+ var regex_aicc = __assign(__assign({}, regex_scorm12), {
1913
+ CMIIdentifier: "^\\w{1,255}$",
1914
+ });
1915
+ var regex_scorm2004 = {
1916
+ CMIString200: "^[\\u0000-\\uFFFF]{0,200}$",
1917
+ CMIString250: "^[\\u0000-\\uFFFF]{0,250}$",
1918
+ CMIString1000: "^[\\u0000-\\uFFFF]{0,1000}$",
1919
+ CMIString4000: "^[\\u0000-\\uFFFF]{0,4000}$",
1920
+ CMIString64000: "^[\\u0000-\\uFFFF]{0,64000}$",
1921
+ CMILang: "^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",
1922
+ CMILangString250: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",
1923
+ CMILangcr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",
1924
+ CMILangString250cr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",
1925
+ CMILangString4000: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",
1926
+ 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})?)?)?)?)?)?)?)?$",
1927
+ CMITimespan: "^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$",
1928
+ CMIInteger: "^\\d+$",
1929
+ CMISInteger: "^-?([0-9]+)$",
1930
+ CMIDecimal: "^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",
1931
+ CMIIdentifier: "^\\S{1,250}[a-zA-Z0-9]$",
1932
+ CMIShortIdentifier: "^[\\w\\.\\-\\_]{1,250}$",
1933
+ CMILongIdentifier: "^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",
1934
+ CMIFeedback: "^.*$",
1935
+ CMIIndex: "[._](\\d+).",
1936
+ CMIIndexStore: ".N(\\d+).",
1937
+ CMICStatus: "^(completed|incomplete|not attempted|unknown)$",
1938
+ CMISStatus: "^(passed|failed|unknown)$",
1939
+ CMIExit: "^(time-out|suspend|logout|normal)$",
1940
+ CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
1941
+ CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
1942
+ 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)$",
1943
+ NAVBoolean: "^(unknown|true|false$)",
1944
+ NAVTarget: "^{target=\\S{0,}[a-zA-Z0-9-_]+}$",
1945
+ scaled_range: "-1#1",
1946
+ audio_range: "0#*",
1947
+ speed_range: "0#*",
1948
+ text_range: "-1#1",
1949
+ progress_range: "0#1",
1950
+ };
1951
+ var Regex = {
1952
+ aicc: regex_aicc,
1953
+ scorm12: regex_scorm12,
1954
+ scorm2004: regex_scorm2004,
1955
+ };
1956
+ /* harmony default export */ var regex = (Regex);
1993
1957
 
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);
1958
+ ;// ./src/cmi/common/validation.ts
1959
+ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
1960
+ if (typeof value !== "string") {
1961
+ return false;
2003
1962
  }
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();
1963
+ var formatRegex = new RegExp(regexPattern);
1964
+ var matches = value.match(formatRegex);
1965
+ if (allowEmptyString && value === "") {
1966
+ return true;
1967
+ }
1968
+ if (value === undefined || !matches || matches[0] === "") {
1969
+ throw new errorClass(errorCode);
1970
+ }
1971
+ return true;
1972
+ }
1973
+ function checkValidRange(value, rangePattern, errorCode, errorClass) {
1974
+ var ranges = rangePattern.split("#");
1975
+ value = value * 1.0;
1976
+ if (value >= ranges[0]) {
1977
+ if (ranges[1] === "*" || value <= ranges[1]) {
1978
+ return true;
1979
+ }
1980
+ else {
1981
+ throw new errorClass(errorCode);
1982
+ }
1983
+ }
1984
+ else {
1985
+ throw new errorClass(errorCode);
1986
+ }
1987
+ }
1988
+
1989
+ ;// ./src/cmi/scorm12/validation.ts
1990
+
1991
+
1992
+
1993
+ function check12ValidFormat(value, regexPattern, allowEmptyString) {
1994
+ return checkValidFormat(value, regexPattern, error_codes.scorm12.TYPE_MISMATCH, Scorm12ValidationError, allowEmptyString);
1995
+ }
1996
+ function check12ValidRange(value, rangePattern, allowEmptyString) {
1997
+ if (!allowEmptyString && value === "") {
1998
+ throw new Scorm12ValidationError(error_codes.scorm12.VALUE_OUT_OF_RANGE);
1999
+ }
2000
+ return checkValidRange(value, rangePattern, error_codes.scorm12.VALUE_OUT_OF_RANGE, Scorm12ValidationError);
2001
+ }
2002
+
2003
+ ;// ./src/cmi/common/score.ts
2004
+
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+ var scorm12_constants = api_constants.scorm12;
2011
+ var scorm12_regex = regex.scorm12;
2012
+ var score_scorm12_error_codes = error_codes.scorm12;
2013
+ var CMIScore = (function (_super) {
2014
+ __extends(CMIScore, _super);
2015
+ function CMIScore(params) {
2016
+ var _this = _super.call(this) || this;
2017
+ _this._raw = "";
2018
+ _this._min = "";
2019
+ _this.__children = params.score_children || scorm12_constants.score_children;
2020
+ _this.__score_range = !params.score_range
2021
+ ? false
2022
+ : scorm12_regex.score_range;
2023
+ _this._max = params.max || params.max === "" ? params.max : "100";
2024
+ _this.__invalid_error_code =
2025
+ params.invalidErrorCode || score_scorm12_error_codes.INVALID_SET_VALUE;
2026
+ _this.__invalid_type_code =
2027
+ params.invalidTypeCode || score_scorm12_error_codes.TYPE_MISMATCH;
2028
+ _this.__invalid_range_code =
2029
+ params.invalidRangeCode || score_scorm12_error_codes.VALUE_OUT_OF_RANGE;
2030
+ _this.__decimal_regex = params.decimalRegex || scorm12_regex.CMIDecimal;
2031
+ _this.__error_class = params.errorClass;
2025
2032
  return _this;
2026
2033
  }
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", {
2034
+ Object.defineProperty(CMIScore.prototype, "_children", {
2063
2035
  get: function () {
2064
2036
  return this.__children;
2065
2037
  },
2066
2038
  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
- }
2039
+ throw new this.__error_class(this.__invalid_error_code);
2081
2040
  },
2082
2041
  enumerable: false,
2083
2042
  configurable: true
2084
2043
  });
2085
- Object.defineProperty(CMI.prototype, "launch_data", {
2044
+ Object.defineProperty(CMIScore.prototype, "raw", {
2086
2045
  get: function () {
2087
- return this._launch_data;
2046
+ return this._raw;
2088
2047
  },
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;
2048
+ set: function (raw) {
2049
+ if (checkValidFormat(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2050
+ (!this.__score_range ||
2051
+ checkValidRange(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2052
+ this._raw = raw;
2095
2053
  }
2096
2054
  },
2097
2055
  enumerable: false,
2098
2056
  configurable: true
2099
2057
  });
2100
- Object.defineProperty(CMI.prototype, "comments", {
2058
+ Object.defineProperty(CMIScore.prototype, "min", {
2101
2059
  get: function () {
2102
- return this._comments;
2060
+ return this._min;
2103
2061
  },
2104
- set: function (comments) {
2105
- if (check12ValidFormat(comments, scorm12_cmi_scorm12_regex.CMIString4096, true)) {
2106
- this._comments = comments;
2062
+ set: function (min) {
2063
+ if (checkValidFormat(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2064
+ (!this.__score_range ||
2065
+ checkValidRange(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2066
+ this._min = min;
2107
2067
  }
2108
2068
  },
2109
2069
  enumerable: false,
2110
2070
  configurable: true
2111
2071
  });
2112
- Object.defineProperty(CMI.prototype, "comments_from_lms", {
2072
+ Object.defineProperty(CMIScore.prototype, "max", {
2113
2073
  get: function () {
2114
- return this._comments_from_lms;
2074
+ return this._max;
2115
2075
  },
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;
2076
+ set: function (max) {
2077
+ if (checkValidFormat(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
2078
+ (!this.__score_range ||
2079
+ checkValidRange(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
2080
+ this._max = max;
2122
2081
  }
2123
2082
  },
2124
2083
  enumerable: false,
2125
2084
  configurable: true
2126
2085
  });
2127
- CMI.prototype.getCurrentTotalTime = function () {
2128
- return this.core.getCurrentTotalTime(this.start_time);
2086
+ CMIScore.prototype.toJSON = function () {
2087
+ this.jsonString = true;
2088
+ var result = {
2089
+ raw: this.raw,
2090
+ min: this.min,
2091
+ max: this.max,
2092
+ };
2093
+ delete this.jsonString;
2094
+ return result;
2129
2095
  };
2130
- return CMI;
2131
- }(BaseRootCMI));
2096
+ return CMIScore;
2097
+ }(BaseCMI));
2098
+
2099
+
2100
+ ;// ./src/cmi/aicc/core.ts
2101
+
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+
2108
+
2132
2109
 
2133
2110
  var CMICore = (function (_super) {
2134
2111
  __extends(CMICore, _super);
2135
2112
  function CMICore() {
2136
2113
  var _this = _super.call(this) || this;
2137
- _this.__children = scorm12_cmi_scorm12_constants.core_children;
2114
+ _this.__children = api_constants.scorm12.core_children;
2138
2115
  _this._student_id = "";
2139
2116
  _this._student_name = "";
2140
2117
  _this._lesson_location = "";
@@ -2147,11 +2124,11 @@ var CMICore = (function (_super) {
2147
2124
  _this._session_time = "00:00:00";
2148
2125
  _this._suspend_data = "";
2149
2126
  _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,
2127
+ score_children: api_constants.scorm12.score_children,
2128
+ score_range: regex.scorm12.score_range,
2129
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
2130
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
2131
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
2155
2132
  errorClass: Scorm12ValidationError,
2156
2133
  });
2157
2134
  return _this;
@@ -2166,7 +2143,7 @@ var CMICore = (function (_super) {
2166
2143
  return this.__children;
2167
2144
  },
2168
2145
  set: function (_children) {
2169
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2146
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2170
2147
  },
2171
2148
  enumerable: false,
2172
2149
  configurable: true
@@ -2177,7 +2154,7 @@ var CMICore = (function (_super) {
2177
2154
  },
2178
2155
  set: function (student_id) {
2179
2156
  if (this.initialized) {
2180
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2157
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2181
2158
  }
2182
2159
  else {
2183
2160
  this._student_id = student_id;
@@ -2192,7 +2169,7 @@ var CMICore = (function (_super) {
2192
2169
  },
2193
2170
  set: function (student_name) {
2194
2171
  if (this.initialized) {
2195
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2172
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2196
2173
  }
2197
2174
  else {
2198
2175
  this._student_name = student_name;
@@ -2206,7 +2183,7 @@ var CMICore = (function (_super) {
2206
2183
  return this._lesson_location;
2207
2184
  },
2208
2185
  set: function (lesson_location) {
2209
- if (check12ValidFormat(lesson_location, scorm12_cmi_scorm12_regex.CMIString256, true)) {
2186
+ if (check12ValidFormat(lesson_location, regex.scorm12.CMIString256, true)) {
2210
2187
  this._lesson_location = lesson_location;
2211
2188
  }
2212
2189
  },
@@ -2219,7 +2196,7 @@ var CMICore = (function (_super) {
2219
2196
  },
2220
2197
  set: function (credit) {
2221
2198
  if (this.initialized) {
2222
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2199
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2223
2200
  }
2224
2201
  else {
2225
2202
  this._credit = credit;
@@ -2234,12 +2211,12 @@ var CMICore = (function (_super) {
2234
2211
  },
2235
2212
  set: function (lesson_status) {
2236
2213
  if (this.initialized) {
2237
- if (check12ValidFormat(lesson_status, scorm12_cmi_scorm12_regex.CMIStatus)) {
2214
+ if (check12ValidFormat(lesson_status, regex.scorm12.CMIStatus)) {
2238
2215
  this._lesson_status = lesson_status;
2239
2216
  }
2240
2217
  }
2241
2218
  else {
2242
- if (check12ValidFormat(lesson_status, scorm12_cmi_scorm12_regex.CMIStatus2)) {
2219
+ if (check12ValidFormat(lesson_status, regex.scorm12.CMIStatus2)) {
2243
2220
  this._lesson_status = lesson_status;
2244
2221
  }
2245
2222
  }
@@ -2253,7 +2230,7 @@ var CMICore = (function (_super) {
2253
2230
  },
2254
2231
  set: function (entry) {
2255
2232
  if (this.initialized) {
2256
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2233
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2257
2234
  }
2258
2235
  else {
2259
2236
  this._entry = entry;
@@ -2268,7 +2245,7 @@ var CMICore = (function (_super) {
2268
2245
  },
2269
2246
  set: function (total_time) {
2270
2247
  if (this.initialized) {
2271
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2248
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2272
2249
  }
2273
2250
  else {
2274
2251
  this._total_time = total_time;
@@ -2283,7 +2260,7 @@ var CMICore = (function (_super) {
2283
2260
  },
2284
2261
  set: function (lesson_mode) {
2285
2262
  if (this.initialized) {
2286
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2263
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2287
2264
  }
2288
2265
  else {
2289
2266
  this._lesson_mode = lesson_mode;
@@ -2295,12 +2272,12 @@ var CMICore = (function (_super) {
2295
2272
  Object.defineProperty(CMICore.prototype, "exit", {
2296
2273
  get: function () {
2297
2274
  if (!this.jsonString) {
2298
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2275
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2299
2276
  }
2300
2277
  return this._exit;
2301
2278
  },
2302
2279
  set: function (exit) {
2303
- if (check12ValidFormat(exit, scorm12_cmi_scorm12_regex.CMIExit, true)) {
2280
+ if (check12ValidFormat(exit, regex.scorm12.CMIExit, true)) {
2304
2281
  this._exit = exit;
2305
2282
  }
2306
2283
  },
@@ -2310,12 +2287,12 @@ var CMICore = (function (_super) {
2310
2287
  Object.defineProperty(CMICore.prototype, "session_time", {
2311
2288
  get: function () {
2312
2289
  if (!this.jsonString) {
2313
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2290
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2314
2291
  }
2315
2292
  return this._session_time;
2316
2293
  },
2317
2294
  set: function (session_time) {
2318
- if (check12ValidFormat(session_time, scorm12_cmi_scorm12_regex.CMITimespan)) {
2295
+ if (check12ValidFormat(session_time, regex.scorm12.CMITimespan)) {
2319
2296
  this._session_time = session_time;
2320
2297
  }
2321
2298
  },
@@ -2327,7 +2304,7 @@ var CMICore = (function (_super) {
2327
2304
  return this._suspend_data;
2328
2305
  },
2329
2306
  set: function (suspend_data) {
2330
- if (check12ValidFormat(suspend_data, scorm12_cmi_scorm12_regex.CMIString4096, true)) {
2307
+ if (check12ValidFormat(suspend_data, regex.scorm12.CMIString4096, true)) {
2331
2308
  this._suspend_data = suspend_data;
2332
2309
  }
2333
2310
  },
@@ -2341,7 +2318,7 @@ var CMICore = (function (_super) {
2341
2318
  var seconds = new Date().getTime() - startTime;
2342
2319
  sessionTime = getSecondsAsHHMMSS(seconds / 1000);
2343
2320
  }
2344
- return addHHMMSSTimeStrings(this._total_time, sessionTime, new RegExp(scorm12_cmi_scorm12_regex.CMITimespan));
2321
+ return addHHMMSSTimeStrings(this._total_time, sessionTime, new RegExp(regex.scorm12.CMITimespan));
2345
2322
  };
2346
2323
  CMICore.prototype.toJSON = function () {
2347
2324
  this.jsonString = true;
@@ -2363,18 +2340,89 @@ var CMICore = (function (_super) {
2363
2340
  return CMICore;
2364
2341
  }(BaseCMI));
2365
2342
 
2343
+
2344
+ ;// ./src/cmi/scorm12/objectives.ts
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2366
2354
  var CMIObjectives = (function (_super) {
2367
2355
  __extends(CMIObjectives, _super);
2368
2356
  function CMIObjectives() {
2369
2357
  return _super.call(this, {
2370
- children: scorm12_cmi_scorm12_constants.objectives_children,
2371
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2358
+ children: api_constants.scorm12.objectives_children,
2359
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2372
2360
  errorClass: Scorm12ValidationError,
2373
2361
  }) || this;
2374
2362
  }
2375
2363
  return CMIObjectives;
2376
2364
  }(CMIArray));
2377
2365
 
2366
+ var CMIObjectivesObject = (function (_super) {
2367
+ __extends(CMIObjectivesObject, _super);
2368
+ function CMIObjectivesObject() {
2369
+ var _this = _super.call(this) || this;
2370
+ _this._id = "";
2371
+ _this._status = "";
2372
+ _this.score = new CMIScore({
2373
+ score_children: api_constants.scorm12.score_children,
2374
+ score_range: regex.scorm12.score_range,
2375
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
2376
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
2377
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
2378
+ errorClass: Scorm12ValidationError,
2379
+ });
2380
+ return _this;
2381
+ }
2382
+ Object.defineProperty(CMIObjectivesObject.prototype, "id", {
2383
+ get: function () {
2384
+ return this._id;
2385
+ },
2386
+ set: function (id) {
2387
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2388
+ this._id = id;
2389
+ }
2390
+ },
2391
+ enumerable: false,
2392
+ configurable: true
2393
+ });
2394
+ Object.defineProperty(CMIObjectivesObject.prototype, "status", {
2395
+ get: function () {
2396
+ return this._status;
2397
+ },
2398
+ set: function (status) {
2399
+ if (check12ValidFormat(status, regex.scorm12.CMIStatus2)) {
2400
+ this._status = status;
2401
+ }
2402
+ },
2403
+ enumerable: false,
2404
+ configurable: true
2405
+ });
2406
+ CMIObjectivesObject.prototype.toJSON = function () {
2407
+ this.jsonString = true;
2408
+ var result = {
2409
+ id: this.id,
2410
+ status: this.status,
2411
+ score: this.score,
2412
+ };
2413
+ delete this.jsonString;
2414
+ return result;
2415
+ };
2416
+ return CMIObjectivesObject;
2417
+ }(BaseCMI));
2418
+
2419
+
2420
+ ;// ./src/cmi/scorm12/student_data.ts
2421
+
2422
+
2423
+
2424
+
2425
+
2378
2426
  var CMIStudentData = (function (_super) {
2379
2427
  __extends(CMIStudentData, _super);
2380
2428
  function CMIStudentData(student_data_children) {
@@ -2384,7 +2432,7 @@ var CMIStudentData = (function (_super) {
2384
2432
  _this._time_limit_action = "";
2385
2433
  _this.__children = student_data_children
2386
2434
  ? student_data_children
2387
- : scorm12_cmi_scorm12_constants.student_data_children;
2435
+ : api_constants.scorm12.student_data_children;
2388
2436
  return _this;
2389
2437
  }
2390
2438
  Object.defineProperty(CMIStudentData.prototype, "_children", {
@@ -2392,7 +2440,7 @@ var CMIStudentData = (function (_super) {
2392
2440
  return this.__children;
2393
2441
  },
2394
2442
  set: function (_children) {
2395
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2443
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2396
2444
  },
2397
2445
  enumerable: false,
2398
2446
  configurable: true
@@ -2403,7 +2451,7 @@ var CMIStudentData = (function (_super) {
2403
2451
  },
2404
2452
  set: function (mastery_score) {
2405
2453
  if (this.initialized) {
2406
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2454
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2407
2455
  }
2408
2456
  else {
2409
2457
  this._mastery_score = mastery_score;
@@ -2418,7 +2466,7 @@ var CMIStudentData = (function (_super) {
2418
2466
  },
2419
2467
  set: function (max_time_allowed) {
2420
2468
  if (this.initialized) {
2421
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2469
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2422
2470
  }
2423
2471
  else {
2424
2472
  this._max_time_allowed = max_time_allowed;
@@ -2433,7 +2481,7 @@ var CMIStudentData = (function (_super) {
2433
2481
  },
2434
2482
  set: function (time_limit_action) {
2435
2483
  if (this.initialized) {
2436
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.READ_ONLY_ELEMENT);
2484
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2437
2485
  }
2438
2486
  else {
2439
2487
  this._time_limit_action = time_limit_action;
@@ -2455,6 +2503,15 @@ var CMIStudentData = (function (_super) {
2455
2503
  return CMIStudentData;
2456
2504
  }(BaseCMI));
2457
2505
 
2506
+
2507
+ ;// ./src/cmi/scorm12/student_preference.ts
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2458
2515
  var CMIStudentPreference = (function (_super) {
2459
2516
  __extends(CMIStudentPreference, _super);
2460
2517
  function CMIStudentPreference(student_preference_children) {
@@ -2465,7 +2522,7 @@ var CMIStudentPreference = (function (_super) {
2465
2522
  _this._text = "";
2466
2523
  _this.__children = student_preference_children
2467
2524
  ? student_preference_children
2468
- : scorm12_cmi_scorm12_constants.student_preference_children;
2525
+ : api_constants.scorm12.student_preference_children;
2469
2526
  return _this;
2470
2527
  }
2471
2528
  Object.defineProperty(CMIStudentPreference.prototype, "_children", {
@@ -2473,7 +2530,7 @@ var CMIStudentPreference = (function (_super) {
2473
2530
  return this.__children;
2474
2531
  },
2475
2532
  set: function (_children) {
2476
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE);
2533
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2477
2534
  },
2478
2535
  enumerable: false,
2479
2536
  configurable: true
@@ -2483,8 +2540,8 @@ var CMIStudentPreference = (function (_super) {
2483
2540
  return this._audio;
2484
2541
  },
2485
2542
  set: function (audio) {
2486
- if (check12ValidFormat(audio, scorm12_cmi_scorm12_regex.CMISInteger) &&
2487
- check12ValidRange(audio, scorm12_cmi_scorm12_regex.audio_range)) {
2543
+ if (check12ValidFormat(audio, regex.scorm12.CMISInteger) &&
2544
+ check12ValidRange(audio, regex.scorm12.audio_range)) {
2488
2545
  this._audio = audio;
2489
2546
  }
2490
2547
  },
@@ -2496,7 +2553,7 @@ var CMIStudentPreference = (function (_super) {
2496
2553
  return this._language;
2497
2554
  },
2498
2555
  set: function (language) {
2499
- if (check12ValidFormat(language, scorm12_cmi_scorm12_regex.CMIString256)) {
2556
+ if (check12ValidFormat(language, regex.scorm12.CMIString256)) {
2500
2557
  this._language = language;
2501
2558
  }
2502
2559
  },
@@ -2508,8 +2565,8 @@ var CMIStudentPreference = (function (_super) {
2508
2565
  return this._speed;
2509
2566
  },
2510
2567
  set: function (speed) {
2511
- if (check12ValidFormat(speed, scorm12_cmi_scorm12_regex.CMISInteger) &&
2512
- check12ValidRange(speed, scorm12_cmi_scorm12_regex.speed_range)) {
2568
+ if (check12ValidFormat(speed, regex.scorm12.CMISInteger) &&
2569
+ check12ValidRange(speed, regex.scorm12.speed_range)) {
2513
2570
  this._speed = speed;
2514
2571
  }
2515
2572
  },
@@ -2521,8 +2578,8 @@ var CMIStudentPreference = (function (_super) {
2521
2578
  return this._text;
2522
2579
  },
2523
2580
  set: function (text) {
2524
- if (check12ValidFormat(text, scorm12_cmi_scorm12_regex.CMISInteger) &&
2525
- check12ValidRange(text, scorm12_cmi_scorm12_regex.text_range)) {
2581
+ if (check12ValidFormat(text, regex.scorm12.CMISInteger) &&
2582
+ check12ValidRange(text, regex.scorm12.text_range)) {
2526
2583
  this._text = text;
2527
2584
  }
2528
2585
  },
@@ -2543,12 +2600,22 @@ var CMIStudentPreference = (function (_super) {
2543
2600
  return CMIStudentPreference;
2544
2601
  }(BaseCMI));
2545
2602
 
2603
+
2604
+ ;// ./src/cmi/scorm12/interactions.ts
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2546
2613
  var CMIInteractions = (function (_super) {
2547
2614
  __extends(CMIInteractions, _super);
2548
2615
  function CMIInteractions() {
2549
2616
  return _super.call(this, {
2550
- children: scorm12_cmi_scorm12_constants.interactions_children,
2551
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2617
+ children: api_constants.scorm12.interactions_children,
2618
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2552
2619
  errorClass: Scorm12ValidationError,
2553
2620
  }) || this;
2554
2621
  }
@@ -2567,14 +2634,14 @@ var CMIInteractionsObject = (function (_super) {
2567
2634
  _this._result = "";
2568
2635
  _this._latency = "";
2569
2636
  _this.objectives = new CMIArray({
2570
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2637
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2571
2638
  errorClass: Scorm12ValidationError,
2572
- children: scorm12_cmi_scorm12_constants.objectives_children,
2639
+ children: api_constants.scorm12.objectives_children,
2573
2640
  });
2574
2641
  _this.correct_responses = new CMIArray({
2575
- errorCode: scorm12_cmi_scorm12_error_codes.INVALID_SET_VALUE,
2642
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
2576
2643
  errorClass: Scorm12ValidationError,
2577
- children: scorm12_cmi_scorm12_constants.correct_responses_children,
2644
+ children: api_constants.scorm12.correct_responses_children,
2578
2645
  });
2579
2646
  return _this;
2580
2647
  }
@@ -2587,12 +2654,12 @@ var CMIInteractionsObject = (function (_super) {
2587
2654
  Object.defineProperty(CMIInteractionsObject.prototype, "id", {
2588
2655
  get: function () {
2589
2656
  if (!this.jsonString) {
2590
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2657
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2591
2658
  }
2592
2659
  return this._id;
2593
2660
  },
2594
2661
  set: function (id) {
2595
- if (check12ValidFormat(id, scorm12_cmi_scorm12_regex.CMIIdentifier)) {
2662
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2596
2663
  this._id = id;
2597
2664
  }
2598
2665
  },
@@ -2602,12 +2669,12 @@ var CMIInteractionsObject = (function (_super) {
2602
2669
  Object.defineProperty(CMIInteractionsObject.prototype, "time", {
2603
2670
  get: function () {
2604
2671
  if (!this.jsonString) {
2605
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2672
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2606
2673
  }
2607
2674
  return this._time;
2608
2675
  },
2609
2676
  set: function (time) {
2610
- if (check12ValidFormat(time, scorm12_cmi_scorm12_regex.CMITime)) {
2677
+ if (check12ValidFormat(time, regex.scorm12.CMITime)) {
2611
2678
  this._time = time;
2612
2679
  }
2613
2680
  },
@@ -2617,12 +2684,12 @@ var CMIInteractionsObject = (function (_super) {
2617
2684
  Object.defineProperty(CMIInteractionsObject.prototype, "type", {
2618
2685
  get: function () {
2619
2686
  if (!this.jsonString) {
2620
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2687
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2621
2688
  }
2622
2689
  return this._type;
2623
2690
  },
2624
2691
  set: function (type) {
2625
- if (check12ValidFormat(type, scorm12_cmi_scorm12_regex.CMIType)) {
2692
+ if (check12ValidFormat(type, regex.scorm12.CMIType)) {
2626
2693
  this._type = type;
2627
2694
  }
2628
2695
  },
@@ -2632,13 +2699,13 @@ var CMIInteractionsObject = (function (_super) {
2632
2699
  Object.defineProperty(CMIInteractionsObject.prototype, "weighting", {
2633
2700
  get: function () {
2634
2701
  if (!this.jsonString) {
2635
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2702
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2636
2703
  }
2637
2704
  return this._weighting;
2638
2705
  },
2639
2706
  set: function (weighting) {
2640
- if (check12ValidFormat(weighting, scorm12_cmi_scorm12_regex.CMIDecimal) &&
2641
- check12ValidRange(weighting, scorm12_cmi_scorm12_regex.weighting_range)) {
2707
+ if (check12ValidFormat(weighting, regex.scorm12.CMIDecimal) &&
2708
+ check12ValidRange(weighting, regex.scorm12.weighting_range)) {
2642
2709
  this._weighting = weighting;
2643
2710
  }
2644
2711
  },
@@ -2648,12 +2715,12 @@ var CMIInteractionsObject = (function (_super) {
2648
2715
  Object.defineProperty(CMIInteractionsObject.prototype, "student_response", {
2649
2716
  get: function () {
2650
2717
  if (!this.jsonString) {
2651
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2718
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2652
2719
  }
2653
2720
  return this._student_response;
2654
2721
  },
2655
2722
  set: function (student_response) {
2656
- if (check12ValidFormat(student_response, scorm12_cmi_scorm12_regex.CMIFeedback, true)) {
2723
+ if (check12ValidFormat(student_response, regex.scorm12.CMIFeedback, true)) {
2657
2724
  this._student_response = student_response;
2658
2725
  }
2659
2726
  },
@@ -2663,12 +2730,12 @@ var CMIInteractionsObject = (function (_super) {
2663
2730
  Object.defineProperty(CMIInteractionsObject.prototype, "result", {
2664
2731
  get: function () {
2665
2732
  if (!this.jsonString) {
2666
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2733
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2667
2734
  }
2668
2735
  return this._result;
2669
2736
  },
2670
2737
  set: function (result) {
2671
- if (check12ValidFormat(result, scorm12_cmi_scorm12_regex.CMIResult)) {
2738
+ if (check12ValidFormat(result, regex.scorm12.CMIResult)) {
2672
2739
  this._result = result;
2673
2740
  }
2674
2741
  },
@@ -2678,12 +2745,12 @@ var CMIInteractionsObject = (function (_super) {
2678
2745
  Object.defineProperty(CMIInteractionsObject.prototype, "latency", {
2679
2746
  get: function () {
2680
2747
  if (!this.jsonString) {
2681
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2748
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2682
2749
  }
2683
2750
  return this._latency;
2684
2751
  },
2685
2752
  set: function (latency) {
2686
- if (check12ValidFormat(latency, scorm12_cmi_scorm12_regex.CMITimespan)) {
2753
+ if (check12ValidFormat(latency, regex.scorm12.CMITimespan)) {
2687
2754
  this._latency = latency;
2688
2755
  }
2689
2756
  },
@@ -2709,59 +2776,6 @@ var CMIInteractionsObject = (function (_super) {
2709
2776
  return CMIInteractionsObject;
2710
2777
  }(BaseCMI));
2711
2778
 
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
2779
  var CMIInteractionsObjectivesObject = (function (_super) {
2766
2780
  __extends(CMIInteractionsObjectivesObject, _super);
2767
2781
  function CMIInteractionsObjectivesObject() {
@@ -2774,7 +2788,7 @@ var CMIInteractionsObjectivesObject = (function (_super) {
2774
2788
  return this._id;
2775
2789
  },
2776
2790
  set: function (id) {
2777
- if (check12ValidFormat(id, scorm12_cmi_scorm12_regex.CMIIdentifier)) {
2791
+ if (check12ValidFormat(id, regex.scorm12.CMIIdentifier)) {
2778
2792
  this._id = id;
2779
2793
  }
2780
2794
  },
@@ -2802,12 +2816,12 @@ var CMIInteractionsCorrectResponsesObject = (function (_super) {
2802
2816
  Object.defineProperty(CMIInteractionsCorrectResponsesObject.prototype, "pattern", {
2803
2817
  get: function () {
2804
2818
  if (!this.jsonString) {
2805
- throw new Scorm12ValidationError(scorm12_cmi_scorm12_error_codes.WRITE_ONLY_ELEMENT);
2819
+ throw new Scorm12ValidationError(error_codes.scorm12.WRITE_ONLY_ELEMENT);
2806
2820
  }
2807
2821
  return this._pattern;
2808
2822
  },
2809
2823
  set: function (pattern) {
2810
- if (check12ValidFormat(pattern, scorm12_cmi_scorm12_regex.CMIFeedback, true)) {
2824
+ if (check12ValidFormat(pattern, regex.scorm12.CMIFeedback, true)) {
2811
2825
  this._pattern = pattern;
2812
2826
  }
2813
2827
  },
@@ -2825,6 +2839,153 @@ var CMIInteractionsCorrectResponsesObject = (function (_super) {
2825
2839
  return CMIInteractionsCorrectResponsesObject;
2826
2840
  }(BaseCMI));
2827
2841
 
2842
+
2843
+ ;// ./src/cmi/scorm12/cmi.ts
2844
+
2845
+
2846
+
2847
+
2848
+
2849
+
2850
+
2851
+
2852
+
2853
+
2854
+
2855
+
2856
+ var CMI = (function (_super) {
2857
+ __extends(CMI, _super);
2858
+ function CMI(cmi_children, student_data, initialized) {
2859
+ var _this = _super.call(this) || this;
2860
+ _this.__children = "";
2861
+ _this.__version = "3.4";
2862
+ _this._launch_data = "";
2863
+ _this._comments = "";
2864
+ _this._comments_from_lms = "";
2865
+ if (initialized)
2866
+ _this.initialize();
2867
+ _this.__children = cmi_children
2868
+ ? cmi_children
2869
+ : api_constants.scorm12.cmi_children;
2870
+ _this.core = new CMICore();
2871
+ _this.objectives = new CMIObjectives();
2872
+ _this.student_data = student_data ? student_data : new CMIStudentData();
2873
+ _this.student_preference = new CMIStudentPreference();
2874
+ _this.interactions = new CMIInteractions();
2875
+ return _this;
2876
+ }
2877
+ CMI.prototype.initialize = function () {
2878
+ var _a, _b, _c, _d, _e;
2879
+ _super.prototype.initialize.call(this);
2880
+ (_a = this.core) === null || _a === void 0 ? void 0 : _a.initialize();
2881
+ (_b = this.objectives) === null || _b === void 0 ? void 0 : _b.initialize();
2882
+ (_c = this.student_data) === null || _c === void 0 ? void 0 : _c.initialize();
2883
+ (_d = this.student_preference) === null || _d === void 0 ? void 0 : _d.initialize();
2884
+ (_e = this.interactions) === null || _e === void 0 ? void 0 : _e.initialize();
2885
+ };
2886
+ CMI.prototype.toJSON = function () {
2887
+ this.jsonString = true;
2888
+ var result = {
2889
+ suspend_data: this.suspend_data,
2890
+ launch_data: this.launch_data,
2891
+ comments: this.comments,
2892
+ comments_from_lms: this.comments_from_lms,
2893
+ core: this.core,
2894
+ objectives: this.objectives,
2895
+ student_data: this.student_data,
2896
+ student_preference: this.student_preference,
2897
+ interactions: this.interactions,
2898
+ };
2899
+ delete this.jsonString;
2900
+ return result;
2901
+ };
2902
+ Object.defineProperty(CMI.prototype, "_version", {
2903
+ get: function () {
2904
+ return this.__version;
2905
+ },
2906
+ set: function (_version) {
2907
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2908
+ },
2909
+ enumerable: false,
2910
+ configurable: true
2911
+ });
2912
+ Object.defineProperty(CMI.prototype, "_children", {
2913
+ get: function () {
2914
+ return this.__children;
2915
+ },
2916
+ set: function (_children) {
2917
+ throw new Scorm12ValidationError(error_codes.scorm12.INVALID_SET_VALUE);
2918
+ },
2919
+ enumerable: false,
2920
+ configurable: true
2921
+ });
2922
+ Object.defineProperty(CMI.prototype, "suspend_data", {
2923
+ get: function () {
2924
+ var _a;
2925
+ return (_a = this.core) === null || _a === void 0 ? void 0 : _a.suspend_data;
2926
+ },
2927
+ set: function (suspend_data) {
2928
+ if (this.core) {
2929
+ this.core.suspend_data = suspend_data;
2930
+ }
2931
+ },
2932
+ enumerable: false,
2933
+ configurable: true
2934
+ });
2935
+ Object.defineProperty(CMI.prototype, "launch_data", {
2936
+ get: function () {
2937
+ return this._launch_data;
2938
+ },
2939
+ set: function (launch_data) {
2940
+ if (this.initialized) {
2941
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2942
+ }
2943
+ else {
2944
+ this._launch_data = launch_data;
2945
+ }
2946
+ },
2947
+ enumerable: false,
2948
+ configurable: true
2949
+ });
2950
+ Object.defineProperty(CMI.prototype, "comments", {
2951
+ get: function () {
2952
+ return this._comments;
2953
+ },
2954
+ set: function (comments) {
2955
+ if (check12ValidFormat(comments, regex.scorm12.CMIString4096, true)) {
2956
+ this._comments = comments;
2957
+ }
2958
+ },
2959
+ enumerable: false,
2960
+ configurable: true
2961
+ });
2962
+ Object.defineProperty(CMI.prototype, "comments_from_lms", {
2963
+ get: function () {
2964
+ return this._comments_from_lms;
2965
+ },
2966
+ set: function (comments_from_lms) {
2967
+ if (this.initialized) {
2968
+ throw new Scorm12ValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
2969
+ }
2970
+ else {
2971
+ this._comments_from_lms = comments_from_lms;
2972
+ }
2973
+ },
2974
+ enumerable: false,
2975
+ configurable: true
2976
+ });
2977
+ CMI.prototype.getCurrentTotalTime = function () {
2978
+ return this.core.getCurrentTotalTime(this.start_time);
2979
+ };
2980
+ return CMI;
2981
+ }(BaseRootCMI));
2982
+
2983
+
2984
+ ;// ./src/cmi/scorm12/nav.ts
2985
+
2986
+
2987
+
2988
+
2828
2989
  var NAV = (function (_super) {
2829
2990
  __extends(NAV, _super);
2830
2991
  function NAV() {
@@ -2837,7 +2998,7 @@ var NAV = (function (_super) {
2837
2998
  return this._event;
2838
2999
  },
2839
3000
  set: function (event) {
2840
- if (check12ValidFormat(event, scorm12_cmi_scorm12_regex.NAVEvent)) {
3001
+ if (check12ValidFormat(event, regex.scorm12.NAVEvent)) {
2841
3002
  this._event = event;
2842
3003
  }
2843
3004
  },
@@ -2863,9 +3024,10 @@ var NAV = (function (_super) {
2863
3024
 
2864
3025
 
2865
3026
 
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;
3027
+
3028
+
3029
+
3030
+
2869
3031
  var Scorm12API = (function (_super) {
2870
3032
  __extends(Scorm12API, _super);
2871
3033
  function Scorm12API(settings) {
@@ -2875,7 +3037,8 @@ var Scorm12API = (function (_super) {
2875
3037
  settings.mastery_override = false;
2876
3038
  }
2877
3039
  }
2878
- _this = _super.call(this, Scorm12API_scorm12_error_codes, settings) || this;
3040
+ _this = _super.call(this, error_codes.scorm12, settings) || this;
3041
+ _this.statusSetByModule = false;
2879
3042
  _this.cmi = new CMI();
2880
3043
  _this.nav = new NAV();
2881
3044
  _this.LMSInitialize = _this.lmsInitialize;
@@ -2888,35 +3051,83 @@ var Scorm12API = (function (_super) {
2888
3051
  _this.LMSGetDiagnostic = _this.lmsGetDiagnostic;
2889
3052
  return _this;
2890
3053
  }
3054
+ Scorm12API.prototype.reset = function (settings) {
3055
+ this.commonReset(settings);
3056
+ this.cmi = new CMI();
3057
+ this.nav = new NAV();
3058
+ };
2891
3059
  Scorm12API.prototype.lmsInitialize = function () {
2892
3060
  this.cmi.initialize();
3061
+ if (this.cmi.core.lesson_status) {
3062
+ this.statusSetByModule = true;
3063
+ }
3064
+ else {
3065
+ this.cmi.core.lesson_status = "not attempted";
3066
+ }
2893
3067
  return this.initialize("LMSInitialize", "LMS was already initialized!", "LMS is already finished!");
2894
3068
  };
2895
3069
  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");
3070
+ var _this = this;
3071
+ (function () { return __awaiter(_this, void 0, void 0, function () {
3072
+ return __generator(this, function (_a) {
3073
+ switch (_a.label) {
3074
+ case 0: return [4, this.internalFinish()];
3075
+ case 1:
3076
+ _a.sent();
3077
+ return [2];
2901
3078
  }
2902
- else {
2903
- this.processListeners("SequencePrevious");
3079
+ });
3080
+ }); })();
3081
+ return api_constants.global.SCORM_TRUE;
3082
+ };
3083
+ Scorm12API.prototype.internalFinish = function () {
3084
+ return __awaiter(this, void 0, void 0, function () {
3085
+ var result;
3086
+ return __generator(this, function (_a) {
3087
+ switch (_a.label) {
3088
+ case 0: return [4, this.terminate("LMSFinish", true)];
3089
+ case 1:
3090
+ result = _a.sent();
3091
+ if (result === api_constants.global.SCORM_TRUE) {
3092
+ if (this.nav.event !== "") {
3093
+ if (this.nav.event === "continue") {
3094
+ this.processListeners("SequenceNext");
3095
+ }
3096
+ else {
3097
+ this.processListeners("SequencePrevious");
3098
+ }
3099
+ }
3100
+ else if (this.settings.autoProgress) {
3101
+ this.processListeners("SequenceNext");
3102
+ }
3103
+ }
3104
+ return [2, result];
2904
3105
  }
2905
- }
2906
- else if (this.settings.autoProgress) {
2907
- this.processListeners("SequenceNext");
2908
- }
2909
- }
2910
- return result;
3106
+ });
3107
+ });
2911
3108
  };
2912
3109
  Scorm12API.prototype.lmsGetValue = function (CMIElement) {
2913
3110
  return this.getValue("LMSGetValue", false, CMIElement);
2914
3111
  };
2915
3112
  Scorm12API.prototype.lmsSetValue = function (CMIElement, value) {
3113
+ if (CMIElement === "cmi.core.lesson_status") {
3114
+ this.statusSetByModule = true;
3115
+ }
2916
3116
  return this.setValue("LMSSetValue", "LMSCommit", false, CMIElement, value);
2917
3117
  };
2918
3118
  Scorm12API.prototype.lmsCommit = function () {
2919
- return this.commit("LMSCommit", false);
3119
+ var _this = this;
3120
+ (function () { return __awaiter(_this, void 0, void 0, function () {
3121
+ return __generator(this, function (_a) {
3122
+ switch (_a.label) {
3123
+ case 0: return [4, this.commit("LMSCommit", false)];
3124
+ case 1:
3125
+ _a.sent();
3126
+ return [2];
3127
+ }
3128
+ });
3129
+ }); })();
3130
+ return api_constants.global.SCORM_TRUE;
2920
3131
  };
2921
3132
  Scorm12API.prototype.lmsGetLastError = function () {
2922
3133
  return this.getLastError("LMSGetLastError");
@@ -2934,19 +3145,19 @@ var Scorm12API = (function (_super) {
2934
3145
  return this._commonGetCMIValue("getCMIValue", false, CMIElement);
2935
3146
  };
2936
3147
  Scorm12API.prototype.getChildElement = function (CMIElement, _value, foundFirstIndex) {
2937
- if (this.stringMatches(CMIElement, "cmi\\.objectives\\.\\d+")) {
3148
+ if (stringMatches(CMIElement, "cmi\\.objectives\\.\\d+")) {
2938
3149
  return new CMIObjectivesObject();
2939
3150
  }
2940
3151
  else if (foundFirstIndex &&
2941
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")) {
3152
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")) {
2942
3153
  return new CMIInteractionsCorrectResponsesObject();
2943
3154
  }
2944
3155
  else if (foundFirstIndex &&
2945
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
3156
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
2946
3157
  return new CMIInteractionsObjectivesObject();
2947
3158
  }
2948
3159
  else if (!foundFirstIndex &&
2949
- this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
3160
+ stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
2950
3161
  return new CMIInteractionsObject();
2951
3162
  }
2952
3163
  return null;
@@ -2957,11 +3168,11 @@ var Scorm12API = (function (_super) {
2957
3168
  var basicMessage = "No Error";
2958
3169
  var detailMessage = "No Error";
2959
3170
  errorNumber = String(errorNumber);
2960
- if (Scorm12API_scorm12_constants.error_descriptions[errorNumber]) {
3171
+ if (api_constants.scorm12.error_descriptions[errorNumber]) {
2961
3172
  basicMessage =
2962
- Scorm12API_scorm12_constants.error_descriptions[errorNumber].basicMessage;
3173
+ api_constants.scorm12.error_descriptions[errorNumber].basicMessage;
2963
3174
  detailMessage =
2964
- Scorm12API_scorm12_constants.error_descriptions[errorNumber].detailMessage;
3175
+ api_constants.scorm12.error_descriptions[errorNumber].detailMessage;
2965
3176
  }
2966
3177
  return detail ? detailMessage : basicMessage;
2967
3178
  };
@@ -2991,111 +3202,76 @@ var Scorm12API = (function (_super) {
2991
3202
  }
2992
3203
  };
2993
3204
  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";
3205
+ return __awaiter(this, void 0, void 0, function () {
3206
+ var originalStatus, commitObject;
3207
+ var _a, _b, _c;
3208
+ return __generator(this, function (_d) {
3209
+ switch (_d.label) {
3210
+ case 0:
3211
+ if (terminateCommit) {
3212
+ originalStatus = this.cmi.core.lesson_status;
3213
+ if (!this.cmi.core.lesson_status ||
3214
+ (!this.statusSetByModule &&
3215
+ this.cmi.core.lesson_status === "not attempted")) {
3216
+ this.cmi.core.lesson_status = "completed";
3217
+ }
3218
+ if (this.cmi.core.lesson_mode === "normal") {
3219
+ if (this.cmi.core.credit === "credit") {
3220
+ if (this.settings.mastery_override &&
3221
+ this.cmi.student_data.mastery_score !== "" &&
3222
+ this.cmi.core.score.raw !== "") {
3223
+ this.cmi.core.lesson_status =
3224
+ parseFloat(this.cmi.core.score.raw) >=
3225
+ parseFloat(this.cmi.student_data.mastery_score)
3226
+ ? "passed"
3227
+ : "failed";
3228
+ }
3229
+ }
3230
+ }
3231
+ else if (this.cmi.core.lesson_mode === "browse") {
3232
+ 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) || "") === "" &&
3233
+ originalStatus === "not attempted") {
3234
+ this.cmi.core.lesson_status = "browsed";
3235
+ }
3236
+ }
3008
3237
  }
3009
- else {
3010
- this.cmi.core.lesson_status = "failed";
3238
+ commitObject = this.renderCommitCMI(terminateCommit || this.settings.alwaysSendTotalTime);
3239
+ if (this.apiLogLevel === api_constants.global.LOG_LEVEL_DEBUG) {
3240
+ console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
3241
+ console.debug(commitObject);
3011
3242
  }
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";
3243
+ if (!(typeof this.settings.lmsCommitUrl === "string")) return [3, 2];
3244
+ return [4, this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit)];
3245
+ case 1: return [2, _d.sent()];
3246
+ case 2: return [2, {
3247
+ result: api_constants.global.SCORM_TRUE,
3248
+ errorCode: 0,
3249
+ }];
3019
3250
  }
3020
- }
3021
- }
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);
3029
- }
3030
- else {
3031
- return {
3032
- result: Scorm12API_global_constants.SCORM_TRUE,
3033
- errorCode: 0,
3034
- };
3035
- }
3251
+ });
3252
+ });
3036
3253
  };
3037
3254
  return Scorm12API;
3038
3255
  }(src_BaseAPI));
3039
3256
  /* harmony default export */ var src_Scorm12API = (Scorm12API);
3040
3257
 
3041
- ;// ./src/cmi/aicc_cmi.ts
3042
-
3043
-
3044
-
3045
-
3258
+ ;// ./src/cmi/aicc/validation.ts
3046
3259
 
3047
3260
 
3048
3261
 
3049
- var aicc_constants = api_constants.aicc;
3050
- var aicc_regex = regex.aicc;
3051
3262
  var aicc_error_codes = error_codes.scorm12;
3052
3263
  function checkAICCValidFormat(value, regexPattern, allowEmptyString) {
3053
3264
  return checkValidFormat(value, regexPattern, aicc_error_codes.TYPE_MISMATCH, AICCValidationError, allowEmptyString);
3054
3265
  }
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));
3266
+
3267
+ ;// ./src/cmi/aicc/evaluation.ts
3268
+
3269
+
3270
+
3271
+
3272
+
3273
+
3274
+
3099
3275
 
3100
3276
  var CMIEvaluation = (function (_super) {
3101
3277
  __extends(CMIEvaluation, _super);
@@ -3119,28 +3295,97 @@ var CMIEvaluation = (function (_super) {
3119
3295
  };
3120
3296
  return CMIEvaluation;
3121
3297
  }(BaseCMI));
3298
+
3122
3299
  var CMIEvaluationComments = (function (_super) {
3123
3300
  __extends(CMIEvaluationComments, _super);
3124
3301
  function CMIEvaluationComments() {
3125
3302
  return _super.call(this, {
3126
- children: aicc_constants.comments_children,
3127
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
3303
+ children: api_constants.aicc.comments_children,
3304
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
3128
3305
  errorClass: AICCValidationError,
3129
3306
  }) || this;
3130
3307
  }
3131
3308
  return CMIEvaluationComments;
3132
3309
  }(CMIArray));
3310
+ var CMIEvaluationCommentsObject = (function (_super) {
3311
+ __extends(CMIEvaluationCommentsObject, _super);
3312
+ function CMIEvaluationCommentsObject() {
3313
+ var _this = _super.call(this) || this;
3314
+ _this._content = "";
3315
+ _this._location = "";
3316
+ _this._time = "";
3317
+ return _this;
3318
+ }
3319
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "content", {
3320
+ get: function () {
3321
+ return this._content;
3322
+ },
3323
+ set: function (content) {
3324
+ if (checkAICCValidFormat(content, regex.aicc.CMIString256)) {
3325
+ this._content = content;
3326
+ }
3327
+ },
3328
+ enumerable: false,
3329
+ configurable: true
3330
+ });
3331
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "location", {
3332
+ get: function () {
3333
+ return this._location;
3334
+ },
3335
+ set: function (location) {
3336
+ if (checkAICCValidFormat(location, regex.aicc.CMIString256)) {
3337
+ this._location = location;
3338
+ }
3339
+ },
3340
+ enumerable: false,
3341
+ configurable: true
3342
+ });
3343
+ Object.defineProperty(CMIEvaluationCommentsObject.prototype, "time", {
3344
+ get: function () {
3345
+ return this._time;
3346
+ },
3347
+ set: function (time) {
3348
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3349
+ this._time = time;
3350
+ }
3351
+ },
3352
+ enumerable: false,
3353
+ configurable: true
3354
+ });
3355
+ CMIEvaluationCommentsObject.prototype.toJSON = function () {
3356
+ this.jsonString = true;
3357
+ var result = {
3358
+ content: this.content,
3359
+ location: this.location,
3360
+ time: this.time,
3361
+ };
3362
+ delete this.jsonString;
3363
+ return result;
3364
+ };
3365
+ return CMIEvaluationCommentsObject;
3366
+ }(BaseCMI));
3367
+
3368
+
3369
+ ;// ./src/cmi/aicc/student_preferences.ts
3370
+
3371
+
3372
+
3373
+
3374
+
3375
+
3376
+
3377
+
3133
3378
  var AICCStudentPreferences = (function (_super) {
3134
3379
  __extends(AICCStudentPreferences, _super);
3135
3380
  function AICCStudentPreferences() {
3136
- var _this = _super.call(this, aicc_constants.student_preference_children) || this;
3381
+ var _this = _super.call(this, api_constants.aicc.student_preference_children) || this;
3137
3382
  _this._lesson_type = "";
3138
3383
  _this._text_color = "";
3139
3384
  _this._text_location = "";
3140
3385
  _this._text_size = "";
3141
3386
  _this._video = "";
3142
3387
  _this.windows = new CMIArray({
3143
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
3388
+ errorCode: error_codes.scorm12.INVALID_SET_VALUE,
3144
3389
  errorClass: AICCValidationError,
3145
3390
  children: "",
3146
3391
  });
@@ -3156,7 +3401,7 @@ var AICCStudentPreferences = (function (_super) {
3156
3401
  return this._lesson_type;
3157
3402
  },
3158
3403
  set: function (lesson_type) {
3159
- if (checkAICCValidFormat(lesson_type, aicc_regex.CMIString256)) {
3404
+ if (checkAICCValidFormat(lesson_type, regex.aicc.CMIString256)) {
3160
3405
  this._lesson_type = lesson_type;
3161
3406
  }
3162
3407
  },
@@ -3168,7 +3413,7 @@ var AICCStudentPreferences = (function (_super) {
3168
3413
  return this._text_color;
3169
3414
  },
3170
3415
  set: function (text_color) {
3171
- if (checkAICCValidFormat(text_color, aicc_regex.CMIString256)) {
3416
+ if (checkAICCValidFormat(text_color, regex.aicc.CMIString256)) {
3172
3417
  this._text_color = text_color;
3173
3418
  }
3174
3419
  },
@@ -3180,7 +3425,7 @@ var AICCStudentPreferences = (function (_super) {
3180
3425
  return this._text_location;
3181
3426
  },
3182
3427
  set: function (text_location) {
3183
- if (checkAICCValidFormat(text_location, aicc_regex.CMIString256)) {
3428
+ if (checkAICCValidFormat(text_location, regex.aicc.CMIString256)) {
3184
3429
  this._text_location = text_location;
3185
3430
  }
3186
3431
  },
@@ -3192,7 +3437,7 @@ var AICCStudentPreferences = (function (_super) {
3192
3437
  return this._text_size;
3193
3438
  },
3194
3439
  set: function (text_size) {
3195
- if (checkAICCValidFormat(text_size, aicc_regex.CMIString256)) {
3440
+ if (checkAICCValidFormat(text_size, regex.aicc.CMIString256)) {
3196
3441
  this._text_size = text_size;
3197
3442
  }
3198
3443
  },
@@ -3204,7 +3449,7 @@ var AICCStudentPreferences = (function (_super) {
3204
3449
  return this._video;
3205
3450
  },
3206
3451
  set: function (video) {
3207
- if (checkAICCValidFormat(video, aicc_regex.CMIString256)) {
3452
+ if (checkAICCValidFormat(video, regex.aicc.CMIString256)) {
3208
3453
  this._video = video;
3209
3454
  }
3210
3455
  },
@@ -3230,52 +3475,19 @@ var AICCStudentPreferences = (function (_super) {
3230
3475
  };
3231
3476
  return AICCStudentPreferences;
3232
3477
  }(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));
3478
+
3479
+
3480
+ ;// ./src/cmi/aicc/student_demographics.ts
3481
+
3482
+
3483
+
3484
+
3485
+
3274
3486
  var CMIStudentDemographics = (function (_super) {
3275
3487
  __extends(CMIStudentDemographics, _super);
3276
3488
  function CMIStudentDemographics() {
3277
3489
  var _this = _super.call(this) || this;
3278
- _this.__children = aicc_constants.student_demographics_children;
3490
+ _this.__children = api_constants.aicc.student_demographics_children;
3279
3491
  _this._city = "";
3280
3492
  _this._class = "";
3281
3493
  _this._company = "";
@@ -3304,7 +3516,7 @@ var CMIStudentDemographics = (function (_super) {
3304
3516
  },
3305
3517
  set: function (city) {
3306
3518
  if (this.initialized) {
3307
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3519
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3308
3520
  }
3309
3521
  else {
3310
3522
  this._city = city;
@@ -3319,7 +3531,7 @@ var CMIStudentDemographics = (function (_super) {
3319
3531
  },
3320
3532
  set: function (clazz) {
3321
3533
  if (this.initialized) {
3322
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3534
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3323
3535
  }
3324
3536
  else {
3325
3537
  this._class = clazz;
@@ -3334,7 +3546,7 @@ var CMIStudentDemographics = (function (_super) {
3334
3546
  },
3335
3547
  set: function (company) {
3336
3548
  if (this.initialized) {
3337
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3549
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3338
3550
  }
3339
3551
  else {
3340
3552
  this._company = company;
@@ -3349,7 +3561,7 @@ var CMIStudentDemographics = (function (_super) {
3349
3561
  },
3350
3562
  set: function (country) {
3351
3563
  if (this.initialized) {
3352
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3564
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3353
3565
  }
3354
3566
  else {
3355
3567
  this._country = country;
@@ -3364,7 +3576,7 @@ var CMIStudentDemographics = (function (_super) {
3364
3576
  },
3365
3577
  set: function (experience) {
3366
3578
  if (this.initialized) {
3367
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3579
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3368
3580
  }
3369
3581
  else {
3370
3582
  this._experience = experience;
@@ -3379,7 +3591,7 @@ var CMIStudentDemographics = (function (_super) {
3379
3591
  },
3380
3592
  set: function (familiar_name) {
3381
3593
  if (this.initialized) {
3382
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3594
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3383
3595
  }
3384
3596
  else {
3385
3597
  this._familiar_name = familiar_name;
@@ -3394,7 +3606,7 @@ var CMIStudentDemographics = (function (_super) {
3394
3606
  },
3395
3607
  set: function (instructor_name) {
3396
3608
  if (this.initialized) {
3397
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3609
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3398
3610
  }
3399
3611
  else {
3400
3612
  this._instructor_name = instructor_name;
@@ -3409,7 +3621,7 @@ var CMIStudentDemographics = (function (_super) {
3409
3621
  },
3410
3622
  set: function (title) {
3411
3623
  if (this.initialized) {
3412
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3624
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3413
3625
  }
3414
3626
  else {
3415
3627
  this._title = title;
@@ -3424,7 +3636,7 @@ var CMIStudentDemographics = (function (_super) {
3424
3636
  },
3425
3637
  set: function (native_language) {
3426
3638
  if (this.initialized) {
3427
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3639
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3428
3640
  }
3429
3641
  else {
3430
3642
  this._native_language = native_language;
@@ -3439,7 +3651,7 @@ var CMIStudentDemographics = (function (_super) {
3439
3651
  },
3440
3652
  set: function (state) {
3441
3653
  if (this.initialized) {
3442
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3654
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3443
3655
  }
3444
3656
  else {
3445
3657
  this._state = state;
@@ -3454,7 +3666,7 @@ var CMIStudentDemographics = (function (_super) {
3454
3666
  },
3455
3667
  set: function (street_address) {
3456
3668
  if (this.initialized) {
3457
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3669
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3458
3670
  }
3459
3671
  else {
3460
3672
  this._street_address = street_address;
@@ -3469,7 +3681,7 @@ var CMIStudentDemographics = (function (_super) {
3469
3681
  },
3470
3682
  set: function (telephone) {
3471
3683
  if (this.initialized) {
3472
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3684
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3473
3685
  }
3474
3686
  else {
3475
3687
  this._telephone = telephone;
@@ -3484,7 +3696,7 @@ var CMIStudentDemographics = (function (_super) {
3484
3696
  },
3485
3697
  set: function (years_experience) {
3486
3698
  if (this.initialized) {
3487
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
3699
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3488
3700
  }
3489
3701
  else {
3490
3702
  this._years_experience = years_experience;
@@ -3516,121 +3728,22 @@ var CMIStudentDemographics = (function (_super) {
3516
3728
  return CMIStudentDemographics;
3517
3729
  }(BaseCMI));
3518
3730
 
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
3731
 
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));
3732
+ ;// ./src/cmi/aicc/tries.ts
3733
+
3734
+
3735
+
3736
+
3737
+
3738
+
3739
+
3740
+
3628
3741
 
3629
3742
  var CMITries = (function (_super) {
3630
3743
  __extends(CMITries, _super);
3631
3744
  function CMITries() {
3632
3745
  return _super.call(this, {
3633
- children: aicc_constants.tries_children,
3746
+ children: api_constants.aicc.tries_children,
3634
3747
  }) || this;
3635
3748
  }
3636
3749
  return CMITries;
@@ -3643,11 +3756,11 @@ var CMITriesObject = (function (_super) {
3643
3756
  _this._status = "";
3644
3757
  _this._time = "";
3645
3758
  _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,
3759
+ score_children: api_constants.aicc.score_children,
3760
+ score_range: regex.aicc.score_range,
3761
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
3762
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
3763
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
3651
3764
  errorClass: AICCValidationError,
3652
3765
  });
3653
3766
  return _this;
@@ -3662,7 +3775,7 @@ var CMITriesObject = (function (_super) {
3662
3775
  return this._status;
3663
3776
  },
3664
3777
  set: function (status) {
3665
- if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
3778
+ if (checkAICCValidFormat(status, regex.aicc.CMIStatus2)) {
3666
3779
  this._status = status;
3667
3780
  }
3668
3781
  },
@@ -3674,7 +3787,7 @@ var CMITriesObject = (function (_super) {
3674
3787
  return this._time;
3675
3788
  },
3676
3789
  set: function (time) {
3677
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
3790
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3678
3791
  this._time = time;
3679
3792
  }
3680
3793
  },
@@ -3694,11 +3807,22 @@ var CMITriesObject = (function (_super) {
3694
3807
  return CMITriesObject;
3695
3808
  }(BaseCMI));
3696
3809
 
3810
+
3811
+ ;// ./src/cmi/aicc/attempts.ts
3812
+
3813
+
3814
+
3815
+
3816
+
3817
+
3818
+
3819
+
3820
+
3697
3821
  var CMIAttemptRecords = (function (_super) {
3698
3822
  __extends(CMIAttemptRecords, _super);
3699
3823
  function CMIAttemptRecords() {
3700
3824
  return _super.call(this, {
3701
- children: aicc_constants.attempt_records_children,
3825
+ children: api_constants.aicc.attempt_records_children,
3702
3826
  }) || this;
3703
3827
  }
3704
3828
  return CMIAttemptRecords;
@@ -3710,11 +3834,11 @@ var CMIAttemptRecordsObject = (function (_super) {
3710
3834
  var _this = _super.call(this) || this;
3711
3835
  _this._lesson_status = "";
3712
3836
  _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,
3837
+ score_children: api_constants.aicc.score_children,
3838
+ score_range: regex.aicc.score_range,
3839
+ invalidErrorCode: error_codes.scorm12.INVALID_SET_VALUE,
3840
+ invalidTypeCode: error_codes.scorm12.TYPE_MISMATCH,
3841
+ invalidRangeCode: error_codes.scorm12.VALUE_OUT_OF_RANGE,
3718
3842
  errorClass: AICCValidationError,
3719
3843
  });
3720
3844
  return _this;
@@ -3729,7 +3853,7 @@ var CMIAttemptRecordsObject = (function (_super) {
3729
3853
  return this._lesson_status;
3730
3854
  },
3731
3855
  set: function (lesson_status) {
3732
- if (checkAICCValidFormat(lesson_status, aicc_regex.CMIStatus2)) {
3856
+ if (checkAICCValidFormat(lesson_status, regex.aicc.CMIStatus2)) {
3733
3857
  this._lesson_status = lesson_status;
3734
3858
  }
3735
3859
  },
@@ -3748,90 +3872,267 @@ var CMIAttemptRecordsObject = (function (_super) {
3748
3872
  return CMIAttemptRecordsObject;
3749
3873
  }(BaseCMI));
3750
3874
 
3751
- var CMIEvaluationCommentsObject = (function (_super) {
3752
- __extends(CMIEvaluationCommentsObject, _super);
3753
- function CMIEvaluationCommentsObject() {
3875
+
3876
+ ;// ./src/cmi/aicc/student_data.ts
3877
+
3878
+
3879
+
3880
+
3881
+
3882
+
3883
+
3884
+ var AICCCMIStudentData = (function (_super) {
3885
+ __extends(AICCCMIStudentData, _super);
3886
+ function AICCCMIStudentData() {
3887
+ var _this = _super.call(this, api_constants.aicc.student_data_children) || this;
3888
+ _this._tries_during_lesson = "";
3889
+ _this.tries = new CMITries();
3890
+ _this.attempt_records = new CMIAttemptRecords();
3891
+ return _this;
3892
+ }
3893
+ AICCCMIStudentData.prototype.initialize = function () {
3894
+ var _a, _b;
3895
+ _super.prototype.initialize.call(this);
3896
+ (_a = this.tries) === null || _a === void 0 ? void 0 : _a.initialize();
3897
+ (_b = this.attempt_records) === null || _b === void 0 ? void 0 : _b.initialize();
3898
+ };
3899
+ Object.defineProperty(AICCCMIStudentData.prototype, "tries_during_lesson", {
3900
+ get: function () {
3901
+ return this._tries_during_lesson;
3902
+ },
3903
+ set: function (tries_during_lesson) {
3904
+ if (this.initialized) {
3905
+ throw new AICCValidationError(error_codes.scorm12.READ_ONLY_ELEMENT);
3906
+ }
3907
+ else {
3908
+ this._tries_during_lesson = tries_during_lesson;
3909
+ }
3910
+ },
3911
+ enumerable: false,
3912
+ configurable: true
3913
+ });
3914
+ AICCCMIStudentData.prototype.toJSON = function () {
3915
+ this.jsonString = true;
3916
+ var result = {
3917
+ mastery_score: this.mastery_score,
3918
+ max_time_allowed: this.max_time_allowed,
3919
+ time_limit_action: this.time_limit_action,
3920
+ tries: this.tries,
3921
+ attempt_records: this.attempt_records,
3922
+ };
3923
+ delete this.jsonString;
3924
+ return result;
3925
+ };
3926
+ return AICCCMIStudentData;
3927
+ }(CMIStudentData));
3928
+
3929
+
3930
+ ;// ./src/cmi/aicc/paths.ts
3931
+
3932
+
3933
+
3934
+
3935
+
3936
+
3937
+ var CMIPaths = (function (_super) {
3938
+ __extends(CMIPaths, _super);
3939
+ function CMIPaths() {
3940
+ return _super.call(this, {
3941
+ children: api_constants.aicc.paths_children,
3942
+ }) || this;
3943
+ }
3944
+ return CMIPaths;
3945
+ }(CMIArray));
3946
+
3947
+ var CMIPathsObject = (function (_super) {
3948
+ __extends(CMIPathsObject, _super);
3949
+ function CMIPathsObject() {
3754
3950
  var _this = _super.call(this) || this;
3755
- _this._content = "";
3756
- _this._location = "";
3951
+ _this._location_id = "";
3952
+ _this._date = "";
3757
3953
  _this._time = "";
3954
+ _this._status = "";
3955
+ _this._why_left = "";
3956
+ _this._time_in_element = "";
3758
3957
  return _this;
3759
3958
  }
3760
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "content", {
3959
+ Object.defineProperty(CMIPathsObject.prototype, "location_id", {
3761
3960
  get: function () {
3762
- return this._content;
3961
+ return this._location_id;
3763
3962
  },
3764
- set: function (content) {
3765
- if (checkAICCValidFormat(content, aicc_regex.CMIString256)) {
3766
- this._content = content;
3963
+ set: function (location_id) {
3964
+ if (checkAICCValidFormat(location_id, regex.aicc.CMIString256)) {
3965
+ this._location_id = location_id;
3767
3966
  }
3768
3967
  },
3769
3968
  enumerable: false,
3770
3969
  configurable: true
3771
3970
  });
3772
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "location", {
3971
+ Object.defineProperty(CMIPathsObject.prototype, "date", {
3773
3972
  get: function () {
3774
- return this._location;
3973
+ return this._date;
3775
3974
  },
3776
- set: function (location) {
3777
- if (checkAICCValidFormat(location, aicc_regex.CMIString256)) {
3778
- this._location = location;
3975
+ set: function (date) {
3976
+ if (checkAICCValidFormat(date, regex.aicc.CMIString256)) {
3977
+ this._date = date;
3779
3978
  }
3780
3979
  },
3781
3980
  enumerable: false,
3782
3981
  configurable: true
3783
3982
  });
3784
- Object.defineProperty(CMIEvaluationCommentsObject.prototype, "time", {
3983
+ Object.defineProperty(CMIPathsObject.prototype, "time", {
3785
3984
  get: function () {
3786
3985
  return this._time;
3787
3986
  },
3788
3987
  set: function (time) {
3789
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
3988
+ if (checkAICCValidFormat(time, regex.aicc.CMITime)) {
3790
3989
  this._time = time;
3791
3990
  }
3792
3991
  },
3793
3992
  enumerable: false,
3794
3993
  configurable: true
3795
3994
  });
3796
- CMIEvaluationCommentsObject.prototype.toJSON = function () {
3995
+ Object.defineProperty(CMIPathsObject.prototype, "status", {
3996
+ get: function () {
3997
+ return this._status;
3998
+ },
3999
+ set: function (status) {
4000
+ if (checkAICCValidFormat(status, regex.aicc.CMIStatus2)) {
4001
+ this._status = status;
4002
+ }
4003
+ },
4004
+ enumerable: false,
4005
+ configurable: true
4006
+ });
4007
+ Object.defineProperty(CMIPathsObject.prototype, "why_left", {
4008
+ get: function () {
4009
+ return this._why_left;
4010
+ },
4011
+ set: function (why_left) {
4012
+ if (checkAICCValidFormat(why_left, regex.aicc.CMIString256)) {
4013
+ this._why_left = why_left;
4014
+ }
4015
+ },
4016
+ enumerable: false,
4017
+ configurable: true
4018
+ });
4019
+ Object.defineProperty(CMIPathsObject.prototype, "time_in_element", {
4020
+ get: function () {
4021
+ return this._time_in_element;
4022
+ },
4023
+ set: function (time_in_element) {
4024
+ if (checkAICCValidFormat(time_in_element, regex.aicc.CMITime)) {
4025
+ this._time_in_element = time_in_element;
4026
+ }
4027
+ },
4028
+ enumerable: false,
4029
+ configurable: true
4030
+ });
4031
+ CMIPathsObject.prototype.toJSON = function () {
3797
4032
  this.jsonString = true;
3798
4033
  var result = {
3799
- content: this.content,
3800
- location: this.location,
4034
+ location_id: this.location_id,
4035
+ date: this.date,
3801
4036
  time: this.time,
4037
+ status: this.status,
4038
+ why_left: this.why_left,
4039
+ time_in_element: this.time_in_element,
3802
4040
  };
3803
4041
  delete this.jsonString;
3804
4042
  return result;
3805
4043
  };
3806
- return CMIEvaluationCommentsObject;
4044
+ return CMIPathsObject;
3807
4045
  }(BaseCMI));
3808
4046
 
3809
4047
 
4048
+ ;// ./src/cmi/aicc/cmi.ts
4049
+
4050
+
4051
+
4052
+
4053
+
4054
+
4055
+
4056
+
4057
+ var cmi_CMI = (function (_super) {
4058
+ __extends(CMI, _super);
4059
+ function CMI(initialized) {
4060
+ if (initialized === void 0) { initialized = false; }
4061
+ var _this = _super.call(this, api_constants.aicc.cmi_children) || this;
4062
+ if (initialized)
4063
+ _this.initialize();
4064
+ _this.student_preference = new AICCStudentPreferences();
4065
+ _this.student_data = new AICCCMIStudentData();
4066
+ _this.student_demographics = new CMIStudentDemographics();
4067
+ _this.evaluation = new CMIEvaluation();
4068
+ _this.paths = new CMIPaths();
4069
+ return _this;
4070
+ }
4071
+ CMI.prototype.initialize = function () {
4072
+ var _a, _b, _c, _d, _e;
4073
+ _super.prototype.initialize.call(this);
4074
+ (_a = this.student_preference) === null || _a === void 0 ? void 0 : _a.initialize();
4075
+ (_b = this.student_data) === null || _b === void 0 ? void 0 : _b.initialize();
4076
+ (_c = this.student_demographics) === null || _c === void 0 ? void 0 : _c.initialize();
4077
+ (_d = this.evaluation) === null || _d === void 0 ? void 0 : _d.initialize();
4078
+ (_e = this.paths) === null || _e === void 0 ? void 0 : _e.initialize();
4079
+ };
4080
+ CMI.prototype.toJSON = function () {
4081
+ this.jsonString = true;
4082
+ var result = {
4083
+ suspend_data: this.suspend_data,
4084
+ launch_data: this.launch_data,
4085
+ comments: this.comments,
4086
+ comments_from_lms: this.comments_from_lms,
4087
+ core: this.core,
4088
+ objectives: this.objectives,
4089
+ student_data: this.student_data,
4090
+ student_preference: this.student_preference,
4091
+ student_demographics: this.student_demographics,
4092
+ interactions: this.interactions,
4093
+ evaluation: this.evaluation,
4094
+ paths: this.paths,
4095
+ };
4096
+ delete this.jsonString;
4097
+ return result;
4098
+ };
4099
+ return CMI;
4100
+ }(CMI));
4101
+
4102
+
3810
4103
  ;// ./src/AICC.ts
3811
4104
 
3812
4105
 
3813
4106
 
3814
4107
 
4108
+
4109
+
4110
+
4111
+
4112
+
3815
4113
  var AICC = (function (_super) {
3816
4114
  __extends(AICC, _super);
3817
4115
  function AICC(settings) {
3818
4116
  var _this = _super.call(this, settings) || this;
3819
- _this.cmi = new aicc_cmi_CMI();
4117
+ _this.cmi = new cmi_CMI();
3820
4118
  _this.nav = new NAV();
3821
4119
  return _this;
3822
4120
  }
3823
4121
  AICC.prototype.getChildElement = function (CMIElement, value, foundFirstIndex) {
3824
4122
  var newChild = _super.prototype.getChildElement.call(this, CMIElement, value, foundFirstIndex);
3825
4123
  if (!newChild) {
3826
- if (this.stringMatches(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")) {
4124
+ if (stringMatches(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")) {
3827
4125
  newChild = new CMIEvaluationCommentsObject();
3828
4126
  }
3829
- else if (this.stringMatches(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")) {
4127
+ else if (stringMatches(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")) {
3830
4128
  newChild = new CMITriesObject();
3831
4129
  }
3832
- else if (this.stringMatches(CMIElement, "cmi\\.student_data\\.attempt_records\\.\\d+")) {
4130
+ else if (stringMatches(CMIElement, "cmi\\.student_data\\.attempt_records\\.\\d+")) {
3833
4131
  newChild = new CMIAttemptRecordsObject();
3834
4132
  }
4133
+ else if (stringMatches(CMIElement, "cmi\\.paths\\.\\d+")) {
4134
+ newChild = new CMIPathsObject();
4135
+ }
3835
4136
  }
3836
4137
  return newChild;
3837
4138
  };