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,19 +1,19 @@
1
- import {describe, it} from 'mocha';
2
- import APIConstants from '../../src/constants/api_constants';
3
- import ErrorCodes from '../../src/constants/error_codes';
1
+ import { describe, it } from "mocha";
2
+ import APIConstants from "../../src/constants/api_constants";
3
+ import ErrorCodes from "../../src/constants/error_codes";
4
4
  import {
5
5
  CMI,
6
6
  CMIEvaluationCommentsObject,
7
7
  CMITriesObject,
8
- } from '../../src/cmi/aicc_cmi';
9
- import * as h from '../cmi_helpers';
8
+ } from "../../src/cmi/aicc_cmi";
9
+ import * as h from "../cmi_helpers";
10
10
  import {
11
11
  CMIInteractionsObject,
12
12
  CMIObjectivesObject,
13
13
  NAV,
14
- } from '../../src/cmi/scorm12_cmi';
15
- import {expect} from 'chai';
16
- import {scorm12_values} from '../field_values';
14
+ } from "../../src/cmi/scorm12_cmi";
15
+ import { expect } from "expect";
16
+ import { scorm12Values } from "../field_values";
17
17
 
18
18
  const aicc_constants = APIConstants.aicc;
19
19
  const scorm12_error_codes = ErrorCodes.scorm12;
@@ -23,9 +23,9 @@ const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
23
23
  const write_only = scorm12_error_codes.WRITE_ONLY_ELEMENT;
24
24
  const read_only = scorm12_error_codes.READ_ONLY_ELEMENT;
25
25
 
26
- describe('AICC CMI Tests', () => {
27
- describe('CMI Spec Tests', () => {
28
- describe('Pre-Initialize Tests', () => {
26
+ describe("AICC CMI Tests", () => {
27
+ describe("CMI Spec Tests", () => {
28
+ describe("Pre-Initialize Tests", () => {
29
29
  const cmi = () => {
30
30
  return new CMI();
31
31
  };
@@ -35,34 +35,36 @@ describe('AICC CMI Tests', () => {
35
35
  */
36
36
  h.checkReadOnly({
37
37
  cmi: cmi(),
38
- fieldName: 'cmi._version',
39
- expectedValue: '3.4',
38
+ fieldName: "cmi._version",
39
+ expectedValue: "3.4",
40
40
  expectedError: invalid_set,
41
41
  });
42
42
  h.checkReadOnly({
43
43
  cmi: cmi(),
44
- fieldName: 'cmi._children',
44
+ fieldName: "cmi._children",
45
45
  expectedValue: aicc_constants.cmi_children,
46
46
  expectedError: invalid_set,
47
47
  });
48
48
 
49
49
  h.checkFieldConstraintSize({
50
50
  cmi: cmi(),
51
- fieldName: 'cmi.suspend_data', limit: 4096,
51
+ fieldName: "cmi.suspend_data",
52
+ limit: 4096,
52
53
  expectedError: type_mismatch,
53
54
  });
54
55
  h.checkReadAndWrite({
55
56
  cmi: cmi(),
56
- fieldName: 'cmi.launch_data',
57
+ fieldName: "cmi.launch_data",
57
58
  });
58
59
  h.checkFieldConstraintSize({
59
60
  cmi: cmi(),
60
- fieldName: 'cmi.comments', limit: 4096,
61
+ fieldName: "cmi.comments",
62
+ limit: 4096,
61
63
  expectedError: type_mismatch,
62
64
  });
63
65
  h.checkReadAndWrite({
64
66
  cmi: cmi(),
65
- fieldName: 'cmi.comments_from_lms',
67
+ fieldName: "cmi.comments_from_lms",
66
68
  });
67
69
 
68
70
  /**
@@ -70,75 +72,75 @@ describe('AICC CMI Tests', () => {
70
72
  */
71
73
  h.checkReadOnly({
72
74
  cmi: cmi(),
73
- fieldName: 'cmi.core._children',
75
+ fieldName: "cmi.core._children",
74
76
  expectedValue: aicc_constants.core_children,
75
77
  expectedError: invalid_set,
76
78
  });
77
79
  h.checkReadAndWrite({
78
80
  cmi: cmi(),
79
- fieldName: 'cmi.core.student_id',
81
+ fieldName: "cmi.core.student_id",
80
82
  });
81
83
  h.checkReadAndWrite({
82
84
  cmi: cmi(),
83
- fieldName: 'cmi.core.student_name',
85
+ fieldName: "cmi.core.student_name",
84
86
  });
85
87
  h.checkFieldConstraintSize({
86
88
  cmi: cmi(),
87
- fieldName: 'cmi.core.lesson_location',
89
+ fieldName: "cmi.core.lesson_location",
88
90
  limit: 255,
89
91
  expectedError: type_mismatch,
90
92
  });
91
93
  h.checkReadAndWrite({
92
94
  cmi: cmi(),
93
- fieldName: 'cmi.core.credit',
95
+ fieldName: "cmi.core.credit",
94
96
  });
95
97
  h.checkRead({
96
98
  cmi: cmi(),
97
- fieldName: 'cmi.core.lesson_status',
98
- expectedValue: 'not attempted',
99
+ fieldName: "cmi.core.lesson_status",
100
+ expectedValue: "not attempted",
99
101
  });
100
102
  h.checkValidValues({
101
103
  cmi: cmi(),
102
- fieldName: 'cmi.core.lesson_status',
103
- validValues: scorm12_values.validLessonStatus,
104
- invalidValues: scorm12_values.invalidLessonStatus,
104
+ fieldName: "cmi.core.lesson_status",
105
+ validValues: scorm12Values.validLessonStatus,
106
+ invalidValues: scorm12Values.invalidLessonStatus,
105
107
  });
106
108
  h.checkReadAndWrite({
107
109
  cmi: cmi(),
108
- fieldName: 'cmi.core.entry',
110
+ fieldName: "cmi.core.entry",
109
111
  });
110
112
  h.checkReadAndWrite({
111
113
  cmi: cmi(),
112
- fieldName: 'cmi.core.total_time',
114
+ fieldName: "cmi.core.total_time",
113
115
  });
114
116
  h.checkReadAndWrite({
115
117
  cmi: cmi(),
116
- fieldName: 'cmi.core.lesson_mode',
117
- expectedValue: 'normal',
118
+ fieldName: "cmi.core.lesson_mode",
119
+ expectedValue: "normal",
118
120
  });
119
121
  h.checkWrite({
120
122
  cmi: cmi(),
121
- fieldName: 'cmi.core.exit',
122
- valueToTest: 'suspend',
123
+ fieldName: "cmi.core.exit",
124
+ valueToTest: "suspend",
123
125
  });
124
126
  h.checkValidValues({
125
127
  cmi: cmi(),
126
- fieldName: 'cmi.core.exit',
127
- validValues: scorm12_values.validExit,
128
- invalidValues: scorm12_values.invalidExit,
128
+ fieldName: "cmi.core.exit",
129
+ validValues: scorm12Values.validExit,
130
+ invalidValues: scorm12Values.invalidExit,
129
131
  });
130
132
 
131
133
  h.checkWriteOnly({
132
134
  cmi: cmi(),
133
- fieldName: 'cmi.core.session_time',
134
- valueToTest: '00:00:00',
135
+ fieldName: "cmi.core.session_time",
136
+ valueToTest: "00:00:00",
135
137
  expectedError: write_only,
136
138
  });
137
139
  h.checkValidValues({
138
140
  cmi: cmi(),
139
- fieldName: 'cmi.core.session_time',
140
- validValues: scorm12_values.validTimespan,
141
- invalidValues: scorm12_values.invalidTimespan,
141
+ fieldName: "cmi.core.session_time",
142
+ validValues: scorm12Values.validTimespan,
143
+ invalidValues: scorm12Values.invalidTimespan,
142
144
  });
143
145
 
144
146
  /**
@@ -146,28 +148,28 @@ describe('AICC CMI Tests', () => {
146
148
  */
147
149
  h.checkReadOnly({
148
150
  cmi: cmi(),
149
- fieldName: 'cmi.core.score._children',
151
+ fieldName: "cmi.core.score._children",
150
152
  expectedValue: aicc_constants.score_children,
151
153
  expectedError: invalid_set,
152
154
  });
153
155
 
154
156
  h.checkValidValues({
155
157
  cmi: cmi(),
156
- fieldName: 'cmi.core.score.raw',
157
- validValues: scorm12_values.validScoreRange,
158
- invalidValues: scorm12_values.invalidScoreRange,
158
+ fieldName: "cmi.core.score.raw",
159
+ validValues: scorm12Values.validScoreRange,
160
+ invalidValues: scorm12Values.invalidScoreRange,
159
161
  });
160
162
  h.checkValidValues({
161
163
  cmi: cmi(),
162
- fieldName: 'cmi.core.score.min',
163
- validValues: scorm12_values.validScoreRange,
164
- invalidValues: scorm12_values.invalidScoreRange,
164
+ fieldName: "cmi.core.score.min",
165
+ validValues: scorm12Values.validScoreRange,
166
+ invalidValues: scorm12Values.invalidScoreRange,
165
167
  });
166
168
  h.checkValidValues({
167
169
  cmi: cmi(),
168
- fieldName: 'cmi.core.score.max',
169
- validValues: scorm12_values.validScoreRange,
170
- invalidValues: scorm12_values.invalidScoreRange,
170
+ fieldName: "cmi.core.score.max",
171
+ validValues: scorm12Values.validScoreRange,
172
+ invalidValues: scorm12Values.invalidScoreRange,
171
173
  });
172
174
 
173
175
  /**
@@ -175,13 +177,14 @@ describe('AICC CMI Tests', () => {
175
177
  */
176
178
  h.checkReadOnly({
177
179
  cmi: cmi(),
178
- fieldName: 'cmi.objectives._children',
180
+ fieldName: "cmi.objectives._children",
179
181
  expectedValue: aicc_constants.objectives_children,
180
182
  expectedError: invalid_set,
181
183
  });
182
184
  h.checkReadOnly({
183
185
  cmi: cmi(),
184
- fieldName: 'cmi.objectives._count', expectedValue: 0,
186
+ fieldName: "cmi.objectives._count",
187
+ expectedValue: 0,
185
188
  expectedError: invalid_set,
186
189
  });
187
190
 
@@ -190,25 +193,25 @@ describe('AICC CMI Tests', () => {
190
193
  */
191
194
  h.checkReadOnly({
192
195
  cmi: cmi(),
193
- fieldName: 'cmi.student_data._children',
196
+ fieldName: "cmi.student_data._children",
194
197
  expectedValue: aicc_constants.student_data_children,
195
198
  expectedError: invalid_set,
196
199
  });
197
200
  h.checkReadAndWrite({
198
201
  cmi: cmi(),
199
- fieldName: 'cmi.student_data.mastery_score',
202
+ fieldName: "cmi.student_data.mastery_score",
200
203
  });
201
204
  h.checkReadAndWrite({
202
205
  cmi: cmi(),
203
- fieldName: 'cmi.student_data.max_time_allowed',
206
+ fieldName: "cmi.student_data.max_time_allowed",
204
207
  });
205
208
  h.checkReadAndWrite({
206
209
  cmi: cmi(),
207
- fieldName: 'cmi.student_data.time_limit_action',
210
+ fieldName: "cmi.student_data.time_limit_action",
208
211
  });
209
212
  h.checkReadAndWrite({
210
213
  cmi: cmi(),
211
- fieldName: 'cmi.student_data.tries_during_lesson',
214
+ fieldName: "cmi.student_data.tries_during_lesson",
212
215
  });
213
216
 
214
217
  /**
@@ -216,35 +219,33 @@ describe('AICC CMI Tests', () => {
216
219
  */
217
220
  h.checkReadOnly({
218
221
  cmi: cmi(),
219
- fieldName: 'cmi.student_preference._children',
222
+ fieldName: "cmi.student_preference._children",
220
223
  expectedValue: aicc_constants.student_preference_children,
221
224
  expectedError: invalid_set,
222
225
  });
223
226
  h.checkValidValues({
224
227
  cmi: cmi(),
225
- fieldName: 'cmi.student_preference.audio',
226
- validValues: scorm12_values.valid0To100Range.concat([
227
- '-1',
228
- ]),
229
- invalidValues: scorm12_values.invalid0To100Range,
228
+ fieldName: "cmi.student_preference.audio",
229
+ validValues: scorm12Values.valid0To100Range.concat(["-1"]),
230
+ invalidValues: scorm12Values.invalid0To100Range,
230
231
  });
231
232
  h.checkFieldConstraintSize({
232
233
  cmi: cmi(),
233
- fieldName: 'cmi.student_preference.language',
234
+ fieldName: "cmi.student_preference.language",
234
235
  limit: 255,
235
236
  expectedError: type_mismatch,
236
237
  });
237
238
  h.checkValidValues({
238
239
  cmi: cmi(),
239
- fieldName: 'cmi.student_preference.speed',
240
- validValues: scorm12_values.validSpeedRange,
241
- invalidValues: scorm12_values.invalidSpeedRange,
240
+ fieldName: "cmi.student_preference.speed",
241
+ validValues: scorm12Values.validSpeedRange,
242
+ invalidValues: scorm12Values.invalidSpeedRange,
242
243
  });
243
244
  h.checkValidValues({
244
245
  cmi: cmi(),
245
- fieldName: 'cmi.student_preference.text',
246
- validValues: scorm12_values.validIntegerScaledRange,
247
- invalidValues: scorm12_values.invalidIntegerScaledRange,
246
+ fieldName: "cmi.student_preference.text",
247
+ validValues: scorm12Values.validIntegerScaledRange,
248
+ invalidValues: scorm12Values.invalidIntegerScaledRange,
248
249
  });
249
250
 
250
251
  /**
@@ -252,18 +253,19 @@ describe('AICC CMI Tests', () => {
252
253
  */
253
254
  h.checkReadOnly({
254
255
  cmi: cmi(),
255
- fieldName: 'cmi.interactions._children',
256
+ fieldName: "cmi.interactions._children",
256
257
  expectedValue: aicc_constants.interactions_children,
257
258
  expectedError: invalid_set,
258
259
  });
259
260
  h.checkReadOnly({
260
261
  cmi: cmi(),
261
- fieldName: 'cmi.interactions._count', expectedValue: 0,
262
+ fieldName: "cmi.interactions._count",
263
+ expectedValue: 0,
262
264
  expectedError: invalid_set,
263
265
  });
264
266
  });
265
267
 
266
- describe('Post-Initialize Tests', () => {
268
+ describe("Post-Initialize Tests", () => {
267
269
  const cmi = () => {
268
270
  const obj = new CMI();
269
271
  obj.initialize();
@@ -275,34 +277,36 @@ describe('AICC CMI Tests', () => {
275
277
  */
276
278
  h.checkReadOnly({
277
279
  cmi: cmi(),
278
- fieldName: 'cmi._version',
279
- expectedValue: '3.4',
280
+ fieldName: "cmi._version",
281
+ expectedValue: "3.4",
280
282
  expectedError: invalid_set,
281
283
  });
282
284
  h.checkReadOnly({
283
285
  cmi: cmi(),
284
- fieldName: 'cmi._children',
286
+ fieldName: "cmi._children",
285
287
  expectedValue: aicc_constants.cmi_children,
286
288
  expectedError: invalid_set,
287
289
  });
288
290
  h.checkFieldConstraintSize({
289
291
  cmi: cmi(),
290
- fieldName: 'cmi.suspend_data', limit: 4096,
292
+ fieldName: "cmi.suspend_data",
293
+ limit: 4096,
291
294
  expectedError: type_mismatch,
292
295
  });
293
296
  h.checkReadOnly({
294
297
  cmi: cmi(),
295
- fieldName: 'cmi.launch_data',
298
+ fieldName: "cmi.launch_data",
296
299
  expectedError: read_only,
297
300
  });
298
301
  h.checkFieldConstraintSize({
299
302
  cmi: cmi(),
300
- fieldName: 'cmi.comments', limit: 4096,
303
+ fieldName: "cmi.comments",
304
+ limit: 4096,
301
305
  expectedError: type_mismatch,
302
306
  });
303
307
  h.checkReadOnly({
304
308
  cmi: cmi(),
305
- fieldName: 'cmi.comments_from_lms',
309
+ fieldName: "cmi.comments_from_lms",
306
310
  expectedError: read_only,
307
311
  });
308
312
 
@@ -311,80 +315,80 @@ describe('AICC CMI Tests', () => {
311
315
  */
312
316
  h.checkReadOnly({
313
317
  cmi: cmi(),
314
- fieldName: 'cmi.core._children',
318
+ fieldName: "cmi.core._children",
315
319
  expectedValue: aicc_constants.core_children,
316
320
  expectedError: invalid_set,
317
321
  });
318
322
  h.checkReadOnly({
319
323
  cmi: cmi(),
320
- fieldName: 'cmi.core.student_id',
324
+ fieldName: "cmi.core.student_id",
321
325
  expectedError: read_only,
322
326
  });
323
327
  h.checkReadOnly({
324
328
  cmi: cmi(),
325
- fieldName: 'cmi.core.student_name',
329
+ fieldName: "cmi.core.student_name",
326
330
  expectedError: read_only,
327
331
  });
328
332
  h.checkFieldConstraintSize({
329
333
  cmi: cmi(),
330
- fieldName: 'cmi.core.lesson_location',
334
+ fieldName: "cmi.core.lesson_location",
331
335
  limit: 255,
332
336
  expectedError: type_mismatch,
333
337
  });
334
338
  h.checkReadOnly({
335
339
  cmi: cmi(),
336
- fieldName: 'cmi.core.credit',
340
+ fieldName: "cmi.core.credit",
337
341
  expectedError: read_only,
338
342
  });
339
343
  h.checkRead({
340
344
  cmi: cmi(),
341
- fieldName: 'cmi.core.lesson_status',
342
- expectedValue: 'not attempted',
345
+ fieldName: "cmi.core.lesson_status",
346
+ expectedValue: "not attempted",
343
347
  });
344
348
  h.checkValidValues({
345
349
  cmi: cmi(),
346
- fieldName: 'cmi.core.lesson_status',
347
- validValues: scorm12_values.validLessonStatus,
348
- invalidValues: scorm12_values.invalidLessonStatus,
350
+ fieldName: "cmi.core.lesson_status",
351
+ validValues: scorm12Values.validLessonStatus,
352
+ invalidValues: scorm12Values.invalidLessonStatus,
349
353
  });
350
354
  h.checkReadOnly({
351
355
  cmi: cmi(),
352
- fieldName: 'cmi.core.entry',
356
+ fieldName: "cmi.core.entry",
353
357
  expectedError: read_only,
354
358
  });
355
359
  h.checkReadOnly({
356
360
  cmi: cmi(),
357
- fieldName: 'cmi.core.total_time',
361
+ fieldName: "cmi.core.total_time",
358
362
  expectedError: read_only,
359
363
  });
360
364
  h.checkReadOnly({
361
365
  cmi: cmi(),
362
- fieldName: 'cmi.core.lesson_mode',
363
- expectedValue: 'normal',
366
+ fieldName: "cmi.core.lesson_mode",
367
+ expectedValue: "normal",
364
368
  expectedError: read_only,
365
369
  });
366
370
  h.checkWrite({
367
371
  cmi: cmi(),
368
- fieldName: 'cmi.core.exit',
369
- valueToTest: 'suspend',
372
+ fieldName: "cmi.core.exit",
373
+ valueToTest: "suspend",
370
374
  });
371
375
  h.checkValidValues({
372
376
  cmi: cmi(),
373
- fieldName: 'cmi.core.exit',
374
- validValues: scorm12_values.validExit,
375
- invalidValues: scorm12_values.invalidExit,
377
+ fieldName: "cmi.core.exit",
378
+ validValues: scorm12Values.validExit,
379
+ invalidValues: scorm12Values.invalidExit,
376
380
  });
377
381
  h.checkWriteOnly({
378
382
  cmi: cmi(),
379
- fieldName: 'cmi.core.session_time',
380
- valueToTest: '00:00:00',
383
+ fieldName: "cmi.core.session_time",
384
+ valueToTest: "00:00:00",
381
385
  expectedError: write_only,
382
386
  });
383
387
  h.checkValidValues({
384
388
  cmi: cmi(),
385
- fieldName: 'cmi.core.session_time',
386
- validValues: scorm12_values.validTimespan,
387
- invalidValues: scorm12_values.invalidTimespan,
389
+ fieldName: "cmi.core.session_time",
390
+ validValues: scorm12Values.validTimespan,
391
+ invalidValues: scorm12Values.invalidTimespan,
388
392
  });
389
393
 
390
394
  /**
@@ -392,27 +396,27 @@ describe('AICC CMI Tests', () => {
392
396
  */
393
397
  h.checkReadOnly({
394
398
  cmi: cmi(),
395
- fieldName: 'cmi.core.score._children',
399
+ fieldName: "cmi.core.score._children",
396
400
  expectedValue: aicc_constants.score_children,
397
401
  expectedError: invalid_set,
398
402
  });
399
403
  h.checkValidValues({
400
404
  cmi: cmi(),
401
- fieldName: 'cmi.core.score.raw',
402
- validValues: scorm12_values.validScoreRange,
403
- invalidValues: scorm12_values.invalidScoreRange,
405
+ fieldName: "cmi.core.score.raw",
406
+ validValues: scorm12Values.validScoreRange,
407
+ invalidValues: scorm12Values.invalidScoreRange,
404
408
  });
405
409
  h.checkValidValues({
406
410
  cmi: cmi(),
407
- fieldName: 'cmi.core.score.min',
408
- validValues: scorm12_values.validScoreRange,
409
- invalidValues: scorm12_values.invalidScoreRange,
411
+ fieldName: "cmi.core.score.min",
412
+ validValues: scorm12Values.validScoreRange,
413
+ invalidValues: scorm12Values.invalidScoreRange,
410
414
  });
411
415
  h.checkValidValues({
412
416
  cmi: cmi(),
413
- fieldName: 'cmi.core.score.max',
414
- validValues: scorm12_values.validScoreRange,
415
- invalidValues: scorm12_values.invalidScoreRange,
417
+ fieldName: "cmi.core.score.max",
418
+ validValues: scorm12Values.validScoreRange,
419
+ invalidValues: scorm12Values.invalidScoreRange,
416
420
  });
417
421
 
418
422
  /**
@@ -420,13 +424,14 @@ describe('AICC CMI Tests', () => {
420
424
  */
421
425
  h.checkReadOnly({
422
426
  cmi: cmi(),
423
- fieldName: 'cmi.objectives._children',
427
+ fieldName: "cmi.objectives._children",
424
428
  expectedValue: aicc_constants.objectives_children,
425
429
  expectedError: invalid_set,
426
430
  });
427
431
  h.checkReadOnly({
428
432
  cmi: cmi(),
429
- fieldName: 'cmi.objectives._count', expectedValue: 0,
433
+ fieldName: "cmi.objectives._count",
434
+ expectedValue: 0,
430
435
  expectedError: invalid_set,
431
436
  });
432
437
 
@@ -435,28 +440,28 @@ describe('AICC CMI Tests', () => {
435
440
  */
436
441
  h.checkReadOnly({
437
442
  cmi: cmi(),
438
- fieldName: 'cmi.student_data._children',
443
+ fieldName: "cmi.student_data._children",
439
444
  expectedValue: aicc_constants.student_data_children,
440
445
  expectedError: invalid_set,
441
446
  });
442
447
  h.checkReadOnly({
443
448
  cmi: cmi(),
444
- fieldName: 'cmi.student_data.mastery_score',
449
+ fieldName: "cmi.student_data.mastery_score",
445
450
  expectedError: read_only,
446
451
  });
447
452
  h.checkReadOnly({
448
453
  cmi: cmi(),
449
- fieldName: 'cmi.student_data.max_time_allowed',
454
+ fieldName: "cmi.student_data.max_time_allowed",
450
455
  expectedError: read_only,
451
456
  });
452
457
  h.checkReadOnly({
453
458
  cmi: cmi(),
454
- fieldName: 'cmi.student_data.time_limit_action',
459
+ fieldName: "cmi.student_data.time_limit_action",
455
460
  expectedError: read_only,
456
461
  });
457
462
  h.checkReadOnly({
458
463
  cmi: cmi(),
459
- fieldName: 'cmi.student_data.tries_during_lesson',
464
+ fieldName: "cmi.student_data.tries_during_lesson",
460
465
  expectedError: read_only,
461
466
  });
462
467
 
@@ -465,35 +470,33 @@ describe('AICC CMI Tests', () => {
465
470
  */
466
471
  h.checkReadOnly({
467
472
  cmi: cmi(),
468
- fieldName: 'cmi.student_preference._children',
473
+ fieldName: "cmi.student_preference._children",
469
474
  expectedValue: aicc_constants.student_preference_children,
470
475
  expectedError: invalid_set,
471
476
  });
472
477
  h.checkValidValues({
473
478
  cmi: cmi(),
474
- fieldName: 'cmi.student_preference.audio',
475
- validValues: scorm12_values.valid0To100Range.concat([
476
- '-1',
477
- ]),
478
- invalidValues: scorm12_values.invalid0To100Range,
479
+ fieldName: "cmi.student_preference.audio",
480
+ validValues: scorm12Values.valid0To100Range.concat(["-1"]),
481
+ invalidValues: scorm12Values.invalid0To100Range,
479
482
  });
480
483
  h.checkFieldConstraintSize({
481
484
  cmi: cmi(),
482
- fieldName: 'cmi.student_preference.language',
485
+ fieldName: "cmi.student_preference.language",
483
486
  limit: 255,
484
487
  expectedError: type_mismatch,
485
488
  });
486
489
  h.checkValidValues({
487
490
  cmi: cmi(),
488
- fieldName: 'cmi.student_preference.speed',
489
- validValues: scorm12_values.validSpeedRange,
490
- invalidValues: scorm12_values.invalidSpeedRange,
491
+ fieldName: "cmi.student_preference.speed",
492
+ validValues: scorm12Values.validSpeedRange,
493
+ invalidValues: scorm12Values.invalidSpeedRange,
491
494
  });
492
495
  h.checkValidValues({
493
496
  cmi: cmi(),
494
- fieldName: 'cmi.student_preference.text',
495
- validValues: scorm12_values.validIntegerScaledRange,
496
- invalidValues: scorm12_values.invalidIntegerScaledRange,
497
+ fieldName: "cmi.student_preference.text",
498
+ validValues: scorm12Values.validIntegerScaledRange,
499
+ invalidValues: scorm12Values.invalidIntegerScaledRange,
497
500
  });
498
501
 
499
502
  /**
@@ -501,33 +504,32 @@ describe('AICC CMI Tests', () => {
501
504
  */
502
505
  h.checkReadOnly({
503
506
  cmi: cmi(),
504
- fieldName: 'cmi.interactions._children',
507
+ fieldName: "cmi.interactions._children",
505
508
  expectedValue: aicc_constants.interactions_children,
506
509
  expectedError: invalid_set,
507
510
  });
508
511
  h.checkReadOnly({
509
512
  cmi: cmi(),
510
- fieldName: 'cmi.interactions._count', expectedValue: 0,
513
+ fieldName: "cmi.interactions._count",
514
+ expectedValue: 0,
511
515
  expectedError: invalid_set,
512
516
  });
513
517
 
514
- it('should export JSON', () => {
518
+ it("should export JSON", () => {
515
519
  const cmiObj = cmi();
516
520
  cmiObj.objectives.childArray.push(new CMIObjectivesObject());
517
521
  cmiObj.interactions.childArray.push(new CMIInteractionsObject());
518
522
  cmiObj.evaluation.comments.childArray.push(
519
- new CMIEvaluationCommentsObject());
523
+ new CMIEvaluationCommentsObject(),
524
+ );
520
525
  cmiObj.student_data.tries.childArray.push(new CMITriesObject());
521
- expect(
522
- JSON.stringify(cmiObj),
523
- ).
524
- to.
525
- equal(
526
- '{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":"","tries":{"0":{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}}},"student_preference":{"audio":"","language":"","lesson_type":"","speed":"","text":"","text_color":"","text_location":"","text_size":"","video":"","windows":{}},"student_demographics":{"city":"","class":"","company":"","country":"","experience":"","familiar_name":"","instructor_name":"","title":"","native_language":"","state":"","street_address":"","telephone":"","years_experience":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}},"evaluation":{"comments":{"0":{"content":"","location":"","time":""}}},"paths":{}}');
526
+ expect(JSON.stringify(cmiObj)).toEqual(
527
+ '{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":"","tries":{"0":{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}}},"student_preference":{"audio":"","language":"","lesson_type":"","speed":"","text":"","text_color":"","text_location":"","text_size":"","video":"","windows":{}},"student_demographics":{"city":"","class":"","company":"","country":"","experience":"","familiar_name":"","instructor_name":"","title":"","native_language":"","state":"","street_address":"","telephone":"","years_experience":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}},"evaluation":{"comments":{"0":{"content":"","location":"","time":""}}},"paths":{}}',
528
+ );
527
529
  });
528
530
  });
529
531
 
530
- describe('CMITriesObject Tests', () => {
532
+ describe("CMITriesObject Tests", () => {
531
533
  const triesObject = () => {
532
534
  return new CMITriesObject();
533
535
  };
@@ -542,31 +544,28 @@ describe('AICC CMI Tests', () => {
542
544
  */
543
545
  h.checkRead({
544
546
  cmi: triesObject(),
545
- fieldName: 'cmi.status',
547
+ fieldName: "cmi.status",
546
548
  });
547
549
  h.checkRead({
548
550
  cmi: triesInitialized(),
549
- fieldName: 'cmi.status',
551
+ fieldName: "cmi.status",
550
552
  });
551
553
  h.checkValidValues({
552
554
  cmi: triesObject(),
553
- fieldName: 'cmi.status',
554
- validValues: scorm12_values.validLessonStatus.concat([
555
- 'not attempted',
556
- ]),
557
- invalidValues: scorm12_values.invalidLessonStatus,
555
+ fieldName: "cmi.status",
556
+ validValues: scorm12Values.validLessonStatus.concat(["not attempted"]),
557
+ invalidValues: scorm12Values.invalidLessonStatus,
558
558
  });
559
559
  h.checkReadAndWrite({
560
560
  cmi: triesObject(),
561
- fieldName: 'cmi.time',
562
- expectedError: write_only,
563
- valueToTest: '23:59:59',
561
+ fieldName: "cmi.time",
562
+ valueToTest: "23:59:59",
564
563
  });
565
564
  h.checkValidValues({
566
565
  cmi: triesObject(),
567
- fieldName: 'cmi.time',
568
- validValues: scorm12_values.validTime,
569
- invalidValues: scorm12_values.invalidTime,
566
+ fieldName: "cmi.time",
567
+ validValues: scorm12Values.validTime,
568
+ invalidValues: scorm12Values.invalidTime,
570
569
  });
571
570
 
572
571
  /**
@@ -574,41 +573,38 @@ describe('AICC CMI Tests', () => {
574
573
  */
575
574
  h.checkReadOnly({
576
575
  cmi: triesObject(),
577
- fieldName: 'cmi.score._children',
576
+ fieldName: "cmi.score._children",
578
577
  expectedValue: aicc_constants.score_children,
579
578
  expectedError: invalid_set,
580
579
  });
581
580
  h.checkValidValues({
582
581
  cmi: triesObject(),
583
- fieldName: 'cmi.score.raw',
584
- validValues: scorm12_values.validScoreRange,
585
- invalidValues: scorm12_values.invalidScoreRange,
582
+ fieldName: "cmi.score.raw",
583
+ validValues: scorm12Values.validScoreRange,
584
+ invalidValues: scorm12Values.invalidScoreRange,
586
585
  });
587
586
  h.checkValidValues({
588
587
  cmi: triesObject(),
589
- fieldName: 'cmi.score.min',
590
- validValues: scorm12_values.validScoreRange,
591
- invalidValues: scorm12_values.invalidScoreRange,
588
+ fieldName: "cmi.score.min",
589
+ validValues: scorm12Values.validScoreRange,
590
+ invalidValues: scorm12Values.invalidScoreRange,
592
591
  });
593
592
  h.checkValidValues({
594
593
  cmi: triesObject(),
595
- fieldName: 'cmi.score.max',
596
- validValues: scorm12_values.validScoreRange,
597
- invalidValues: scorm12_values.invalidScoreRange,
594
+ fieldName: "cmi.score.max",
595
+ validValues: scorm12Values.validScoreRange,
596
+ invalidValues: scorm12Values.invalidScoreRange,
598
597
  });
599
598
 
600
- it('should export JSON', () => {
599
+ it("should export JSON", () => {
601
600
  const cmi = triesObject();
602
- expect(
603
- JSON.stringify(cmi),
604
- ).
605
- to.
606
- equal(
607
- '{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}');
601
+ expect(JSON.stringify(cmi)).toEqual(
602
+ '{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}',
603
+ );
608
604
  });
609
605
  });
610
606
 
611
- describe('CMIEvaluationCommentsObject Tests', () => {
607
+ describe("CMIEvaluationCommentsObject Tests", () => {
612
608
  const evaluationComment = () => {
613
609
  return new CMIEvaluationCommentsObject();
614
610
  };
@@ -618,38 +614,37 @@ describe('AICC CMI Tests', () => {
618
614
  */
619
615
  h.checkFieldConstraintSize({
620
616
  cmi: evaluationComment(),
621
- fieldName: 'cmi.content',
617
+ fieldName: "cmi.content",
622
618
  expectedError: type_mismatch,
623
619
  limit: 255,
624
620
  });
625
621
  h.checkFieldConstraintSize({
626
622
  cmi: evaluationComment(),
627
- fieldName: 'cmi.location',
623
+ fieldName: "cmi.location",
628
624
  expectedError: type_mismatch,
629
625
  limit: 255,
630
626
  });
631
627
  h.checkReadAndWrite({
632
628
  cmi: evaluationComment(),
633
- fieldName: 'cmi.time',
634
- expectedError: write_only,
635
- valueToTest: '23:59:59',
629
+ fieldName: "cmi.time",
630
+ valueToTest: "23:59:59",
636
631
  });
637
632
  h.checkValidValues({
638
633
  cmi: evaluationComment(),
639
- fieldName: 'cmi.time',
640
- validValues: scorm12_values.validTime,
641
- invalidValues: scorm12_values.invalidTime,
634
+ fieldName: "cmi.time",
635
+ validValues: scorm12Values.validTime,
636
+ invalidValues: scorm12Values.invalidTime,
642
637
  });
643
638
 
644
- it('should export JSON', () => {
639
+ it("should export JSON", () => {
645
640
  const cmi = evaluationComment();
646
- expect(
647
- JSON.stringify(cmi),
648
- ).to.equal('{"content":"","location":"","time":""}');
641
+ expect(JSON.stringify(cmi)).toEqual(
642
+ '{"content":"","location":"","time":""}',
643
+ );
649
644
  });
650
645
  });
651
646
 
652
- describe('NAV Tests', () => {
647
+ describe("NAV Tests", () => {
653
648
  const nav = () => {
654
649
  return new NAV();
655
650
  };
@@ -659,25 +654,14 @@ describe('AICC CMI Tests', () => {
659
654
  */
660
655
  h.checkValidValues({
661
656
  cmi: nav(),
662
- fieldName: 'cmi.event',
663
- validValues: [
664
- 'previous',
665
- 'continue',
666
- ],
667
- invalidValues: [
668
- 'P',
669
- 'f',
670
- 'complete',
671
- 'started',
672
- 'in progress',
673
- ],
674
- });
675
-
676
- it('should export JSON', () => {
657
+ fieldName: "cmi.event",
658
+ validValues: ["previous", "continue"],
659
+ invalidValues: ["P", "f", "complete", "started", "in progress"],
660
+ });
661
+
662
+ it("should export JSON", () => {
677
663
  const cmi = nav();
678
- expect(
679
- JSON.stringify(cmi),
680
- ).to.equal('{"event":""}');
664
+ expect(JSON.stringify(cmi)).toEqual('{"event":""}');
681
665
  });
682
666
  });
683
667
  });