scorm-again 1.7.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/.babelrc +18 -7
  2. package/.github/dependabot.yml +5 -0
  3. package/.github/workflows/main.yml +79 -0
  4. package/.jsdoc.json +4 -5
  5. package/.mocharc.json +8 -0
  6. package/.run/Mocha Unit Tests.run.xml +5 -2
  7. package/CONTRIBUTING.md +1 -1
  8. package/README.md +14 -1
  9. package/dist/aicc.js +3661 -7170
  10. package/dist/aicc.js.map +1 -1
  11. package/dist/aicc.min.js +2 -40
  12. package/dist/aicc.min.js.map +1 -0
  13. package/dist/scorm-again.js +5671 -10695
  14. package/dist/scorm-again.js.map +1 -1
  15. package/dist/scorm-again.min.js +2 -52
  16. package/dist/scorm-again.min.js.map +1 -0
  17. package/dist/scorm12.js +2871 -5433
  18. package/dist/scorm12.js.map +1 -1
  19. package/dist/scorm12.min.js +2 -34
  20. package/dist/scorm12.min.js.map +1 -0
  21. package/dist/scorm2004.js +3868 -6797
  22. package/dist/scorm2004.js.map +1 -1
  23. package/dist/scorm2004.min.js +2 -40
  24. package/dist/scorm2004.min.js.map +1 -0
  25. package/eslint.config.js +21 -0
  26. package/package.json +72 -34
  27. package/results.json +34254 -0
  28. package/src/{AICC.js → AICC.ts} +27 -21
  29. package/src/BaseAPI.ts +1449 -0
  30. package/src/Scorm12API.ts +360 -0
  31. package/src/{Scorm2004API.js → Scorm2004API.ts} +245 -163
  32. package/src/cmi/aicc_cmi.ts +1248 -0
  33. package/src/cmi/common.ts +411 -0
  34. package/src/cmi/scorm12_cmi.ts +1426 -0
  35. package/src/cmi/scorm2004_cmi.ts +1874 -0
  36. package/src/constants/api_constants.ts +318 -0
  37. package/src/constants/error_codes.ts +88 -0
  38. package/src/constants/language_constants.ts +394 -0
  39. package/src/constants/regex.ts +97 -0
  40. package/src/constants/{response_constants.js → response_constants.ts} +67 -62
  41. package/src/exceptions.ts +133 -0
  42. package/src/exports/aicc.js +1 -1
  43. package/src/exports/scorm-again.js +3 -3
  44. package/src/exports/scorm12.js +1 -1
  45. package/src/exports/scorm2004.js +1 -1
  46. package/src/{utilities.js → utilities.ts} +114 -74
  47. package/tea.yaml +6 -0
  48. package/test/{AICC.spec.js → AICC.spec.ts} +70 -72
  49. package/test/Scorm12API.spec.ts +580 -0
  50. package/test/Scorm2004API.spec.ts +812 -0
  51. package/test/api_helpers.ts +176 -0
  52. package/test/cmi/{aicc_cmi.spec.js → aicc_cmi.spec.ts} +193 -209
  53. package/test/cmi/{scorm12_cmi.spec.js → scorm12_cmi.spec.ts} +251 -269
  54. package/test/cmi/scorm2004_cmi.spec.ts +1031 -0
  55. package/test/cmi_helpers.ts +207 -0
  56. package/test/exceptions.spec.ts +79 -0
  57. package/test/field_values.ts +202 -0
  58. package/test/utilities.spec.ts +322 -0
  59. package/tsconfig.json +18 -0
  60. package/webpack.config.js +65 -0
  61. package/.circleci/config.yml +0 -99
  62. package/.codeclimate.yml +0 -7
  63. package/.eslintrc.js +0 -36
  64. package/src/.flowconfig +0 -11
  65. package/src/BaseAPI.js +0 -1275
  66. package/src/Scorm12API.js +0 -308
  67. package/src/cmi/aicc_cmi.js +0 -1141
  68. package/src/cmi/common.js +0 -328
  69. package/src/cmi/scorm12_cmi.js +0 -1312
  70. package/src/cmi/scorm2004_cmi.js +0 -1692
  71. package/src/constants/api_constants.js +0 -218
  72. package/src/constants/error_codes.js +0 -87
  73. package/src/constants/language_constants.js +0 -76
  74. package/src/constants/regex.js +0 -84
  75. package/src/exceptions.js +0 -104
  76. package/test/Scorm12API.spec.js +0 -528
  77. package/test/Scorm2004API.spec.js +0 -775
  78. package/test/abstract_classes.spec.js +0 -17
  79. package/test/api_helpers.js +0 -128
  80. package/test/cmi/scorm2004_cmi.spec.js +0 -1066
  81. package/test/cmi_helpers.js +0 -161
  82. package/test/exceptions.spec.js +0 -71
  83. package/test/field_values.js +0 -353
  84. package/test/utilities.spec.js +0 -339
  85. package/webpack.js +0 -78
@@ -1,1141 +0,0 @@
1
- import * as Scorm12CMI from './scorm12_cmi';
2
- import {BaseCMI, checkValidFormat, CMIArray, CMIScore} from './common';
3
- import APIConstants from '../constants/api_constants';
4
- import Regex from '../constants/regex';
5
- import ErrorCodes from '../constants/error_codes';
6
- import {AICCValidationError} from '../exceptions';
7
-
8
- const aicc_constants = APIConstants.aicc;
9
- const aicc_regex = Regex.aicc;
10
- const aicc_error_codes = ErrorCodes.scorm12;
11
-
12
- /**
13
- * Helper method for throwing Read Only error
14
- */
15
- function throwReadOnlyError() {
16
- throw new AICCValidationError(aicc_error_codes.READ_ONLY_ELEMENT);
17
- }
18
-
19
- /**
20
- * Helper method, no reason to have to pass the same error codes every time
21
- * @param {*} value
22
- * @param {string} regexPattern
23
- * @param {boolean} allowEmptyString
24
- * @return {boolean}
25
- */
26
- function checkAICCValidFormat(
27
- value: String,
28
- regexPattern: String,
29
- allowEmptyString?: boolean) {
30
- return checkValidFormat(
31
- value,
32
- regexPattern,
33
- aicc_error_codes.TYPE_MISMATCH,
34
- AICCValidationError,
35
- allowEmptyString
36
- );
37
- }
38
-
39
- /**
40
- * CMI Class for AICC
41
- */
42
- export class CMI extends Scorm12CMI.CMI {
43
- /**
44
- * Constructor for AICC CMI object
45
- * @param {boolean} initialized
46
- */
47
- constructor(initialized: boolean) {
48
- super(aicc_constants.cmi_children);
49
-
50
- if (initialized) this.initialize();
51
-
52
- this.student_preference = new AICCStudentPreferences();
53
- this.student_data = new AICCCMIStudentData();
54
- this.student_demographics = new CMIStudentDemographics();
55
- this.evaluation = new CMIEvaluation();
56
- this.paths = new CMIPaths();
57
- }
58
-
59
- /**
60
- * Called when the API has been initialized after the CMI has been created
61
- */
62
- initialize() {
63
- super.initialize();
64
- this.student_preference?.initialize();
65
- this.student_data?.initialize();
66
- this.student_demographics?.initialize();
67
- this.evaluation?.initialize();
68
- this.paths?.initialize();
69
- }
70
-
71
- /**
72
- * toJSON for cmi
73
- *
74
- * @return {
75
- * {
76
- * suspend_data: string,
77
- * launch_data: string,
78
- * comments: string,
79
- * comments_from_lms: string,
80
- * core: CMICore,
81
- * objectives: CMIObjectives,
82
- * student_data: CMIStudentData,
83
- * student_preference: CMIStudentPreference,
84
- * interactions: CMIInteractions,
85
- * paths: CMIPaths
86
- * }
87
- * }
88
- */
89
- toJSON() {
90
- this.jsonString = true;
91
- const result = {
92
- 'suspend_data': this.suspend_data,
93
- 'launch_data': this.launch_data,
94
- 'comments': this.comments,
95
- 'comments_from_lms': this.comments_from_lms,
96
- 'core': this.core,
97
- 'objectives': this.objectives,
98
- 'student_data': this.student_data,
99
- 'student_preference': this.student_preference,
100
- 'student_demographics': this.student_demographics,
101
- 'interactions': this.interactions,
102
- 'evaluation': this.evaluation,
103
- 'paths': this.paths,
104
- };
105
- delete this.jsonString;
106
- return result;
107
- }
108
- }
109
-
110
- /**
111
- * AICC Evaluation object
112
- */
113
- class CMIEvaluation extends BaseCMI {
114
- /**
115
- * Constructor for AICC Evaluation object
116
- */
117
- constructor() {
118
- super();
119
-
120
- this.comments = new CMIEvaluationComments();
121
- }
122
-
123
- /**
124
- * Called when the API has been initialized after the CMI has been created
125
- */
126
- initialize() {
127
- super.initialize();
128
- this.comments?.initialize();
129
- }
130
-
131
- /**
132
- * toJSON for cmi.evaluation object
133
- * @return {{comments: CMIEvaluationComments}}
134
- */
135
- toJSON() {
136
- this.jsonString = true;
137
- const result = {
138
- 'comments': this.comments,
139
- };
140
- delete this.jsonString;
141
- return result;
142
- }
143
- }
144
-
145
- /**
146
- * Class representing AICC's cmi.evaluation.comments object
147
- */
148
- class CMIEvaluationComments extends CMIArray {
149
- /**
150
- * Constructor for AICC Evaluation Comments object
151
- */
152
- constructor() {
153
- super({
154
- children: aicc_constants.comments_children,
155
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
156
- errorClass: AICCValidationError,
157
- });
158
- }
159
- }
160
-
161
- /**
162
- * StudentPreferences class for AICC
163
- */
164
- class AICCStudentPreferences extends Scorm12CMI.CMIStudentPreference {
165
- /**
166
- * Constructor for AICC Student Preferences object
167
- */
168
- constructor() {
169
- super(aicc_constants.student_preference_children);
170
-
171
- this.windows = new CMIArray({
172
- errorCode: aicc_error_codes.INVALID_SET_VALUE,
173
- errorClass: AICCValidationError,
174
- children: '',
175
- });
176
- }
177
-
178
- /**
179
- * Called when the API has been initialized after the CMI has been created
180
- */
181
- initialize() {
182
- super.initialize();
183
- this.windows?.initialize();
184
- }
185
-
186
- #lesson_type = '';
187
- #text_color = '';
188
- #text_location = '';
189
- #text_size = '';
190
- #video = '';
191
-
192
- /**
193
- * Getter for #lesson_type
194
- * @return {string}
195
- */
196
- get lesson_type(): string {
197
- return this.#lesson_type;
198
- }
199
-
200
- /**
201
- * Setter for #lesson_type
202
- * @param {string} lesson_type
203
- */
204
- set lesson_type(lesson_type: string) {
205
- if (checkAICCValidFormat(lesson_type, aicc_regex.CMIString256)) {
206
- this.#lesson_type = lesson_type;
207
- }
208
- }
209
-
210
- /**
211
- * Getter for #text_color
212
- * @return {string}
213
- */
214
- get text_color(): string {
215
- return this.#text_color;
216
- }
217
-
218
- /**
219
- * Setter for #text_color
220
- * @param {string} text_color
221
- */
222
- set text_color(text_color: string) {
223
- if (checkAICCValidFormat(text_color, aicc_regex.CMIString256)) {
224
- this.#text_color = text_color;
225
- }
226
- }
227
-
228
- /**
229
- * Getter for #text_location
230
- * @return {string}
231
- */
232
- get text_location(): string {
233
- return this.#text_location;
234
- }
235
-
236
- /**
237
- * Setter for #text_location
238
- * @param {string} text_location
239
- */
240
- set text_location(text_location: string) {
241
- if (checkAICCValidFormat(text_location, aicc_regex.CMIString256)) {
242
- this.#text_location = text_location;
243
- }
244
- }
245
-
246
- /**
247
- * Getter for #text_size
248
- * @return {string}
249
- */
250
- get text_size(): string {
251
- return this.#text_size;
252
- }
253
-
254
- /**
255
- * Setter for #text_size
256
- * @param {string} text_size
257
- */
258
- set text_size(text_size: string) {
259
- if (checkAICCValidFormat(text_size, aicc_regex.CMIString256)) {
260
- this.#text_size = text_size;
261
- }
262
- }
263
-
264
- /**
265
- * Getter for #video
266
- * @return {string}
267
- */
268
- get video(): string {
269
- return this.#video;
270
- }
271
-
272
- /**
273
- * Setter for #video
274
- * @param {string} video
275
- */
276
- set video(video: string) {
277
- if (checkAICCValidFormat(video, aicc_regex.CMIString256)) {
278
- this.#video = video;
279
- }
280
- }
281
-
282
- /**
283
- * toJSON for cmi.student_preference
284
- *
285
- * @return {
286
- * {
287
- * audio: string,
288
- * language: string,
289
- * speed: string,
290
- * text: string
291
- * }
292
- * }
293
- */
294
- toJSON() {
295
- this.jsonString = true;
296
- const result = {
297
- 'audio': this.audio,
298
- 'language': this.language,
299
- 'lesson_type': this.lesson_type,
300
- 'speed': this.speed,
301
- 'text': this.text,
302
- 'text_color': this.text_color,
303
- 'text_location': this.text_location,
304
- 'text_size': this.text_size,
305
- 'video': this.video,
306
- 'windows': this.windows,
307
- };
308
- delete this.jsonString;
309
- return result;
310
- }
311
- }
312
-
313
- /**
314
- * StudentData class for AICC
315
- */
316
- class AICCCMIStudentData extends Scorm12CMI.CMIStudentData {
317
- /**
318
- * Constructor for AICC StudentData object
319
- */
320
- constructor() {
321
- super(aicc_constants.student_data_children);
322
-
323
- this.tries = new CMITries();
324
- }
325
-
326
- /**
327
- * Called when the API has been initialized after the CMI has been created
328
- */
329
- initialize() {
330
- super.initialize();
331
- this.tries?.initialize();
332
- }
333
-
334
- #tries_during_lesson = '';
335
-
336
- /**
337
- * Getter for tries_during_lesson
338
- * @return {string}
339
- */
340
- get tries_during_lesson() {
341
- return this.#tries_during_lesson;
342
- }
343
-
344
- /**
345
- * Setter for #tries_during_lesson. Sets an error if trying to set after
346
- * initialization.
347
- * @param {string} tries_during_lesson
348
- */
349
- set tries_during_lesson(tries_during_lesson) {
350
- !this.initialized ?
351
- this.#tries_during_lesson = tries_during_lesson :
352
- throwReadOnlyError();
353
- }
354
-
355
- /**
356
- * toJSON for cmi.student_data object
357
- * @return {
358
- * {
359
- * mastery_score: string,
360
- * max_time_allowed: string,
361
- * time_limit_action: string,
362
- * tries: CMITries
363
- * }
364
- * }
365
- */
366
- toJSON() {
367
- this.jsonString = true;
368
- const result = {
369
- 'mastery_score': this.mastery_score,
370
- 'max_time_allowed': this.max_time_allowed,
371
- 'time_limit_action': this.time_limit_action,
372
- 'tries': this.tries,
373
- };
374
- delete this.jsonString;
375
- return result;
376
- }
377
- }
378
-
379
- /**
380
- * Class representing the AICC cmi.student_demographics object
381
- */
382
- export class CMIStudentDemographics extends BaseCMI {
383
- /**
384
- * Constructor for AICC StudentDemographics object
385
- */
386
- constructor() {
387
- super();
388
- }
389
-
390
- #_children = aicc_constants.student_demographics_children;
391
- #city = '';
392
- #class = '';
393
- #company = '';
394
- #country = '';
395
- #experience = '';
396
- #familiar_name = '';
397
- #instructor_name = '';
398
- #title = '';
399
- #native_language = '';
400
- #state = '';
401
- #street_address = '';
402
- #telephone = '';
403
- #years_experience = '';
404
-
405
- /**
406
- * Getter for _children
407
- * @return {string}
408
- */
409
- get _children() {
410
- return this.#_children;
411
- }
412
-
413
- /**
414
- * Getter for city
415
- * @return {string}
416
- */
417
- get city() {
418
- return this.#city;
419
- }
420
-
421
- /**
422
- * Setter for #city. Sets an error if trying to set after
423
- * initialization.
424
- * @param {string} city
425
- */
426
- set city(city) {
427
- !this.initialized ?
428
- this.#city = city :
429
- throwReadOnlyError();
430
- }
431
-
432
- /**
433
- * Getter for class
434
- * @return {string}
435
- */
436
- get class() {
437
- return this.#class;
438
- }
439
-
440
- /**
441
- * Setter for #class. Sets an error if trying to set after
442
- * initialization.
443
- * @param {string} clazz
444
- */
445
- set class(clazz) {
446
- !this.initialized ?
447
- this.#class = clazz :
448
- throwReadOnlyError();
449
- }
450
-
451
- /**
452
- * Getter for company
453
- * @return {string}
454
- */
455
- get company() {
456
- return this.#company;
457
- }
458
-
459
- /**
460
- * Setter for #company. Sets an error if trying to set after
461
- * initialization.
462
- * @param {string} company
463
- */
464
- set company(company) {
465
- !this.initialized ?
466
- this.#company = company :
467
- throwReadOnlyError();
468
- }
469
-
470
- /**
471
- * Getter for country
472
- * @return {string}
473
- */
474
- get country() {
475
- return this.#country;
476
- }
477
-
478
- /**
479
- * Setter for #country. Sets an error if trying to set after
480
- * initialization.
481
- * @param {string} country
482
- */
483
- set country(country) {
484
- !this.initialized ?
485
- this.#country = country :
486
- throwReadOnlyError();
487
- }
488
-
489
- /**
490
- * Getter for experience
491
- * @return {string}
492
- */
493
- get experience() {
494
- return this.#experience;
495
- }
496
-
497
- /**
498
- * Setter for #experience. Sets an error if trying to set after
499
- * initialization.
500
- * @param {string} experience
501
- */
502
- set experience(experience) {
503
- !this.initialized ?
504
- this.#experience = experience :
505
- throwReadOnlyError();
506
- }
507
-
508
- /**
509
- * Getter for familiar_name
510
- * @return {string}
511
- */
512
- get familiar_name() {
513
- return this.#familiar_name;
514
- }
515
-
516
- /**
517
- * Setter for #familiar_name. Sets an error if trying to set after
518
- * initialization.
519
- * @param {string} familiar_name
520
- */
521
- set familiar_name(familiar_name) {
522
- !this.initialized ?
523
- this.#familiar_name = familiar_name :
524
- throwReadOnlyError();
525
- }
526
-
527
- /**
528
- * Getter for instructor_name
529
- * @return {string}
530
- */
531
- get instructor_name() {
532
- return this.#instructor_name;
533
- }
534
-
535
- /**
536
- * Setter for #instructor_name. Sets an error if trying to set after
537
- * initialization.
538
- * @param {string} instructor_name
539
- */
540
- set instructor_name(instructor_name) {
541
- !this.initialized ?
542
- this.#instructor_name = instructor_name :
543
- throwReadOnlyError();
544
- }
545
-
546
- /**
547
- * Getter for title
548
- * @return {string}
549
- */
550
- get title() {
551
- return this.#title;
552
- }
553
-
554
- /**
555
- * Setter for #title. Sets an error if trying to set after
556
- * initialization.
557
- * @param {string} title
558
- */
559
- set title(title) {
560
- !this.initialized ?
561
- this.#title = title :
562
- throwReadOnlyError();
563
- }
564
-
565
- /**
566
- * Getter for native_language
567
- * @return {string}
568
- */
569
- get native_language() {
570
- return this.#native_language;
571
- }
572
-
573
- /**
574
- * Setter for #native_language. Sets an error if trying to set after
575
- * initialization.
576
- * @param {string} native_language
577
- */
578
- set native_language(native_language) {
579
- !this.initialized ?
580
- this.#native_language = native_language :
581
- throwReadOnlyError();
582
- }
583
-
584
- /**
585
- * Getter for state
586
- * @return {string}
587
- */
588
- get state() {
589
- return this.#state;
590
- }
591
-
592
- /**
593
- * Setter for #state. Sets an error if trying to set after
594
- * initialization.
595
- * @param {string} state
596
- */
597
- set state(state) {
598
- !this.initialized ?
599
- this.#state = state :
600
- throwReadOnlyError();
601
- }
602
-
603
- /**
604
- * Getter for street_address
605
- * @return {string}
606
- */
607
- get street_address() {
608
- return this.#street_address;
609
- }
610
-
611
- /**
612
- * Setter for #street_address. Sets an error if trying to set after
613
- * initialization.
614
- * @param {string} street_address
615
- */
616
- set street_address(street_address) {
617
- !this.initialized ?
618
- this.#street_address = street_address :
619
- throwReadOnlyError();
620
- }
621
-
622
- /**
623
- * Getter for telephone
624
- * @return {string}
625
- */
626
- get telephone() {
627
- return this.#telephone;
628
- }
629
-
630
- /**
631
- * Setter for #telephone. Sets an error if trying to set after
632
- * initialization.
633
- * @param {string} telephone
634
- */
635
- set telephone(telephone) {
636
- !this.initialized ?
637
- this.#telephone = telephone :
638
- throwReadOnlyError();
639
- }
640
-
641
- /**
642
- * Getter for years_experience
643
- * @return {string}
644
- */
645
- get years_experience() {
646
- return this.#years_experience;
647
- }
648
-
649
- /**
650
- * Setter for #years_experience. Sets an error if trying to set after
651
- * initialization.
652
- * @param {string} years_experience
653
- */
654
- set years_experience(years_experience) {
655
- !this.initialized ?
656
- this.#years_experience = years_experience :
657
- throwReadOnlyError();
658
- }
659
-
660
- /**
661
- * toJSON for cmi.student_demographics object
662
- * @return {
663
- * {
664
- * city: string,
665
- * class: string,
666
- * company: string,
667
- * country: string,
668
- * experience: string,
669
- * familiar_name: string,
670
- * instructor_name: string,
671
- * title: string,
672
- * native_language: string,
673
- * state: string,
674
- * street_address: string,
675
- * telephone: string,
676
- * years_experience: string
677
- * }
678
- * }
679
- */
680
- toJSON() {
681
- this.jsonString = true;
682
- const result = {
683
- 'city': this.city,
684
- 'class': this.class,
685
- 'company': this.company,
686
- 'country': this.country,
687
- 'experience': this.experience,
688
- 'familiar_name': this.familiar_name,
689
- 'instructor_name': this.instructor_name,
690
- 'title': this.title,
691
- 'native_language': this.native_language,
692
- 'state': this.state,
693
- 'street_address': this.street_address,
694
- 'telephone': this.telephone,
695
- 'years_experience': this.years_experience,
696
- };
697
- delete this.jsonString;
698
- return result;
699
- }
700
- }
701
-
702
- /**
703
- * Class representing the AICC cmi.paths object
704
- */
705
- export class CMIPaths extends CMIArray {
706
- /**
707
- * Constructor for inline Paths Array class
708
- */
709
- constructor() {
710
- super({children: aicc_constants.paths_children});
711
- }
712
- }
713
-
714
- /**
715
- * Class for AICC Paths
716
- */
717
- export class CMIPathsObject extends BaseCMI {
718
- /**
719
- * Constructor for AICC Paths objects
720
- */
721
- constructor() {
722
- super();
723
- }
724
-
725
- #location_id = '';
726
- #date = '';
727
- #time = '';
728
- #status = '';
729
- #why_left = '';
730
- #time_in_element = '';
731
-
732
- /**
733
- * Getter for #location_id
734
- * @return {string}
735
- */
736
- get location_id() {
737
- return this.#location_id;
738
- }
739
-
740
- /**
741
- * Setter for #location_id
742
- * @param {string} location_id
743
- */
744
- set location_id(location_id) {
745
- if (checkAICCValidFormat(location_id, aicc_regex.CMIString256)) {
746
- this.#location_id = location_id;
747
- }
748
- }
749
-
750
- /**
751
- * Getter for #date
752
- * @return {string}
753
- */
754
- get date() {
755
- return this.#date;
756
- }
757
-
758
- /**
759
- * Setter for #date
760
- * @param {string} date
761
- */
762
- set date(date) {
763
- if (checkAICCValidFormat(date, aicc_regex.CMIString256)) {
764
- this.#date = date;
765
- }
766
- }
767
-
768
- /**
769
- * Getter for #time
770
- * @return {string}
771
- */
772
- get time() {
773
- return this.#time;
774
- }
775
-
776
- /**
777
- * Setter for #time
778
- * @param {string} time
779
- */
780
- set time(time) {
781
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
782
- this.#time = time;
783
- }
784
- }
785
-
786
- /**
787
- * Getter for #status
788
- * @return {string}
789
- */
790
- get status() {
791
- return this.#status;
792
- }
793
-
794
- /**
795
- * Setter for #status
796
- * @param {string} status
797
- */
798
- set status(status) {
799
- if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
800
- this.#status = status;
801
- }
802
- }
803
-
804
- /**
805
- * Getter for #why_left
806
- * @return {string}
807
- */
808
- get why_left() {
809
- return this.#why_left;
810
- }
811
-
812
- /**
813
- * Setter for #why_left
814
- * @param {string} why_left
815
- */
816
- set why_left(why_left) {
817
- if (checkAICCValidFormat(why_left, aicc_regex.CMIString256)) {
818
- this.#why_left = why_left;
819
- }
820
- }
821
-
822
- /**
823
- * Getter for #time_in_element
824
- * @return {string}
825
- */
826
- get time_in_element() {
827
- return this.#time_in_element;
828
- }
829
-
830
- /**
831
- * Setter for #time_in_element
832
- * @param {string} time_in_element
833
- */
834
- set time_in_element(time_in_element) {
835
- if (checkAICCValidFormat(time_in_element, aicc_regex.CMITime)) {
836
- this.#time_in_element = time_in_element;
837
- }
838
- }
839
-
840
- /**
841
- * toJSON for cmi.paths.n object
842
- * @return {
843
- * {
844
- * location_id: string,
845
- * date: string,
846
- * time: string,
847
- * status: string,
848
- * why_left: string,
849
- * time_in_element: string
850
- * }
851
- * }
852
- */
853
- toJSON() {
854
- this.jsonString = true;
855
- const result = {
856
- 'location_id': this.location_id,
857
- 'date': this.date,
858
- 'time': this.time,
859
- 'status': this.status,
860
- 'why_left': this.why_left,
861
- 'time_in_element': this.time_in_element,
862
- };
863
- delete this.jsonString;
864
- return result;
865
- }
866
- }
867
-
868
- /**
869
- * Class representing the AICC cmi.student_data.tries object
870
- */
871
- export class CMITries extends CMIArray {
872
- /**
873
- * Constructor for inline Tries Array class
874
- */
875
- constructor() {
876
- super({children: aicc_constants.tries_children});
877
- }
878
- }
879
-
880
- /**
881
- * Class for AICC Tries
882
- */
883
- export class CMITriesObject extends BaseCMI {
884
- /**
885
- * Constructor for AICC Tries object
886
- */
887
- constructor() {
888
- super();
889
-
890
- this.score = new CMIScore(
891
- {
892
- score_children: aicc_constants.score_children,
893
- score_range: aicc_regex.score_range,
894
- invalidErrorCode: aicc_error_codes.INVALID_SET_VALUE,
895
- invalidTypeCode: aicc_error_codes.TYPE_MISMATCH,
896
- invalidRangeCode: aicc_error_codes.VALUE_OUT_OF_RANGE,
897
- errorClass: AICCValidationError,
898
- });
899
- }
900
-
901
- /**
902
- * Called when the API has been initialized after the CMI has been created
903
- */
904
- initialize() {
905
- super.initialize();
906
- this.score?.initialize();
907
- }
908
-
909
- #status = '';
910
- #time = '';
911
-
912
- /**
913
- * Getter for #status
914
- * @return {string}
915
- */
916
- get status() {
917
- return this.#status;
918
- }
919
-
920
- /**
921
- * Setter for #status
922
- * @param {string} status
923
- */
924
- set status(status) {
925
- if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
926
- this.#status = status;
927
- }
928
- }
929
-
930
- /**
931
- * Getter for #time
932
- * @return {string}
933
- */
934
- get time() {
935
- return this.#time;
936
- }
937
-
938
- /**
939
- * Setter for #time
940
- * @param {string} time
941
- */
942
- set time(time) {
943
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
944
- this.#time = time;
945
- }
946
- }
947
-
948
- /**
949
- * toJSON for cmi.student_data.tries.n object
950
- * @return {
951
- * {
952
- * status: string,
953
- * time: string,
954
- * score: CMIScore
955
- * }
956
- * }
957
- */
958
- toJSON() {
959
- this.jsonString = true;
960
- const result = {
961
- 'status': this.status,
962
- 'time': this.time,
963
- 'score': this.score,
964
- };
965
- delete this.jsonString;
966
- return result;
967
- }
968
- }
969
-
970
- /**
971
- * Class for cmi.student_data.attempt_records array
972
- */
973
- export class CMIAttemptRecords extends CMIArray {
974
- /**
975
- * Constructor for inline Tries Array class
976
- */
977
- constructor() {
978
- super({children: aicc_constants.attempt_records_children});
979
- }
980
- }
981
-
982
- /**
983
- * Class for AICC Attempt Records
984
- */
985
- export class CMIAttemptRecordsObject extends BaseCMI {
986
- /**
987
- * Constructor for AICC Attempt Records object
988
- */
989
- constructor() {
990
- super();
991
-
992
- this.score = new CMIScore(
993
- {
994
- score_children: aicc_constants.score_children,
995
- score_range: aicc_regex.score_range,
996
- invalidErrorCode: aicc_error_codes.INVALID_SET_VALUE,
997
- invalidTypeCode: aicc_error_codes.TYPE_MISMATCH,
998
- invalidRangeCode: aicc_error_codes.VALUE_OUT_OF_RANGE,
999
- errorClass: AICCValidationError,
1000
- });
1001
- }
1002
-
1003
- /**
1004
- * Called when the API has been initialized after the CMI has been created
1005
- */
1006
- initialize() {
1007
- super.initialize();
1008
- this.score?.initialize();
1009
- }
1010
-
1011
- #lesson_status = '';
1012
-
1013
- /**
1014
- * Getter for #lesson_status
1015
- * @return {string}
1016
- */
1017
- get lesson_status() {
1018
- return this.#lesson_status;
1019
- }
1020
-
1021
- /**
1022
- * Setter for #lesson_status
1023
- * @param {string} lesson_status
1024
- */
1025
- set lesson_status(lesson_status) {
1026
- if (checkAICCValidFormat(lesson_status, aicc_regex.CMIStatus2)) {
1027
- this.#lesson_status = lesson_status;
1028
- }
1029
- }
1030
-
1031
- /**
1032
- * toJSON for cmi.student_data.attempt_records.n object
1033
- * @return {
1034
- * {
1035
- * status: string,
1036
- * time: string,
1037
- * score: CMIScore
1038
- * }
1039
- * }
1040
- */
1041
- toJSON() {
1042
- this.jsonString = true;
1043
- const result = {
1044
- 'lesson_status': this.lesson_status,
1045
- 'score': this.score,
1046
- };
1047
- delete this.jsonString;
1048
- return result;
1049
- }
1050
- }
1051
-
1052
- /**
1053
- * Class for AICC Evaluation Comments
1054
- */
1055
- export class CMIEvaluationCommentsObject extends BaseCMI {
1056
- /**
1057
- * Constructor for Evaluation Comments
1058
- */
1059
- constructor() {
1060
- super();
1061
- }
1062
-
1063
- #content = '';
1064
- #location = '';
1065
- #time = '';
1066
-
1067
- /**
1068
- * Getter for #content
1069
- * @return {string}
1070
- */
1071
- get content() {
1072
- return this.#content;
1073
- }
1074
-
1075
- /**
1076
- * Setter for #content
1077
- * @param {string} content
1078
- */
1079
- set content(content) {
1080
- if (checkAICCValidFormat(content, aicc_regex.CMIString256)) {
1081
- this.#content = content;
1082
- }
1083
- }
1084
-
1085
- /**
1086
- * Getter for #location
1087
- * @return {string}
1088
- */
1089
- get location() {
1090
- return this.#location;
1091
- }
1092
-
1093
- /**
1094
- * Setter for #location
1095
- * @param {string} location
1096
- */
1097
- set location(location) {
1098
- if (checkAICCValidFormat(location, aicc_regex.CMIString256)) {
1099
- this.#location = location;
1100
- }
1101
- }
1102
-
1103
- /**
1104
- * Getter for #time
1105
- * @return {string}
1106
- */
1107
- get time() {
1108
- return this.#time;
1109
- }
1110
-
1111
- /**
1112
- * Setting for #time
1113
- * @param {string} time
1114
- */
1115
- set time(time) {
1116
- if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
1117
- this.#time = time;
1118
- }
1119
- }
1120
-
1121
- /**
1122
- * toJSON for cmi.evaulation.comments.n object
1123
- * @return {
1124
- * {
1125
- * content: string,
1126
- * location: string,
1127
- * time: string
1128
- * }
1129
- * }
1130
- */
1131
- toJSON() {
1132
- this.jsonString = true;
1133
- const result = {
1134
- 'content': this.content,
1135
- 'location': this.location,
1136
- 'time': this.time,
1137
- };
1138
- delete this.jsonString;
1139
- return result;
1140
- }
1141
- }