scorm-again 1.7.0 → 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 +73 -35
  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,1692 +0,0 @@
1
- // @flow
2
- import {
3
- BaseCMI,
4
- checkValidFormat,
5
- checkValidRange,
6
- CMIArray,
7
- CMIScore,
8
- } from './common';
9
- import APIConstants from '../constants/api_constants';
10
- import Regex from '../constants/regex';
11
- import ErrorCodes from '../constants/error_codes';
12
- import Responses from '../constants/response_constants';
13
- import {Scorm2004ValidationError} from '../exceptions';
14
- import * as Util from '../utilities';
15
-
16
- const scorm2004_constants = APIConstants.scorm2004;
17
- const scorm2004_error_codes = ErrorCodes.scorm2004;
18
- const learner_responses = Responses.learner;
19
-
20
- const scorm2004_regex = Regex.scorm2004;
21
-
22
- /**
23
- * Helper method for throwing Read Only error
24
- */
25
- function throwReadOnlyError() {
26
- throw new Scorm2004ValidationError(scorm2004_error_codes.READ_ONLY_ELEMENT);
27
- }
28
-
29
- /**
30
- * Helper method for throwing Write Only error
31
- */
32
- function throwWriteOnlyError() {
33
- throw new Scorm2004ValidationError(scorm2004_error_codes.WRITE_ONLY_ELEMENT);
34
- }
35
-
36
- /**
37
- * Helper method for throwing Type Mismatch error
38
- */
39
- function throwTypeMismatchError() {
40
- throw new Scorm2004ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
41
- }
42
-
43
- /**
44
- * Helper method for throwing Dependency Not Established error
45
- */
46
- function throwDependencyNotEstablishedError() {
47
- throw new Scorm2004ValidationError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
48
- }
49
-
50
- /**
51
- * Helper method for throwing Dependency Not Established error
52
- */
53
- function throwGeneralSetError() {
54
- throw new Scorm2004ValidationError(scorm2004_error_codes.GENERAL_SET_FAILURE);
55
- }
56
-
57
- /**
58
- * Helper method, no reason to have to pass the same error codes every time
59
- * @param {*} value
60
- * @param {string} regexPattern
61
- * @param {boolean} allowEmptyString
62
- * @return {boolean}
63
- */
64
- function check2004ValidFormat(
65
- value: String,
66
- regexPattern: String,
67
- allowEmptyString?: boolean) {
68
- return checkValidFormat(
69
- value,
70
- regexPattern,
71
- scorm2004_error_codes.TYPE_MISMATCH,
72
- Scorm2004ValidationError,
73
- allowEmptyString,
74
- );
75
- }
76
-
77
- /**
78
- * Helper method, no reason to have to pass the same error codes every time
79
- * @param {*} value
80
- * @param {string} rangePattern
81
- * @return {boolean}
82
- */
83
- function check2004ValidRange(value: any, rangePattern: String) {
84
- return checkValidRange(
85
- value,
86
- rangePattern,
87
- scorm2004_error_codes.VALUE_OUT_OF_RANGE,
88
- Scorm2004ValidationError,
89
- );
90
- }
91
-
92
- /**
93
- * Class representing cmi object for SCORM 2004
94
- */
95
- export class CMI extends BaseCMI {
96
- /**
97
- * Constructor for the SCORM 2004 cmi object
98
- * @param {boolean} initialized
99
- */
100
- constructor(initialized: boolean) {
101
- super();
102
-
103
- this.learner_preference = new CMILearnerPreference();
104
- this.score = new Scorm2004CMIScore();
105
- this.comments_from_learner = new CMICommentsFromLearner();
106
- this.comments_from_lms = new CMICommentsFromLMS();
107
- this.interactions = new CMIInteractions();
108
- this.objectives = new CMIObjectives();
109
-
110
- if (initialized) this.initialize();
111
- }
112
-
113
- #_version = '1.0';
114
- #_children = scorm2004_constants.cmi_children;
115
- #completion_status = 'unknown';
116
- #completion_threshold = '';
117
- #credit = 'credit';
118
- #entry = '';
119
- #exit = '';
120
- #launch_data = '';
121
- #learner_id = '';
122
- #learner_name = '';
123
- #location = '';
124
- #max_time_allowed = '';
125
- #mode = 'normal';
126
- #progress_measure = '';
127
- #scaled_passing_score = '';
128
- #session_time = 'PT0H0M0S';
129
- #success_status = 'unknown';
130
- #suspend_data = '';
131
- #time_limit_action = 'continue,no message';
132
- #total_time = '';
133
-
134
- /**
135
- * Called when the API has been initialized after the CMI has been created
136
- */
137
- initialize() {
138
- super.initialize();
139
- this.learner_preference?.initialize();
140
- this.score?.initialize();
141
- this.comments_from_learner?.initialize();
142
- this.comments_from_lms?.initialize();
143
- this.interactions?.initialize();
144
- this.objectives?.initialize();
145
- }
146
-
147
- /**
148
- * Getter for #_version
149
- * @return {string}
150
- * @private
151
- */
152
- get _version() {
153
- return this.#_version;
154
- }
155
-
156
- /**
157
- * Setter for #_version. Just throws an error.
158
- * @param {string} _version
159
- * @private
160
- */
161
- set _version(_version) {
162
- throwReadOnlyError();
163
- }
164
-
165
- /**
166
- * Getter for #_children
167
- * @return {string}
168
- * @private
169
- */
170
- get _children() {
171
- return this.#_children;
172
- }
173
-
174
- /**
175
- * Setter for #_children. Just throws an error.
176
- * @param {number} _children
177
- * @private
178
- */
179
- set _children(_children) {
180
- throwReadOnlyError();
181
- }
182
-
183
- /**
184
- * Getter for #completion_status
185
- * @return {string}
186
- */
187
- get completion_status() {
188
- return this.#completion_status;
189
- }
190
-
191
- /**
192
- * Setter for #completion_status
193
- * @param {string} completion_status
194
- */
195
- set completion_status(completion_status) {
196
- if (check2004ValidFormat(completion_status, scorm2004_regex.CMICStatus)) {
197
- this.#completion_status = completion_status;
198
- }
199
- }
200
-
201
- /**
202
- * Getter for #completion_threshold
203
- * @return {string}
204
- */
205
- get completion_threshold() {
206
- return this.#completion_threshold;
207
- }
208
-
209
- /**
210
- * Setter for #completion_threshold. Can only be called before initialization.
211
- * @param {string} completion_threshold
212
- */
213
- set completion_threshold(completion_threshold) {
214
- !this.initialized ?
215
- this.#completion_threshold = completion_threshold :
216
- throwReadOnlyError();
217
- }
218
-
219
- /**
220
- * Setter for #credit
221
- * @return {string}
222
- */
223
- get credit() {
224
- return this.#credit;
225
- }
226
-
227
- /**
228
- * Setter for #credit. Can only be called before initialization.
229
- * @param {string} credit
230
- */
231
- set credit(credit) {
232
- !this.initialized ? this.#credit = credit : throwReadOnlyError();
233
- }
234
-
235
- /**
236
- * Getter for #entry
237
- * @return {string}
238
- */
239
- get entry() {
240
- return this.#entry;
241
- }
242
-
243
- /**
244
- * Setter for #entry. Can only be called before initialization.
245
- * @param {string} entry
246
- */
247
- set entry(entry) {
248
- !this.initialized ? this.#entry = entry : throwReadOnlyError();
249
- }
250
-
251
- /**
252
- * Getter for #exit. Should only be called during JSON export.
253
- * @return {string}
254
- */
255
- get exit() {
256
- return (!this.jsonString) ? throwWriteOnlyError() : this.#exit;
257
- }
258
-
259
- /**
260
- * Getter for #exit
261
- * @param {string} exit
262
- */
263
- set exit(exit) {
264
- if (check2004ValidFormat(exit, scorm2004_regex.CMIExit, true)) {
265
- this.#exit = exit;
266
- }
267
- }
268
-
269
- /**
270
- * Getter for #launch_data
271
- * @return {string}
272
- */
273
- get launch_data() {
274
- return this.#launch_data;
275
- }
276
-
277
- /**
278
- * Setter for #launch_data. Can only be called before initialization.
279
- * @param {string} launch_data
280
- */
281
- set launch_data(launch_data) {
282
- !this.initialized ? this.#launch_data = launch_data : throwReadOnlyError();
283
- }
284
-
285
- /**
286
- * Getter for #learner_id
287
- * @return {string}
288
- */
289
- get learner_id() {
290
- return this.#learner_id;
291
- }
292
-
293
- /**
294
- * Setter for #learner_id. Can only be called before initialization.
295
- * @param {string} learner_id
296
- */
297
- set learner_id(learner_id) {
298
- !this.initialized ? this.#learner_id = learner_id : throwReadOnlyError();
299
- }
300
-
301
- /**
302
- * Getter for #learner_name
303
- * @return {string}
304
- */
305
- get learner_name() {
306
- return this.#learner_name;
307
- }
308
-
309
- /**
310
- * Setter for #learner_name. Can only be called before initialization.
311
- * @param {string} learner_name
312
- */
313
- set learner_name(learner_name) {
314
- !this.initialized ?
315
- this.#learner_name = learner_name :
316
- throwReadOnlyError();
317
- }
318
-
319
- /**
320
- * Getter for #location
321
- * @return {string}
322
- */
323
- get location() {
324
- return this.#location;
325
- }
326
-
327
- /**
328
- * Setter for #location
329
- * @param {string} location
330
- */
331
- set location(location) {
332
- if (check2004ValidFormat(location, scorm2004_regex.CMIString1000)) {
333
- this.#location = location;
334
- }
335
- }
336
-
337
- /**
338
- * Getter for #max_time_allowed
339
- * @return {string}
340
- */
341
- get max_time_allowed() {
342
- return this.#max_time_allowed;
343
- }
344
-
345
- /**
346
- * Setter for #max_time_allowed. Can only be called before initialization.
347
- * @param {string} max_time_allowed
348
- */
349
- set max_time_allowed(max_time_allowed) {
350
- !this.initialized ?
351
- this.#max_time_allowed = max_time_allowed :
352
- throwReadOnlyError();
353
- }
354
-
355
- /**
356
- * Getter for #mode
357
- * @return {string}
358
- */
359
- get mode() {
360
- return this.#mode;
361
- }
362
-
363
- /**
364
- * Setter for #mode. Can only be called before initialization.
365
- * @param {string} mode
366
- */
367
- set mode(mode) {
368
- !this.initialized ? this.#mode = mode : throwReadOnlyError();
369
- }
370
-
371
- /**
372
- * Getter for #progress_measure
373
- * @return {string}
374
- */
375
- get progress_measure() {
376
- return this.#progress_measure;
377
- }
378
-
379
- /**
380
- * Setter for #progress_measure
381
- * @param {string} progress_measure
382
- */
383
- set progress_measure(progress_measure) {
384
- if (check2004ValidFormat(progress_measure, scorm2004_regex.CMIDecimal) &&
385
- check2004ValidRange(progress_measure, scorm2004_regex.progress_range)) {
386
- this.#progress_measure = progress_measure;
387
- }
388
- }
389
-
390
- /**
391
- * Getter for #scaled_passing_score
392
- * @return {string}
393
- */
394
- get scaled_passing_score() {
395
- return this.#scaled_passing_score;
396
- }
397
-
398
- /**
399
- * Setter for #scaled_passing_score. Can only be called before initialization.
400
- * @param {string} scaled_passing_score
401
- */
402
- set scaled_passing_score(scaled_passing_score) {
403
- !this.initialized ?
404
- this.#scaled_passing_score = scaled_passing_score :
405
- throwReadOnlyError();
406
- }
407
-
408
- /**
409
- * Getter for #session_time. Should only be called during JSON export.
410
- * @return {string}
411
- */
412
- get session_time() {
413
- return (!this.jsonString) ? throwWriteOnlyError() : this.#session_time;
414
- }
415
-
416
- /**
417
- * Setter for #session_time
418
- * @param {string} session_time
419
- */
420
- set session_time(session_time) {
421
- if (check2004ValidFormat(session_time, scorm2004_regex.CMITimespan)) {
422
- this.#session_time = session_time;
423
- }
424
- }
425
-
426
- /**
427
- * Getter for #success_status
428
- * @return {string}
429
- */
430
- get success_status() {
431
- return this.#success_status;
432
- }
433
-
434
- /**
435
- * Setter for #success_status
436
- * @param {string} success_status
437
- */
438
- set success_status(success_status) {
439
- if (check2004ValidFormat(success_status, scorm2004_regex.CMISStatus)) {
440
- this.#success_status = success_status;
441
- }
442
- }
443
-
444
- /**
445
- * Getter for #suspend_data
446
- * @return {string}
447
- */
448
- get suspend_data() {
449
- return this.#suspend_data;
450
- }
451
-
452
- /**
453
- * Setter for #suspend_data
454
- * @param {string} suspend_data
455
- */
456
- set suspend_data(suspend_data) {
457
- if (check2004ValidFormat(suspend_data, scorm2004_regex.CMIString64000,
458
- true)) {
459
- this.#suspend_data = suspend_data;
460
- }
461
- }
462
-
463
- /**
464
- * Getter for #time_limit_action
465
- * @return {string}
466
- */
467
- get time_limit_action() {
468
- return this.#time_limit_action;
469
- }
470
-
471
- /**
472
- * Setter for #time_limit_action. Can only be called before initialization.
473
- * @param {string} time_limit_action
474
- */
475
- set time_limit_action(time_limit_action) {
476
- !this.initialized ?
477
- this.#time_limit_action = time_limit_action :
478
- throwReadOnlyError();
479
- }
480
-
481
- /**
482
- * Getter for #total_time
483
- * @return {string}
484
- */
485
- get total_time() {
486
- return this.#total_time;
487
- }
488
-
489
- /**
490
- * Setter for #total_time. Can only be called before initialization.
491
- * @param {string} total_time
492
- */
493
- set total_time(total_time) {
494
- !this.initialized ? this.#total_time = total_time : throwReadOnlyError();
495
- }
496
-
497
- /**
498
- * Adds the current session time to the existing total time.
499
- *
500
- * @return {string} ISO8601 Duration
501
- */
502
- getCurrentTotalTime() {
503
- let sessionTime = this.#session_time;
504
- const startTime = this.start_time;
505
-
506
- if (typeof startTime !== 'undefined' && startTime !== null) {
507
- const seconds = new Date().getTime() - startTime;
508
- sessionTime = Util.getSecondsAsISODuration(seconds / 1000);
509
- }
510
-
511
- return Util.addTwoDurations(
512
- this.#total_time,
513
- sessionTime,
514
- scorm2004_regex.CMITimespan,
515
- );
516
- }
517
-
518
- /**
519
- * toJSON for cmi
520
- *
521
- * @return {
522
- * {
523
- * comments_from_learner: CMICommentsFromLearner,
524
- * comments_from_lms: CMICommentsFromLMS,
525
- * completion_status: string,
526
- * completion_threshold: string,
527
- * credit: string,
528
- * entry: string,
529
- * exit: string,
530
- * interactions: CMIInteractions,
531
- * launch_data: string,
532
- * learner_id: string,
533
- * learner_name: string,
534
- * learner_preference: CMILearnerPreference,
535
- * location: string,
536
- * max_time_allowed: string,
537
- * mode: string,
538
- * objectives: CMIObjectives,
539
- * progress_measure: string,
540
- * scaled_passing_score: string,
541
- * score: Scorm2004CMIScore,
542
- * session_time: string,
543
- * success_status: string,
544
- * suspend_data: string,
545
- * time_limit_action: string
546
- * }
547
- * }
548
- */
549
- toJSON() {
550
- this.jsonString = true;
551
- const result = {
552
- 'comments_from_learner': this.comments_from_learner,
553
- 'comments_from_lms': this.comments_from_lms,
554
- 'completion_status': this.completion_status,
555
- 'completion_threshold': this.completion_threshold,
556
- 'credit': this.credit,
557
- 'entry': this.entry,
558
- 'exit': this.exit,
559
- 'interactions': this.interactions,
560
- 'launch_data': this.launch_data,
561
- 'learner_id': this.learner_id,
562
- 'learner_name': this.learner_name,
563
- 'learner_preference': this.learner_preference,
564
- 'location': this.location,
565
- 'max_time_allowed': this.max_time_allowed,
566
- 'mode': this.mode,
567
- 'objectives': this.objectives,
568
- 'progress_measure': this.progress_measure,
569
- 'scaled_passing_score': this.scaled_passing_score,
570
- 'score': this.score,
571
- 'session_time': this.session_time,
572
- 'success_status': this.success_status,
573
- 'suspend_data': this.suspend_data,
574
- 'time_limit_action': this.time_limit_action,
575
- };
576
- delete this.jsonString;
577
- return result;
578
- }
579
- }
580
-
581
- /**
582
- * Class for SCORM 2004's cmi.learner_preference object
583
- */
584
- class CMILearnerPreference extends BaseCMI {
585
- #_children = scorm2004_constants.student_preference_children;
586
- #audio_level = '1';
587
- #language = '';
588
- #delivery_speed = '1';
589
- #audio_captioning = '0';
590
-
591
- /**
592
- * Constructor for cmi.learner_preference
593
- */
594
- constructor() {
595
- super();
596
- }
597
-
598
- /**
599
- * Getter for #_children
600
- * @return {string}
601
- * @private
602
- */
603
- get _children() {
604
- return this.#_children;
605
- }
606
-
607
- /**
608
- * Setter for #_children. Just throws an error.
609
- * @param {string} _children
610
- * @private
611
- */
612
- set _children(_children) {
613
- throwReadOnlyError();
614
- }
615
-
616
- /**
617
- * Getter for #audio_level
618
- * @return {string}
619
- */
620
- get audio_level() {
621
- return this.#audio_level;
622
- }
623
-
624
- /**
625
- * Setter for #audio_level
626
- * @param {string} audio_level
627
- */
628
- set audio_level(audio_level) {
629
- if (check2004ValidFormat(audio_level, scorm2004_regex.CMIDecimal) &&
630
- check2004ValidRange(audio_level, scorm2004_regex.audio_range)) {
631
- this.#audio_level = audio_level;
632
- }
633
- }
634
-
635
- /**
636
- * Getter for #language
637
- * @return {string}
638
- */
639
- get language() {
640
- return this.#language;
641
- }
642
-
643
- /**
644
- * Setter for #language
645
- * @param {string} language
646
- */
647
- set language(language) {
648
- if (check2004ValidFormat(language, scorm2004_regex.CMILang)) {
649
- this.#language = language;
650
- }
651
- }
652
-
653
- /**
654
- * Getter for #delivery_speed
655
- * @return {string}
656
- */
657
- get delivery_speed() {
658
- return this.#delivery_speed;
659
- }
660
-
661
- /**
662
- * Setter for #delivery_speed
663
- * @param {string} delivery_speed
664
- */
665
- set delivery_speed(delivery_speed) {
666
- if (check2004ValidFormat(delivery_speed, scorm2004_regex.CMIDecimal) &&
667
- check2004ValidRange(delivery_speed, scorm2004_regex.speed_range)) {
668
- this.#delivery_speed = delivery_speed;
669
- }
670
- }
671
-
672
- /**
673
- * Getter for #audio_captioning
674
- * @return {string}
675
- */
676
- get audio_captioning() {
677
- return this.#audio_captioning;
678
- }
679
-
680
- /**
681
- * Setter for #audio_captioning
682
- * @param {string} audio_captioning
683
- */
684
- set audio_captioning(audio_captioning) {
685
- if (check2004ValidFormat(audio_captioning, scorm2004_regex.CMISInteger) &&
686
- check2004ValidRange(audio_captioning, scorm2004_regex.text_range)) {
687
- this.#audio_captioning = audio_captioning;
688
- }
689
- }
690
-
691
- /**
692
- * toJSON for cmi.learner_preference
693
- *
694
- * @return {
695
- * {
696
- * audio_level: string,
697
- * language: string,
698
- * delivery_speed: string,
699
- * audio_captioning: string
700
- * }
701
- * }
702
- */
703
- toJSON() {
704
- this.jsonString = true;
705
- const result = {
706
- 'audio_level': this.audio_level,
707
- 'language': this.language,
708
- 'delivery_speed': this.delivery_speed,
709
- 'audio_captioning': this.audio_captioning,
710
- };
711
- delete this.jsonString;
712
- return result;
713
- }
714
- }
715
-
716
- /**
717
- * Class representing SCORM 2004's cmi.interactions object
718
- */
719
- class CMIInteractions extends CMIArray {
720
- /**
721
- * Constructor for cmi.objectives Array
722
- */
723
- constructor() {
724
- super({
725
- children: scorm2004_constants.interactions_children,
726
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
727
- errorClass: Scorm2004ValidationError,
728
- });
729
- }
730
- }
731
-
732
- /**
733
- * Class representing SCORM 2004's cmi.objectives object
734
- */
735
- class CMIObjectives extends CMIArray {
736
- /**
737
- * Constructor for cmi.objectives Array
738
- */
739
- constructor() {
740
- super({
741
- children: scorm2004_constants.objectives_children,
742
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
743
- errorClass: Scorm2004ValidationError,
744
- });
745
- }
746
- }
747
-
748
- /**
749
- * Class representing SCORM 2004's cmi.comments_from_lms object
750
- */
751
- class CMICommentsFromLMS extends CMIArray {
752
- /**
753
- * Constructor for cmi.comments_from_lms Array
754
- */
755
- constructor() {
756
- super({
757
- children: scorm2004_constants.comments_children,
758
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
759
- errorClass: Scorm2004ValidationError,
760
- });
761
- }
762
- }
763
-
764
- /**
765
- * Class representing SCORM 2004's cmi.comments_from_learner object
766
- */
767
- class CMICommentsFromLearner extends CMIArray {
768
- /**
769
- * Constructor for cmi.comments_from_learner Array
770
- */
771
- constructor() {
772
- super({
773
- children: scorm2004_constants.comments_children,
774
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
775
- errorClass: Scorm2004ValidationError,
776
- });
777
- }
778
- }
779
-
780
- /**
781
- * Class for SCORM 2004's cmi.interaction.n object
782
- */
783
- export class CMIInteractionsObject extends BaseCMI {
784
- #id = '';
785
- #type = '';
786
- #timestamp = '';
787
- #weighting = '';
788
- #learner_response = '';
789
- #result = '';
790
- #latency = '';
791
- #description = '';
792
-
793
- /**
794
- * Constructor for cmi.interaction.n
795
- */
796
- constructor() {
797
- super();
798
-
799
- this.objectives = new CMIArray({
800
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
801
- errorClass: Scorm2004ValidationError,
802
- children: scorm2004_constants.objectives_children,
803
- });
804
- this.correct_responses = new CMIArray({
805
- errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
806
- errorClass: Scorm2004ValidationError,
807
- children: scorm2004_constants.correct_responses_children,
808
- });
809
- }
810
-
811
- /**
812
- * Called when the API has been initialized after the CMI has been created
813
- */
814
- initialize() {
815
- super.initialize();
816
- this.objectives?.initialize();
817
- this.correct_responses?.initialize();
818
- }
819
-
820
- /**
821
- * Getter for #id
822
- * @return {string}
823
- */
824
- get id() {
825
- return this.#id;
826
- }
827
-
828
- /**
829
- * Setter for #id
830
- * @param {string} id
831
- */
832
- set id(id) {
833
- if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
834
- this.#id = id;
835
- }
836
- }
837
-
838
- /**
839
- * Getter for #type
840
- * @return {string}
841
- */
842
- get type() {
843
- return this.#type;
844
- }
845
-
846
- /**
847
- * Setter for #type
848
- * @param {string} type
849
- */
850
- set type(type) {
851
- if (this.initialized && this.#id === '') {
852
- throwDependencyNotEstablishedError();
853
- } else {
854
- if (check2004ValidFormat(type, scorm2004_regex.CMIType)) {
855
- this.#type = type;
856
- }
857
- }
858
- }
859
-
860
- /**
861
- * Getter for #timestamp
862
- * @return {string}
863
- */
864
- get timestamp() {
865
- return this.#timestamp;
866
- }
867
-
868
- /**
869
- * Setter for #timestamp
870
- * @param {string} timestamp
871
- */
872
- set timestamp(timestamp) {
873
- if (this.initialized && this.#id === '') {
874
- throwDependencyNotEstablishedError();
875
- } else {
876
- if (check2004ValidFormat(timestamp, scorm2004_regex.CMITime)) {
877
- this.#timestamp = timestamp;
878
- }
879
- }
880
- }
881
-
882
- /**
883
- * Getter for #weighting
884
- * @return {string}
885
- */
886
- get weighting() {
887
- return this.#weighting;
888
- }
889
-
890
- /**
891
- * Setter for #weighting
892
- * @param {string} weighting
893
- */
894
- set weighting(weighting) {
895
- if (this.initialized && this.#id === '') {
896
- throwDependencyNotEstablishedError();
897
- } else {
898
- if (check2004ValidFormat(weighting, scorm2004_regex.CMIDecimal)) {
899
- this.#weighting = weighting;
900
- }
901
- }
902
- }
903
-
904
- /**
905
- * Getter for #learner_response
906
- * @return {string}
907
- */
908
- get learner_response() {
909
- return this.#learner_response;
910
- }
911
-
912
- /**
913
- * Setter for #learner_response. Does type validation to make sure response
914
- * matches SCORM 2004's spec
915
- * @param {string} learner_response
916
- */
917
- set learner_response(learner_response) {
918
- if (this.initialized && (this.#type === '' || this.#id === '')) {
919
- throwDependencyNotEstablishedError();
920
- } else {
921
- let nodes = [];
922
- const response_type = learner_responses[this.type];
923
- if (response_type) {
924
- if (response_type?.delimiter) {
925
- nodes = learner_response.split(response_type.delimiter);
926
- } else {
927
- nodes[0] = learner_response;
928
- }
929
-
930
- if ((nodes.length > 0) && (nodes.length <= response_type.max)) {
931
- const formatRegex = new RegExp(response_type.format);
932
- for (let i = 0; i < nodes.length; i++) {
933
- if (response_type?.delimiter2) {
934
- const values = nodes[i].split(response_type.delimiter2);
935
- if (values.length === 2) {
936
- if (!values[0].match(formatRegex)) {
937
- throwTypeMismatchError();
938
- } else {
939
- if (!values[1].match(new RegExp(response_type.format2))) {
940
- throwTypeMismatchError();
941
- }
942
- }
943
- } else {
944
- throwTypeMismatchError();
945
- }
946
- } else {
947
- if (!nodes[i].match(formatRegex)) {
948
- throwTypeMismatchError();
949
- } else {
950
- if (nodes[i] !== '' && response_type.unique) {
951
- for (let j = 0; j < i; j++) {
952
- if (nodes[i] === nodes[j]) {
953
- throwTypeMismatchError();
954
- }
955
- }
956
- }
957
- }
958
- }
959
- }
960
- } else {
961
- throwGeneralSetError();
962
- }
963
-
964
- this.#learner_response = learner_response;
965
- } else {
966
- throwTypeMismatchError();
967
- }
968
- }
969
- }
970
-
971
- /**
972
- * Getter for #result
973
- * @return {string}
974
- */
975
- get result() {
976
- return this.#result;
977
- }
978
-
979
- /**
980
- * Setter for #result
981
- * @param {string} result
982
- */
983
- set result(result) {
984
- if (check2004ValidFormat(result, scorm2004_regex.CMIResult)) {
985
- this.#result = result;
986
- }
987
- }
988
-
989
- /**
990
- * Getter for #latency
991
- * @return {string}
992
- */
993
- get latency() {
994
- return this.#latency;
995
- }
996
-
997
- /**
998
- * Setter for #latency
999
- * @param {string} latency
1000
- */
1001
- set latency(latency) {
1002
- if (this.initialized && this.#id === '') {
1003
- throwDependencyNotEstablishedError();
1004
- } else {
1005
- if (check2004ValidFormat(latency, scorm2004_regex.CMITimespan)) {
1006
- this.#latency = latency;
1007
- }
1008
- }
1009
- }
1010
-
1011
- /**
1012
- * Getter for #description
1013
- * @return {string}
1014
- */
1015
- get description() {
1016
- return this.#description;
1017
- }
1018
-
1019
- /**
1020
- * Setter for #description
1021
- * @param {string} description
1022
- */
1023
- set description(description) {
1024
- if (this.initialized && this.#id === '') {
1025
- throwDependencyNotEstablishedError();
1026
- } else {
1027
- if (check2004ValidFormat(description, scorm2004_regex.CMILangString250,
1028
- true)) {
1029
- this.#description = description;
1030
- }
1031
- }
1032
- }
1033
-
1034
- /**
1035
- * toJSON for cmi.interactions.n
1036
- *
1037
- * @return {
1038
- * {
1039
- * id: string,
1040
- * type: string,
1041
- * objectives: CMIArray,
1042
- * timestamp: string,
1043
- * correct_responses: CMIArray,
1044
- * weighting: string,
1045
- * learner_response: string,
1046
- * result: string,
1047
- * latency: string,
1048
- * description: string
1049
- * }
1050
- * }
1051
- */
1052
- toJSON() {
1053
- this.jsonString = true;
1054
- const result = {
1055
- 'id': this.id,
1056
- 'type': this.type,
1057
- 'objectives': this.objectives,
1058
- 'timestamp': this.timestamp,
1059
- 'weighting': this.weighting,
1060
- 'learner_response': this.learner_response,
1061
- 'result': this.result,
1062
- 'latency': this.latency,
1063
- 'description': this.description,
1064
- 'correct_responses': this.correct_responses,
1065
- };
1066
- delete this.jsonString;
1067
- return result;
1068
- }
1069
- }
1070
-
1071
- /**
1072
- * Class for SCORM 2004's cmi.objectives.n object
1073
- */
1074
- export class CMIObjectivesObject extends BaseCMI {
1075
- #id = '';
1076
- #success_status = 'unknown';
1077
- #completion_status = 'unknown';
1078
- #progress_measure = '';
1079
- #description = '';
1080
-
1081
- /**
1082
- * Constructor for cmi.objectives.n
1083
- */
1084
- constructor() {
1085
- super();
1086
-
1087
- this.score = new Scorm2004CMIScore();
1088
- }
1089
-
1090
- /**
1091
- * Called when the API has been initialized after the CMI has been created
1092
- */
1093
- initialize() {
1094
- super.initialize();
1095
- this.score?.initialize();
1096
- }
1097
-
1098
- /**
1099
- * Getter for #id
1100
- * @return {string}
1101
- */
1102
- get id() {
1103
- return this.#id;
1104
- }
1105
-
1106
- /**
1107
- * Setter for #id
1108
- * @param {string} id
1109
- */
1110
- set id(id) {
1111
- if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
1112
- this.#id = id;
1113
- }
1114
- }
1115
-
1116
- /**
1117
- * Getter for #success_status
1118
- * @return {string}
1119
- */
1120
- get success_status() {
1121
- return this.#success_status;
1122
- }
1123
-
1124
- /**
1125
- * Setter for #success_status
1126
- * @param {string} success_status
1127
- */
1128
- set success_status(success_status) {
1129
- if (this.initialized && this.#id === '') {
1130
- throwDependencyNotEstablishedError();
1131
- } else {
1132
- if (check2004ValidFormat(success_status, scorm2004_regex.CMISStatus)) {
1133
- this.#success_status = success_status;
1134
- }
1135
- }
1136
- }
1137
-
1138
- /**
1139
- * Getter for #completion_status
1140
- * @return {string}
1141
- */
1142
- get completion_status() {
1143
- return this.#completion_status;
1144
- }
1145
-
1146
- /**
1147
- * Setter for #completion_status
1148
- * @param {string} completion_status
1149
- */
1150
- set completion_status(completion_status) {
1151
- if (this.initialized && this.#id === '') {
1152
- throwDependencyNotEstablishedError();
1153
- } else {
1154
- if (check2004ValidFormat(completion_status, scorm2004_regex.CMICStatus)) {
1155
- this.#completion_status = completion_status;
1156
- }
1157
- }
1158
- }
1159
-
1160
- /**
1161
- * Getter for #progress_measure
1162
- * @return {string}
1163
- */
1164
- get progress_measure() {
1165
- return this.#progress_measure;
1166
- }
1167
-
1168
- /**
1169
- * Setter for #progress_measure
1170
- * @param {string} progress_measure
1171
- */
1172
- set progress_measure(progress_measure) {
1173
- if (this.initialized && this.#id === '') {
1174
- throwDependencyNotEstablishedError();
1175
- } else {
1176
- if (check2004ValidFormat(progress_measure, scorm2004_regex.CMIDecimal) &&
1177
- check2004ValidRange(progress_measure,
1178
- scorm2004_regex.progress_range)) {
1179
- this.#progress_measure = progress_measure;
1180
- }
1181
- }
1182
- }
1183
-
1184
- /**
1185
- * Getter for #description
1186
- * @return {string}
1187
- */
1188
- get description() {
1189
- return this.#description;
1190
- }
1191
-
1192
- /**
1193
- * Setter for #description
1194
- * @param {string} description
1195
- */
1196
- set description(description) {
1197
- if (this.initialized && this.#id === '') {
1198
- throwDependencyNotEstablishedError();
1199
- } else {
1200
- if (check2004ValidFormat(description, scorm2004_regex.CMILangString250,
1201
- true)) {
1202
- this.#description = description;
1203
- }
1204
- }
1205
- }
1206
-
1207
- /**
1208
- * toJSON for cmi.objectives.n
1209
- *
1210
- * @return {
1211
- * {
1212
- * id: string,
1213
- * success_status: string,
1214
- * completion_status: string,
1215
- * progress_measure: string,
1216
- * description: string,
1217
- * score: Scorm2004CMIScore
1218
- * }
1219
- * }
1220
- */
1221
- toJSON() {
1222
- this.jsonString = true;
1223
- const result = {
1224
- 'id': this.id,
1225
- 'success_status': this.success_status,
1226
- 'completion_status': this.completion_status,
1227
- 'progress_measure': this.progress_measure,
1228
- 'description': this.description,
1229
- 'score': this.score,
1230
- };
1231
- delete this.jsonString;
1232
- return result;
1233
- }
1234
- }
1235
-
1236
- /**
1237
- * Class for SCORM 2004's cmi *.score object
1238
- */
1239
- class Scorm2004CMIScore extends CMIScore {
1240
- #scaled = '';
1241
-
1242
- /**
1243
- * Constructor for cmi *.score
1244
- */
1245
- constructor() {
1246
- super(
1247
- {
1248
- score_children: scorm2004_constants.score_children,
1249
- max: '',
1250
- invalidErrorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
1251
- invalidTypeCode: scorm2004_error_codes.TYPE_MISMATCH,
1252
- invalidRangeCode: scorm2004_error_codes.VALUE_OUT_OF_RANGE,
1253
- decimalRegex: scorm2004_regex.CMIDecimal,
1254
- errorClass: Scorm2004ValidationError,
1255
- });
1256
- }
1257
-
1258
- /**
1259
- * Getter for #scaled
1260
- * @return {string}
1261
- */
1262
- get scaled() {
1263
- return this.#scaled;
1264
- }
1265
-
1266
- /**
1267
- * Setter for #scaled
1268
- * @param {string} scaled
1269
- */
1270
- set scaled(scaled) {
1271
- if (check2004ValidFormat(scaled, scorm2004_regex.CMIDecimal) &&
1272
- check2004ValidRange(scaled, scorm2004_regex.scaled_range)) {
1273
- this.#scaled = scaled;
1274
- }
1275
- }
1276
-
1277
- /**
1278
- * toJSON for cmi *.score
1279
- *
1280
- * @return {
1281
- * {
1282
- * scaled: string,
1283
- * raw: string,
1284
- * min: string,
1285
- * max: string
1286
- * }
1287
- * }
1288
- */
1289
- toJSON() {
1290
- this.jsonString = true;
1291
- const result = {
1292
- 'scaled': this.scaled,
1293
- 'raw': super.raw,
1294
- 'min': super.min,
1295
- 'max': super.max,
1296
- };
1297
- delete this.jsonString;
1298
- return result;
1299
- }
1300
- }
1301
-
1302
- /**
1303
- * Class representing SCORM 2004's cmi.comments_from_learner.n and cmi.comments_from_lms.n object
1304
- */
1305
- export class CMICommentsObject extends BaseCMI {
1306
- #comment = '';
1307
- #location = '';
1308
- #timestamp = '';
1309
- #readOnlyAfterInit;
1310
-
1311
- /**
1312
- * Constructor for cmi.comments_from_learner.n and cmi.comments_from_lms.n
1313
- * @param {boolean} readOnlyAfterInit
1314
- */
1315
- constructor(readOnlyAfterInit = false) {
1316
- super();
1317
- this.#comment = '';
1318
- this.#location = '';
1319
- this.#timestamp = '';
1320
- this.#readOnlyAfterInit = readOnlyAfterInit;
1321
- }
1322
-
1323
- /**
1324
- * Getter for #comment
1325
- * @return {string}
1326
- */
1327
- get comment() {
1328
- return this.#comment;
1329
- }
1330
-
1331
- /**
1332
- * Setter for #comment
1333
- * @param {string} comment
1334
- */
1335
- set comment(comment) {
1336
- if (this.initialized && this.#readOnlyAfterInit) {
1337
- throwReadOnlyError();
1338
- } else {
1339
- if (check2004ValidFormat(comment, scorm2004_regex.CMILangString4000,
1340
- true)) {
1341
- this.#comment = comment;
1342
- }
1343
- }
1344
- }
1345
-
1346
- /**
1347
- * Getter for #location
1348
- * @return {string}
1349
- */
1350
- get location() {
1351
- return this.#location;
1352
- }
1353
-
1354
- /**
1355
- * Setter for #location
1356
- * @param {string} location
1357
- */
1358
- set location(location) {
1359
- if (this.initialized && this.#readOnlyAfterInit) {
1360
- throwReadOnlyError();
1361
- } else {
1362
- if (check2004ValidFormat(location, scorm2004_regex.CMIString250)) {
1363
- this.#location = location;
1364
- }
1365
- }
1366
- }
1367
-
1368
- /**
1369
- * Getter for #timestamp
1370
- * @return {string}
1371
- */
1372
- get timestamp() {
1373
- return this.#timestamp;
1374
- }
1375
-
1376
- /**
1377
- * Setter for #timestamp
1378
- * @param {string} timestamp
1379
- */
1380
- set timestamp(timestamp) {
1381
- if (this.initialized && this.#readOnlyAfterInit) {
1382
- throwReadOnlyError();
1383
- } else {
1384
- if (check2004ValidFormat(timestamp, scorm2004_regex.CMITime)) {
1385
- this.#timestamp = timestamp;
1386
- }
1387
- }
1388
- }
1389
-
1390
- /**
1391
- * toJSON for cmi.comments_from_learner.n object
1392
- * @return {
1393
- * {
1394
- * comment: string,
1395
- * location: string,
1396
- * timestamp: string
1397
- * }
1398
- * }
1399
- */
1400
- toJSON() {
1401
- this.jsonString = true;
1402
- const result = {
1403
- 'comment': this.comment,
1404
- 'location': this.location,
1405
- 'timestamp': this.timestamp,
1406
- };
1407
- delete this.jsonString;
1408
- return result;
1409
- }
1410
- }
1411
-
1412
- /**
1413
- * Class representing SCORM 2004's cmi.interactions.n.objectives.n object
1414
- */
1415
- export class CMIInteractionsObjectivesObject extends BaseCMI {
1416
- #id = '';
1417
-
1418
- /**
1419
- * Constructor for cmi.interactions.n.objectives.n
1420
- */
1421
- constructor() {
1422
- super();
1423
- }
1424
-
1425
- /**
1426
- * Getter for #id
1427
- * @return {string}
1428
- */
1429
- get id() {
1430
- return this.#id;
1431
- }
1432
-
1433
- /**
1434
- * Setter for #id
1435
- * @param {string} id
1436
- */
1437
- set id(id) {
1438
- if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
1439
- this.#id = id;
1440
- }
1441
- }
1442
-
1443
- /**
1444
- * toJSON for cmi.interactions.n.objectives.n
1445
- * @return {
1446
- * {
1447
- * id: string
1448
- * }
1449
- * }
1450
- */
1451
- toJSON() {
1452
- this.jsonString = true;
1453
- const result = {
1454
- 'id': this.id,
1455
- };
1456
- delete this.jsonString;
1457
- return result;
1458
- }
1459
- }
1460
-
1461
- /**
1462
- * Class representing SCORM 2004's cmi.interactions.n.correct_responses.n object
1463
- */
1464
- export class CMIInteractionsCorrectResponsesObject extends BaseCMI {
1465
- #pattern = '';
1466
-
1467
- /**
1468
- * Constructor for cmi.interactions.n.correct_responses.n
1469
- */
1470
- constructor() {
1471
- super();
1472
- }
1473
-
1474
- /**
1475
- * Getter for #pattern
1476
- * @return {string}
1477
- */
1478
- get pattern() {
1479
- return this.#pattern;
1480
- }
1481
-
1482
- /**
1483
- * Setter for #pattern
1484
- * @param {string} pattern
1485
- */
1486
- set pattern(pattern) {
1487
- if (check2004ValidFormat(pattern, scorm2004_regex.CMIFeedback)) {
1488
- this.#pattern = pattern;
1489
- }
1490
- }
1491
-
1492
- /**
1493
- * toJSON cmi.interactions.n.correct_responses.n object
1494
- * @return {
1495
- * {
1496
- * pattern: string
1497
- * }
1498
- * }
1499
- */
1500
- toJSON() {
1501
- this.jsonString = true;
1502
- const result = {
1503
- 'pattern': this.pattern,
1504
- };
1505
- delete this.jsonString;
1506
- return result;
1507
- }
1508
- }
1509
-
1510
- /**
1511
- * Class representing SCORM 2004's adl object
1512
- */
1513
- export class ADL extends BaseCMI {
1514
- /**
1515
- * Constructor for adl
1516
- */
1517
- constructor() {
1518
- super();
1519
-
1520
- this.nav = new ADLNav();
1521
- }
1522
-
1523
- /**
1524
- * Called when the API has been initialized after the CMI has been created
1525
- */
1526
- initialize() {
1527
- super.initialize();
1528
- this.nav?.initialize();
1529
- }
1530
-
1531
- /**
1532
- * toJSON for adl
1533
- * @return {
1534
- * {
1535
- * nav: {
1536
- * request: string
1537
- * }
1538
- * }
1539
- * }
1540
- */
1541
- toJSON() {
1542
- this.jsonString = true;
1543
- const result = {
1544
- 'nav': this.nav,
1545
- };
1546
- delete this.jsonString;
1547
- return result;
1548
- }
1549
- }
1550
-
1551
- /**
1552
- * Class representing SCORM 2004's adl.nav object
1553
- */
1554
- class ADLNav extends BaseCMI {
1555
- #request = '_none_';
1556
-
1557
- /**
1558
- * Constructor for adl.nav
1559
- */
1560
- constructor() {
1561
- super();
1562
-
1563
- this.request_valid = new ADLNavRequestValid();
1564
- }
1565
-
1566
- /**
1567
- * Called when the API has been initialized after the CMI has been created
1568
- */
1569
- initialize() {
1570
- super.initialize();
1571
- this.request_valid?.initialize();
1572
- }
1573
-
1574
- /**
1575
- * Getter for #request
1576
- * @return {string}
1577
- */
1578
- get request() {
1579
- return this.#request;
1580
- }
1581
-
1582
- /**
1583
- * Setter for #request
1584
- * @param {string} request
1585
- */
1586
- set request(request) {
1587
- if (check2004ValidFormat(request, scorm2004_regex.NAVEvent)) {
1588
- this.#request = request;
1589
- }
1590
- }
1591
-
1592
- /**
1593
- * toJSON for adl.nav
1594
- *
1595
- * @return {
1596
- * {
1597
- * request: string
1598
- * }
1599
- * }
1600
- */
1601
- toJSON() {
1602
- this.jsonString = true;
1603
- const result = {
1604
- 'request': this.request,
1605
- };
1606
- delete this.jsonString;
1607
- return result;
1608
- }
1609
- }
1610
-
1611
- /**
1612
- * Class representing SCORM 2004's adl.nav.request_valid object
1613
- */
1614
- class ADLNavRequestValid extends BaseCMI {
1615
- #continue = 'unknown';
1616
- #previous = 'unknown';
1617
- choice = class {
1618
- /**
1619
- * Check if target is valid
1620
- * @param {*} _target
1621
- * @return {string}
1622
- */
1623
- _isTargetValid = (_target) => 'unknown';
1624
- };
1625
- jump = class {
1626
- /**
1627
- * Check if target is valid
1628
- * @param {*} _target
1629
- * @return {string}
1630
- */
1631
- _isTargetValid = (_target) => 'unknown';
1632
- };
1633
-
1634
- /**
1635
- * Constructor for adl.nav.request_valid
1636
- */
1637
- constructor() {
1638
- super();
1639
- }
1640
-
1641
- /**
1642
- * Getter for #continue
1643
- * @return {string}
1644
- */
1645
- get continue() {
1646
- return this.#continue;
1647
- }
1648
-
1649
- /**
1650
- * Setter for #continue. Just throws an error.
1651
- * @param {*} _
1652
- */
1653
- set continue(_) {
1654
- throwReadOnlyError();
1655
- }
1656
-
1657
- /**
1658
- * Getter for #previous
1659
- * @return {string}
1660
- */
1661
- get previous() {
1662
- return this.#previous;
1663
- }
1664
-
1665
- /**
1666
- * Setter for #previous. Just throws an error.
1667
- * @param {*} _
1668
- */
1669
- set previous(_) {
1670
- throwReadOnlyError();
1671
- }
1672
-
1673
- /**
1674
- * toJSON for adl.nav.request_valid
1675
- *
1676
- * @return {
1677
- * {
1678
- * previous: string,
1679
- * continue: string
1680
- * }
1681
- * }
1682
- */
1683
- toJSON() {
1684
- this.jsonString = true;
1685
- const result = {
1686
- 'previous': this.previous,
1687
- 'continue': this.continue,
1688
- };
1689
- delete this.jsonString;
1690
- return result;
1691
- }
1692
- }