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.
- package/.github/workflows/stale.yml +14 -0
- package/.run/{Mocha Unit Tests.run.xml → Mocha Unit Tests (watch).run.xml } +1 -1
- package/.run/Template Mocha.run.xml +17 -0
- package/README.md +171 -72
- package/dist/aicc.js +1441 -1140
- package/dist/aicc.js.map +1 -1
- package/dist/aicc.min.js +1 -1
- package/dist/aicc.min.js.map +1 -1
- package/dist/scorm-again.js +2703 -2212
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +1 -1
- package/dist/scorm-again.min.js.map +1 -1
- package/dist/scorm12.js +1069 -852
- package/dist/scorm12.js.map +1 -1
- package/dist/scorm12.min.js +1 -1
- package/dist/scorm12.min.js.map +1 -1
- package/dist/scorm2004.js +1861 -1571
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/package.json +10 -6
- package/src/AICC.ts +15 -17
- package/src/BaseAPI.ts +268 -417
- package/src/Scorm12API.ts +65 -38
- package/src/Scorm2004API.ts +151 -117
- package/src/cmi/aicc/attempts.ts +94 -0
- package/src/cmi/aicc/cmi.ts +100 -0
- package/src/cmi/aicc/core.ts +360 -0
- package/src/cmi/aicc/evaluation.ts +157 -0
- package/src/cmi/aicc/paths.ts +180 -0
- package/src/cmi/aicc/student_data.ts +86 -0
- package/src/cmi/aicc/student_demographics.ts +367 -0
- package/src/cmi/aicc/student_preferences.ts +176 -0
- package/src/cmi/aicc/tries.ts +116 -0
- package/src/cmi/aicc/validation.ts +25 -0
- package/src/cmi/common/array.ts +77 -0
- package/src/cmi/common/base_cmi.ts +46 -0
- package/src/cmi/common/score.ts +203 -0
- package/src/cmi/common/validation.ts +60 -0
- package/src/cmi/scorm12/cmi.ts +224 -0
- package/src/cmi/scorm12/interactions.ts +368 -0
- package/src/cmi/scorm12/nav.ts +54 -0
- package/src/cmi/scorm12/objectives.ts +112 -0
- package/src/cmi/scorm12/student_data.ts +130 -0
- package/src/cmi/scorm12/student_preference.ts +158 -0
- package/src/cmi/scorm12/validation.ts +48 -0
- package/src/cmi/scorm2004/adl.ts +272 -0
- package/src/cmi/scorm2004/cmi.ts +599 -0
- package/src/cmi/scorm2004/comments.ts +163 -0
- package/src/cmi/scorm2004/interactions.ts +466 -0
- package/src/cmi/scorm2004/learner_preference.ts +152 -0
- package/src/cmi/scorm2004/objectives.ts +212 -0
- package/src/cmi/scorm2004/score.ts +78 -0
- package/src/cmi/scorm2004/validation.ts +42 -0
- package/src/constants/default_settings.ts +81 -0
- package/src/constants/enums.ts +5 -0
- package/src/constants/regex.ts +2 -2
- package/src/constants/response_constants.ts +2 -0
- package/src/exceptions.ts +22 -1
- package/src/helpers/scheduled_commit.ts +42 -0
- package/src/interfaces/IBaseAPI.ts +35 -0
- package/src/types/api_types.ts +32 -0
- package/src/utilities/debounce.ts +31 -0
- package/src/utilities.ts +56 -0
- package/test/AICC.spec.ts +11 -1
- package/test/Scorm12API.spec.ts +262 -9
- package/test/Scorm2004API.spec.ts +488 -2
- package/test/cmi/aicc_cmi.spec.ts +188 -11
- package/test/cmi/scorm12_cmi.spec.ts +5 -5
- package/test/cmi/scorm2004_cmi.spec.ts +8 -8
- package/test/cmi_helpers.ts +1 -1
- package/test/types/api_types.spec.ts +126 -0
- package/test/utilities/debounce.spec.ts +56 -0
- package/src/cmi/aicc_cmi.ts +0 -1248
- package/src/cmi/common.ts +0 -411
- package/src/cmi/scorm12_cmi.ts +0 -1426
- package/src/cmi/scorm2004_cmi.ts +0 -1874
package/dist/scorm2004.js
CHANGED
|
@@ -381,9 +381,88 @@ function __disposeResources(env) {
|
|
|
381
381
|
__disposeResources,
|
|
382
382
|
});
|
|
383
383
|
|
|
384
|
-
;// ./src/
|
|
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
|
|
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({},
|
|
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
|
|
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:
|
|
586
|
-
scorm12:
|
|
664
|
+
global: api_constants_global,
|
|
665
|
+
scorm12: api_constants_scorm12,
|
|
587
666
|
aicc: aicc,
|
|
588
|
-
scorm2004:
|
|
667
|
+
scorm2004: api_constants_scorm2004,
|
|
589
668
|
};
|
|
590
669
|
/* harmony default export */ var api_constants = (APIConstants);
|
|
591
670
|
|
|
592
|
-
;// ./src/
|
|
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
|
|
709
|
-
var
|
|
710
|
-
var
|
|
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
|
|
733
|
-
__extends(
|
|
734
|
-
function
|
|
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.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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
|
-
|
|
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.
|
|
712
|
+
return this._errorMessage;
|
|
786
713
|
},
|
|
787
714
|
enumerable: false,
|
|
788
715
|
configurable: true
|
|
789
716
|
});
|
|
790
|
-
Object.defineProperty(
|
|
717
|
+
Object.defineProperty(ValidationError.prototype, "detailedMessage", {
|
|
791
718
|
get: function () {
|
|
792
|
-
return this.
|
|
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/
|
|
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
|
-
|
|
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:
|
|
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,
|
|
1235
|
-
return __generator(this, function (
|
|
1236
|
-
switch (
|
|
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
|
-
|
|
1057
|
+
_b = (_a = JSON).parse;
|
|
1240
1058
|
return [4, response.text()];
|
|
1241
1059
|
case 1:
|
|
1242
|
-
httpResult =
|
|
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:
|
|
1065
|
+
result: api_constants.global.SCORM_TRUE,
|
|
1248
1066
|
errorCode: 0,
|
|
1249
1067
|
}];
|
|
1250
1068
|
}
|
|
1251
1069
|
else {
|
|
1252
1070
|
return [2, {
|
|
1253
|
-
result:
|
|
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 ===
|
|
1081
|
+
: httpResult.result === api_constants.global.SCORM_TRUE
|
|
1264
1082
|
? 0
|
|
1265
1083
|
: 101,
|
|
1266
1084
|
}];
|
|
1267
1085
|
}
|
|
1268
|
-
|
|
1086
|
+
_c.label = 2;
|
|
1269
1087
|
case 2: return [2, {
|
|
1270
|
-
result:
|
|
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
|
|
1100
|
+
case api_constants.global.LOG_LEVEL_ERROR:
|
|
1283
1101
|
console.error(logMessage);
|
|
1284
1102
|
break;
|
|
1285
|
-
case
|
|
1103
|
+
case api_constants.global.LOG_LEVEL_WARNING:
|
|
1286
1104
|
console.warn(logMessage);
|
|
1287
1105
|
break;
|
|
1288
|
-
case
|
|
1106
|
+
case api_constants.global.LOG_LEVEL_INFO:
|
|
1289
1107
|
console.info(logMessage);
|
|
1290
1108
|
break;
|
|
1291
|
-
case
|
|
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
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
this.
|
|
1310
|
-
this.
|
|
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
|
-
|
|
1320
|
-
|
|
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 =
|
|
1198
|
+
this.currentState = api_constants.global.STATE_INITIALIZED;
|
|
1332
1199
|
this.lastErrorCode = "0";
|
|
1333
|
-
returnValue =
|
|
1200
|
+
returnValue = api_constants.global.SCORM_TRUE;
|
|
1334
1201
|
this.processListeners(callbackName);
|
|
1335
1202
|
}
|
|
1336
|
-
this.apiLog(callbackName, "returned: " + returnValue,
|
|
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
|
-
|
|
1359
|
-
|
|
1360
|
-
this
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
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,
|
|
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 =
|
|
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 =
|
|
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,
|
|
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 (
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
1390
|
+
return api_constants.global.SCORM_FALSE;
|
|
1529
1391
|
}
|
|
1530
1392
|
var structure = CMIElement.split(".");
|
|
1531
1393
|
var refObject = this;
|
|
1532
|
-
var returnValue =
|
|
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
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
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 (
|
|
1551
|
-
this.
|
|
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 =
|
|
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 ===
|
|
1593
|
-
this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value),
|
|
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(
|
|
1518
|
+
this.throwSCORMError(error_codes.scorm12.CHILDREN_ERROR);
|
|
1654
1519
|
}
|
|
1655
1520
|
else if (attribute === "_count") {
|
|
1656
|
-
this.throwSCORMError(
|
|
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 ===
|
|
1530
|
+
return this.currentState === api_constants.global.STATE_INITIALIZED;
|
|
1666
1531
|
};
|
|
1667
1532
|
BaseAPI.prototype.isNotInitialized = function () {
|
|
1668
|
-
return this.currentState ===
|
|
1533
|
+
return this.currentState === api_constants.global.STATE_NOT_INITIALIZED;
|
|
1669
1534
|
};
|
|
1670
1535
|
BaseAPI.prototype.isTerminated = function () {
|
|
1671
|
-
return this.currentState ===
|
|
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),
|
|
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),
|
|
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,
|
|
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),
|
|
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,
|
|
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 !==
|
|
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
|
-
|
|
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 (
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
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
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
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
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
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",
|
|
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",
|
|
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 =
|
|
1826
|
+
returnValue = api_constants.global.SCORM_FALSE;
|
|
1950
1827
|
}
|
|
1951
1828
|
else {
|
|
1952
1829
|
if (e instanceof Error && e.message) {
|
|
@@ -1959,112 +1836,344 @@ var BaseAPI = (function () {
|
|
|
1959
1836
|
}
|
|
1960
1837
|
return returnValue;
|
|
1961
1838
|
};
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
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
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
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
|
|
1883
|
+
return BaseAPI;
|
|
1984
1884
|
}());
|
|
1885
|
+
/* harmony default export */ var src_BaseAPI = (BaseAPI);
|
|
1985
1886
|
|
|
1986
|
-
;// ./src/constants/
|
|
1887
|
+
;// ./src/constants/regex.ts
|
|
1987
1888
|
|
|
1988
|
-
var
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
},
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
"fill-in"
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
"
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
},
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
},
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
},
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
};
|
|
2055
|
-
var
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
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);
|
|
1957
|
+
|
|
1958
|
+
;// ./src/cmi/common/validation.ts
|
|
1959
|
+
function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
|
|
1960
|
+
if (typeof value !== "string") {
|
|
1961
|
+
return false;
|
|
1962
|
+
}
|
|
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/scorm2004/validation.ts
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
function check2004ValidFormat(value, regexPattern, allowEmptyString) {
|
|
1994
|
+
return checkValidFormat(value, regexPattern, error_codes.scorm2004.TYPE_MISMATCH, Scorm2004ValidationError, allowEmptyString);
|
|
1995
|
+
}
|
|
1996
|
+
function check2004ValidRange(value, rangePattern) {
|
|
1997
|
+
return checkValidRange(value, rangePattern, error_codes.scorm2004.VALUE_OUT_OF_RANGE, Scorm2004ValidationError);
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
;// ./src/cmi/scorm2004/learner_preference.ts
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
var CMILearnerPreference = (function (_super) {
|
|
2009
|
+
__extends(CMILearnerPreference, _super);
|
|
2010
|
+
function CMILearnerPreference() {
|
|
2011
|
+
var _this = _super.call(this) || this;
|
|
2012
|
+
_this.__children = api_constants.scorm2004.student_preference_children;
|
|
2013
|
+
_this._audio_level = "1";
|
|
2014
|
+
_this._language = "";
|
|
2015
|
+
_this._delivery_speed = "1";
|
|
2016
|
+
_this._audio_captioning = "0";
|
|
2017
|
+
return _this;
|
|
2018
|
+
}
|
|
2019
|
+
Object.defineProperty(CMILearnerPreference.prototype, "_children", {
|
|
2020
|
+
get: function () {
|
|
2021
|
+
return this.__children;
|
|
2022
|
+
},
|
|
2023
|
+
set: function (_children) {
|
|
2024
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
2025
|
+
},
|
|
2026
|
+
enumerable: false,
|
|
2027
|
+
configurable: true
|
|
2028
|
+
});
|
|
2029
|
+
Object.defineProperty(CMILearnerPreference.prototype, "audio_level", {
|
|
2030
|
+
get: function () {
|
|
2031
|
+
return this._audio_level;
|
|
2032
|
+
},
|
|
2033
|
+
set: function (audio_level) {
|
|
2034
|
+
if (check2004ValidFormat(audio_level, regex.scorm2004.CMIDecimal) &&
|
|
2035
|
+
check2004ValidRange(audio_level, regex.scorm2004.audio_range)) {
|
|
2036
|
+
this._audio_level = audio_level;
|
|
2037
|
+
}
|
|
2038
|
+
},
|
|
2039
|
+
enumerable: false,
|
|
2040
|
+
configurable: true
|
|
2041
|
+
});
|
|
2042
|
+
Object.defineProperty(CMILearnerPreference.prototype, "language", {
|
|
2043
|
+
get: function () {
|
|
2044
|
+
return this._language;
|
|
2045
|
+
},
|
|
2046
|
+
set: function (language) {
|
|
2047
|
+
if (check2004ValidFormat(language, regex.scorm2004.CMILang)) {
|
|
2048
|
+
this._language = language;
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
enumerable: false,
|
|
2052
|
+
configurable: true
|
|
2053
|
+
});
|
|
2054
|
+
Object.defineProperty(CMILearnerPreference.prototype, "delivery_speed", {
|
|
2055
|
+
get: function () {
|
|
2056
|
+
return this._delivery_speed;
|
|
2057
|
+
},
|
|
2058
|
+
set: function (delivery_speed) {
|
|
2059
|
+
if (check2004ValidFormat(delivery_speed, regex.scorm2004.CMIDecimal) &&
|
|
2060
|
+
check2004ValidRange(delivery_speed, regex.scorm2004.speed_range)) {
|
|
2061
|
+
this._delivery_speed = delivery_speed;
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
enumerable: false,
|
|
2065
|
+
configurable: true
|
|
2066
|
+
});
|
|
2067
|
+
Object.defineProperty(CMILearnerPreference.prototype, "audio_captioning", {
|
|
2068
|
+
get: function () {
|
|
2069
|
+
return this._audio_captioning;
|
|
2070
|
+
},
|
|
2071
|
+
set: function (audio_captioning) {
|
|
2072
|
+
if (check2004ValidFormat(audio_captioning, regex.scorm2004.CMISInteger) &&
|
|
2073
|
+
check2004ValidRange(audio_captioning, regex.scorm2004.text_range)) {
|
|
2074
|
+
this._audio_captioning = audio_captioning;
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
2077
|
+
enumerable: false,
|
|
2078
|
+
configurable: true
|
|
2079
|
+
});
|
|
2080
|
+
CMILearnerPreference.prototype.toJSON = function () {
|
|
2081
|
+
this.jsonString = true;
|
|
2082
|
+
var result = {
|
|
2083
|
+
audio_level: this.audio_level,
|
|
2084
|
+
language: this.language,
|
|
2085
|
+
delivery_speed: this.delivery_speed,
|
|
2086
|
+
audio_captioning: this.audio_captioning,
|
|
2087
|
+
};
|
|
2088
|
+
delete this.jsonString;
|
|
2089
|
+
return result;
|
|
2090
|
+
};
|
|
2091
|
+
return CMILearnerPreference;
|
|
2092
|
+
}(BaseCMI));
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
;// ./src/constants/response_constants.ts
|
|
2096
|
+
|
|
2097
|
+
var scorm2004_regex = regex.scorm2004;
|
|
2098
|
+
var LearnerResponses = {
|
|
2099
|
+
"true-false": {
|
|
2100
|
+
format: "^true$|^false$",
|
|
2101
|
+
max: 1,
|
|
2102
|
+
delimiter: "",
|
|
2103
|
+
unique: false,
|
|
2104
|
+
},
|
|
2105
|
+
choice: {
|
|
2106
|
+
format: scorm2004_regex.CMILongIdentifier,
|
|
2107
|
+
max: 36,
|
|
2108
|
+
delimiter: "[,]",
|
|
2109
|
+
unique: true,
|
|
2110
|
+
},
|
|
2111
|
+
"fill-in": {
|
|
2112
|
+
format: scorm2004_regex.CMILangString250,
|
|
2113
|
+
max: 10,
|
|
2114
|
+
delimiter: "[,]",
|
|
2115
|
+
unique: false,
|
|
2116
|
+
},
|
|
2117
|
+
"long-fill-in": {
|
|
2118
|
+
format: scorm2004_regex.CMILangString4000,
|
|
2119
|
+
max: 1,
|
|
2120
|
+
delimiter: "",
|
|
2121
|
+
unique: false,
|
|
2122
|
+
},
|
|
2123
|
+
matching: {
|
|
2124
|
+
format: scorm2004_regex.CMIShortIdentifier,
|
|
2125
|
+
format2: scorm2004_regex.CMIShortIdentifier,
|
|
2126
|
+
max: 36,
|
|
2127
|
+
delimiter: "[,]",
|
|
2128
|
+
delimiter2: "[.]",
|
|
2129
|
+
unique: false,
|
|
2130
|
+
},
|
|
2131
|
+
performance: {
|
|
2132
|
+
format: "^$|" + scorm2004_regex.CMIShortIdentifier,
|
|
2133
|
+
format2: scorm2004_regex.CMIDecimal + "|^$|" + scorm2004_regex.CMIShortIdentifier,
|
|
2134
|
+
max: 250,
|
|
2135
|
+
delimiter: "[,]",
|
|
2136
|
+
delimiter2: "[.]",
|
|
2137
|
+
unique: false,
|
|
2138
|
+
},
|
|
2139
|
+
sequencing: {
|
|
2140
|
+
format: scorm2004_regex.CMIShortIdentifier,
|
|
2141
|
+
max: 36,
|
|
2142
|
+
delimiter: "[,]",
|
|
2143
|
+
unique: false,
|
|
2144
|
+
},
|
|
2145
|
+
likert: {
|
|
2146
|
+
format: scorm2004_regex.CMIShortIdentifier,
|
|
2147
|
+
max: 1,
|
|
2148
|
+
delimiter: "",
|
|
2149
|
+
unique: false,
|
|
2150
|
+
},
|
|
2151
|
+
numeric: {
|
|
2152
|
+
format: scorm2004_regex.CMIDecimal,
|
|
2153
|
+
max: 1,
|
|
2154
|
+
delimiter: "",
|
|
2155
|
+
unique: false,
|
|
2156
|
+
},
|
|
2157
|
+
other: {
|
|
2158
|
+
format: scorm2004_regex.CMIString4000,
|
|
2159
|
+
max: 1,
|
|
2160
|
+
delimiter: "",
|
|
2161
|
+
unique: false,
|
|
2162
|
+
},
|
|
2163
|
+
};
|
|
2164
|
+
var CorrectResponses = {
|
|
2165
|
+
"true-false": {
|
|
2166
|
+
max: 1,
|
|
2167
|
+
delimiter: "",
|
|
2168
|
+
unique: false,
|
|
2169
|
+
duplicate: false,
|
|
2170
|
+
format: "^true$|^false$",
|
|
2171
|
+
limit: 1,
|
|
2172
|
+
},
|
|
2173
|
+
choice: {
|
|
2174
|
+
max: 36,
|
|
2175
|
+
delimiter: "[,]",
|
|
2176
|
+
unique: true,
|
|
2068
2177
|
duplicate: false,
|
|
2069
2178
|
format: scorm2004_regex.CMILongIdentifier,
|
|
2070
2179
|
},
|
|
@@ -2095,6 +2204,7 @@ var CorrectResponses = {
|
|
|
2095
2204
|
max: 250,
|
|
2096
2205
|
delimiter: "[,]",
|
|
2097
2206
|
delimiter2: "[.]",
|
|
2207
|
+
delimiter3: "[:]",
|
|
2098
2208
|
unique: false,
|
|
2099
2209
|
duplicate: false,
|
|
2100
2210
|
format: "^$|" + scorm2004_regex.CMIShortIdentifier,
|
|
@@ -2133,7 +2243,7 @@ var CorrectResponses = {
|
|
|
2133
2243
|
},
|
|
2134
2244
|
};
|
|
2135
2245
|
|
|
2136
|
-
;// ./src/cmi/
|
|
2246
|
+
;// ./src/cmi/scorm2004/interactions.ts
|
|
2137
2247
|
|
|
2138
2248
|
|
|
2139
2249
|
|
|
@@ -2142,734 +2252,588 @@ var CorrectResponses = {
|
|
|
2142
2252
|
|
|
2143
2253
|
|
|
2144
2254
|
|
|
2145
|
-
|
|
2146
|
-
var
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2255
|
+
|
|
2256
|
+
var CMIInteractions = (function (_super) {
|
|
2257
|
+
__extends(CMIInteractions, _super);
|
|
2258
|
+
function CMIInteractions() {
|
|
2259
|
+
return _super.call(this, {
|
|
2260
|
+
children: api_constants.scorm2004.interactions_children,
|
|
2261
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2262
|
+
errorClass: Scorm2004ValidationError,
|
|
2263
|
+
}) || this;
|
|
2264
|
+
}
|
|
2265
|
+
return CMIInteractions;
|
|
2266
|
+
}(CMIArray));
|
|
2267
|
+
|
|
2268
|
+
var CMIInteractionsObject = (function (_super) {
|
|
2269
|
+
__extends(CMIInteractionsObject, _super);
|
|
2270
|
+
function CMIInteractionsObject() {
|
|
2159
2271
|
var _this = _super.call(this) || this;
|
|
2160
|
-
_this.
|
|
2161
|
-
_this.
|
|
2162
|
-
_this.
|
|
2163
|
-
_this.
|
|
2164
|
-
_this.
|
|
2165
|
-
_this.
|
|
2166
|
-
_this.
|
|
2167
|
-
_this.
|
|
2168
|
-
_this.
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
_this.
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
_this._time_limit_action = "continue,no message";
|
|
2179
|
-
_this._total_time = "";
|
|
2180
|
-
_this.learner_preference = new CMILearnerPreference();
|
|
2181
|
-
_this.score = new Scorm2004CMIScore();
|
|
2182
|
-
_this.comments_from_learner = new CMICommentsFromLearner();
|
|
2183
|
-
_this.comments_from_lms = new CMICommentsFromLMS();
|
|
2184
|
-
_this.interactions = new CMIInteractions();
|
|
2185
|
-
_this.objectives = new CMIObjectives();
|
|
2186
|
-
if (initialized)
|
|
2187
|
-
_this.initialize();
|
|
2272
|
+
_this._id = "";
|
|
2273
|
+
_this._type = "";
|
|
2274
|
+
_this._timestamp = "";
|
|
2275
|
+
_this._weighting = "";
|
|
2276
|
+
_this._learner_response = "";
|
|
2277
|
+
_this._result = "";
|
|
2278
|
+
_this._latency = "";
|
|
2279
|
+
_this._description = "";
|
|
2280
|
+
_this.objectives = new CMIArray({
|
|
2281
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2282
|
+
errorClass: Scorm2004ValidationError,
|
|
2283
|
+
children: api_constants.scorm2004.objectives_children,
|
|
2284
|
+
});
|
|
2285
|
+
_this.correct_responses = new CMIArray({
|
|
2286
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2287
|
+
errorClass: Scorm2004ValidationError,
|
|
2288
|
+
children: api_constants.scorm2004.correct_responses_children,
|
|
2289
|
+
});
|
|
2188
2290
|
return _this;
|
|
2189
2291
|
}
|
|
2190
|
-
|
|
2191
|
-
var _a, _b
|
|
2292
|
+
CMIInteractionsObject.prototype.initialize = function () {
|
|
2293
|
+
var _a, _b;
|
|
2192
2294
|
_super.prototype.initialize.call(this);
|
|
2193
|
-
(_a = this.
|
|
2194
|
-
(_b = this.
|
|
2195
|
-
(_c = this.comments_from_learner) === null || _c === void 0 ? void 0 : _c.initialize();
|
|
2196
|
-
(_d = this.comments_from_lms) === null || _d === void 0 ? void 0 : _d.initialize();
|
|
2197
|
-
(_e = this.interactions) === null || _e === void 0 ? void 0 : _e.initialize();
|
|
2198
|
-
(_f = this.objectives) === null || _f === void 0 ? void 0 : _f.initialize();
|
|
2295
|
+
(_a = this.objectives) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
2296
|
+
(_b = this.correct_responses) === null || _b === void 0 ? void 0 : _b.initialize();
|
|
2199
2297
|
};
|
|
2200
|
-
Object.defineProperty(
|
|
2201
|
-
get: function () {
|
|
2202
|
-
return this.__version;
|
|
2203
|
-
},
|
|
2204
|
-
set: function (_version) {
|
|
2205
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2206
|
-
},
|
|
2207
|
-
enumerable: false,
|
|
2208
|
-
configurable: true
|
|
2209
|
-
});
|
|
2210
|
-
Object.defineProperty(CMI.prototype, "_children", {
|
|
2211
|
-
get: function () {
|
|
2212
|
-
return this.__children;
|
|
2213
|
-
},
|
|
2214
|
-
set: function (_children) {
|
|
2215
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2216
|
-
},
|
|
2217
|
-
enumerable: false,
|
|
2218
|
-
configurable: true
|
|
2219
|
-
});
|
|
2220
|
-
Object.defineProperty(CMI.prototype, "completion_status", {
|
|
2221
|
-
get: function () {
|
|
2222
|
-
return this._completion_status;
|
|
2223
|
-
},
|
|
2224
|
-
set: function (completion_status) {
|
|
2225
|
-
if (check2004ValidFormat(completion_status, scorm2004_cmi_scorm2004_regex.CMICStatus)) {
|
|
2226
|
-
this._completion_status = completion_status;
|
|
2227
|
-
}
|
|
2228
|
-
},
|
|
2229
|
-
enumerable: false,
|
|
2230
|
-
configurable: true
|
|
2231
|
-
});
|
|
2232
|
-
Object.defineProperty(CMI.prototype, "completion_threshold", {
|
|
2233
|
-
get: function () {
|
|
2234
|
-
return this._completion_threshold;
|
|
2235
|
-
},
|
|
2236
|
-
set: function (completion_threshold) {
|
|
2237
|
-
if (this.initialized) {
|
|
2238
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2239
|
-
}
|
|
2240
|
-
else {
|
|
2241
|
-
this._completion_threshold = completion_threshold;
|
|
2242
|
-
}
|
|
2243
|
-
},
|
|
2244
|
-
enumerable: false,
|
|
2245
|
-
configurable: true
|
|
2246
|
-
});
|
|
2247
|
-
Object.defineProperty(CMI.prototype, "credit", {
|
|
2248
|
-
get: function () {
|
|
2249
|
-
return this._credit;
|
|
2250
|
-
},
|
|
2251
|
-
set: function (credit) {
|
|
2252
|
-
if (this.initialized) {
|
|
2253
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2254
|
-
}
|
|
2255
|
-
else {
|
|
2256
|
-
this._credit = credit;
|
|
2257
|
-
}
|
|
2258
|
-
},
|
|
2259
|
-
enumerable: false,
|
|
2260
|
-
configurable: true
|
|
2261
|
-
});
|
|
2262
|
-
Object.defineProperty(CMI.prototype, "entry", {
|
|
2263
|
-
get: function () {
|
|
2264
|
-
return this._entry;
|
|
2265
|
-
},
|
|
2266
|
-
set: function (entry) {
|
|
2267
|
-
if (this.initialized) {
|
|
2268
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2269
|
-
}
|
|
2270
|
-
else {
|
|
2271
|
-
this._entry = entry;
|
|
2272
|
-
}
|
|
2273
|
-
},
|
|
2274
|
-
enumerable: false,
|
|
2275
|
-
configurable: true
|
|
2276
|
-
});
|
|
2277
|
-
Object.defineProperty(CMI.prototype, "exit", {
|
|
2278
|
-
get: function () {
|
|
2279
|
-
if (!this.jsonString) {
|
|
2280
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.WRITE_ONLY_ELEMENT);
|
|
2281
|
-
}
|
|
2282
|
-
return this._exit;
|
|
2283
|
-
},
|
|
2284
|
-
set: function (exit) {
|
|
2285
|
-
if (check2004ValidFormat(exit, scorm2004_cmi_scorm2004_regex.CMIExit, true)) {
|
|
2286
|
-
this._exit = exit;
|
|
2287
|
-
}
|
|
2288
|
-
},
|
|
2289
|
-
enumerable: false,
|
|
2290
|
-
configurable: true
|
|
2291
|
-
});
|
|
2292
|
-
Object.defineProperty(CMI.prototype, "launch_data", {
|
|
2293
|
-
get: function () {
|
|
2294
|
-
return this._launch_data;
|
|
2295
|
-
},
|
|
2296
|
-
set: function (launch_data) {
|
|
2297
|
-
if (this.initialized) {
|
|
2298
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2299
|
-
}
|
|
2300
|
-
else {
|
|
2301
|
-
this._launch_data = launch_data;
|
|
2302
|
-
}
|
|
2303
|
-
},
|
|
2304
|
-
enumerable: false,
|
|
2305
|
-
configurable: true
|
|
2306
|
-
});
|
|
2307
|
-
Object.defineProperty(CMI.prototype, "learner_id", {
|
|
2308
|
-
get: function () {
|
|
2309
|
-
return this._learner_id;
|
|
2310
|
-
},
|
|
2311
|
-
set: function (learner_id) {
|
|
2312
|
-
if (this.initialized) {
|
|
2313
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2314
|
-
}
|
|
2315
|
-
else {
|
|
2316
|
-
this._learner_id = learner_id;
|
|
2317
|
-
}
|
|
2318
|
-
},
|
|
2319
|
-
enumerable: false,
|
|
2320
|
-
configurable: true
|
|
2321
|
-
});
|
|
2322
|
-
Object.defineProperty(CMI.prototype, "learner_name", {
|
|
2323
|
-
get: function () {
|
|
2324
|
-
return this._learner_name;
|
|
2325
|
-
},
|
|
2326
|
-
set: function (learner_name) {
|
|
2327
|
-
if (this.initialized) {
|
|
2328
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
|
|
2329
|
-
}
|
|
2330
|
-
else {
|
|
2331
|
-
this._learner_name = learner_name;
|
|
2332
|
-
}
|
|
2333
|
-
},
|
|
2334
|
-
enumerable: false,
|
|
2335
|
-
configurable: true
|
|
2336
|
-
});
|
|
2337
|
-
Object.defineProperty(CMI.prototype, "location", {
|
|
2298
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "id", {
|
|
2338
2299
|
get: function () {
|
|
2339
|
-
return this.
|
|
2300
|
+
return this._id;
|
|
2340
2301
|
},
|
|
2341
|
-
set: function (
|
|
2342
|
-
if (check2004ValidFormat(
|
|
2343
|
-
this.
|
|
2302
|
+
set: function (id) {
|
|
2303
|
+
if (check2004ValidFormat(id, regex.scorm2004.CMILongIdentifier)) {
|
|
2304
|
+
this._id = id;
|
|
2344
2305
|
}
|
|
2345
2306
|
},
|
|
2346
2307
|
enumerable: false,
|
|
2347
2308
|
configurable: true
|
|
2348
2309
|
});
|
|
2349
|
-
Object.defineProperty(
|
|
2310
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "type", {
|
|
2350
2311
|
get: function () {
|
|
2351
|
-
return this.
|
|
2312
|
+
return this._type;
|
|
2352
2313
|
},
|
|
2353
|
-
set: function (
|
|
2354
|
-
if (this.initialized) {
|
|
2355
|
-
throw new Scorm2004ValidationError(
|
|
2314
|
+
set: function (type) {
|
|
2315
|
+
if (this.initialized && this._id === "") {
|
|
2316
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2356
2317
|
}
|
|
2357
2318
|
else {
|
|
2358
|
-
|
|
2319
|
+
if (check2004ValidFormat(type, regex.scorm2004.CMIType)) {
|
|
2320
|
+
this._type = type;
|
|
2321
|
+
}
|
|
2359
2322
|
}
|
|
2360
2323
|
},
|
|
2361
2324
|
enumerable: false,
|
|
2362
2325
|
configurable: true
|
|
2363
2326
|
});
|
|
2364
|
-
Object.defineProperty(
|
|
2327
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "timestamp", {
|
|
2365
2328
|
get: function () {
|
|
2366
|
-
return this.
|
|
2329
|
+
return this._timestamp;
|
|
2367
2330
|
},
|
|
2368
|
-
set: function (
|
|
2369
|
-
if (this.initialized) {
|
|
2370
|
-
throw new Scorm2004ValidationError(
|
|
2331
|
+
set: function (timestamp) {
|
|
2332
|
+
if (this.initialized && this._id === "") {
|
|
2333
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2371
2334
|
}
|
|
2372
2335
|
else {
|
|
2373
|
-
|
|
2336
|
+
if (check2004ValidFormat(timestamp, regex.scorm2004.CMITime)) {
|
|
2337
|
+
this._timestamp = timestamp;
|
|
2338
|
+
}
|
|
2374
2339
|
}
|
|
2375
2340
|
},
|
|
2376
2341
|
enumerable: false,
|
|
2377
2342
|
configurable: true
|
|
2378
2343
|
});
|
|
2379
|
-
Object.defineProperty(
|
|
2344
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "weighting", {
|
|
2380
2345
|
get: function () {
|
|
2381
|
-
return this.
|
|
2346
|
+
return this._weighting;
|
|
2382
2347
|
},
|
|
2383
|
-
set: function (
|
|
2384
|
-
if (
|
|
2385
|
-
|
|
2386
|
-
|
|
2348
|
+
set: function (weighting) {
|
|
2349
|
+
if (this.initialized && this._id === "") {
|
|
2350
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2351
|
+
}
|
|
2352
|
+
else {
|
|
2353
|
+
if (check2004ValidFormat(weighting, regex.scorm2004.CMIDecimal)) {
|
|
2354
|
+
this._weighting = weighting;
|
|
2355
|
+
}
|
|
2387
2356
|
}
|
|
2388
2357
|
},
|
|
2389
2358
|
enumerable: false,
|
|
2390
2359
|
configurable: true
|
|
2391
2360
|
});
|
|
2392
|
-
Object.defineProperty(
|
|
2361
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "learner_response", {
|
|
2393
2362
|
get: function () {
|
|
2394
|
-
return this.
|
|
2363
|
+
return this._learner_response;
|
|
2395
2364
|
},
|
|
2396
|
-
set: function (
|
|
2397
|
-
if (this.initialized) {
|
|
2398
|
-
throw new Scorm2004ValidationError(
|
|
2365
|
+
set: function (learner_response) {
|
|
2366
|
+
if (this.initialized && (this._type === "" || this._id === "")) {
|
|
2367
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2399
2368
|
}
|
|
2400
2369
|
else {
|
|
2401
|
-
|
|
2370
|
+
var nodes = [];
|
|
2371
|
+
var response_type = LearnerResponses[this.type];
|
|
2372
|
+
if (response_type) {
|
|
2373
|
+
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter) {
|
|
2374
|
+
nodes = learner_response.split(response_type.delimiter);
|
|
2375
|
+
}
|
|
2376
|
+
else {
|
|
2377
|
+
nodes[0] = learner_response;
|
|
2378
|
+
}
|
|
2379
|
+
if (nodes.length > 0 && nodes.length <= response_type.max) {
|
|
2380
|
+
var formatRegex = new RegExp(response_type.format);
|
|
2381
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
2382
|
+
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
|
|
2383
|
+
var values = nodes[i].split(response_type.delimiter2);
|
|
2384
|
+
if (values.length === 2) {
|
|
2385
|
+
if (!values[0].match(formatRegex)) {
|
|
2386
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2387
|
+
}
|
|
2388
|
+
else {
|
|
2389
|
+
if (!response_type.format2 ||
|
|
2390
|
+
!values[1].match(new RegExp(response_type.format2))) {
|
|
2391
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
else {
|
|
2396
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
else {
|
|
2400
|
+
if (!nodes[i].match(formatRegex)) {
|
|
2401
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
if (nodes[i] !== "" && response_type.unique) {
|
|
2405
|
+
for (var j = 0; j < i; j++) {
|
|
2406
|
+
if (nodes[i] === nodes[j]) {
|
|
2407
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
else {
|
|
2416
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.GENERAL_SET_FAILURE);
|
|
2417
|
+
}
|
|
2418
|
+
this._learner_response = learner_response;
|
|
2419
|
+
}
|
|
2420
|
+
else {
|
|
2421
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
2422
|
+
}
|
|
2402
2423
|
}
|
|
2403
2424
|
},
|
|
2404
2425
|
enumerable: false,
|
|
2405
2426
|
configurable: true
|
|
2406
2427
|
});
|
|
2407
|
-
Object.defineProperty(
|
|
2428
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "result", {
|
|
2408
2429
|
get: function () {
|
|
2409
|
-
|
|
2410
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.WRITE_ONLY_ELEMENT);
|
|
2411
|
-
}
|
|
2412
|
-
return this._session_time;
|
|
2430
|
+
return this._result;
|
|
2413
2431
|
},
|
|
2414
|
-
set: function (
|
|
2415
|
-
if (check2004ValidFormat(
|
|
2416
|
-
this.
|
|
2432
|
+
set: function (result) {
|
|
2433
|
+
if (check2004ValidFormat(result, regex.scorm2004.CMIResult)) {
|
|
2434
|
+
this._result = result;
|
|
2417
2435
|
}
|
|
2418
2436
|
},
|
|
2419
2437
|
enumerable: false,
|
|
2420
2438
|
configurable: true
|
|
2421
2439
|
});
|
|
2422
|
-
Object.defineProperty(
|
|
2440
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "latency", {
|
|
2423
2441
|
get: function () {
|
|
2424
|
-
return this.
|
|
2442
|
+
return this._latency;
|
|
2425
2443
|
},
|
|
2426
|
-
set: function (
|
|
2427
|
-
if (
|
|
2428
|
-
|
|
2444
|
+
set: function (latency) {
|
|
2445
|
+
if (this.initialized && this._id === "") {
|
|
2446
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2447
|
+
}
|
|
2448
|
+
else {
|
|
2449
|
+
if (check2004ValidFormat(latency, regex.scorm2004.CMITimespan)) {
|
|
2450
|
+
this._latency = latency;
|
|
2451
|
+
}
|
|
2429
2452
|
}
|
|
2430
2453
|
},
|
|
2431
2454
|
enumerable: false,
|
|
2432
2455
|
configurable: true
|
|
2433
2456
|
});
|
|
2434
|
-
Object.defineProperty(
|
|
2457
|
+
Object.defineProperty(CMIInteractionsObject.prototype, "description", {
|
|
2435
2458
|
get: function () {
|
|
2436
|
-
return this.
|
|
2459
|
+
return this._description;
|
|
2437
2460
|
},
|
|
2438
|
-
set: function (
|
|
2439
|
-
if (
|
|
2440
|
-
|
|
2461
|
+
set: function (description) {
|
|
2462
|
+
if (this.initialized && this._id === "") {
|
|
2463
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2464
|
+
}
|
|
2465
|
+
else {
|
|
2466
|
+
if (check2004ValidFormat(description, regex.scorm2004.CMILangString250, true)) {
|
|
2467
|
+
this._description = description;
|
|
2468
|
+
}
|
|
2441
2469
|
}
|
|
2442
2470
|
},
|
|
2443
2471
|
enumerable: false,
|
|
2444
2472
|
configurable: true
|
|
2445
2473
|
});
|
|
2446
|
-
|
|
2474
|
+
CMIInteractionsObject.prototype.toJSON = function () {
|
|
2475
|
+
this.jsonString = true;
|
|
2476
|
+
var result = {
|
|
2477
|
+
id: this.id,
|
|
2478
|
+
type: this.type,
|
|
2479
|
+
objectives: this.objectives,
|
|
2480
|
+
timestamp: this.timestamp,
|
|
2481
|
+
weighting: this.weighting,
|
|
2482
|
+
learner_response: this.learner_response,
|
|
2483
|
+
result: this.result,
|
|
2484
|
+
latency: this.latency,
|
|
2485
|
+
description: this.description,
|
|
2486
|
+
correct_responses: this.correct_responses,
|
|
2487
|
+
};
|
|
2488
|
+
delete this.jsonString;
|
|
2489
|
+
return result;
|
|
2490
|
+
};
|
|
2491
|
+
return CMIInteractionsObject;
|
|
2492
|
+
}(BaseCMI));
|
|
2493
|
+
|
|
2494
|
+
var CMIInteractionsObjectivesObject = (function (_super) {
|
|
2495
|
+
__extends(CMIInteractionsObjectivesObject, _super);
|
|
2496
|
+
function CMIInteractionsObjectivesObject() {
|
|
2497
|
+
var _this = _super.call(this) || this;
|
|
2498
|
+
_this._id = "";
|
|
2499
|
+
return _this;
|
|
2500
|
+
}
|
|
2501
|
+
Object.defineProperty(CMIInteractionsObjectivesObject.prototype, "id", {
|
|
2447
2502
|
get: function () {
|
|
2448
|
-
return this.
|
|
2503
|
+
return this._id;
|
|
2449
2504
|
},
|
|
2450
|
-
set: function (
|
|
2451
|
-
if (
|
|
2452
|
-
|
|
2453
|
-
}
|
|
2454
|
-
else {
|
|
2455
|
-
this._time_limit_action = time_limit_action;
|
|
2505
|
+
set: function (id) {
|
|
2506
|
+
if (check2004ValidFormat(id, regex.scorm2004.CMILongIdentifier)) {
|
|
2507
|
+
this._id = id;
|
|
2456
2508
|
}
|
|
2457
2509
|
},
|
|
2458
2510
|
enumerable: false,
|
|
2459
2511
|
configurable: true
|
|
2460
2512
|
});
|
|
2461
|
-
|
|
2513
|
+
CMIInteractionsObjectivesObject.prototype.toJSON = function () {
|
|
2514
|
+
this.jsonString = true;
|
|
2515
|
+
var result = {
|
|
2516
|
+
id: this.id,
|
|
2517
|
+
};
|
|
2518
|
+
delete this.jsonString;
|
|
2519
|
+
return result;
|
|
2520
|
+
};
|
|
2521
|
+
return CMIInteractionsObjectivesObject;
|
|
2522
|
+
}(BaseCMI));
|
|
2523
|
+
|
|
2524
|
+
var CMIInteractionsCorrectResponsesObject = (function (_super) {
|
|
2525
|
+
__extends(CMIInteractionsCorrectResponsesObject, _super);
|
|
2526
|
+
function CMIInteractionsCorrectResponsesObject() {
|
|
2527
|
+
var _this = _super.call(this) || this;
|
|
2528
|
+
_this._pattern = "";
|
|
2529
|
+
return _this;
|
|
2530
|
+
}
|
|
2531
|
+
Object.defineProperty(CMIInteractionsCorrectResponsesObject.prototype, "pattern", {
|
|
2462
2532
|
get: function () {
|
|
2463
|
-
return this.
|
|
2533
|
+
return this._pattern;
|
|
2464
2534
|
},
|
|
2465
|
-
set: function (
|
|
2466
|
-
if (
|
|
2467
|
-
|
|
2468
|
-
}
|
|
2469
|
-
else {
|
|
2470
|
-
this._total_time = total_time;
|
|
2535
|
+
set: function (pattern) {
|
|
2536
|
+
if (check2004ValidFormat(pattern, regex.scorm2004.CMIFeedback)) {
|
|
2537
|
+
this._pattern = pattern;
|
|
2471
2538
|
}
|
|
2472
2539
|
},
|
|
2473
2540
|
enumerable: false,
|
|
2474
2541
|
configurable: true
|
|
2475
2542
|
});
|
|
2476
|
-
|
|
2477
|
-
var sessionTime = this._session_time;
|
|
2478
|
-
var startTime = this.start_time;
|
|
2479
|
-
if (typeof startTime !== "undefined" && startTime !== null) {
|
|
2480
|
-
var seconds = new Date().getTime() - startTime;
|
|
2481
|
-
sessionTime = getSecondsAsISODuration(seconds / 1000);
|
|
2482
|
-
}
|
|
2483
|
-
return addTwoDurations(this._total_time, sessionTime, scorm2004_cmi_scorm2004_regex.CMITimespan);
|
|
2484
|
-
};
|
|
2485
|
-
CMI.prototype.toJSON = function () {
|
|
2543
|
+
CMIInteractionsCorrectResponsesObject.prototype.toJSON = function () {
|
|
2486
2544
|
this.jsonString = true;
|
|
2487
2545
|
var result = {
|
|
2488
|
-
|
|
2489
|
-
comments_from_lms: this.comments_from_lms,
|
|
2490
|
-
completion_status: this.completion_status,
|
|
2491
|
-
completion_threshold: this.completion_threshold,
|
|
2492
|
-
credit: this.credit,
|
|
2493
|
-
entry: this.entry,
|
|
2494
|
-
exit: this.exit,
|
|
2495
|
-
interactions: this.interactions,
|
|
2496
|
-
launch_data: this.launch_data,
|
|
2497
|
-
learner_id: this.learner_id,
|
|
2498
|
-
learner_name: this.learner_name,
|
|
2499
|
-
learner_preference: this.learner_preference,
|
|
2500
|
-
location: this.location,
|
|
2501
|
-
max_time_allowed: this.max_time_allowed,
|
|
2502
|
-
mode: this.mode,
|
|
2503
|
-
objectives: this.objectives,
|
|
2504
|
-
progress_measure: this.progress_measure,
|
|
2505
|
-
scaled_passing_score: this.scaled_passing_score,
|
|
2506
|
-
score: this.score,
|
|
2507
|
-
session_time: this.session_time,
|
|
2508
|
-
success_status: this.success_status,
|
|
2509
|
-
suspend_data: this.suspend_data,
|
|
2510
|
-
time_limit_action: this.time_limit_action,
|
|
2546
|
+
pattern: this.pattern,
|
|
2511
2547
|
};
|
|
2512
2548
|
delete this.jsonString;
|
|
2513
2549
|
return result;
|
|
2514
2550
|
};
|
|
2515
|
-
return
|
|
2516
|
-
}(
|
|
2551
|
+
return CMIInteractionsCorrectResponsesObject;
|
|
2552
|
+
}(BaseCMI));
|
|
2517
2553
|
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2554
|
+
|
|
2555
|
+
;// ./src/cmi/common/score.ts
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
|
|
2562
|
+
var scorm12_constants = api_constants.scorm12;
|
|
2563
|
+
var scorm12_regex = regex.scorm12;
|
|
2564
|
+
var score_scorm12_error_codes = error_codes.scorm12;
|
|
2565
|
+
var CMIScore = (function (_super) {
|
|
2566
|
+
__extends(CMIScore, _super);
|
|
2567
|
+
function CMIScore(params) {
|
|
2521
2568
|
var _this = _super.call(this) || this;
|
|
2522
|
-
_this.
|
|
2523
|
-
_this.
|
|
2524
|
-
_this.
|
|
2525
|
-
_this.
|
|
2526
|
-
|
|
2569
|
+
_this._raw = "";
|
|
2570
|
+
_this._min = "";
|
|
2571
|
+
_this.__children = params.score_children || scorm12_constants.score_children;
|
|
2572
|
+
_this.__score_range = !params.score_range
|
|
2573
|
+
? false
|
|
2574
|
+
: scorm12_regex.score_range;
|
|
2575
|
+
_this._max = params.max || params.max === "" ? params.max : "100";
|
|
2576
|
+
_this.__invalid_error_code =
|
|
2577
|
+
params.invalidErrorCode || score_scorm12_error_codes.INVALID_SET_VALUE;
|
|
2578
|
+
_this.__invalid_type_code =
|
|
2579
|
+
params.invalidTypeCode || score_scorm12_error_codes.TYPE_MISMATCH;
|
|
2580
|
+
_this.__invalid_range_code =
|
|
2581
|
+
params.invalidRangeCode || score_scorm12_error_codes.VALUE_OUT_OF_RANGE;
|
|
2582
|
+
_this.__decimal_regex = params.decimalRegex || scorm12_regex.CMIDecimal;
|
|
2583
|
+
_this.__error_class = params.errorClass;
|
|
2527
2584
|
return _this;
|
|
2528
2585
|
}
|
|
2529
|
-
Object.defineProperty(
|
|
2586
|
+
Object.defineProperty(CMIScore.prototype, "_children", {
|
|
2530
2587
|
get: function () {
|
|
2531
2588
|
return this.__children;
|
|
2532
2589
|
},
|
|
2533
2590
|
set: function (_children) {
|
|
2534
|
-
throw new
|
|
2591
|
+
throw new this.__error_class(this.__invalid_error_code);
|
|
2535
2592
|
},
|
|
2536
2593
|
enumerable: false,
|
|
2537
2594
|
configurable: true
|
|
2538
2595
|
});
|
|
2539
|
-
Object.defineProperty(
|
|
2596
|
+
Object.defineProperty(CMIScore.prototype, "raw", {
|
|
2540
2597
|
get: function () {
|
|
2541
|
-
return this.
|
|
2598
|
+
return this._raw;
|
|
2542
2599
|
},
|
|
2543
|
-
set: function (
|
|
2544
|
-
if (
|
|
2545
|
-
|
|
2546
|
-
|
|
2600
|
+
set: function (raw) {
|
|
2601
|
+
if (checkValidFormat(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
2602
|
+
(!this.__score_range ||
|
|
2603
|
+
checkValidRange(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
2604
|
+
this._raw = raw;
|
|
2547
2605
|
}
|
|
2548
2606
|
},
|
|
2549
2607
|
enumerable: false,
|
|
2550
2608
|
configurable: true
|
|
2551
2609
|
});
|
|
2552
|
-
Object.defineProperty(
|
|
2610
|
+
Object.defineProperty(CMIScore.prototype, "min", {
|
|
2553
2611
|
get: function () {
|
|
2554
|
-
return this.
|
|
2612
|
+
return this._min;
|
|
2555
2613
|
},
|
|
2556
|
-
set: function (
|
|
2557
|
-
if (
|
|
2558
|
-
this.
|
|
2614
|
+
set: function (min) {
|
|
2615
|
+
if (checkValidFormat(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
2616
|
+
(!this.__score_range ||
|
|
2617
|
+
checkValidRange(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
2618
|
+
this._min = min;
|
|
2559
2619
|
}
|
|
2560
2620
|
},
|
|
2561
2621
|
enumerable: false,
|
|
2562
2622
|
configurable: true
|
|
2563
2623
|
});
|
|
2564
|
-
Object.defineProperty(
|
|
2624
|
+
Object.defineProperty(CMIScore.prototype, "max", {
|
|
2565
2625
|
get: function () {
|
|
2566
|
-
return this.
|
|
2626
|
+
return this._max;
|
|
2567
2627
|
},
|
|
2568
|
-
set: function (
|
|
2569
|
-
if (
|
|
2570
|
-
|
|
2571
|
-
|
|
2628
|
+
set: function (max) {
|
|
2629
|
+
if (checkValidFormat(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
2630
|
+
(!this.__score_range ||
|
|
2631
|
+
checkValidRange(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
2632
|
+
this._max = max;
|
|
2572
2633
|
}
|
|
2573
2634
|
},
|
|
2574
2635
|
enumerable: false,
|
|
2575
2636
|
configurable: true
|
|
2576
2637
|
});
|
|
2577
|
-
|
|
2638
|
+
CMIScore.prototype.toJSON = function () {
|
|
2639
|
+
this.jsonString = true;
|
|
2640
|
+
var result = {
|
|
2641
|
+
raw: this.raw,
|
|
2642
|
+
min: this.min,
|
|
2643
|
+
max: this.max,
|
|
2644
|
+
};
|
|
2645
|
+
delete this.jsonString;
|
|
2646
|
+
return result;
|
|
2647
|
+
};
|
|
2648
|
+
return CMIScore;
|
|
2649
|
+
}(BaseCMI));
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
;// ./src/cmi/scorm2004/score.ts
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2660
|
+
var Scorm2004CMIScore = (function (_super) {
|
|
2661
|
+
__extends(Scorm2004CMIScore, _super);
|
|
2662
|
+
function Scorm2004CMIScore() {
|
|
2663
|
+
var _this = _super.call(this, {
|
|
2664
|
+
score_children: api_constants.scorm2004.score_children,
|
|
2665
|
+
max: "",
|
|
2666
|
+
invalidErrorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2667
|
+
invalidTypeCode: error_codes.scorm2004.TYPE_MISMATCH,
|
|
2668
|
+
invalidRangeCode: error_codes.scorm2004.VALUE_OUT_OF_RANGE,
|
|
2669
|
+
decimalRegex: regex.scorm2004.CMIDecimal,
|
|
2670
|
+
errorClass: Scorm2004ValidationError,
|
|
2671
|
+
}) || this;
|
|
2672
|
+
_this._scaled = "";
|
|
2673
|
+
return _this;
|
|
2674
|
+
}
|
|
2675
|
+
Object.defineProperty(Scorm2004CMIScore.prototype, "scaled", {
|
|
2578
2676
|
get: function () {
|
|
2579
|
-
return this.
|
|
2677
|
+
return this._scaled;
|
|
2580
2678
|
},
|
|
2581
|
-
set: function (
|
|
2582
|
-
if (check2004ValidFormat(
|
|
2583
|
-
check2004ValidRange(
|
|
2584
|
-
this.
|
|
2679
|
+
set: function (scaled) {
|
|
2680
|
+
if (check2004ValidFormat(scaled, regex.scorm2004.CMIDecimal) &&
|
|
2681
|
+
check2004ValidRange(scaled, regex.scorm2004.scaled_range)) {
|
|
2682
|
+
this._scaled = scaled;
|
|
2585
2683
|
}
|
|
2586
2684
|
},
|
|
2587
2685
|
enumerable: false,
|
|
2588
2686
|
configurable: true
|
|
2589
2687
|
});
|
|
2590
|
-
|
|
2688
|
+
Scorm2004CMIScore.prototype.toJSON = function () {
|
|
2591
2689
|
this.jsonString = true;
|
|
2592
2690
|
var result = {
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2691
|
+
scaled: this.scaled,
|
|
2692
|
+
raw: this.raw,
|
|
2693
|
+
min: this.min,
|
|
2694
|
+
max: this.max,
|
|
2597
2695
|
};
|
|
2598
2696
|
delete this.jsonString;
|
|
2599
2697
|
return result;
|
|
2600
2698
|
};
|
|
2601
|
-
return
|
|
2602
|
-
}(
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
var CMIObjectives = (function (_super) {
|
|
2615
|
-
__extends(CMIObjectives, _super);
|
|
2616
|
-
function CMIObjectives() {
|
|
2617
|
-
return _super.call(this, {
|
|
2618
|
-
children: scorm2004_constants.objectives_children,
|
|
2619
|
-
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
|
2620
|
-
errorClass: Scorm2004ValidationError,
|
|
2621
|
-
}) || this;
|
|
2622
|
-
}
|
|
2623
|
-
return CMIObjectives;
|
|
2624
|
-
}(CMIArray));
|
|
2699
|
+
return Scorm2004CMIScore;
|
|
2700
|
+
}(CMIScore));
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
;// ./src/cmi/scorm2004/comments.ts
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2625
2712
|
var CMICommentsFromLMS = (function (_super) {
|
|
2626
2713
|
__extends(CMICommentsFromLMS, _super);
|
|
2627
2714
|
function CMICommentsFromLMS() {
|
|
2628
2715
|
return _super.call(this, {
|
|
2629
|
-
children:
|
|
2630
|
-
errorCode:
|
|
2716
|
+
children: api_constants.scorm2004.comments_children,
|
|
2717
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2631
2718
|
errorClass: Scorm2004ValidationError,
|
|
2632
2719
|
}) || this;
|
|
2633
2720
|
}
|
|
2634
2721
|
return CMICommentsFromLMS;
|
|
2635
2722
|
}(CMIArray));
|
|
2723
|
+
|
|
2636
2724
|
var CMICommentsFromLearner = (function (_super) {
|
|
2637
2725
|
__extends(CMICommentsFromLearner, _super);
|
|
2638
2726
|
function CMICommentsFromLearner() {
|
|
2639
|
-
return _super.call(this, {
|
|
2640
|
-
children:
|
|
2641
|
-
errorCode:
|
|
2642
|
-
errorClass: Scorm2004ValidationError,
|
|
2643
|
-
}) || this;
|
|
2644
|
-
}
|
|
2645
|
-
return CMICommentsFromLearner;
|
|
2646
|
-
}(CMIArray));
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
_this
|
|
2653
|
-
_this.
|
|
2654
|
-
_this.
|
|
2655
|
-
_this.
|
|
2656
|
-
_this.
|
|
2657
|
-
_this.
|
|
2658
|
-
_this.
|
|
2659
|
-
_this.
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
});
|
|
2664
|
-
_this.correct_responses = new CMIArray({
|
|
2665
|
-
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
|
2666
|
-
errorClass: Scorm2004ValidationError,
|
|
2667
|
-
children: scorm2004_constants.correct_responses_children,
|
|
2668
|
-
});
|
|
2669
|
-
return _this;
|
|
2670
|
-
}
|
|
2671
|
-
CMIInteractionsObject.prototype.initialize = function () {
|
|
2672
|
-
var _a, _b;
|
|
2673
|
-
_super.prototype.initialize.call(this);
|
|
2674
|
-
(_a = this.objectives) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
2675
|
-
(_b = this.correct_responses) === null || _b === void 0 ? void 0 : _b.initialize();
|
|
2676
|
-
};
|
|
2677
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "id", {
|
|
2678
|
-
get: function () {
|
|
2679
|
-
return this._id;
|
|
2680
|
-
},
|
|
2681
|
-
set: function (id) {
|
|
2682
|
-
if (check2004ValidFormat(id, scorm2004_cmi_scorm2004_regex.CMILongIdentifier)) {
|
|
2683
|
-
this._id = id;
|
|
2684
|
-
}
|
|
2685
|
-
},
|
|
2686
|
-
enumerable: false,
|
|
2687
|
-
configurable: true
|
|
2688
|
-
});
|
|
2689
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "type", {
|
|
2690
|
-
get: function () {
|
|
2691
|
-
return this._type;
|
|
2692
|
-
},
|
|
2693
|
-
set: function (type) {
|
|
2694
|
-
if (this.initialized && this._id === "") {
|
|
2695
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
|
2696
|
-
}
|
|
2697
|
-
else {
|
|
2698
|
-
if (check2004ValidFormat(type, scorm2004_cmi_scorm2004_regex.CMIType)) {
|
|
2699
|
-
this._type = type;
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
},
|
|
2703
|
-
enumerable: false,
|
|
2704
|
-
configurable: true
|
|
2705
|
-
});
|
|
2706
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "timestamp", {
|
|
2707
|
-
get: function () {
|
|
2708
|
-
return this._timestamp;
|
|
2709
|
-
},
|
|
2710
|
-
set: function (timestamp) {
|
|
2711
|
-
if (this.initialized && this._id === "") {
|
|
2712
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
|
2713
|
-
}
|
|
2714
|
-
else {
|
|
2715
|
-
if (check2004ValidFormat(timestamp, scorm2004_cmi_scorm2004_regex.CMITime)) {
|
|
2716
|
-
this._timestamp = timestamp;
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
},
|
|
2720
|
-
enumerable: false,
|
|
2721
|
-
configurable: true
|
|
2722
|
-
});
|
|
2723
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "weighting", {
|
|
2724
|
-
get: function () {
|
|
2725
|
-
return this._weighting;
|
|
2726
|
-
},
|
|
2727
|
-
set: function (weighting) {
|
|
2728
|
-
if (this.initialized && this._id === "") {
|
|
2729
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
|
2730
|
-
}
|
|
2731
|
-
else {
|
|
2732
|
-
if (check2004ValidFormat(weighting, scorm2004_cmi_scorm2004_regex.CMIDecimal)) {
|
|
2733
|
-
this._weighting = weighting;
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
},
|
|
2737
|
-
enumerable: false,
|
|
2738
|
-
configurable: true
|
|
2739
|
-
});
|
|
2740
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "learner_response", {
|
|
2741
|
-
get: function () {
|
|
2742
|
-
return this._learner_response;
|
|
2743
|
-
},
|
|
2744
|
-
set: function (learner_response) {
|
|
2745
|
-
if (this.initialized && (this._type === "" || this._id === "")) {
|
|
2746
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
|
2747
|
-
}
|
|
2748
|
-
else {
|
|
2749
|
-
var nodes = [];
|
|
2750
|
-
var response_type = learner_responses[this.type];
|
|
2751
|
-
if (response_type) {
|
|
2752
|
-
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter) {
|
|
2753
|
-
nodes = learner_response.split(response_type.delimiter);
|
|
2754
|
-
}
|
|
2755
|
-
else {
|
|
2756
|
-
nodes[0] = learner_response;
|
|
2757
|
-
}
|
|
2758
|
-
if (nodes.length > 0 && nodes.length <= response_type.max) {
|
|
2759
|
-
var formatRegex = new RegExp(response_type.format);
|
|
2760
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
2761
|
-
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
|
|
2762
|
-
var values = nodes[i].split(response_type.delimiter2);
|
|
2763
|
-
if (values.length === 2) {
|
|
2764
|
-
if (!values[0].match(formatRegex)) {
|
|
2765
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2766
|
-
}
|
|
2767
|
-
else {
|
|
2768
|
-
if (!response_type.format2 ||
|
|
2769
|
-
!values[1].match(new RegExp(response_type.format2))) {
|
|
2770
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
2774
|
-
else {
|
|
2775
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
else {
|
|
2779
|
-
if (!nodes[i].match(formatRegex)) {
|
|
2780
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2781
|
-
}
|
|
2782
|
-
else {
|
|
2783
|
-
if (nodes[i] !== "" && response_type.unique) {
|
|
2784
|
-
for (var j = 0; j < i; j++) {
|
|
2785
|
-
if (nodes[i] === nodes[j]) {
|
|
2786
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
}
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
else {
|
|
2795
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.GENERAL_SET_FAILURE);
|
|
2796
|
-
}
|
|
2797
|
-
this._learner_response = learner_response;
|
|
2798
|
-
}
|
|
2799
|
-
else {
|
|
2800
|
-
throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
},
|
|
2804
|
-
enumerable: false,
|
|
2805
|
-
configurable: true
|
|
2806
|
-
});
|
|
2807
|
-
Object.defineProperty(CMIInteractionsObject.prototype, "result", {
|
|
2727
|
+
return _super.call(this, {
|
|
2728
|
+
children: api_constants.scorm2004.comments_children,
|
|
2729
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2730
|
+
errorClass: Scorm2004ValidationError,
|
|
2731
|
+
}) || this;
|
|
2732
|
+
}
|
|
2733
|
+
return CMICommentsFromLearner;
|
|
2734
|
+
}(CMIArray));
|
|
2735
|
+
|
|
2736
|
+
var CMICommentsObject = (function (_super) {
|
|
2737
|
+
__extends(CMICommentsObject, _super);
|
|
2738
|
+
function CMICommentsObject(readOnlyAfterInit) {
|
|
2739
|
+
if (readOnlyAfterInit === void 0) { readOnlyAfterInit = false; }
|
|
2740
|
+
var _this = _super.call(this) || this;
|
|
2741
|
+
_this._comment = "";
|
|
2742
|
+
_this._location = "";
|
|
2743
|
+
_this._timestamp = "";
|
|
2744
|
+
_this._comment = "";
|
|
2745
|
+
_this._location = "";
|
|
2746
|
+
_this._timestamp = "";
|
|
2747
|
+
_this._readOnlyAfterInit = readOnlyAfterInit;
|
|
2748
|
+
return _this;
|
|
2749
|
+
}
|
|
2750
|
+
Object.defineProperty(CMICommentsObject.prototype, "comment", {
|
|
2808
2751
|
get: function () {
|
|
2809
|
-
return this.
|
|
2752
|
+
return this._comment;
|
|
2810
2753
|
},
|
|
2811
|
-
set: function (
|
|
2812
|
-
if (
|
|
2813
|
-
|
|
2754
|
+
set: function (comment) {
|
|
2755
|
+
if (this.initialized && this._readOnlyAfterInit) {
|
|
2756
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
2757
|
+
}
|
|
2758
|
+
else {
|
|
2759
|
+
if (check2004ValidFormat(comment, regex.scorm2004.CMILangString4000, true)) {
|
|
2760
|
+
this._comment = comment;
|
|
2761
|
+
}
|
|
2814
2762
|
}
|
|
2815
2763
|
},
|
|
2816
2764
|
enumerable: false,
|
|
2817
2765
|
configurable: true
|
|
2818
2766
|
});
|
|
2819
|
-
Object.defineProperty(
|
|
2767
|
+
Object.defineProperty(CMICommentsObject.prototype, "location", {
|
|
2820
2768
|
get: function () {
|
|
2821
|
-
return this.
|
|
2769
|
+
return this._location;
|
|
2822
2770
|
},
|
|
2823
|
-
set: function (
|
|
2824
|
-
if (this.initialized && this.
|
|
2825
|
-
throw new Scorm2004ValidationError(
|
|
2771
|
+
set: function (location) {
|
|
2772
|
+
if (this.initialized && this._readOnlyAfterInit) {
|
|
2773
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
2826
2774
|
}
|
|
2827
2775
|
else {
|
|
2828
|
-
if (check2004ValidFormat(
|
|
2829
|
-
this.
|
|
2776
|
+
if (check2004ValidFormat(location, regex.scorm2004.CMIString250)) {
|
|
2777
|
+
this._location = location;
|
|
2830
2778
|
}
|
|
2831
2779
|
}
|
|
2832
2780
|
},
|
|
2833
2781
|
enumerable: false,
|
|
2834
2782
|
configurable: true
|
|
2835
2783
|
});
|
|
2836
|
-
Object.defineProperty(
|
|
2784
|
+
Object.defineProperty(CMICommentsObject.prototype, "timestamp", {
|
|
2837
2785
|
get: function () {
|
|
2838
|
-
return this.
|
|
2786
|
+
return this._timestamp;
|
|
2839
2787
|
},
|
|
2840
|
-
set: function (
|
|
2841
|
-
if (this.initialized && this.
|
|
2842
|
-
throw new Scorm2004ValidationError(
|
|
2788
|
+
set: function (timestamp) {
|
|
2789
|
+
if (this.initialized && this._readOnlyAfterInit) {
|
|
2790
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
2843
2791
|
}
|
|
2844
2792
|
else {
|
|
2845
|
-
if (check2004ValidFormat(
|
|
2846
|
-
this.
|
|
2793
|
+
if (check2004ValidFormat(timestamp, regex.scorm2004.CMITime)) {
|
|
2794
|
+
this._timestamp = timestamp;
|
|
2847
2795
|
}
|
|
2848
2796
|
}
|
|
2849
2797
|
},
|
|
2850
2798
|
enumerable: false,
|
|
2851
2799
|
configurable: true
|
|
2852
2800
|
});
|
|
2853
|
-
|
|
2801
|
+
CMICommentsObject.prototype.toJSON = function () {
|
|
2854
2802
|
this.jsonString = true;
|
|
2855
2803
|
var result = {
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
objectives: this.objectives,
|
|
2804
|
+
comment: this.comment,
|
|
2805
|
+
location: this.location,
|
|
2859
2806
|
timestamp: this.timestamp,
|
|
2860
|
-
weighting: this.weighting,
|
|
2861
|
-
learner_response: this.learner_response,
|
|
2862
|
-
result: this.result,
|
|
2863
|
-
latency: this.latency,
|
|
2864
|
-
description: this.description,
|
|
2865
|
-
correct_responses: this.correct_responses,
|
|
2866
2807
|
};
|
|
2867
2808
|
delete this.jsonString;
|
|
2868
2809
|
return result;
|
|
2869
2810
|
};
|
|
2870
|
-
return
|
|
2811
|
+
return CMICommentsObject;
|
|
2871
2812
|
}(BaseCMI));
|
|
2872
2813
|
|
|
2814
|
+
|
|
2815
|
+
;// ./src/cmi/scorm2004/objectives.ts
|
|
2816
|
+
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
|
|
2824
|
+
|
|
2825
|
+
var CMIObjectives = (function (_super) {
|
|
2826
|
+
__extends(CMIObjectives, _super);
|
|
2827
|
+
function CMIObjectives() {
|
|
2828
|
+
return _super.call(this, {
|
|
2829
|
+
children: api_constants.scorm2004.objectives_children,
|
|
2830
|
+
errorCode: error_codes.scorm2004.READ_ONLY_ELEMENT,
|
|
2831
|
+
errorClass: Scorm2004ValidationError,
|
|
2832
|
+
}) || this;
|
|
2833
|
+
}
|
|
2834
|
+
return CMIObjectives;
|
|
2835
|
+
}(CMIArray));
|
|
2836
|
+
|
|
2873
2837
|
var CMIObjectivesObject = (function (_super) {
|
|
2874
2838
|
__extends(CMIObjectivesObject, _super);
|
|
2875
2839
|
function CMIObjectivesObject() {
|
|
@@ -2892,7 +2856,7 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2892
2856
|
return this._id;
|
|
2893
2857
|
},
|
|
2894
2858
|
set: function (id) {
|
|
2895
|
-
if (check2004ValidFormat(id,
|
|
2859
|
+
if (check2004ValidFormat(id, regex.scorm2004.CMILongIdentifier)) {
|
|
2896
2860
|
this._id = id;
|
|
2897
2861
|
}
|
|
2898
2862
|
},
|
|
@@ -2905,10 +2869,10 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2905
2869
|
},
|
|
2906
2870
|
set: function (success_status) {
|
|
2907
2871
|
if (this.initialized && this._id === "") {
|
|
2908
|
-
throw new Scorm2004ValidationError(
|
|
2872
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2909
2873
|
}
|
|
2910
2874
|
else {
|
|
2911
|
-
if (check2004ValidFormat(success_status,
|
|
2875
|
+
if (check2004ValidFormat(success_status, regex.scorm2004.CMISStatus)) {
|
|
2912
2876
|
this._success_status = success_status;
|
|
2913
2877
|
}
|
|
2914
2878
|
}
|
|
@@ -2922,10 +2886,10 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2922
2886
|
},
|
|
2923
2887
|
set: function (completion_status) {
|
|
2924
2888
|
if (this.initialized && this._id === "") {
|
|
2925
|
-
throw new Scorm2004ValidationError(
|
|
2889
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2926
2890
|
}
|
|
2927
2891
|
else {
|
|
2928
|
-
if (check2004ValidFormat(completion_status,
|
|
2892
|
+
if (check2004ValidFormat(completion_status, regex.scorm2004.CMICStatus)) {
|
|
2929
2893
|
this._completion_status = completion_status;
|
|
2930
2894
|
}
|
|
2931
2895
|
}
|
|
@@ -2939,11 +2903,11 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2939
2903
|
},
|
|
2940
2904
|
set: function (progress_measure) {
|
|
2941
2905
|
if (this.initialized && this._id === "") {
|
|
2942
|
-
throw new Scorm2004ValidationError(
|
|
2906
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2943
2907
|
}
|
|
2944
2908
|
else {
|
|
2945
|
-
if (check2004ValidFormat(progress_measure,
|
|
2946
|
-
check2004ValidRange(progress_measure,
|
|
2909
|
+
if (check2004ValidFormat(progress_measure, regex.scorm2004.CMIDecimal) &&
|
|
2910
|
+
check2004ValidRange(progress_measure, regex.scorm2004.progress_range)) {
|
|
2947
2911
|
this._progress_measure = progress_measure;
|
|
2948
2912
|
}
|
|
2949
2913
|
}
|
|
@@ -2957,10 +2921,10 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2957
2921
|
},
|
|
2958
2922
|
set: function (description) {
|
|
2959
2923
|
if (this.initialized && this._id === "") {
|
|
2960
|
-
throw new Scorm2004ValidationError(
|
|
2924
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
2961
2925
|
}
|
|
2962
2926
|
else {
|
|
2963
|
-
if (check2004ValidFormat(description,
|
|
2927
|
+
if (check2004ValidFormat(description, regex.scorm2004.CMILangString250, true)) {
|
|
2964
2928
|
this._description = description;
|
|
2965
2929
|
}
|
|
2966
2930
|
}
|
|
@@ -2984,294 +2948,384 @@ var CMIObjectivesObject = (function (_super) {
|
|
|
2984
2948
|
return CMIObjectivesObject;
|
|
2985
2949
|
}(BaseCMI));
|
|
2986
2950
|
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
2951
|
+
|
|
2952
|
+
;// ./src/cmi/scorm2004/cmi.ts
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
var CMI = (function (_super) {
|
|
2967
|
+
__extends(CMI, _super);
|
|
2968
|
+
function CMI(initialized) {
|
|
2969
|
+
if (initialized === void 0) { initialized = false; }
|
|
2970
|
+
var _this = _super.call(this) || this;
|
|
2971
|
+
_this.__version = "1.0";
|
|
2972
|
+
_this.__children = api_constants.scorm2004.cmi_children;
|
|
2973
|
+
_this._completion_status = "unknown";
|
|
2974
|
+
_this._completion_threshold = "";
|
|
2975
|
+
_this._credit = "credit";
|
|
2976
|
+
_this._entry = "";
|
|
2977
|
+
_this._exit = "";
|
|
2978
|
+
_this._launch_data = "";
|
|
2979
|
+
_this._learner_id = "";
|
|
2980
|
+
_this._learner_name = "";
|
|
2981
|
+
_this._location = "";
|
|
2982
|
+
_this._max_time_allowed = "";
|
|
2983
|
+
_this._mode = "normal";
|
|
2984
|
+
_this._progress_measure = "";
|
|
2985
|
+
_this._scaled_passing_score = "";
|
|
2986
|
+
_this._session_time = "PT0H0M0S";
|
|
2987
|
+
_this._success_status = "unknown";
|
|
2988
|
+
_this._suspend_data = "";
|
|
2989
|
+
_this._time_limit_action = "continue,no message";
|
|
2990
|
+
_this._total_time = "";
|
|
2991
|
+
_this.learner_preference = new CMILearnerPreference();
|
|
2992
|
+
_this.score = new Scorm2004CMIScore();
|
|
2993
|
+
_this.comments_from_learner = new CMICommentsFromLearner();
|
|
2994
|
+
_this.comments_from_lms = new CMICommentsFromLMS();
|
|
2995
|
+
_this.interactions = new CMIInteractions();
|
|
2996
|
+
_this.objectives = new CMIObjectives();
|
|
2997
|
+
if (initialized)
|
|
2998
|
+
_this.initialize();
|
|
3000
2999
|
return _this;
|
|
3001
3000
|
}
|
|
3002
|
-
|
|
3001
|
+
CMI.prototype.initialize = function () {
|
|
3002
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3003
|
+
_super.prototype.initialize.call(this);
|
|
3004
|
+
(_a = this.learner_preference) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
3005
|
+
(_b = this.score) === null || _b === void 0 ? void 0 : _b.initialize();
|
|
3006
|
+
(_c = this.comments_from_learner) === null || _c === void 0 ? void 0 : _c.initialize();
|
|
3007
|
+
(_d = this.comments_from_lms) === null || _d === void 0 ? void 0 : _d.initialize();
|
|
3008
|
+
(_e = this.interactions) === null || _e === void 0 ? void 0 : _e.initialize();
|
|
3009
|
+
(_f = this.objectives) === null || _f === void 0 ? void 0 : _f.initialize();
|
|
3010
|
+
};
|
|
3011
|
+
Object.defineProperty(CMI.prototype, "_version", {
|
|
3003
3012
|
get: function () {
|
|
3004
|
-
return this.
|
|
3013
|
+
return this.__version;
|
|
3005
3014
|
},
|
|
3006
|
-
set: function (
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3015
|
+
set: function (_version) {
|
|
3016
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3017
|
+
},
|
|
3018
|
+
enumerable: false,
|
|
3019
|
+
configurable: true
|
|
3020
|
+
});
|
|
3021
|
+
Object.defineProperty(CMI.prototype, "_children", {
|
|
3022
|
+
get: function () {
|
|
3023
|
+
return this.__children;
|
|
3024
|
+
},
|
|
3025
|
+
set: function (_children) {
|
|
3026
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3027
|
+
},
|
|
3028
|
+
enumerable: false,
|
|
3029
|
+
configurable: true
|
|
3030
|
+
});
|
|
3031
|
+
Object.defineProperty(CMI.prototype, "completion_status", {
|
|
3032
|
+
get: function () {
|
|
3033
|
+
return this._completion_status;
|
|
3034
|
+
},
|
|
3035
|
+
set: function (completion_status) {
|
|
3036
|
+
if (check2004ValidFormat(completion_status, regex.scorm2004.CMICStatus)) {
|
|
3037
|
+
this._completion_status = completion_status;
|
|
3038
|
+
}
|
|
3039
|
+
},
|
|
3040
|
+
enumerable: false,
|
|
3041
|
+
configurable: true
|
|
3042
|
+
});
|
|
3043
|
+
Object.defineProperty(CMI.prototype, "completion_threshold", {
|
|
3044
|
+
get: function () {
|
|
3045
|
+
return this._completion_threshold;
|
|
3046
|
+
},
|
|
3047
|
+
set: function (completion_threshold) {
|
|
3048
|
+
if (this.initialized) {
|
|
3049
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3050
|
+
}
|
|
3051
|
+
else {
|
|
3052
|
+
this._completion_threshold = completion_threshold;
|
|
3053
|
+
}
|
|
3054
|
+
},
|
|
3055
|
+
enumerable: false,
|
|
3056
|
+
configurable: true
|
|
3057
|
+
});
|
|
3058
|
+
Object.defineProperty(CMI.prototype, "credit", {
|
|
3059
|
+
get: function () {
|
|
3060
|
+
return this._credit;
|
|
3061
|
+
},
|
|
3062
|
+
set: function (credit) {
|
|
3063
|
+
if (this.initialized) {
|
|
3064
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3065
|
+
}
|
|
3066
|
+
else {
|
|
3067
|
+
this._credit = credit;
|
|
3068
|
+
}
|
|
3069
|
+
},
|
|
3070
|
+
enumerable: false,
|
|
3071
|
+
configurable: true
|
|
3072
|
+
});
|
|
3073
|
+
Object.defineProperty(CMI.prototype, "entry", {
|
|
3074
|
+
get: function () {
|
|
3075
|
+
return this._entry;
|
|
3076
|
+
},
|
|
3077
|
+
set: function (entry) {
|
|
3078
|
+
if (this.initialized) {
|
|
3079
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3080
|
+
}
|
|
3081
|
+
else {
|
|
3082
|
+
this._entry = entry;
|
|
3083
|
+
}
|
|
3084
|
+
},
|
|
3085
|
+
enumerable: false,
|
|
3086
|
+
configurable: true
|
|
3087
|
+
});
|
|
3088
|
+
Object.defineProperty(CMI.prototype, "exit", {
|
|
3089
|
+
get: function () {
|
|
3090
|
+
if (!this.jsonString) {
|
|
3091
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.WRITE_ONLY_ELEMENT);
|
|
3092
|
+
}
|
|
3093
|
+
return this._exit;
|
|
3094
|
+
},
|
|
3095
|
+
set: function (exit) {
|
|
3096
|
+
if (check2004ValidFormat(exit, regex.scorm2004.CMIExit, true)) {
|
|
3097
|
+
this._exit = exit;
|
|
3098
|
+
}
|
|
3099
|
+
},
|
|
3100
|
+
enumerable: false,
|
|
3101
|
+
configurable: true
|
|
3102
|
+
});
|
|
3103
|
+
Object.defineProperty(CMI.prototype, "launch_data", {
|
|
3104
|
+
get: function () {
|
|
3105
|
+
return this._launch_data;
|
|
3106
|
+
},
|
|
3107
|
+
set: function (launch_data) {
|
|
3108
|
+
if (this.initialized) {
|
|
3109
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3110
|
+
}
|
|
3111
|
+
else {
|
|
3112
|
+
this._launch_data = launch_data;
|
|
3113
|
+
}
|
|
3114
|
+
},
|
|
3115
|
+
enumerable: false,
|
|
3116
|
+
configurable: true
|
|
3117
|
+
});
|
|
3118
|
+
Object.defineProperty(CMI.prototype, "learner_id", {
|
|
3119
|
+
get: function () {
|
|
3120
|
+
return this._learner_id;
|
|
3121
|
+
},
|
|
3122
|
+
set: function (learner_id) {
|
|
3123
|
+
if (this.initialized) {
|
|
3124
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3125
|
+
}
|
|
3126
|
+
else {
|
|
3127
|
+
this._learner_id = learner_id;
|
|
3010
3128
|
}
|
|
3011
3129
|
},
|
|
3012
3130
|
enumerable: false,
|
|
3013
3131
|
configurable: true
|
|
3014
3132
|
});
|
|
3015
|
-
|
|
3016
|
-
this.jsonString = true;
|
|
3017
|
-
var result = {
|
|
3018
|
-
scaled: this.scaled,
|
|
3019
|
-
raw: this.raw,
|
|
3020
|
-
min: this.min,
|
|
3021
|
-
max: this.max,
|
|
3022
|
-
};
|
|
3023
|
-
delete this.jsonString;
|
|
3024
|
-
return result;
|
|
3025
|
-
};
|
|
3026
|
-
return Scorm2004CMIScore;
|
|
3027
|
-
}(CMIScore));
|
|
3028
|
-
var CMICommentsObject = (function (_super) {
|
|
3029
|
-
__extends(CMICommentsObject, _super);
|
|
3030
|
-
function CMICommentsObject(readOnlyAfterInit) {
|
|
3031
|
-
if (readOnlyAfterInit === void 0) { readOnlyAfterInit = false; }
|
|
3032
|
-
var _this = _super.call(this) || this;
|
|
3033
|
-
_this._comment = "";
|
|
3034
|
-
_this._location = "";
|
|
3035
|
-
_this._timestamp = "";
|
|
3036
|
-
_this._comment = "";
|
|
3037
|
-
_this._location = "";
|
|
3038
|
-
_this._timestamp = "";
|
|
3039
|
-
_this._readOnlyAfterInit = readOnlyAfterInit;
|
|
3040
|
-
return _this;
|
|
3041
|
-
}
|
|
3042
|
-
Object.defineProperty(CMICommentsObject.prototype, "comment", {
|
|
3133
|
+
Object.defineProperty(CMI.prototype, "learner_name", {
|
|
3043
3134
|
get: function () {
|
|
3044
|
-
return this.
|
|
3135
|
+
return this._learner_name;
|
|
3045
3136
|
},
|
|
3046
|
-
set: function (
|
|
3047
|
-
if (this.initialized
|
|
3048
|
-
throw new Scorm2004ValidationError(
|
|
3137
|
+
set: function (learner_name) {
|
|
3138
|
+
if (this.initialized) {
|
|
3139
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3049
3140
|
}
|
|
3050
3141
|
else {
|
|
3051
|
-
|
|
3052
|
-
this._comment = comment;
|
|
3053
|
-
}
|
|
3142
|
+
this._learner_name = learner_name;
|
|
3054
3143
|
}
|
|
3055
3144
|
},
|
|
3056
3145
|
enumerable: false,
|
|
3057
3146
|
configurable: true
|
|
3058
3147
|
});
|
|
3059
|
-
Object.defineProperty(
|
|
3148
|
+
Object.defineProperty(CMI.prototype, "location", {
|
|
3060
3149
|
get: function () {
|
|
3061
3150
|
return this._location;
|
|
3062
3151
|
},
|
|
3063
3152
|
set: function (location) {
|
|
3064
|
-
if (
|
|
3065
|
-
|
|
3153
|
+
if (check2004ValidFormat(location, regex.scorm2004.CMIString1000)) {
|
|
3154
|
+
this._location = location;
|
|
3155
|
+
}
|
|
3156
|
+
},
|
|
3157
|
+
enumerable: false,
|
|
3158
|
+
configurable: true
|
|
3159
|
+
});
|
|
3160
|
+
Object.defineProperty(CMI.prototype, "max_time_allowed", {
|
|
3161
|
+
get: function () {
|
|
3162
|
+
return this._max_time_allowed;
|
|
3163
|
+
},
|
|
3164
|
+
set: function (max_time_allowed) {
|
|
3165
|
+
if (this.initialized) {
|
|
3166
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3066
3167
|
}
|
|
3067
3168
|
else {
|
|
3068
|
-
|
|
3069
|
-
this._location = location;
|
|
3070
|
-
}
|
|
3169
|
+
this._max_time_allowed = max_time_allowed;
|
|
3071
3170
|
}
|
|
3072
3171
|
},
|
|
3073
3172
|
enumerable: false,
|
|
3074
3173
|
configurable: true
|
|
3075
3174
|
});
|
|
3076
|
-
Object.defineProperty(
|
|
3175
|
+
Object.defineProperty(CMI.prototype, "mode", {
|
|
3077
3176
|
get: function () {
|
|
3078
|
-
return this.
|
|
3177
|
+
return this._mode;
|
|
3079
3178
|
},
|
|
3080
|
-
set: function (
|
|
3081
|
-
if (this.initialized
|
|
3082
|
-
throw new Scorm2004ValidationError(
|
|
3179
|
+
set: function (mode) {
|
|
3180
|
+
if (this.initialized) {
|
|
3181
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3083
3182
|
}
|
|
3084
3183
|
else {
|
|
3085
|
-
|
|
3086
|
-
this._timestamp = timestamp;
|
|
3087
|
-
}
|
|
3184
|
+
this._mode = mode;
|
|
3088
3185
|
}
|
|
3089
3186
|
},
|
|
3090
3187
|
enumerable: false,
|
|
3091
3188
|
configurable: true
|
|
3092
3189
|
});
|
|
3093
|
-
|
|
3094
|
-
this.jsonString = true;
|
|
3095
|
-
var result = {
|
|
3096
|
-
comment: this.comment,
|
|
3097
|
-
location: this.location,
|
|
3098
|
-
timestamp: this.timestamp,
|
|
3099
|
-
};
|
|
3100
|
-
delete this.jsonString;
|
|
3101
|
-
return result;
|
|
3102
|
-
};
|
|
3103
|
-
return CMICommentsObject;
|
|
3104
|
-
}(BaseCMI));
|
|
3105
|
-
|
|
3106
|
-
var CMIInteractionsObjectivesObject = (function (_super) {
|
|
3107
|
-
__extends(CMIInteractionsObjectivesObject, _super);
|
|
3108
|
-
function CMIInteractionsObjectivesObject() {
|
|
3109
|
-
var _this = _super.call(this) || this;
|
|
3110
|
-
_this._id = "";
|
|
3111
|
-
return _this;
|
|
3112
|
-
}
|
|
3113
|
-
Object.defineProperty(CMIInteractionsObjectivesObject.prototype, "id", {
|
|
3190
|
+
Object.defineProperty(CMI.prototype, "progress_measure", {
|
|
3114
3191
|
get: function () {
|
|
3115
|
-
return this.
|
|
3192
|
+
return this._progress_measure;
|
|
3116
3193
|
},
|
|
3117
|
-
set: function (
|
|
3118
|
-
if (check2004ValidFormat(
|
|
3119
|
-
|
|
3194
|
+
set: function (progress_measure) {
|
|
3195
|
+
if (check2004ValidFormat(progress_measure, regex.scorm2004.CMIDecimal) &&
|
|
3196
|
+
check2004ValidRange(progress_measure, regex.scorm2004.progress_range)) {
|
|
3197
|
+
this._progress_measure = progress_measure;
|
|
3120
3198
|
}
|
|
3121
3199
|
},
|
|
3122
3200
|
enumerable: false,
|
|
3123
3201
|
configurable: true
|
|
3124
3202
|
});
|
|
3125
|
-
|
|
3126
|
-
this.jsonString = true;
|
|
3127
|
-
var result = {
|
|
3128
|
-
id: this.id,
|
|
3129
|
-
};
|
|
3130
|
-
delete this.jsonString;
|
|
3131
|
-
return result;
|
|
3132
|
-
};
|
|
3133
|
-
return CMIInteractionsObjectivesObject;
|
|
3134
|
-
}(BaseCMI));
|
|
3135
|
-
|
|
3136
|
-
var CMIInteractionsCorrectResponsesObject = (function (_super) {
|
|
3137
|
-
__extends(CMIInteractionsCorrectResponsesObject, _super);
|
|
3138
|
-
function CMIInteractionsCorrectResponsesObject() {
|
|
3139
|
-
var _this = _super.call(this) || this;
|
|
3140
|
-
_this._pattern = "";
|
|
3141
|
-
return _this;
|
|
3142
|
-
}
|
|
3143
|
-
Object.defineProperty(CMIInteractionsCorrectResponsesObject.prototype, "pattern", {
|
|
3203
|
+
Object.defineProperty(CMI.prototype, "scaled_passing_score", {
|
|
3144
3204
|
get: function () {
|
|
3145
|
-
return this.
|
|
3205
|
+
return this._scaled_passing_score;
|
|
3146
3206
|
},
|
|
3147
|
-
set: function (
|
|
3148
|
-
if (
|
|
3149
|
-
|
|
3207
|
+
set: function (scaled_passing_score) {
|
|
3208
|
+
if (this.initialized) {
|
|
3209
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3210
|
+
}
|
|
3211
|
+
else {
|
|
3212
|
+
this._scaled_passing_score = scaled_passing_score;
|
|
3150
3213
|
}
|
|
3151
3214
|
},
|
|
3152
3215
|
enumerable: false,
|
|
3153
3216
|
configurable: true
|
|
3154
3217
|
});
|
|
3155
|
-
|
|
3156
|
-
this.jsonString = true;
|
|
3157
|
-
var result = {
|
|
3158
|
-
pattern: this.pattern,
|
|
3159
|
-
};
|
|
3160
|
-
delete this.jsonString;
|
|
3161
|
-
return result;
|
|
3162
|
-
};
|
|
3163
|
-
return CMIInteractionsCorrectResponsesObject;
|
|
3164
|
-
}(BaseCMI));
|
|
3165
|
-
|
|
3166
|
-
var ADL = (function (_super) {
|
|
3167
|
-
__extends(ADL, _super);
|
|
3168
|
-
function ADL() {
|
|
3169
|
-
var _this = _super.call(this) || this;
|
|
3170
|
-
_this.nav = new ADLNav();
|
|
3171
|
-
return _this;
|
|
3172
|
-
}
|
|
3173
|
-
ADL.prototype.initialize = function () {
|
|
3174
|
-
var _a;
|
|
3175
|
-
_super.prototype.initialize.call(this);
|
|
3176
|
-
(_a = this.nav) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
3177
|
-
};
|
|
3178
|
-
ADL.prototype.toJSON = function () {
|
|
3179
|
-
this.jsonString = true;
|
|
3180
|
-
var result = {
|
|
3181
|
-
nav: this.nav,
|
|
3182
|
-
};
|
|
3183
|
-
delete this.jsonString;
|
|
3184
|
-
return result;
|
|
3185
|
-
};
|
|
3186
|
-
return ADL;
|
|
3187
|
-
}(BaseCMI));
|
|
3188
|
-
|
|
3189
|
-
var ADLNav = (function (_super) {
|
|
3190
|
-
__extends(ADLNav, _super);
|
|
3191
|
-
function ADLNav() {
|
|
3192
|
-
var _this = _super.call(this) || this;
|
|
3193
|
-
_this._request = "_none_";
|
|
3194
|
-
_this.request_valid = new ADLNavRequestValid();
|
|
3195
|
-
return _this;
|
|
3196
|
-
}
|
|
3197
|
-
ADLNav.prototype.initialize = function () {
|
|
3198
|
-
var _a;
|
|
3199
|
-
_super.prototype.initialize.call(this);
|
|
3200
|
-
(_a = this.request_valid) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
3201
|
-
};
|
|
3202
|
-
Object.defineProperty(ADLNav.prototype, "request", {
|
|
3218
|
+
Object.defineProperty(CMI.prototype, "session_time", {
|
|
3203
3219
|
get: function () {
|
|
3204
|
-
|
|
3220
|
+
if (!this.jsonString) {
|
|
3221
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.WRITE_ONLY_ELEMENT);
|
|
3222
|
+
}
|
|
3223
|
+
return this._session_time;
|
|
3205
3224
|
},
|
|
3206
|
-
set: function (
|
|
3207
|
-
if (check2004ValidFormat(
|
|
3208
|
-
this.
|
|
3225
|
+
set: function (session_time) {
|
|
3226
|
+
if (check2004ValidFormat(session_time, regex.scorm2004.CMITimespan)) {
|
|
3227
|
+
this._session_time = session_time;
|
|
3209
3228
|
}
|
|
3210
3229
|
},
|
|
3211
3230
|
enumerable: false,
|
|
3212
3231
|
configurable: true
|
|
3213
3232
|
});
|
|
3214
|
-
|
|
3215
|
-
this.jsonString = true;
|
|
3216
|
-
var result = {
|
|
3217
|
-
request: this.request,
|
|
3218
|
-
};
|
|
3219
|
-
delete this.jsonString;
|
|
3220
|
-
return result;
|
|
3221
|
-
};
|
|
3222
|
-
return ADLNav;
|
|
3223
|
-
}(BaseCMI));
|
|
3224
|
-
var ADLNavRequestValid = (function (_super) {
|
|
3225
|
-
__extends(ADLNavRequestValid, _super);
|
|
3226
|
-
function ADLNavRequestValid() {
|
|
3227
|
-
var _this = _super.call(this) || this;
|
|
3228
|
-
_this._continue = "unknown";
|
|
3229
|
-
_this._previous = "unknown";
|
|
3230
|
-
_this.choice = (function () {
|
|
3231
|
-
function class_1() {
|
|
3232
|
-
this._isTargetValid = function (_target) { return "unknown"; };
|
|
3233
|
-
}
|
|
3234
|
-
return class_1;
|
|
3235
|
-
}());
|
|
3236
|
-
_this.jump = (function () {
|
|
3237
|
-
function class_2() {
|
|
3238
|
-
this._isTargetValid = function (_target) { return "unknown"; };
|
|
3239
|
-
}
|
|
3240
|
-
return class_2;
|
|
3241
|
-
}());
|
|
3242
|
-
return _this;
|
|
3243
|
-
}
|
|
3244
|
-
Object.defineProperty(ADLNavRequestValid.prototype, "continue", {
|
|
3233
|
+
Object.defineProperty(CMI.prototype, "success_status", {
|
|
3245
3234
|
get: function () {
|
|
3246
|
-
return this.
|
|
3235
|
+
return this._success_status;
|
|
3247
3236
|
},
|
|
3248
|
-
set: function (
|
|
3249
|
-
|
|
3237
|
+
set: function (success_status) {
|
|
3238
|
+
if (check2004ValidFormat(success_status, regex.scorm2004.CMISStatus)) {
|
|
3239
|
+
this._success_status = success_status;
|
|
3240
|
+
}
|
|
3250
3241
|
},
|
|
3251
3242
|
enumerable: false,
|
|
3252
3243
|
configurable: true
|
|
3253
3244
|
});
|
|
3254
|
-
Object.defineProperty(
|
|
3245
|
+
Object.defineProperty(CMI.prototype, "suspend_data", {
|
|
3255
3246
|
get: function () {
|
|
3256
|
-
return this.
|
|
3247
|
+
return this._suspend_data;
|
|
3257
3248
|
},
|
|
3258
|
-
set: function (
|
|
3259
|
-
|
|
3249
|
+
set: function (suspend_data) {
|
|
3250
|
+
if (check2004ValidFormat(suspend_data, regex.scorm2004.CMIString64000, true)) {
|
|
3251
|
+
this._suspend_data = suspend_data;
|
|
3252
|
+
}
|
|
3260
3253
|
},
|
|
3261
3254
|
enumerable: false,
|
|
3262
3255
|
configurable: true
|
|
3263
3256
|
});
|
|
3264
|
-
|
|
3257
|
+
Object.defineProperty(CMI.prototype, "time_limit_action", {
|
|
3258
|
+
get: function () {
|
|
3259
|
+
return this._time_limit_action;
|
|
3260
|
+
},
|
|
3261
|
+
set: function (time_limit_action) {
|
|
3262
|
+
if (this.initialized) {
|
|
3263
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3264
|
+
}
|
|
3265
|
+
else {
|
|
3266
|
+
this._time_limit_action = time_limit_action;
|
|
3267
|
+
}
|
|
3268
|
+
},
|
|
3269
|
+
enumerable: false,
|
|
3270
|
+
configurable: true
|
|
3271
|
+
});
|
|
3272
|
+
Object.defineProperty(CMI.prototype, "total_time", {
|
|
3273
|
+
get: function () {
|
|
3274
|
+
return this._total_time;
|
|
3275
|
+
},
|
|
3276
|
+
set: function (total_time) {
|
|
3277
|
+
if (this.initialized) {
|
|
3278
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3279
|
+
}
|
|
3280
|
+
else {
|
|
3281
|
+
this._total_time = total_time;
|
|
3282
|
+
}
|
|
3283
|
+
},
|
|
3284
|
+
enumerable: false,
|
|
3285
|
+
configurable: true
|
|
3286
|
+
});
|
|
3287
|
+
CMI.prototype.getCurrentTotalTime = function () {
|
|
3288
|
+
var sessionTime = this._session_time;
|
|
3289
|
+
var startTime = this.start_time;
|
|
3290
|
+
if (typeof startTime !== "undefined" && startTime !== null) {
|
|
3291
|
+
var seconds = new Date().getTime() - startTime;
|
|
3292
|
+
sessionTime = getSecondsAsISODuration(seconds / 1000);
|
|
3293
|
+
}
|
|
3294
|
+
return addTwoDurations(this._total_time, sessionTime, regex.scorm2004.CMITimespan);
|
|
3295
|
+
};
|
|
3296
|
+
CMI.prototype.toJSON = function () {
|
|
3265
3297
|
this.jsonString = true;
|
|
3266
3298
|
var result = {
|
|
3267
|
-
|
|
3268
|
-
|
|
3299
|
+
comments_from_learner: this.comments_from_learner,
|
|
3300
|
+
comments_from_lms: this.comments_from_lms,
|
|
3301
|
+
completion_status: this.completion_status,
|
|
3302
|
+
completion_threshold: this.completion_threshold,
|
|
3303
|
+
credit: this.credit,
|
|
3304
|
+
entry: this.entry,
|
|
3305
|
+
exit: this.exit,
|
|
3306
|
+
interactions: this.interactions,
|
|
3307
|
+
launch_data: this.launch_data,
|
|
3308
|
+
learner_id: this.learner_id,
|
|
3309
|
+
learner_name: this.learner_name,
|
|
3310
|
+
learner_preference: this.learner_preference,
|
|
3311
|
+
location: this.location,
|
|
3312
|
+
max_time_allowed: this.max_time_allowed,
|
|
3313
|
+
mode: this.mode,
|
|
3314
|
+
objectives: this.objectives,
|
|
3315
|
+
progress_measure: this.progress_measure,
|
|
3316
|
+
scaled_passing_score: this.scaled_passing_score,
|
|
3317
|
+
score: this.score,
|
|
3318
|
+
session_time: this.session_time,
|
|
3319
|
+
success_status: this.success_status,
|
|
3320
|
+
suspend_data: this.suspend_data,
|
|
3321
|
+
time_limit_action: this.time_limit_action,
|
|
3269
3322
|
};
|
|
3270
3323
|
delete this.jsonString;
|
|
3271
3324
|
return result;
|
|
3272
3325
|
};
|
|
3273
|
-
return
|
|
3274
|
-
}(
|
|
3326
|
+
return CMI;
|
|
3327
|
+
}(BaseRootCMI));
|
|
3328
|
+
|
|
3275
3329
|
|
|
3276
3330
|
;// ./src/constants/language_constants.ts
|
|
3277
3331
|
var ValidLanguages = [
|
|
@@ -3669,6 +3723,183 @@ var ValidLanguages = [
|
|
|
3669
3723
|
];
|
|
3670
3724
|
/* harmony default export */ var language_constants = (ValidLanguages);
|
|
3671
3725
|
|
|
3726
|
+
;// ./src/constants/enums.ts
|
|
3727
|
+
var NAVBoolean;
|
|
3728
|
+
(function (NAVBoolean) {
|
|
3729
|
+
NAVBoolean["unknown"] = "unknown";
|
|
3730
|
+
NAVBoolean["true"] = "true";
|
|
3731
|
+
NAVBoolean["false"] = "false";
|
|
3732
|
+
})(NAVBoolean || (NAVBoolean = {}));
|
|
3733
|
+
|
|
3734
|
+
;// ./src/cmi/scorm2004/adl.ts
|
|
3735
|
+
|
|
3736
|
+
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
var ADL = (function (_super) {
|
|
3743
|
+
__extends(ADL, _super);
|
|
3744
|
+
function ADL() {
|
|
3745
|
+
var _this = _super.call(this) || this;
|
|
3746
|
+
_this.nav = new ADLNav();
|
|
3747
|
+
return _this;
|
|
3748
|
+
}
|
|
3749
|
+
ADL.prototype.initialize = function () {
|
|
3750
|
+
var _a;
|
|
3751
|
+
_super.prototype.initialize.call(this);
|
|
3752
|
+
(_a = this.nav) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
3753
|
+
};
|
|
3754
|
+
ADL.prototype.toJSON = function () {
|
|
3755
|
+
this.jsonString = true;
|
|
3756
|
+
var result = {
|
|
3757
|
+
nav: this.nav,
|
|
3758
|
+
};
|
|
3759
|
+
delete this.jsonString;
|
|
3760
|
+
return result;
|
|
3761
|
+
};
|
|
3762
|
+
return ADL;
|
|
3763
|
+
}(BaseCMI));
|
|
3764
|
+
|
|
3765
|
+
var ADLNav = (function (_super) {
|
|
3766
|
+
__extends(ADLNav, _super);
|
|
3767
|
+
function ADLNav() {
|
|
3768
|
+
var _this = _super.call(this) || this;
|
|
3769
|
+
_this._request = "_none_";
|
|
3770
|
+
_this.request_valid = new ADLNavRequestValid();
|
|
3771
|
+
return _this;
|
|
3772
|
+
}
|
|
3773
|
+
ADLNav.prototype.initialize = function () {
|
|
3774
|
+
var _a;
|
|
3775
|
+
_super.prototype.initialize.call(this);
|
|
3776
|
+
(_a = this.request_valid) === null || _a === void 0 ? void 0 : _a.initialize();
|
|
3777
|
+
};
|
|
3778
|
+
Object.defineProperty(ADLNav.prototype, "request", {
|
|
3779
|
+
get: function () {
|
|
3780
|
+
return this._request;
|
|
3781
|
+
},
|
|
3782
|
+
set: function (request) {
|
|
3783
|
+
if (check2004ValidFormat(request, regex.scorm2004.NAVEvent)) {
|
|
3784
|
+
this._request = request;
|
|
3785
|
+
}
|
|
3786
|
+
},
|
|
3787
|
+
enumerable: false,
|
|
3788
|
+
configurable: true
|
|
3789
|
+
});
|
|
3790
|
+
ADLNav.prototype.toJSON = function () {
|
|
3791
|
+
this.jsonString = true;
|
|
3792
|
+
var result = {
|
|
3793
|
+
request: this.request,
|
|
3794
|
+
};
|
|
3795
|
+
delete this.jsonString;
|
|
3796
|
+
return result;
|
|
3797
|
+
};
|
|
3798
|
+
return ADLNav;
|
|
3799
|
+
}(BaseCMI));
|
|
3800
|
+
|
|
3801
|
+
var ADLNavRequestValid = (function (_super) {
|
|
3802
|
+
__extends(ADLNavRequestValid, _super);
|
|
3803
|
+
function ADLNavRequestValid() {
|
|
3804
|
+
var _this = _super.call(this) || this;
|
|
3805
|
+
_this._continue = "unknown";
|
|
3806
|
+
_this._previous = "unknown";
|
|
3807
|
+
_this._choice = {};
|
|
3808
|
+
_this._jump = {};
|
|
3809
|
+
return _this;
|
|
3810
|
+
}
|
|
3811
|
+
Object.defineProperty(ADLNavRequestValid.prototype, "continue", {
|
|
3812
|
+
get: function () {
|
|
3813
|
+
return this._continue;
|
|
3814
|
+
},
|
|
3815
|
+
set: function (_continue) {
|
|
3816
|
+
if (this.initialized) {
|
|
3817
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3818
|
+
}
|
|
3819
|
+
if (check2004ValidFormat(_continue, regex.scorm2004.NAVBoolean)) {
|
|
3820
|
+
this._continue = _continue;
|
|
3821
|
+
}
|
|
3822
|
+
},
|
|
3823
|
+
enumerable: false,
|
|
3824
|
+
configurable: true
|
|
3825
|
+
});
|
|
3826
|
+
Object.defineProperty(ADLNavRequestValid.prototype, "previous", {
|
|
3827
|
+
get: function () {
|
|
3828
|
+
return this._previous;
|
|
3829
|
+
},
|
|
3830
|
+
set: function (_previous) {
|
|
3831
|
+
if (this.initialized) {
|
|
3832
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3833
|
+
}
|
|
3834
|
+
if (check2004ValidFormat(_previous, regex.scorm2004.NAVBoolean)) {
|
|
3835
|
+
this._previous = _previous;
|
|
3836
|
+
}
|
|
3837
|
+
},
|
|
3838
|
+
enumerable: false,
|
|
3839
|
+
configurable: true
|
|
3840
|
+
});
|
|
3841
|
+
Object.defineProperty(ADLNavRequestValid.prototype, "choice", {
|
|
3842
|
+
get: function () {
|
|
3843
|
+
return this._choice;
|
|
3844
|
+
},
|
|
3845
|
+
set: function (choice) {
|
|
3846
|
+
if (this.initialized) {
|
|
3847
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3848
|
+
}
|
|
3849
|
+
if (typeof choice !== "object") {
|
|
3850
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3851
|
+
}
|
|
3852
|
+
for (var key in choice) {
|
|
3853
|
+
if ({}.hasOwnProperty.call(choice, key)) {
|
|
3854
|
+
if (check2004ValidFormat(choice[key], regex.scorm2004.NAVBoolean) &&
|
|
3855
|
+
check2004ValidFormat(key, regex.scorm2004.NAVTarget)) {
|
|
3856
|
+
this._choice[key] =
|
|
3857
|
+
NAVBoolean[choice[key]];
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
},
|
|
3862
|
+
enumerable: false,
|
|
3863
|
+
configurable: true
|
|
3864
|
+
});
|
|
3865
|
+
Object.defineProperty(ADLNavRequestValid.prototype, "jump", {
|
|
3866
|
+
get: function () {
|
|
3867
|
+
return this._jump;
|
|
3868
|
+
},
|
|
3869
|
+
set: function (jump) {
|
|
3870
|
+
if (this.initialized) {
|
|
3871
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.READ_ONLY_ELEMENT);
|
|
3872
|
+
}
|
|
3873
|
+
if (typeof jump !== "object") {
|
|
3874
|
+
throw new Scorm2004ValidationError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3875
|
+
}
|
|
3876
|
+
for (var key in jump) {
|
|
3877
|
+
if ({}.hasOwnProperty.call(jump, key)) {
|
|
3878
|
+
if (check2004ValidFormat(jump[key], regex.scorm2004.NAVBoolean) &&
|
|
3879
|
+
check2004ValidFormat(key, regex.scorm2004.NAVTarget)) {
|
|
3880
|
+
this._jump[key] = NAVBoolean[jump[key]];
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
},
|
|
3885
|
+
enumerable: false,
|
|
3886
|
+
configurable: true
|
|
3887
|
+
});
|
|
3888
|
+
ADLNavRequestValid.prototype.toJSON = function () {
|
|
3889
|
+
this.jsonString = true;
|
|
3890
|
+
var result = {
|
|
3891
|
+
previous: this._previous,
|
|
3892
|
+
continue: this._continue,
|
|
3893
|
+
choice: this._choice,
|
|
3894
|
+
jump: this._jump,
|
|
3895
|
+
};
|
|
3896
|
+
delete this.jsonString;
|
|
3897
|
+
return result;
|
|
3898
|
+
};
|
|
3899
|
+
return ADLNavRequestValid;
|
|
3900
|
+
}(BaseCMI));
|
|
3901
|
+
|
|
3902
|
+
|
|
3672
3903
|
;// ./src/Scorm2004API.ts
|
|
3673
3904
|
|
|
3674
3905
|
|
|
@@ -3679,11 +3910,12 @@ var ValidLanguages = [
|
|
|
3679
3910
|
|
|
3680
3911
|
|
|
3681
3912
|
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3913
|
+
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3687
3919
|
var Scorm2004API = (function (_super) {
|
|
3688
3920
|
__extends(Scorm2004API, _super);
|
|
3689
3921
|
function Scorm2004API(settings) {
|
|
@@ -3693,7 +3925,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3693
3925
|
settings.mastery_override = false;
|
|
3694
3926
|
}
|
|
3695
3927
|
}
|
|
3696
|
-
_this = _super.call(this,
|
|
3928
|
+
_this = _super.call(this, error_codes.scorm2004, settings) || this;
|
|
3697
3929
|
_this._version = "1.0";
|
|
3698
3930
|
_this.cmi = new CMI();
|
|
3699
3931
|
_this.adl = new ADL();
|
|
@@ -3707,6 +3939,11 @@ var Scorm2004API = (function (_super) {
|
|
|
3707
3939
|
_this.GetDiagnostic = _this.lmsGetDiagnostic;
|
|
3708
3940
|
return _this;
|
|
3709
3941
|
}
|
|
3942
|
+
Scorm2004API.prototype.reset = function (settings) {
|
|
3943
|
+
this.commonReset(settings);
|
|
3944
|
+
this.cmi = new CMI();
|
|
3945
|
+
this.adl = new ADL();
|
|
3946
|
+
};
|
|
3710
3947
|
Object.defineProperty(Scorm2004API.prototype, "version", {
|
|
3711
3948
|
get: function () {
|
|
3712
3949
|
return this._version;
|
|
@@ -3719,47 +3956,92 @@ var Scorm2004API = (function (_super) {
|
|
|
3719
3956
|
return this.initialize("Initialize");
|
|
3720
3957
|
};
|
|
3721
3958
|
Scorm2004API.prototype.lmsFinish = function () {
|
|
3722
|
-
var
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
switch (
|
|
3726
|
-
case
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
this.processListeners("SequencePrevious");
|
|
3731
|
-
break;
|
|
3732
|
-
case "choice":
|
|
3733
|
-
this.processListeners("SequenceChoice");
|
|
3734
|
-
break;
|
|
3735
|
-
case "exit":
|
|
3736
|
-
this.processListeners("SequenceExit");
|
|
3737
|
-
break;
|
|
3738
|
-
case "exitAll":
|
|
3739
|
-
this.processListeners("SequenceExitAll");
|
|
3740
|
-
break;
|
|
3741
|
-
case "abandon":
|
|
3742
|
-
this.processListeners("SequenceAbandon");
|
|
3743
|
-
break;
|
|
3744
|
-
case "abandonAll":
|
|
3745
|
-
this.processListeners("SequenceAbandonAll");
|
|
3746
|
-
break;
|
|
3959
|
+
var _this = this;
|
|
3960
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3961
|
+
return __generator(this, function (_a) {
|
|
3962
|
+
switch (_a.label) {
|
|
3963
|
+
case 0: return [4, this.internalFinish()];
|
|
3964
|
+
case 1:
|
|
3965
|
+
_a.sent();
|
|
3966
|
+
return [2];
|
|
3747
3967
|
}
|
|
3748
|
-
}
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
return
|
|
3968
|
+
});
|
|
3969
|
+
}); })();
|
|
3970
|
+
return api_constants.global.SCORM_TRUE;
|
|
3971
|
+
};
|
|
3972
|
+
Scorm2004API.prototype.internalFinish = function () {
|
|
3973
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3974
|
+
var result, navActions, request, choiceJumpRegex, matches, target, action;
|
|
3975
|
+
return __generator(this, function (_a) {
|
|
3976
|
+
switch (_a.label) {
|
|
3977
|
+
case 0: return [4, this.terminate("Terminate", true)];
|
|
3978
|
+
case 1:
|
|
3979
|
+
result = _a.sent();
|
|
3980
|
+
if (result === api_constants.global.SCORM_TRUE) {
|
|
3981
|
+
if (this.adl.nav.request !== "_none_") {
|
|
3982
|
+
navActions = {
|
|
3983
|
+
continue: "SequenceNext",
|
|
3984
|
+
previous: "SequencePrevious",
|
|
3985
|
+
choice: "SequenceChoice",
|
|
3986
|
+
jump: "SequenceJump",
|
|
3987
|
+
exit: "SequenceExit",
|
|
3988
|
+
exitAll: "SequenceExitAll",
|
|
3989
|
+
abandon: "SequenceAbandon",
|
|
3990
|
+
abandonAll: "SequenceAbandonAll",
|
|
3991
|
+
};
|
|
3992
|
+
request = this.adl.nav.request;
|
|
3993
|
+
choiceJumpRegex = new RegExp(regex.scorm2004.NAVEvent);
|
|
3994
|
+
matches = request.match(choiceJumpRegex);
|
|
3995
|
+
target = "";
|
|
3996
|
+
if (matches && matches.length > 2) {
|
|
3997
|
+
target = matches[2];
|
|
3998
|
+
request = matches[1].replace(target, "");
|
|
3999
|
+
}
|
|
4000
|
+
action = navActions[request];
|
|
4001
|
+
if (action) {
|
|
4002
|
+
this.processListeners(action, "adl.nav.request", target);
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
else if (this.settings.autoProgress) {
|
|
4006
|
+
this.processListeners("SequenceNext");
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
return [2, result];
|
|
4010
|
+
}
|
|
4011
|
+
});
|
|
4012
|
+
});
|
|
3754
4013
|
};
|
|
3755
4014
|
Scorm2004API.prototype.lmsGetValue = function (CMIElement) {
|
|
4015
|
+
var adlNavRequestRegex = "^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=\\S{0,}([a-zA-Z0-9-_]+)}$";
|
|
4016
|
+
if (stringMatches(CMIElement, adlNavRequestRegex)) {
|
|
4017
|
+
var matches = CMIElement.match(adlNavRequestRegex);
|
|
4018
|
+
var request = matches[1];
|
|
4019
|
+
var target = matches[2].replace("{target=", "").replace("}", "");
|
|
4020
|
+
if (request === "choice" || request === "jump") {
|
|
4021
|
+
if (this.settings.scoItemIdValidator) {
|
|
4022
|
+
return String(this.settings.scoItemIdValidator(target));
|
|
4023
|
+
}
|
|
4024
|
+
return String(this.settings.scoItemIds.includes(target));
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
3756
4027
|
return this.getValue("GetValue", true, CMIElement);
|
|
3757
4028
|
};
|
|
3758
4029
|
Scorm2004API.prototype.lmsSetValue = function (CMIElement, value) {
|
|
3759
4030
|
return this.setValue("SetValue", "Commit", true, CMIElement, value);
|
|
3760
4031
|
};
|
|
3761
4032
|
Scorm2004API.prototype.lmsCommit = function () {
|
|
3762
|
-
|
|
4033
|
+
var _this = this;
|
|
4034
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4035
|
+
return __generator(this, function (_a) {
|
|
4036
|
+
switch (_a.label) {
|
|
4037
|
+
case 0: return [4, this.commit("Commit")];
|
|
4038
|
+
case 1:
|
|
4039
|
+
_a.sent();
|
|
4040
|
+
return [2];
|
|
4041
|
+
}
|
|
4042
|
+
});
|
|
4043
|
+
}); })();
|
|
4044
|
+
return api_constants.global.SCORM_TRUE;
|
|
3763
4045
|
};
|
|
3764
4046
|
Scorm2004API.prototype.lmsGetLastError = function () {
|
|
3765
4047
|
return this.getLastError("GetLastError");
|
|
@@ -3774,49 +4056,52 @@ var Scorm2004API = (function (_super) {
|
|
|
3774
4056
|
return this._commonSetCMIValue("SetValue", true, CMIElement, value);
|
|
3775
4057
|
};
|
|
3776
4058
|
Scorm2004API.prototype.getChildElement = function (CMIElement, value, foundFirstIndex) {
|
|
3777
|
-
if (
|
|
4059
|
+
if (stringMatches(CMIElement, "cmi\\.objectives\\.\\d+")) {
|
|
3778
4060
|
return new CMIObjectivesObject();
|
|
3779
4061
|
}
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
var index = Number(parts[2]);
|
|
3784
|
-
var interaction = this.cmi.interactions.childArray[index];
|
|
3785
|
-
if (this.isInitialized()) {
|
|
3786
|
-
if (!interaction.type) {
|
|
3787
|
-
this.throwSCORMError(Scorm2004API_scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
|
3788
|
-
}
|
|
3789
|
-
else {
|
|
3790
|
-
this.checkDuplicateChoiceResponse(interaction, value);
|
|
3791
|
-
var response_type = correct_responses[interaction.type];
|
|
3792
|
-
if (response_type) {
|
|
3793
|
-
this.checkValidResponseType(response_type, value, interaction.type);
|
|
3794
|
-
}
|
|
3795
|
-
else {
|
|
3796
|
-
this.throwSCORMError(Scorm2004API_scorm2004_error_codes.GENERAL_SET_FAILURE, "Incorrect Response Type: " + interaction.type);
|
|
3797
|
-
}
|
|
3798
|
-
}
|
|
4062
|
+
if (foundFirstIndex) {
|
|
4063
|
+
if (stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")) {
|
|
4064
|
+
return this.createCorrectResponsesObject(CMIElement, value);
|
|
3799
4065
|
}
|
|
3800
|
-
if (
|
|
3801
|
-
return new
|
|
4066
|
+
else if (stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
|
|
4067
|
+
return new CMIInteractionsObjectivesObject();
|
|
3802
4068
|
}
|
|
3803
4069
|
}
|
|
3804
|
-
else if (
|
|
3805
|
-
this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")) {
|
|
3806
|
-
return new CMIInteractionsObjectivesObject();
|
|
3807
|
-
}
|
|
3808
|
-
else if (!foundFirstIndex &&
|
|
3809
|
-
this.stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
|
|
4070
|
+
else if (stringMatches(CMIElement, "cmi\\.interactions\\.\\d+")) {
|
|
3810
4071
|
return new CMIInteractionsObject();
|
|
3811
4072
|
}
|
|
3812
|
-
|
|
4073
|
+
if (stringMatches(CMIElement, "cmi\\.comments_from_learner\\.\\d+")) {
|
|
3813
4074
|
return new CMICommentsObject();
|
|
3814
4075
|
}
|
|
3815
|
-
else if (
|
|
4076
|
+
else if (stringMatches(CMIElement, "cmi\\.comments_from_lms\\.\\d+")) {
|
|
3816
4077
|
return new CMICommentsObject(true);
|
|
3817
4078
|
}
|
|
3818
4079
|
return null;
|
|
3819
4080
|
};
|
|
4081
|
+
Scorm2004API.prototype.createCorrectResponsesObject = function (CMIElement, value) {
|
|
4082
|
+
var parts = CMIElement.split(".");
|
|
4083
|
+
var index = Number(parts[2]);
|
|
4084
|
+
var interaction = this.cmi.interactions.childArray[index];
|
|
4085
|
+
if (this.isInitialized()) {
|
|
4086
|
+
if (!interaction.type) {
|
|
4087
|
+
this.throwSCORMError(error_codes.scorm2004.DEPENDENCY_NOT_ESTABLISHED);
|
|
4088
|
+
}
|
|
4089
|
+
else {
|
|
4090
|
+
this.checkDuplicateChoiceResponse(interaction, value);
|
|
4091
|
+
var response_type = CorrectResponses[interaction.type];
|
|
4092
|
+
if (response_type) {
|
|
4093
|
+
this.checkValidResponseType(response_type, value, interaction.type);
|
|
4094
|
+
}
|
|
4095
|
+
else {
|
|
4096
|
+
this.throwSCORMError(error_codes.scorm2004.GENERAL_SET_FAILURE, "Incorrect Response Type: " + interaction.type);
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
if (this.lastErrorCode === "0") {
|
|
4101
|
+
return new CMIInteractionsCorrectResponsesObject();
|
|
4102
|
+
}
|
|
4103
|
+
return null;
|
|
4104
|
+
};
|
|
3820
4105
|
Scorm2004API.prototype.checkValidResponseType = function (response_type, value, interaction_type) {
|
|
3821
4106
|
var nodes = [];
|
|
3822
4107
|
if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter) {
|
|
@@ -3829,7 +4114,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3829
4114
|
this.checkCorrectResponseValue(interaction_type, nodes, value);
|
|
3830
4115
|
}
|
|
3831
4116
|
else if (nodes.length > response_type.max) {
|
|
3832
|
-
this.throwSCORMError(
|
|
4117
|
+
this.throwSCORMError(error_codes.scorm2004.GENERAL_SET_FAILURE, "Data Model Element Pattern Too Long");
|
|
3833
4118
|
}
|
|
3834
4119
|
};
|
|
3835
4120
|
Scorm2004API.prototype.checkDuplicateChoiceResponse = function (interaction, value) {
|
|
@@ -3838,7 +4123,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3838
4123
|
for (var i = 0; i < interaction_count && this.lastErrorCode === "0"; i++) {
|
|
3839
4124
|
var response = interaction.correct_responses.childArray[i];
|
|
3840
4125
|
if (response.pattern === value) {
|
|
3841
|
-
this.throwSCORMError(
|
|
4126
|
+
this.throwSCORMError(error_codes.scorm2004.GENERAL_SET_FAILURE);
|
|
3842
4127
|
}
|
|
3843
4128
|
}
|
|
3844
4129
|
}
|
|
@@ -3850,7 +4135,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3850
4135
|
var interaction = this.cmi.interactions.childArray[index];
|
|
3851
4136
|
var interaction_count = interaction.correct_responses._count;
|
|
3852
4137
|
this.checkDuplicateChoiceResponse(interaction, value);
|
|
3853
|
-
var response_type =
|
|
4138
|
+
var response_type = CorrectResponses[interaction.type];
|
|
3854
4139
|
if (typeof response_type.limit === "undefined" ||
|
|
3855
4140
|
interaction_count <= response_type.limit) {
|
|
3856
4141
|
this.checkValidResponseType(response_type, value, interaction.type);
|
|
@@ -3861,12 +4146,12 @@ var Scorm2004API = (function (_super) {
|
|
|
3861
4146
|
}
|
|
3862
4147
|
else {
|
|
3863
4148
|
if (this.lastErrorCode === "0") {
|
|
3864
|
-
this.throwSCORMError(
|
|
4149
|
+
this.throwSCORMError(error_codes.scorm2004.GENERAL_SET_FAILURE, "Data Model Element Pattern Already Exists");
|
|
3865
4150
|
}
|
|
3866
4151
|
}
|
|
3867
4152
|
}
|
|
3868
4153
|
else {
|
|
3869
|
-
this.throwSCORMError(
|
|
4154
|
+
this.throwSCORMError(error_codes.scorm2004.GENERAL_SET_FAILURE, "Data Model Element Collection Limit Reached");
|
|
3870
4155
|
}
|
|
3871
4156
|
};
|
|
3872
4157
|
Scorm2004API.prototype.getCMIValue = function (CMIElement) {
|
|
@@ -3876,11 +4161,11 @@ var Scorm2004API = (function (_super) {
|
|
|
3876
4161
|
var basicMessage = "";
|
|
3877
4162
|
var detailMessage = "";
|
|
3878
4163
|
errorNumber = String(errorNumber);
|
|
3879
|
-
if (
|
|
4164
|
+
if (api_constants.scorm2004.error_descriptions[errorNumber]) {
|
|
3880
4165
|
basicMessage =
|
|
3881
|
-
|
|
4166
|
+
api_constants.scorm2004.error_descriptions[errorNumber].basicMessage;
|
|
3882
4167
|
detailMessage =
|
|
3883
|
-
|
|
4168
|
+
api_constants.scorm2004.error_descriptions[errorNumber].detailMessage;
|
|
3884
4169
|
}
|
|
3885
4170
|
return detail ? detailMessage : basicMessage;
|
|
3886
4171
|
};
|
|
@@ -3895,7 +4180,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3895
4180
|
return found;
|
|
3896
4181
|
};
|
|
3897
4182
|
Scorm2004API.prototype.checkCorrectResponseValue = function (interaction_type, nodes, value) {
|
|
3898
|
-
var response =
|
|
4183
|
+
var response = CorrectResponses[interaction_type];
|
|
3899
4184
|
var formatRegex = new RegExp(response.format);
|
|
3900
4185
|
for (var i = 0; i < nodes.length && this.lastErrorCode === "0"; i++) {
|
|
3901
4186
|
if (interaction_type.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")) {
|
|
@@ -3906,36 +4191,36 @@ var Scorm2004API = (function (_super) {
|
|
|
3906
4191
|
if (values.length === 2) {
|
|
3907
4192
|
var matches = values[0].match(formatRegex);
|
|
3908
4193
|
if (!matches) {
|
|
3909
|
-
this.throwSCORMError(
|
|
4194
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3910
4195
|
}
|
|
3911
4196
|
else {
|
|
3912
4197
|
if (!response.format2 ||
|
|
3913
4198
|
!values[1].match(new RegExp(response.format2))) {
|
|
3914
|
-
this.throwSCORMError(
|
|
4199
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3915
4200
|
}
|
|
3916
4201
|
}
|
|
3917
4202
|
}
|
|
3918
4203
|
else {
|
|
3919
|
-
this.throwSCORMError(
|
|
4204
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3920
4205
|
}
|
|
3921
4206
|
}
|
|
3922
4207
|
else {
|
|
3923
4208
|
var matches = nodes[i].match(formatRegex);
|
|
3924
4209
|
if ((!matches && value !== "") ||
|
|
3925
4210
|
(!matches && interaction_type === "true-false")) {
|
|
3926
|
-
this.throwSCORMError(
|
|
4211
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3927
4212
|
}
|
|
3928
4213
|
else {
|
|
3929
4214
|
if (interaction_type === "numeric" && nodes.length > 1) {
|
|
3930
4215
|
if (Number(nodes[0]) > Number(nodes[1])) {
|
|
3931
|
-
this.throwSCORMError(
|
|
4216
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3932
4217
|
}
|
|
3933
4218
|
}
|
|
3934
4219
|
else {
|
|
3935
4220
|
if (nodes[i] !== "" && response.unique) {
|
|
3936
4221
|
for (var j = 0; j < i && this.lastErrorCode === "0"; j++) {
|
|
3937
4222
|
if (nodes[i] === nodes[j]) {
|
|
3938
|
-
this.throwSCORMError(
|
|
4223
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3939
4224
|
}
|
|
3940
4225
|
}
|
|
3941
4226
|
}
|
|
@@ -3954,12 +4239,12 @@ var Scorm2004API = (function (_super) {
|
|
|
3954
4239
|
while (matches) {
|
|
3955
4240
|
switch (matches[2]) {
|
|
3956
4241
|
case "lang":
|
|
3957
|
-
langMatches = node.match(
|
|
4242
|
+
langMatches = node.match(regex.scorm2004.CMILangcr);
|
|
3958
4243
|
if (langMatches) {
|
|
3959
4244
|
var lang = langMatches[3];
|
|
3960
4245
|
if (lang !== undefined && lang.length > 0) {
|
|
3961
4246
|
if (!language_constants.includes(lang.toLowerCase())) {
|
|
3962
|
-
this.throwSCORMError(
|
|
4247
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3963
4248
|
}
|
|
3964
4249
|
}
|
|
3965
4250
|
}
|
|
@@ -3968,7 +4253,7 @@ var Scorm2004API = (function (_super) {
|
|
|
3968
4253
|
case "case_matters":
|
|
3969
4254
|
if (!seenLang && !seenOrder && !seenCase) {
|
|
3970
4255
|
if (matches[3] !== "true" && matches[3] !== "false") {
|
|
3971
|
-
this.throwSCORMError(
|
|
4256
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3972
4257
|
}
|
|
3973
4258
|
}
|
|
3974
4259
|
seenCase = true;
|
|
@@ -3976,13 +4261,11 @@ var Scorm2004API = (function (_super) {
|
|
|
3976
4261
|
case "order_matters":
|
|
3977
4262
|
if (!seenCase && !seenLang && !seenOrder) {
|
|
3978
4263
|
if (matches[3] !== "true" && matches[3] !== "false") {
|
|
3979
|
-
this.throwSCORMError(
|
|
4264
|
+
this.throwSCORMError(error_codes.scorm2004.TYPE_MISMATCH);
|
|
3980
4265
|
}
|
|
3981
4266
|
}
|
|
3982
4267
|
seenOrder = true;
|
|
3983
4268
|
break;
|
|
3984
|
-
default:
|
|
3985
|
-
break;
|
|
3986
4269
|
}
|
|
3987
4270
|
node = node.substring(matches[1].length);
|
|
3988
4271
|
matches = node.match(prefixRegex);
|
|
@@ -4016,57 +4299,64 @@ var Scorm2004API = (function (_super) {
|
|
|
4016
4299
|
}
|
|
4017
4300
|
};
|
|
4018
4301
|
Scorm2004API.prototype.storeData = function (terminateCommit) {
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4302
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4303
|
+
var navRequest, commitObject, result;
|
|
4304
|
+
var _a, _b, _c;
|
|
4305
|
+
return __generator(this, function (_d) {
|
|
4306
|
+
switch (_d.label) {
|
|
4307
|
+
case 0:
|
|
4308
|
+
if (terminateCommit) {
|
|
4309
|
+
if (this.cmi.mode === "normal") {
|
|
4310
|
+
if (this.cmi.credit === "credit") {
|
|
4311
|
+
if (this.cmi.completion_threshold && this.cmi.progress_measure) {
|
|
4312
|
+
if (this.cmi.progress_measure >= this.cmi.completion_threshold) {
|
|
4313
|
+
this.cmi.completion_status = "completed";
|
|
4314
|
+
}
|
|
4315
|
+
else {
|
|
4316
|
+
this.cmi.completion_status = "incomplete";
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
if (this.cmi.scaled_passing_score && this.cmi.score.scaled) {
|
|
4320
|
+
if (this.cmi.score.scaled >= this.cmi.scaled_passing_score) {
|
|
4321
|
+
this.cmi.success_status = "passed";
|
|
4322
|
+
}
|
|
4323
|
+
else {
|
|
4324
|
+
this.cmi.success_status = "failed";
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4026
4329
|
}
|
|
4027
|
-
|
|
4028
|
-
|
|
4330
|
+
navRequest = false;
|
|
4331
|
+
if (this.adl.nav.request !== ((_c = (_b = (_a = this.startingData) === null || _a === void 0 ? void 0 : _a.adl) === null || _b === void 0 ? void 0 : _b.nav) === null || _c === void 0 ? void 0 : _c.request) &&
|
|
4332
|
+
this.adl.nav.request !== "_none_") {
|
|
4333
|
+
this.adl.nav.request = encodeURIComponent(this.adl.nav.request);
|
|
4334
|
+
navRequest = true;
|
|
4029
4335
|
}
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4336
|
+
commitObject = this.renderCommitCMI(terminateCommit || this.settings.alwaysSendTotalTime);
|
|
4337
|
+
if (this.apiLogLevel === api_constants.global.LOG_LEVEL_DEBUG) {
|
|
4338
|
+
console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
|
|
4339
|
+
console.debug(commitObject);
|
|
4034
4340
|
}
|
|
4035
|
-
|
|
4036
|
-
|
|
4341
|
+
if (!(typeof this.settings.lmsCommitUrl === "string")) return [3, 2];
|
|
4342
|
+
return [4, this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit)];
|
|
4343
|
+
case 1:
|
|
4344
|
+
result = _d.sent();
|
|
4345
|
+
{
|
|
4346
|
+
if (navRequest &&
|
|
4347
|
+
result.navRequest !== undefined &&
|
|
4348
|
+
result.navRequest !== "") {
|
|
4349
|
+
Function("\"use strict\";(() => { ".concat(result.navRequest, " })()"))();
|
|
4350
|
+
}
|
|
4037
4351
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
if (this.adl.nav.request !== ((_c = (_b = (_a = this.startingData) === null || _a === void 0 ? void 0 : _a.adl) === null || _b === void 0 ? void 0 : _b.nav) === null || _c === void 0 ? void 0 : _c.request) &&
|
|
4044
|
-
this.adl.nav.request !== "_none_") {
|
|
4045
|
-
this.adl.nav.request = encodeURIComponent(this.adl.nav.request);
|
|
4046
|
-
navRequest = true;
|
|
4047
|
-
}
|
|
4048
|
-
var commitObject = this.renderCommitCMI(terminateCommit || this.settings.alwaysSendTotalTime);
|
|
4049
|
-
if (this.apiLogLevel === Scorm2004API_global_constants.LOG_LEVEL_DEBUG) {
|
|
4050
|
-
console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
|
|
4051
|
-
console.debug(commitObject);
|
|
4052
|
-
}
|
|
4053
|
-
if (typeof this.settings.lmsCommitUrl === "string") {
|
|
4054
|
-
var result = this.processHttpRequest(this.settings.lmsCommitUrl, commitObject, terminateCommit);
|
|
4055
|
-
{
|
|
4056
|
-
if (navRequest &&
|
|
4057
|
-
result.navRequest !== undefined &&
|
|
4058
|
-
result.navRequest !== "") {
|
|
4059
|
-
Function("\"use strict\";(() => { ".concat(result.navRequest, " })()"))();
|
|
4352
|
+
return [2, result];
|
|
4353
|
+
case 2: return [2, {
|
|
4354
|
+
result: api_constants.global.SCORM_TRUE,
|
|
4355
|
+
errorCode: 0,
|
|
4356
|
+
}];
|
|
4060
4357
|
}
|
|
4061
|
-
}
|
|
4062
|
-
|
|
4063
|
-
}
|
|
4064
|
-
else {
|
|
4065
|
-
return {
|
|
4066
|
-
result: Scorm2004API_global_constants.SCORM_TRUE,
|
|
4067
|
-
errorCode: 0,
|
|
4068
|
-
};
|
|
4069
|
-
}
|
|
4358
|
+
});
|
|
4359
|
+
});
|
|
4070
4360
|
};
|
|
4071
4361
|
return Scorm2004API;
|
|
4072
4362
|
}(src_BaseAPI));
|