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,1066 +0,0 @@
1
- import {describe, it} from 'mocha';
2
- import ErrorCodes from '../../src/constants/error_codes';
3
- import APIConstants from '../../src/constants/api_constants';
4
- import {
5
- ADL,
6
- CMI,
7
- CMICommentsObject,
8
- CMIInteractionsCorrectResponsesObject,
9
- CMIInteractionsObject,
10
- CMIInteractionsObjectivesObject,
11
- CMIObjectivesObject,
12
- } from '../../src/cmi/scorm2004_cmi';
13
- import * as h from '../cmi_helpers';
14
- import {expect} from 'chai';
15
- import {scorm2004_values} from '../field_values';
16
-
17
- const scorm2004_constants = APIConstants.scorm2004;
18
- const scorm2004_error_codes = ErrorCodes.scorm2004;
19
-
20
- const read_only = scorm2004_error_codes.READ_ONLY_ELEMENT;
21
- const write_only = scorm2004_error_codes.WRITE_ONLY_ELEMENT;
22
- const type_mismatch = scorm2004_error_codes.TYPE_MISMATCH;
23
-
24
- const cmi = () => {
25
- return new CMI();
26
- };
27
- const cmiInitialized = () => {
28
- const cmiObj = new CMI();
29
- cmiObj.initialize();
30
- return cmiObj;
31
- };
32
- const comments = () => {
33
- return new CMICommentsObject();
34
- };
35
- const lmsComments = () => {
36
- return new CMICommentsObject(true);
37
- };
38
- const lmsCommentsInitialized = () => {
39
- const cmi = lmsComments();
40
- cmi.initialize();
41
- return cmi;
42
- };
43
- const interaction = () => {
44
- return new CMIInteractionsObject();
45
- };
46
- const interactionInitialized = () => {
47
- const cmi = new CMIInteractionsObject();
48
- cmi.initialize();
49
- return cmi;
50
- };
51
- const objective = () => {
52
- return new CMIObjectivesObject();
53
- };
54
- const objectiveInitialized = () => {
55
- const cmi = new CMIObjectivesObject();
56
- cmi.initialize();
57
- return cmi;
58
- };
59
- const interactionObjective = () => {
60
- return new CMIInteractionsObjectivesObject();
61
- };
62
- const correctResponse = () => {
63
- return new CMIInteractionsCorrectResponsesObject();
64
- };
65
- const adl = () => {
66
- return new ADL();
67
- };
68
-
69
- describe('SCORM 2004 CMI Tests', () => {
70
- describe('getCurrentTotalTime()', () => {
71
- h.checkGetCurrentTotalTime({
72
- cmi: cmi(),
73
- startingTotal: 'PT0S',
74
- sessionTime: 'PT15M45S',
75
- expectedTotal: 'PT15M45S',
76
- totalFieldName: 'cmi.total_time',
77
- sessionFieldName: 'cmi.session_time',
78
- });
79
- h.checkGetCurrentTotalTime({
80
- cmi: cmi(),
81
- startingTotal: 'PT60S',
82
- sessionTime: 'PT15M45S',
83
- expectedTotal: 'PT16M45S',
84
- totalFieldName: 'cmi.total_time',
85
- sessionFieldName: 'cmi.session_time',
86
- });
87
- h.checkGetCurrentTotalTime({
88
- cmi: cmi(),
89
- startingTotal: 'PT60S',
90
- sessionTime: 'PT0S',
91
- expectedTotal: 'PT1M',
92
- totalFieldName: 'cmi.total_time',
93
- sessionFieldName: 'cmi.session_time',
94
- });
95
- h.checkGetCurrentTotalTime({
96
- cmi: cmi(),
97
- startingTotal: 'PT25H1M0S',
98
- sessionTime: 'PT13H',
99
- expectedTotal: 'P1DT14H1M',
100
- totalFieldName: 'cmi.total_time',
101
- sessionFieldName: 'cmi.session_time',
102
- });
103
- h.checkGetCurrentTotalTime({
104
- cmi: cmi(),
105
- startingTotal: 'PT48H1M45S',
106
- sessionTime: 'PT13H16S',
107
- expectedTotal: 'P2DT13H2M1S',
108
- totalFieldName: 'cmi.total_time',
109
- sessionFieldName: 'cmi.session_time',
110
- });
111
- });
112
-
113
- describe('CMI Spec Tests', () => {
114
- describe('Pre-Initialize Tests', () => {
115
- /**
116
- * Base CMI Properties
117
- */
118
- h.checkReadOnly({
119
- cmi: cmi(),
120
- fieldName: 'cmi._version',
121
- expectedValue: '1.0',
122
- expectedError: read_only,
123
- });
124
- h.checkReadOnly({
125
- cmi: cmi(),
126
- fieldName: 'cmi._children',
127
- expectedValue: scorm2004_constants.cmi_children,
128
- expectedError: read_only,
129
- });
130
- h.checkValidValues({
131
- cmi: cmi(),
132
- fieldName: 'cmi.completion_status',
133
- expectedError: type_mismatch,
134
- validValues: scorm2004_values.validCStatus,
135
- invalidValues: scorm2004_values.invalidCStatus,
136
- });
137
- h.checkReadAndWrite({
138
- cmi: cmi(),
139
- fieldName: 'cmi.completion_threshold',
140
- });
141
- h.checkReadAndWrite({
142
- cmi: cmi(),
143
- fieldName: 'cmi.credit',
144
- expectedValue: 'credit',
145
- });
146
- h.checkReadAndWrite({
147
- cmi: cmi(),
148
- fieldName: 'cmi.entry',
149
- });
150
- h.checkWriteOnly({
151
- cmi: cmi(),
152
- fieldName: 'cmi.exit',
153
- expectedError: write_only,
154
- valueToTest: 'time-out',
155
- });
156
- h.checkValidValues({
157
- cmi: cmi(),
158
- fieldName: 'cmi.exit',
159
- validValues: scorm2004_values.validExit,
160
- invalidValues: scorm2004_values.invalidExit,
161
- });
162
- h.checkReadAndWrite({
163
- cmi: cmi(),
164
- fieldName: 'cmi.launch_data',
165
- });
166
- h.checkReadAndWrite({
167
- cmi: cmi(),
168
- fieldName: 'cmi.learner_id',
169
- });
170
- h.checkReadAndWrite({
171
- cmi: cmi(),
172
- fieldName: 'cmi.learner_name',
173
- });
174
- h.checkFieldConstraintSize({
175
- cmi: cmi(),
176
- fieldName: 'cmi.location',
177
- limit: 1000,
178
- expectedError: type_mismatch,
179
- });
180
- h.checkReadAndWrite({
181
- cmi: cmi(),
182
- fieldName: 'cmi.max_time_allowed',
183
- });
184
- h.checkReadAndWrite({
185
- cmi: cmi(),
186
- fieldName: 'cmi.mode',
187
- expectedValue: 'normal',
188
- });
189
- h.checkReadAndWrite({
190
- cmi: cmi(),
191
- fieldName: 'cmi.max_time_allowed',
192
- });
193
- h.checkValidValues({
194
- cmi: cmi(),
195
- fieldName: 'cmi.progress_measure',
196
- validValues: scorm2004_values.valid0To1Range,
197
- invalidValues: scorm2004_values.invalid0To1Range,
198
- });
199
- h.checkReadAndWrite({
200
- cmi: cmi(),
201
- fieldName: 'cmi.scaled_passing_score',
202
- });
203
- h.checkWriteOnly({
204
- cmi: cmi(),
205
- fieldName: 'cmi.session_time',
206
- valueToTest: 'P0S',
207
- expectedError: write_only,
208
- });
209
- h.checkValidValues({
210
- cmi: cmi(),
211
- fieldName: 'cmi.session_time',
212
- validValues: scorm2004_values.validISO8601Durations,
213
- invalidValues: scorm2004_values.invalidISO8601Durations,
214
- });
215
- h.checkRead({
216
- cmi: cmi(),
217
- fieldName: 'cmi.success_status',
218
- expectedValue: 'unknown',
219
- });
220
- h.checkValidValues({
221
- cmi: cmi(),
222
- fieldName: 'cmi.success_status',
223
- validValues: scorm2004_values.validSStatus,
224
- invalidValues: scorm2004_values.invalidSStatus,
225
- });
226
- h.checkFieldConstraintSize({
227
- cmi: cmi(),
228
- fieldName: 'cmi.suspend_data',
229
- limit: 64000,
230
- expectedError: type_mismatch,
231
- });
232
- h.checkReadAndWrite({
233
- cmi: cmi(),
234
- fieldName: 'cmi.time_limit_action',
235
- expectedValue: 'continue,no message',
236
- });
237
- h.checkReadAndWrite({
238
- cmi: cmi(),
239
- fieldName: 'cmi.total_time',
240
- expectedValue: '',
241
- });
242
-
243
- /**
244
- * cmi.learner_preference Properties
245
- */
246
- h.checkReadOnly({
247
- cmi: cmi(),
248
- fieldName: 'cmi.learner_preference._children',
249
- expectedValue: scorm2004_constants.student_preference_children,
250
- expectedError: read_only,
251
- });
252
- h.checkValidValues({
253
- cmi: cmi(),
254
- fieldName: 'cmi.learner_preference.audio_level',
255
- validValues: scorm2004_values.valid0To100Range,
256
- invalidValues: scorm2004_values.invalid0To100Range,
257
- });
258
- h.checkValidValues({
259
- cmi: cmi(),
260
- fieldName: 'cmi.learner_preference.language',
261
- validValues: [
262
- 'en',
263
- 'fr',
264
- 'ru',
265
- 'es',
266
- ],
267
- invalidValues: [
268
- 'invalid',
269
- 'a100',
270
- ],
271
- });
272
- h.checkValidValues({
273
- cmi: cmi(),
274
- fieldName: 'cmi.learner_preference.delivery_speed',
275
- validValues: scorm2004_values.valid0To100Range,
276
- invalidValues: scorm2004_values.invalid0To100Range,
277
- });
278
- h.checkValidValues({
279
- cmi: cmi(),
280
- fieldName: 'cmi.learner_preference.audio_captioning',
281
- validValues: scorm2004_values.validIntegerScaledRange,
282
- invalidValues: scorm2004_values.invalidIntegerScaledRange,
283
- });
284
-
285
- /**
286
- * cmi.objectives Properties
287
- */
288
- h.checkReadOnly({
289
- cmi: cmi(),
290
- fieldName: 'cmi.objectives._children',
291
- expectedValue: scorm2004_constants.objectives_children,
292
- expectedError: read_only,
293
- });
294
- h.checkReadOnly({
295
- cmi: cmi(),
296
- fieldName: 'cmi.objectives._count',
297
- expectedValue: 0,
298
- expectedError: read_only,
299
- });
300
-
301
- /**
302
- * cmi.score Properties
303
- */
304
- h.checkReadOnly({
305
- cmi: cmi(),
306
- fieldName: 'cmi.score._children',
307
- expectedValue: scorm2004_constants.score_children,
308
- expectedError: read_only,
309
- });
310
- h.checkValidValues({
311
- cmi: cmi(),
312
- fieldName: 'cmi.score.scaled',
313
- validValues: scorm2004_values.validScaledRange,
314
- invalidValues: scorm2004_values.invalidScaledRange,
315
- });
316
- h.checkValidValues({
317
- cmi: cmi(),
318
- fieldName: 'cmi.score.raw',
319
- validValues: scorm2004_values.validScoreRange,
320
- invalidValues: scorm2004_values.invalidScoreRange,
321
- });
322
- h.checkValidValues({
323
- cmi: cmi(),
324
- fieldName: 'cmi.score.min',
325
- validValues: scorm2004_values.validScoreRange,
326
- invalidValues: scorm2004_values.invalidScoreRange,
327
- });
328
- h.checkValidValues({
329
- cmi: cmi(),
330
- fieldName: 'cmi.score.max',
331
- validValues: scorm2004_values.validScoreRange,
332
- invalidValues: scorm2004_values.invalidScoreRange,
333
- });
334
-
335
- /**
336
- * cmi.comments_from_learner Properties
337
- */
338
- h.checkReadOnly({
339
- cmi: cmi(),
340
- fieldName: 'cmi.comments_from_learner._children',
341
- expectedValue: scorm2004_constants.comments_children,
342
- expectedError: read_only,
343
- });
344
- h.checkReadOnly({
345
- cmi: cmi(),
346
- fieldName: 'cmi.comments_from_learner._count',
347
- expectedValue: 0,
348
- expectedError: read_only,
349
- });
350
-
351
- /**
352
- * cmi.comments_from_lms Properties
353
- */
354
- h.checkReadOnly({
355
- cmi: cmi(),
356
- fieldName: 'cmi.comments_from_lms._children',
357
- expectedValue: scorm2004_constants.comments_children,
358
- expectedError: read_only,
359
- });
360
- h.checkReadOnly({
361
- cmi: cmi(),
362
- fieldName: 'cmi.comments_from_lms._count',
363
- expectedValue: 0,
364
- expectedError: read_only,
365
- });
366
-
367
- /**
368
- * cmi.interactions Properties
369
- */
370
- h.checkReadOnly({
371
- cmi: cmi(),
372
- fieldName: 'cmi.interactions._children',
373
- expectedValue: scorm2004_constants.interactions_children,
374
- expectedError: read_only,
375
- });
376
- h.checkReadOnly({
377
- cmi: cmi(),
378
- fieldName: 'cmi.interactions._count',
379
- expectedValue: 0,
380
- expectedError: read_only,
381
- });
382
-
383
- /**
384
- * cmi.objectives Properties
385
- */
386
- h.checkReadOnly({
387
- cmi: cmi(),
388
- fieldName: 'cmi.objectives._children',
389
- expectedValue: scorm2004_constants.objectives_children,
390
- expectedError: read_only,
391
- });
392
- h.checkReadOnly({
393
- cmi: cmi(),
394
- fieldName: 'cmi.objectives._count',
395
- expectedValue: 0,
396
- expectedError: read_only,
397
- });
398
-
399
- it('should export JSON', () => {
400
- const cmiObj = cmi();
401
- cmiObj.objectives.childArray.push(new CMIObjectivesObject());
402
- cmiObj.interactions.childArray.push(new CMIInteractionsObject());
403
- expect(
404
- JSON.stringify(cmiObj),
405
- ).
406
- to.
407
- equal(
408
- '{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message"}');
409
- });
410
- });
411
-
412
- describe('Post-Initialize Tests', () => {
413
- /**
414
- * Base CMI Properties
415
- */
416
- h.checkReadOnly({
417
- cmi: cmiInitialized(),
418
- fieldName: 'cmi._version',
419
- expectedValue: '1.0',
420
- expectedError: read_only,
421
- });
422
- h.checkReadOnly({
423
- cmi: cmiInitialized(),
424
- fieldName: 'cmi._children',
425
- expectedValue: scorm2004_constants.cmi_children,
426
- expectedError: read_only,
427
- });
428
- h.checkValidValues({
429
- cmi: cmiInitialized(),
430
- fieldName: 'cmi.completion_status',
431
- expectedError: type_mismatch,
432
- validValues: scorm2004_values.validCStatus,
433
- invalidValues: scorm2004_values.invalidCStatus,
434
- });
435
- h.checkReadOnly({
436
- cmi: cmiInitialized(),
437
- fieldName: 'cmi.completion_threshold',
438
- expectedError: read_only,
439
- });
440
- h.checkReadOnly({
441
- cmi: cmiInitialized(),
442
- fieldName: 'cmi.credit',
443
- expectedValue: 'credit',
444
- expectedError: read_only,
445
- });
446
- h.checkReadOnly({
447
- cmi: cmiInitialized(),
448
- fieldName: 'cmi.entry',
449
- expectedError: read_only,
450
- });
451
- h.checkWriteOnly({
452
- cmi: cmiInitialized(),
453
- fieldName: 'cmi.exit',
454
- expectedError: write_only,
455
- valueToTest: 'time-out',
456
- });
457
- h.checkValidValues({
458
- cmi: cmiInitialized(),
459
- fieldName: 'cmi.exit',
460
- validValues: scorm2004_values.validExit,
461
- invalidValues: scorm2004_values.invalidExit,
462
- });
463
- h.checkReadOnly({
464
- cmi: cmiInitialized(),
465
- fieldName: 'cmi.launch_data',
466
- expectedError: read_only,
467
- });
468
- h.checkReadOnly({
469
- cmi: cmiInitialized(),
470
- fieldName: 'cmi.learner_id',
471
- expectedError: read_only,
472
- });
473
- h.checkReadOnly({
474
- cmi: cmiInitialized(),
475
- fieldName: 'cmi.learner_name',
476
- expectedError: read_only,
477
- });
478
- h.checkFieldConstraintSize({
479
- cmi: cmiInitialized(),
480
- fieldName: 'cmi.location',
481
- limit: 1000,
482
- expectedError: type_mismatch,
483
- });
484
- h.checkReadOnly({
485
- cmi: cmiInitialized(),
486
- fieldName: 'cmi.max_time_allowed',
487
- expectedError: read_only,
488
- });
489
- h.checkReadOnly({
490
- cmi: cmiInitialized(),
491
- fieldName: 'cmi.mode',
492
- expectedValue: 'normal',
493
- expectedError: read_only,
494
- });
495
- h.checkReadOnly({
496
- cmi: cmiInitialized(),
497
- fieldName: 'cmi.max_time_allowed',
498
- expectedError: read_only,
499
- });
500
- h.checkValidValues({
501
- cmi: cmiInitialized(),
502
- fieldName: 'cmi.progress_measure',
503
- validValues: scorm2004_values.valid0To1Range,
504
- invalidValues: scorm2004_values.invalid0To1Range,
505
- });
506
- h.checkReadOnly({
507
- cmi: cmiInitialized(),
508
- fieldName: 'cmi.scaled_passing_score',
509
- expectedError: read_only,
510
- });
511
- h.checkWriteOnly({
512
- cmi: cmiInitialized(),
513
- fieldName: 'cmi.session_time',
514
- valueToTest: 'P0S',
515
- expectedError: write_only,
516
- });
517
- h.checkValidValues({
518
- cmi: cmiInitialized(),
519
- fieldName: 'cmi.session_time',
520
- validValues: scorm2004_values.validISO8601Durations,
521
- invalidValues: scorm2004_values.invalidISO8601Durations,
522
- });
523
- h.checkRead({
524
- cmi: cmiInitialized(),
525
- fieldName: 'cmi.success_status',
526
- expectedValue: 'unknown',
527
- });
528
- h.checkValidValues({
529
- cmi: cmiInitialized(),
530
- fieldName: 'cmi.success_status',
531
- validValues: scorm2004_values.validSStatus,
532
- invalidValues: scorm2004_values.invalidSStatus,
533
- });
534
- h.checkFieldConstraintSize({
535
- cmi: cmiInitialized(),
536
- fieldName: 'cmi.suspend_data',
537
- limit: 64000,
538
- expectedError: type_mismatch,
539
- });
540
- h.checkReadOnly({
541
- cmi: cmiInitialized(),
542
- fieldName: 'cmi.time_limit_action',
543
- expectedValue: 'continue,no message',
544
- expectedError: read_only,
545
- });
546
- h.checkReadOnly({
547
- cmi: cmiInitialized(),
548
- fieldName: 'cmi.total_time',
549
- expectedValue: '',
550
- expectedError: read_only,
551
- });
552
-
553
- /**
554
- * cmi.learner_preference Properties
555
- */
556
- h.checkReadOnly({
557
- cmi: cmiInitialized(),
558
- fieldName: 'cmi.learner_preference._children',
559
- expectedValue: scorm2004_constants.student_preference_children,
560
- expectedError: read_only,
561
- });
562
- h.checkValidValues({
563
- cmi: cmiInitialized(),
564
- fieldName: 'cmi.learner_preference.audio_level',
565
- validValues: scorm2004_values.valid0To100Range,
566
- invalidValues: scorm2004_values.invalid0To100Range,
567
- });
568
- h.checkValidValues({
569
- cmi: cmiInitialized(),
570
- fieldName: 'cmi.learner_preference.language',
571
- validValues: [
572
- 'en',
573
- 'fr',
574
- 'ru',
575
- 'es',
576
- ],
577
- invalidValues: [
578
- 'invalid',
579
- 'a100',
580
- ],
581
- });
582
- h.checkValidValues({
583
- cmi: cmiInitialized(),
584
- fieldName: 'cmi.learner_preference.delivery_speed',
585
- validValues: scorm2004_values.valid0To100Range,
586
- invalidValues: scorm2004_values.invalid0To100Range,
587
- });
588
- h.checkValidValues({
589
- cmi: cmiInitialized(),
590
- fieldName: 'cmi.learner_preference.audio_captioning',
591
- validValues: scorm2004_values.validIntegerScaledRange,
592
- invalidValues: scorm2004_values.invalidIntegerScaledRange,
593
- });
594
-
595
- /**
596
- * cmi.objectives Properties
597
- */
598
- h.checkReadOnly({
599
- cmi: cmiInitialized(),
600
- fieldName: 'cmi.objectives._children',
601
- expectedValue: scorm2004_constants.objectives_children,
602
- expectedError: read_only,
603
- });
604
- h.checkReadOnly({
605
- cmi: cmiInitialized(),
606
- fieldName: 'cmi.objectives._count',
607
- expectedValue: 0,
608
- expectedError: read_only,
609
- });
610
-
611
- /**
612
- * cmi.score Properties
613
- */
614
- h.checkReadOnly({
615
- cmi: cmiInitialized(),
616
- fieldName: 'cmi.score._children',
617
- expectedValue: scorm2004_constants.score_children,
618
- expectedError: read_only,
619
- });
620
- h.checkValidValues({
621
- cmi: cmiInitialized(),
622
- fieldName: 'cmi.score.scaled',
623
- validValues: scorm2004_values.validScaledRange,
624
- invalidValues: scorm2004_values.invalidScaledRange,
625
- });
626
- h.checkValidValues({
627
- cmi: cmiInitialized(),
628
- fieldName: 'cmi.score.raw',
629
- validValues: scorm2004_values.validScoreRange,
630
- invalidValues: scorm2004_values.invalidScoreRange,
631
- });
632
- h.checkValidValues({
633
- cmi: cmiInitialized(),
634
- fieldName: 'cmi.score.min',
635
- validValues: scorm2004_values.validScoreRange,
636
- invalidValues: scorm2004_values.invalidScoreRange,
637
- });
638
- h.checkValidValues({
639
- cmi: cmiInitialized(),
640
- fieldName: 'cmi.score.max',
641
- validValues: scorm2004_values.validScoreRange,
642
- invalidValues: scorm2004_values.invalidScoreRange,
643
- });
644
-
645
- /**
646
- * cmi.comments_from_learner Properties
647
- */
648
- h.checkReadOnly({
649
- cmi: cmiInitialized(),
650
- fieldName: 'cmi.comments_from_learner._children',
651
- expectedValue: scorm2004_constants.comments_children,
652
- expectedError: read_only,
653
- });
654
- h.checkReadOnly({
655
- cmi: cmiInitialized(),
656
- fieldName: 'cmi.comments_from_learner._count',
657
- expectedValue: 0,
658
- expectedError: read_only,
659
- });
660
-
661
- /**
662
- * cmi.comments_from_lms Properties
663
- */
664
- h.checkReadOnly({
665
- cmi: cmiInitialized(),
666
- fieldName: 'cmi.comments_from_lms._children',
667
- expectedValue: scorm2004_constants.comments_children,
668
- expectedError: read_only,
669
- });
670
- h.checkReadOnly({
671
- cmi: cmiInitialized(),
672
- fieldName: 'cmi.comments_from_lms._count',
673
- expectedValue: 0,
674
- expectedError: read_only,
675
- });
676
-
677
- /**
678
- * cmi.interactions Properties
679
- */
680
- h.checkReadOnly({
681
- cmi: cmiInitialized(),
682
- fieldName: 'cmi.interactions._children',
683
- expectedValue: scorm2004_constants.interactions_children,
684
- expectedError: read_only,
685
- });
686
- h.checkReadOnly({
687
- cmi: cmiInitialized(),
688
- fieldName: 'cmi.interactions._count',
689
- expectedValue: 0,
690
- expectedError: read_only,
691
- });
692
-
693
- /**
694
- * cmi.objectives Properties
695
- */
696
- h.checkReadOnly({
697
- cmi: cmiInitialized(),
698
- fieldName: 'cmi.objectives._children',
699
- expectedValue: scorm2004_constants.objectives_children,
700
- expectedError: read_only,
701
- });
702
- h.checkReadOnly({
703
- cmi: cmiInitialized(),
704
- fieldName: 'cmi.objectives._count',
705
- expectedValue: 0,
706
- expectedError: read_only,
707
- });
708
-
709
- it('should export JSON', () => {
710
- const cmiObj = cmiInitialized();
711
- cmiObj.objectives.childArray.push(new CMIObjectivesObject());
712
- cmiObj.interactions.childArray.push(new CMIInteractionsObject());
713
- expect(
714
- JSON.stringify(cmiObj),
715
- ).
716
- to.
717
- equal(
718
- '{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message"}');
719
- });
720
- });
721
-
722
- describe('CMICommentsObject Tests', () => {
723
- /**
724
- * cmi.comments_from_learner.n object
725
- */
726
- h.checkValidValues({
727
- cmi: comments(),
728
- fieldName: 'cmi.comment',
729
- validValues: scorm2004_values.validComment,
730
- invalidValues: scorm2004_values.invalidComment,
731
- });
732
-
733
- h.checkFieldConstraintSize({
734
- cmi: comments(),
735
- fieldName: 'cmi.location',
736
- expectedError: type_mismatch,
737
- limit: 250,
738
- });
739
-
740
- h.checkReadAndWrite({
741
- cmi: comments(),
742
- fieldName: 'cmi.timestamp',
743
- valueToTest: '2019-06-25T02:30:00',
744
- });
745
- h.checkValidValues({
746
- cmi: comments(),
747
- fieldName: 'cmi.timestamp',
748
- validValues: scorm2004_values.validTimestamps,
749
- invalidValues: scorm2004_values.invalidTimestamps,
750
- });
751
-
752
- it('should export JSON', () => {
753
- const cmi = comments();
754
- expect(
755
- JSON.stringify(cmi),
756
- ).to.equal('{"comment":"","location":"","timestamp":""}');
757
- });
758
- });
759
-
760
- describe('CMICommentsFromLMSObject Tests', () => {
761
- /**
762
- * cmi.comments_from_lms.n object
763
- */
764
- h.checkValidValues({
765
- cmi: lmsComments(),
766
- fieldName: 'cmi.comment',
767
- validValues: scorm2004_values.validComment,
768
- invalidValues: scorm2004_values.invalidComment,
769
- });
770
-
771
- h.checkFieldConstraintSize({
772
- cmi: lmsComments(),
773
- fieldName: 'cmi.location',
774
- expectedError: type_mismatch,
775
- limit: 250,
776
- });
777
-
778
- h.checkReadAndWrite({
779
- cmi: lmsComments(),
780
- fieldName: 'cmi.timestamp',
781
- valueToTest: scorm2004_values.validTimestamps[0],
782
- });
783
- h.checkValidValues({
784
- cmi: lmsComments(),
785
- fieldName: 'cmi.timestamp',
786
- validValues: scorm2004_values.validTimestamps,
787
- invalidValues: scorm2004_values.invalidTimestamps,
788
- });
789
-
790
- h.checkReadOnly({
791
- cmi: lmsCommentsInitialized(),
792
- fieldName: 'cmi.comment',
793
- expectedError: read_only,
794
- });
795
- h.checkReadOnly({
796
- cmi: lmsCommentsInitialized(),
797
- fieldName: 'cmi.location',
798
- expectedError: read_only,
799
- });
800
- h.checkReadOnly({
801
- cmi: lmsCommentsInitialized(),
802
- fieldName: 'cmi.timestamp',
803
- expectedError: read_only,
804
- });
805
-
806
- it('should export JSON', () => {
807
- const cmi = lmsComments();
808
- expect(
809
- JSON.stringify(cmi),
810
- ).to.equal('{"comment":"","location":"","timestamp":""}');
811
- });
812
- });
813
-
814
- describe('CMIInteractionsObject Tests', () => {
815
- /**
816
- * cmi.interactions.n object
817
- */
818
- h.checkReadAndWrite({
819
- cmi: interaction(),
820
- fieldName: 'cmi.id',
821
- });
822
- h.checkReadAndWrite({
823
- cmi: interactionInitialized(),
824
- fieldName: 'cmi.id',
825
- });
826
-
827
- h.checkValidValues({
828
- cmi: interaction(),
829
- fieldName: 'cmi.timestamp',
830
- validValues: scorm2004_values.validTimestamps,
831
- invalidValues: scorm2004_values.invalidTimestamps,
832
- });
833
- h.checkValidValues({
834
- cmi: interaction(),
835
- fieldName: 'cmi.type',
836
- validValues: scorm2004_values.validType,
837
- invalidValues: scorm2004_values.invalidType,
838
- });
839
- h.checkReadOnly({
840
- cmi: interaction(),
841
- fieldName: 'cmi.objectives._count',
842
- expectedValue: 0,
843
- expectedError: read_only,
844
- });
845
- h.checkReadOnly({
846
- cmi: interaction(),
847
- fieldName: 'cmi.correct_responses._count',
848
- expectedValue: 0,
849
- expectedError: read_only,
850
- });
851
- h.checkWrite({
852
- cmi: interaction(),
853
- fieldName: 'cmi.weighting',
854
- valueToTest: '0',
855
- });
856
- h.checkValidValues({
857
- cmi: interaction(),
858
- fieldName: 'cmi.weighting',
859
- validValues: scorm2004_values.validScoreRange,
860
- invalidValues: scorm2004_values.invalidScoreRange,
861
- });
862
-
863
- /**
864
- * TODO: Learner Response depends on first setting Type, so need to build out lots of test cases
865
- */
866
-
867
- h.checkRead({
868
- cmi: interaction(),
869
- fieldName: 'cmi.result',
870
- });
871
- h.checkValidValues({
872
- cmi: interaction(),
873
- fieldName: 'cmi.result',
874
- validValues: scorm2004_values.validResult.concat([
875
- '1',
876
- '999',
877
- '999.99999',
878
- ]),
879
- invalidValues: scorm2004_values.invalidResult,
880
- });
881
- h.checkRead({
882
- cmi: interaction(),
883
- fieldName: 'cmi.latency',
884
- });
885
- h.checkValidValues({
886
- cmi: interaction(),
887
- fieldName: 'cmi.latency',
888
- validValues: scorm2004_values.validISO8601Durations,
889
- invalidValues: scorm2004_values.invalidISO8601Durations,
890
- });
891
-
892
- h.checkValidValues({
893
- cmi: interaction(),
894
- fieldName: 'cmi.description',
895
- validValues: scorm2004_values.validDescription,
896
- invalidValues: scorm2004_values.invalidDescription,
897
- });
898
-
899
- it('should export JSON', () => {
900
- const cmi = interaction();
901
- cmi.objectives.childArray.push(new CMIInteractionsObjectivesObject());
902
- cmi.correct_responses.childArray.push(
903
- new CMIInteractionsCorrectResponsesObject());
904
- expect(
905
- JSON.stringify(cmi),
906
- ).
907
- to.
908
- equal(
909
- '{"id":"","type":"","objectives":{"0":{"id":""}},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{"0":{"pattern":""}}}');
910
- });
911
- });
912
-
913
- describe('CMIObjectivesObject Tests', () => {
914
- /**
915
- * cmi.objectives.n object
916
- */
917
- h.checkReadAndWrite({
918
- cmi: objective(),
919
- fieldName: 'cmi.id',
920
- });
921
- h.checkReadAndWrite({
922
- cmi: objectiveInitialized(),
923
- fieldName: 'cmi.id',
924
- });
925
- h.checkRead({
926
- cmi: objective(),
927
- fieldName: 'cmi.success_status',
928
- expectedValue: 'unknown',
929
- });
930
- h.checkValidValues({
931
- cmi: objective(),
932
- fieldName: 'cmi.success_status',
933
- validValues: scorm2004_values.validSStatus,
934
- invalidValues: scorm2004_values.invalidSStatus,
935
- });
936
- h.checkRead({
937
- cmi: objective(),
938
- fieldName: 'cmi.completion_status',
939
- expectedValue: 'unknown',
940
- });
941
- h.checkValidValues({
942
- cmi: objective(),
943
- fieldName: 'cmi.completion_status',
944
- validValues: scorm2004_values.validCStatus,
945
- invalidValues: scorm2004_values.invalidCStatus,
946
- });
947
- h.checkValidValues({
948
- cmi: objective(),
949
- fieldName: 'cmi.progress_measure',
950
- validValues: scorm2004_values.valid0To1Range,
951
- invalidValues: scorm2004_values.invalid0To1Range,
952
- });
953
- h.checkValidValues({
954
- cmi: objective(),
955
- fieldName: 'cmi.description',
956
- validValues: scorm2004_values.validDescription,
957
- invalidValues: scorm2004_values.invalidDescription,
958
- });
959
-
960
- /**
961
- * cmi.objectives.n.score Properties
962
- */
963
- h.checkReadOnly({
964
- cmi: objective(),
965
- fieldName: 'cmi.score._children',
966
- expectedValue: scorm2004_constants.score_children,
967
- expectedError: read_only,
968
- });
969
- h.checkValidValues({
970
- cmi: objective(),
971
- fieldName: 'cmi.score.scaled',
972
- validValues: scorm2004_values.validScaledRange,
973
- invalidValues: scorm2004_values.invalidScaledRange,
974
- });
975
- h.checkValidValues({
976
- cmi: objective(),
977
- fieldName: 'cmi.score.raw',
978
- validValues: scorm2004_values.validScoreRange,
979
- invalidValues: scorm2004_values.invalidScoreRange,
980
- });
981
- h.checkValidValues({
982
- cmi: objective(),
983
- fieldName: 'cmi.score.min',
984
- validValues: scorm2004_values.validScoreRange,
985
- invalidValues: scorm2004_values.invalidScoreRange,
986
- });
987
- h.checkValidValues({
988
- cmi: objective(),
989
- fieldName: 'cmi.score.max',
990
- validValues: scorm2004_values.validScoreRange,
991
- invalidValues: scorm2004_values.invalidScoreRange,
992
- });
993
-
994
- it('should export JSON', () => {
995
- const cmi = objective();
996
- expect(
997
- JSON.stringify(cmi),
998
- ).
999
- to.
1000
- equal(
1001
- '{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}');
1002
- });
1003
- });
1004
-
1005
- describe('CMIInteractionsObjectivesObject Tests', () => {
1006
- /**
1007
- * cmi.interactions.n.objectives.n object
1008
- */
1009
- h.checkReadAndWrite({
1010
- cmi: interactionObjective(),
1011
- fieldName: 'cmi.id',
1012
- });
1013
-
1014
- it('should export JSON', () => {
1015
- const cmi = interactionObjective();
1016
- expect(
1017
- JSON.stringify(cmi),
1018
- ).to.equal('{"id":""}');
1019
- });
1020
- });
1021
-
1022
- describe('CMIInteractionsCorrectResponsesObject Tests', () => {
1023
- /**
1024
- * cmi.interactions.n.correct_responses.n object
1025
- */
1026
- h.checkReadAndWrite({
1027
- cmi: correctResponse(),
1028
- fieldName: 'cmi.pattern',
1029
- });
1030
-
1031
- it('should export JSON', () => {
1032
- const cmi = correctResponse();
1033
- expect(
1034
- JSON.stringify(cmi),
1035
- ).to.equal('{"pattern":""}');
1036
- });
1037
- });
1038
-
1039
- describe('ADL Tests', () => {
1040
- describe('ADLNav Tests', () => {
1041
- /**
1042
- * cmi.interactions.n.correct_responses.n object
1043
- */
1044
- h.checkRead({
1045
- cmi: adl(),
1046
- fieldName: 'cmi.nav.request',
1047
- expectedValue: '_none_',
1048
- });
1049
-
1050
- h.checkValidValues({
1051
- cmi: adl(),
1052
- fieldName: 'cmi.nav.request',
1053
- validValues: scorm2004_values.validNavRequest,
1054
- invalidValues: scorm2004_values.invalidNavRequest,
1055
- });
1056
-
1057
- it('should export JSON', () => {
1058
- const cmi = adl();
1059
- expect(
1060
- JSON.stringify(cmi),
1061
- ).to.equal('{"nav":{"request":"_none_"}}');
1062
- });
1063
- });
1064
- });
1065
- });
1066
- });