scorm-again 2.4.1 → 2.6.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 (87) hide show
  1. package/README.md +23 -23
  2. package/dist/aicc.js +676 -493
  3. package/dist/aicc.js.map +1 -1
  4. package/dist/aicc.min.js +1 -1
  5. package/dist/aicc.min.js.map +1 -1
  6. package/dist/esm/aicc.js +692 -496
  7. package/dist/esm/aicc.js.map +1 -1
  8. package/dist/esm/aicc.min.js +1 -1
  9. package/dist/esm/aicc.min.js.map +1 -1
  10. package/dist/esm/scorm-again.js +1151 -743
  11. package/dist/esm/scorm-again.js.map +1 -1
  12. package/dist/esm/scorm-again.min.js +1 -1
  13. package/dist/esm/scorm-again.min.js.map +1 -1
  14. package/dist/esm/scorm12.js +534 -401
  15. package/dist/esm/scorm12.js.map +1 -1
  16. package/dist/esm/scorm12.min.js +1 -1
  17. package/dist/esm/scorm12.min.js.map +1 -1
  18. package/dist/esm/scorm2004.js +712 -465
  19. package/dist/esm/scorm2004.js.map +1 -1
  20. package/dist/esm/scorm2004.min.js +1 -1
  21. package/dist/esm/scorm2004.min.js.map +1 -1
  22. package/dist/scorm-again.js +1127 -731
  23. package/dist/scorm-again.js.map +1 -1
  24. package/dist/scorm-again.min.js +1 -1
  25. package/dist/scorm-again.min.js.map +1 -1
  26. package/dist/scorm12.js +521 -400
  27. package/dist/scorm12.js.map +1 -1
  28. package/dist/scorm12.min.js +1 -1
  29. package/dist/scorm12.min.js.map +1 -1
  30. package/dist/scorm2004.js +698 -464
  31. package/dist/scorm2004.js.map +1 -1
  32. package/dist/scorm2004.min.js +1 -1
  33. package/dist/scorm2004.min.js.map +1 -1
  34. package/package.json +15 -15
  35. package/src/AICC.ts +3 -0
  36. package/src/BaseAPI.ts +60 -95
  37. package/src/Scorm12API.ts +14 -14
  38. package/src/Scorm2004API.ts +107 -37
  39. package/src/cmi/aicc/attempts.ts +22 -12
  40. package/src/cmi/aicc/cmi.ts +2 -2
  41. package/src/cmi/aicc/core.ts +44 -26
  42. package/src/cmi/aicc/evaluation.ts +31 -12
  43. package/src/cmi/aicc/paths.ts +29 -15
  44. package/src/cmi/aicc/student_data.ts +14 -5
  45. package/src/cmi/aicc/student_demographics.ts +31 -24
  46. package/src/cmi/aicc/student_preferences.ts +11 -11
  47. package/src/cmi/aicc/tries.ts +24 -14
  48. package/src/cmi/aicc/validation.ts +3 -4
  49. package/src/cmi/common/array.ts +17 -5
  50. package/src/cmi/common/base_cmi.ts +3 -1
  51. package/src/cmi/common/score.ts +16 -13
  52. package/src/cmi/scorm12/cmi.ts +25 -10
  53. package/src/cmi/scorm12/interactions.ts +62 -28
  54. package/src/cmi/scorm12/nav.ts +13 -5
  55. package/src/cmi/scorm12/objectives.ts +28 -18
  56. package/src/cmi/scorm12/student_data.ts +15 -8
  57. package/src/cmi/scorm12/student_preference.ts +20 -13
  58. package/src/cmi/scorm12/validation.ts +7 -7
  59. package/src/cmi/scorm2004/adl.ts +141 -25
  60. package/src/cmi/scorm2004/cmi.ts +50 -55
  61. package/src/cmi/scorm2004/comments.ts +21 -20
  62. package/src/cmi/scorm2004/interactions.ts +73 -32
  63. package/src/cmi/scorm2004/learner_preference.ts +20 -13
  64. package/src/cmi/scorm2004/objectives.ts +41 -16
  65. package/src/cmi/scorm2004/score.ts +22 -11
  66. package/src/cmi/scorm2004/validation.ts +4 -4
  67. package/src/constants/api_constants.ts +8 -29
  68. package/src/constants/default_settings.ts +26 -12
  69. package/src/constants/enums.ts +9 -0
  70. package/src/constants/error_codes.ts +5 -12
  71. package/src/constants/regex.ts +5 -11
  72. package/src/constants/response_constants.ts +1 -2
  73. package/src/exceptions/aicc_exceptions.ts +29 -0
  74. package/src/exceptions/scorm12_exceptions.ts +29 -0
  75. package/src/exceptions/scorm2004_exceptions.ts +29 -0
  76. package/src/exceptions.ts +1 -86
  77. package/src/types/api_types.ts +29 -5
  78. package/test/AICC.spec.ts +114 -43
  79. package/test/Scorm12API.spec.ts +37 -39
  80. package/test/Scorm2004API.spec.ts +165 -80
  81. package/test/cmi/aicc_cmi.spec.ts +6 -9
  82. package/test/cmi/scorm12_cmi.spec.ts +8 -8
  83. package/test/cmi/scorm2004_cmi.spec.ts +8 -9
  84. package/test/exceptions.spec.ts +11 -9
  85. package/test/types/api_types.spec.ts +40 -47
  86. package/test/utilities.spec.ts +1 -4
  87. package/webpack.config.js +4 -0
@@ -3,15 +3,17 @@ import { after, before, describe, it } from "mocha";
3
3
  import * as sinon from "sinon";
4
4
  import * as h from "./api_helpers";
5
5
  import Pretender from "fetch-pretender";
6
- import ErrorCodes from "../src/constants/error_codes";
6
+ import { scorm2004_errors } from "../src/constants/error_codes";
7
7
  import { Scorm2004Impl } from "../src/Scorm2004API";
8
8
  import { scorm2004Values } from "./field_values";
9
- import APIConstants from "../src/constants/api_constants";
9
+ import {
10
+ global_constants,
11
+ scorm2004_constants,
12
+ } from "../src/constants/api_constants";
10
13
  import { RefObject, Settings } from "../src/types/api_types";
11
14
  import { DefaultSettings } from "../src/constants/default_settings";
12
- import { CMI } from "../src/cmi/scorm2004/cmi";
13
-
14
- const scorm2004_error_codes = ErrorCodes.scorm2004;
15
+ import { CMIInteractions } from "../src/cmi/scorm2004/interactions";
16
+ import { ADLNav } from "../src/cmi/scorm2004/adl";
15
17
 
16
18
  let clock: sinon.SinonFakeTimers;
17
19
  const api = (settings?: Settings, startingData: RefObject = {}) => {
@@ -90,77 +92,146 @@ describe("SCORM 2004 API Tests", () => {
90
92
  h.checkSetCMIValue({
91
93
  api: api(),
92
94
  fieldName: "cmi._version",
93
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
95
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
94
96
  });
95
97
  h.checkSetCMIValue({
96
98
  api: api(),
97
99
  fieldName: "cmi._children",
98
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
100
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
99
101
  });
100
102
  h.checkSetCMIValue({
101
103
  api: api(),
102
104
  fieldName: "cmi.comments_from_learner._children",
103
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
105
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
104
106
  });
105
107
  h.checkSetCMIValue({
106
108
  api: api(),
107
109
  fieldName: "cmi.comments_from_learner._count",
108
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
110
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
109
111
  });
110
112
  h.checkSetCMIValue({
111
113
  api: api(),
112
114
  fieldName: "cmi.comments_from_lms._children",
113
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
115
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
114
116
  });
115
117
  h.checkSetCMIValue({
116
118
  api: api(),
117
119
  fieldName: "cmi.comments_from_lms._count",
118
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
120
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
119
121
  });
120
122
  h.checkSetCMIValue({
121
123
  api: api(),
122
124
  fieldName: "cmi.interactions._children",
123
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
125
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
124
126
  });
125
127
  h.checkSetCMIValue({
126
128
  api: api(),
127
129
  fieldName: "cmi.interactions._count",
128
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
130
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
129
131
  });
130
132
  h.checkSetCMIValue({
131
133
  api: api(),
132
134
  fieldName: "cmi.interactions.0.objectives._count",
133
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
135
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
134
136
  });
135
137
  h.checkSetCMIValue({
136
138
  api: api(),
137
139
  fieldName: "cmi.interactions.0.correct_responses._count",
138
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
140
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
139
141
  });
140
142
  h.checkSetCMIValue({
141
143
  api: api(),
142
144
  fieldName: "cmi.learner_preference._children",
143
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
145
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
144
146
  });
145
147
  h.checkSetCMIValue({
146
148
  api: api(),
147
149
  fieldName: "cmi.objectives._children",
148
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
150
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
149
151
  });
150
152
  h.checkSetCMIValue({
151
153
  api: api(),
152
154
  fieldName: "cmi.objectives._count",
153
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
155
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
154
156
  });
155
157
  h.checkSetCMIValue({
156
158
  api: api(),
157
159
  fieldName: "cmi.objectives.0.score._children",
158
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
160
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
159
161
  });
160
162
  h.checkSetCMIValue({
161
163
  api: api(),
162
164
  fieldName: "cmi.score._children",
163
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
165
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
166
+ });
167
+ });
168
+
169
+ describe("Setting cmi.objectives.n.* should update globalObjectives if it exists", () => {
170
+ it("should update globalObjectives if it exists", () => {
171
+ const scorm2004API = api({
172
+ globalObjectiveIds: ["Objective 1"],
173
+ });
174
+
175
+ scorm2004API.setCMIValue("cmi.objectives.0.id", "Objective 1");
176
+ scorm2004API.setCMIValue("cmi.objectives.0.score.raw", "100");
177
+ scorm2004API.setCMIValue("cmi.objectives.0.score.min", "0");
178
+ scorm2004API.setCMIValue("cmi.objectives.0.score.max", "100");
179
+ scorm2004API.setCMIValue("cmi.objectives.0.success_status", "passed");
180
+ scorm2004API.setCMIValue(
181
+ "cmi.objectives.0.completion_status",
182
+ "completed",
183
+ );
184
+ scorm2004API.setCMIValue("cmi.objectives.0.progress_measure", "1");
185
+
186
+ scorm2004API.setCMIValue("cmi.objectives.1.id", "Objective 2");
187
+ scorm2004API.setCMIValue("cmi.objectives.1.score.raw", "100");
188
+ scorm2004API.setCMIValue("cmi.objectives.1.score.min", "0");
189
+ scorm2004API.setCMIValue("cmi.objectives.1.score.max", "100");
190
+ scorm2004API.setCMIValue("cmi.objectives.1.success_status", "failed");
191
+ scorm2004API.setCMIValue(
192
+ "cmi.objectives.1.completion_status",
193
+ "incomplete",
194
+ );
195
+ scorm2004API.setCMIValue("cmi.objectives.1.progress_measure", "0.5");
196
+
197
+ const globalObjective = scorm2004API.globalObjectives.find(
198
+ (objective) => objective.id === "Objective 1",
199
+ );
200
+
201
+ expect(scorm2004API.getCMIValue("cmi.objectives.0.id")).toEqual(
202
+ "Objective 1",
203
+ );
204
+ expect(scorm2004API.getCMIValue("cmi.objectives.0.score.raw")).toEqual(
205
+ "100",
206
+ );
207
+ expect(scorm2004API.getCMIValue("cmi.objectives.0.score.min")).toEqual(
208
+ "0",
209
+ );
210
+ expect(scorm2004API.getCMIValue("cmi.objectives.0.score.max")).toEqual(
211
+ "100",
212
+ );
213
+ expect(
214
+ scorm2004API.getCMIValue("cmi.objectives.0.success_status"),
215
+ ).toEqual("passed");
216
+ expect(
217
+ scorm2004API.getCMIValue("cmi.objectives.0.completion_status"),
218
+ ).toEqual("completed");
219
+ expect(
220
+ scorm2004API.getCMIValue("cmi.objectives.0.progress_measure"),
221
+ ).toEqual("1");
222
+
223
+ expect(globalObjective?.id).toEqual("Objective 1");
224
+ expect(globalObjective?.score.raw).toEqual("100");
225
+ expect(globalObjective?.score.min).toEqual("0");
226
+ expect(globalObjective?.score.max).toEqual("100");
227
+ expect(globalObjective?.success_status).toEqual("passed");
228
+ expect(globalObjective?.completion_status).toEqual("completed");
229
+ expect(globalObjective?.progress_measure).toEqual("1");
230
+
231
+ const globalObjective2 = scorm2004API.globalObjectives.find(
232
+ (objective) => objective.id === "Objective 2",
233
+ );
234
+ expect(globalObjective2).toBe(undefined);
164
235
  });
165
236
  });
166
237
 
@@ -168,72 +239,72 @@ describe("SCORM 2004 API Tests", () => {
168
239
  h.checkSetCMIValue({
169
240
  api: apiInitialized(),
170
241
  fieldName: "cmi.completion_threshold",
171
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
242
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
172
243
  });
173
244
  h.checkSetCMIValue({
174
245
  api: apiInitialized(),
175
246
  fieldName: "cmi.credit",
176
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
247
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
177
248
  });
178
249
  h.checkSetCMIValue({
179
250
  api: apiInitialized(),
180
251
  fieldName: "cmi.entry",
181
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
252
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
182
253
  });
183
254
  h.checkSetCMIValue({
184
255
  api: apiInitialized(),
185
256
  fieldName: "cmi.launch_data",
186
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
257
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
187
258
  });
188
259
  h.checkSetCMIValue({
189
260
  api: apiInitialized(),
190
261
  fieldName: "cmi.learner_id",
191
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
262
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
192
263
  });
193
264
  h.checkSetCMIValue({
194
265
  api: apiInitialized(),
195
266
  fieldName: "cmi.learner_name",
196
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
267
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
197
268
  });
198
269
  h.checkSetCMIValue({
199
270
  api: apiInitialized(),
200
271
  fieldName: "cmi.max_time_allowed",
201
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
272
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
202
273
  });
203
274
  h.checkSetCMIValue({
204
275
  api: apiInitialized(),
205
276
  fieldName: "cmi.mode",
206
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
277
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
207
278
  });
208
279
  h.checkSetCMIValue({
209
280
  api: apiInitialized(),
210
281
  fieldName: "cmi.scaled_passing_score",
211
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
282
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
212
283
  });
213
284
  h.checkSetCMIValue({
214
285
  api: apiInitialized(),
215
286
  fieldName: "cmi.time_limit_action",
216
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
287
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
217
288
  });
218
289
  h.checkSetCMIValue({
219
290
  api: apiInitialized(),
220
291
  fieldName: "cmi.total_time",
221
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
292
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
222
293
  });
223
294
  h.checkSetCMIValue({
224
295
  api: apiInitialized(),
225
296
  fieldName: "cmi.comments_from_lms.0.comment",
226
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
297
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
227
298
  });
228
299
  h.checkSetCMIValue({
229
300
  api: apiInitialized(),
230
301
  fieldName: "cmi.comments_from_lms.0.location",
231
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
302
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
232
303
  });
233
304
  h.checkSetCMIValue({
234
305
  api: apiInitialized(),
235
306
  fieldName: "cmi.comments_from_lms.0.timestamp",
236
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
307
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
237
308
  });
238
309
  });
239
310
  });
@@ -243,19 +314,19 @@ describe("SCORM 2004 API Tests", () => {
243
314
  h.checkLMSGetValue({
244
315
  api: apiInitialized(),
245
316
  fieldName: "cmi.core.close",
246
- expectedError: scorm2004_error_codes.UNDEFINED_DATA_MODEL,
317
+ expectedError: scorm2004_errors.UNDEFINED_DATA_MODEL,
247
318
  errorThrown: false,
248
319
  });
249
320
  h.checkLMSGetValue({
250
321
  api: apiInitialized(),
251
322
  fieldName: "cmi.core.exit",
252
- expectedError: scorm2004_error_codes.UNDEFINED_DATA_MODEL,
323
+ expectedError: scorm2004_errors.UNDEFINED_DATA_MODEL,
253
324
  errorThrown: false,
254
325
  });
255
326
  h.checkLMSGetValue({
256
327
  api: apiInitialized(),
257
328
  fieldName: "cmi.core.entry",
258
- expectedError: scorm2004_error_codes.UNDEFINED_DATA_MODEL,
329
+ expectedError: scorm2004_errors.UNDEFINED_DATA_MODEL,
259
330
  errorThrown: false,
260
331
  });
261
332
  });
@@ -264,12 +335,12 @@ describe("SCORM 2004 API Tests", () => {
264
335
  h.checkLMSGetValue({
265
336
  api: apiInitialized(),
266
337
  fieldName: "cmi.exit",
267
- expectedError: scorm2004_error_codes.WRITE_ONLY_ELEMENT,
338
+ expectedError: scorm2004_errors.WRITE_ONLY_ELEMENT,
268
339
  });
269
340
  h.checkLMSGetValue({
270
341
  api: apiInitialized(),
271
342
  fieldName: "cmi.session_time",
272
- expectedError: scorm2004_error_codes.WRITE_ONLY_ELEMENT,
343
+ expectedError: scorm2004_errors.WRITE_ONLY_ELEMENT,
273
344
  });
274
345
  });
275
346
  });
@@ -279,26 +350,37 @@ describe("SCORM 2004 API Tests", () => {
279
350
  h.checkLMSSetValue({
280
351
  api: api(),
281
352
  fieldName: "cmi.objectives.0.id",
282
- expectedError: scorm2004_error_codes.STORE_BEFORE_INIT,
353
+ expectedError: scorm2004_errors.STORE_BEFORE_INIT,
283
354
  });
284
355
  h.checkLMSSetValue({
285
356
  api: api(),
286
357
  fieldName: "cmi.interactions.0.id",
287
- expectedError: scorm2004_error_codes.STORE_BEFORE_INIT,
358
+ expectedError: scorm2004_errors.STORE_BEFORE_INIT,
288
359
  });
289
360
  h.checkLMSSetValue({
290
361
  api: api(),
291
362
  fieldName: "cmi.comments_from_learner.0.comment",
292
- expectedError: scorm2004_error_codes.STORE_BEFORE_INIT,
363
+ expectedError: scorm2004_errors.STORE_BEFORE_INIT,
293
364
  });
294
365
  h.checkLMSSetValue({
295
366
  api: api(),
296
367
  fieldName: "cmi.comments_from_lms.0.comment",
297
- expectedError: scorm2004_error_codes.STORE_BEFORE_INIT,
368
+ expectedError: scorm2004_errors.STORE_BEFORE_INIT,
369
+ });
370
+ h.checkLMSSetValue({
371
+ api: api(),
372
+ fieldName: "adl.data.0.store",
373
+ expectedError: scorm2004_errors.STORE_BEFORE_INIT,
298
374
  });
299
375
  });
300
376
 
301
377
  describe("Initialized - Should Succeed", () => {
378
+ h.checkLMSSetValue({
379
+ api: apiInitialized(),
380
+ fieldName: "adl.data.0.store",
381
+ valueToTest: "comment",
382
+ errorThrown: false,
383
+ });
302
384
  h.checkLMSSetValue({
303
385
  api: apiInitialized(),
304
386
  fieldName: "cmi.objectives.0.id",
@@ -468,7 +550,7 @@ describe("SCORM 2004 API Tests", () => {
468
550
  valueToTest:
469
551
  "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer et sodales purus, in aliquam ex. Nunc suscipit interdum tortor ut hendrerit. Donec auctor erat suscipit justo hendrerit, at lacinia ipsum ullamcorper. Cras sollicitudin vestibulum malesuada. Sed non nibh pharetra, suscipit ipsum sed, maximus tortor. Morbi pharetra accumsan turpis id fringilla. In volutpat metus a dui semper, nec tincidunt nibh aliquam. Praesent viverra neque in elementum commodo. Integer hendrerit placerat ante, ac finibus urna tincidunt at. Phasellus consectetur mauris vitae orci viverra luctus. Proin vestibulum blandit mauris quis pellentesque. Proin volutpat hendrerit nisi. Etiam pellentesque urna nec massa congue ultricies. Mauris at eros viverra, posuere tortor id, elementum nisi. In hac habitasse platea dictumst. Pellentesque semper tristique arcu, in tristique metus. Vestibulum ut lacus dui. Aenean mattis malesuada arcu non ullamcorper. Suspendisse tincidunt euismod tincidunt. In tincidunt at nunc rhoncus vehicula. Quisque nulla massa, vestibulum nec laoreet sit amet, posuere eu massa. Donec accumsan efficitur turpis, quis eleifend odio aliquam a. Phasellus placerat ante id dui consectetur dictum. Morbi aliquam, nibh id elementum suscipit, neque ante scelerisque velit, at feugiat turpis odio ac ligula. Phasellus vel urna nulla. Donec vulputate nulla vel purus pellentesque gravida. Vestibulum rutrum, est vel cursus ultrices, orci arcu scelerisque magna, id facilisis mauris arcu ut turpis. Vestibulum consectetur faucibus ante, eu posuere quam ornare et. Aenean vitae dictum neque. Donec nisl justo, porta a sapien quis, luctus congue diam. Integer id metus dolor. Maecenas euismod vulputate leo in lobortis. Vestibulum dignissim finibus est, sed sollicitudin ipsum hendrerit ac. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Pellentesque diam lorem, mattis vel orci interdum, tempor luctus elit. Ut id porta nisi. In dignissim quam urna, et iaculis lectus eleifend ut. Nam vitae felis ac risus tincidunt elementum. Nunc hendrerit augue a nulla hendrerit rutrum. Integer euismod est at orci eleifend, sed laoreet justo auctor. Sed sem orci, imperdiet at erat non, vehicula convallis libero. Aenean hendrerit cursus leo ut malesuada. Donec eu placerat lorem. Sed mattis tristique lorem, eget placerat erat scelerisque faucibus. Vivamus eleifend in augue id mollis. Nulla vehicula, metus eu auctor accumsan, lectus sapien pretium dui, non scelerisque magna augue a sem. Suspendisse sem enim, mattis ac augue non, placerat accumsan sem. Vivamus hendrerit, sapien sit amet consectetur pulvinar, ante nisl pulvinar purus, a ullamcorper dolor leo id arcu. Aliquam sed metus arcu. Quisque erat libero, tincidunt non dictum vel, bibendum ut ante. Nunc vel imperdiet risus. Sed sit amet porta enim. Mauris metus tortor, mattis vitae convallis vitae, dictum nec dui. Aliquam volutpat nisi consequat, gravida tellus eget, cursus purus. Nunc at venenatis enim. Proin dictum, magna ultrices tempor aliquam, metus lacus consectetur odio, quis pharetra massa est at est. Nullam non nibh massa. Duis scelerisque massa a luctus vehicula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec tortor lacus, consequat eget neque sit amet, imperdiet porttitor felis. Duis ante erat, cursus sed venenatis nec, semper sollicitudin felis. Sed tincidunt et tortor quis vehicula. Morbi porta dapibus quam quis iaculis. Nunc mauris dolor, rutrum non pellentesque consectetur, ornare quis lacus. Maecenas eget feugiat odio. Proin vitae magna ut justo bibendum lacinia consequat at orci. Phasellus tincidunt lorem eu justo mollis sagittis. Maecenas fermentum nunc augue, et bibendum augue varius venenatis. Donec eu purus at tellus ullamcorper imperdiet. Duis id orci laoreet, semper eros et, tincidunt nisl. Suspendisse vehicula sed enim ut dignissim. Nam ornare leo eu nibh malesuada, eget ullamcorper sapien egestas. In at commod1",
470
552
  errorThrown: false,
471
- expectedError: scorm2004_error_codes.TYPE_MISMATCH,
553
+ expectedError: scorm2004_errors.TYPE_MISMATCH,
472
554
  });
473
555
  h.checkLMSSetValue({
474
556
  api: apiInitialized({
@@ -484,105 +566,105 @@ describe("SCORM 2004 API Tests", () => {
484
566
  fieldName: "cmi.interactions.0.type",
485
567
  valueToTest: "unknown",
486
568
  errorThrown: false,
487
- expectedError: scorm2004_error_codes.TYPE_MISMATCH,
569
+ expectedError: scorm2004_errors.TYPE_MISMATCH,
488
570
  });
489
571
  h.checkLMSSetValue({
490
572
  api: apiInitialized(),
491
573
  fieldName: "cmi.interactions.0.type",
492
574
  valueToTest: "true-false",
493
575
  errorThrown: false,
494
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
576
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
495
577
  });
496
578
  h.checkLMSSetValue({
497
579
  api: apiInitialized(),
498
580
  fieldName: "cmi.interactions.0.description",
499
581
  valueToTest: "this is an interaction",
500
582
  errorThrown: false,
501
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
583
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
502
584
  });
503
585
  h.checkLMSSetValue({
504
586
  api: apiInitialized(),
505
587
  fieldName: "cmi.interactions.0.timestamp",
506
588
  valueToTest: "PT1S",
507
589
  errorThrown: false,
508
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
590
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
509
591
  });
510
592
  h.checkLMSSetValue({
511
593
  api: apiInitialized(),
512
594
  fieldName: "cmi.interactions.0.weighting",
513
595
  valueToTest: 1.0,
514
596
  errorThrown: false,
515
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
597
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
516
598
  });
517
599
  h.checkLMSSetValue({
518
600
  api: apiInitialized(),
519
601
  fieldName: "cmi.interactions.0.learner_response",
520
602
  valueToTest: "true",
521
603
  errorThrown: false,
522
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
604
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
523
605
  });
524
606
  h.checkLMSSetValue({
525
607
  api: apiInitialized(),
526
608
  fieldName: "cmi.interactions.0.latency",
527
609
  valueToTest: "PT1S",
528
610
  errorThrown: false,
529
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
611
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
530
612
  });
531
613
  h.checkLMSSetValue({
532
614
  api: apiInitialized(),
533
615
  fieldName: "cmi.objectives.0.success_status",
534
616
  valueToTest: "passed",
535
617
  errorThrown: false,
536
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
618
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
537
619
  });
538
620
  h.checkLMSSetValue({
539
621
  api: apiInitialized(),
540
622
  fieldName: "cmi.objectives.0.completion_status",
541
623
  valueToTest: "completed",
542
624
  errorThrown: false,
543
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
625
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
544
626
  });
545
627
  h.checkLMSSetValue({
546
628
  api: apiInitialized(),
547
629
  fieldName: "cmi.objectives.0.progress_measure",
548
630
  valueToTest: 1.0,
549
631
  errorThrown: false,
550
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
632
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
551
633
  });
552
634
  h.checkLMSSetValue({
553
635
  api: apiInitialized(),
554
636
  fieldName: "cmi.objectives.0.description",
555
637
  valueToTest: "this is an objective",
556
638
  errorThrown: false,
557
- expectedError: scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED,
639
+ expectedError: scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED,
558
640
  });
559
641
  h.checkLMSSetValue({
560
642
  api: apiInitialized(),
561
643
  fieldName: "cmi.comments_from_lms.0.comment",
562
644
  valueToTest: "comment",
563
645
  errorThrown: false,
564
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
646
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
565
647
  });
566
648
  h.checkLMSSetValue({
567
649
  api: apiInitialized(),
568
650
  fieldName: "cmi.comments_from_lms.0.location",
569
651
  valueToTest: "location",
570
652
  errorThrown: false,
571
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
653
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
572
654
  });
573
655
  h.checkLMSSetValue({
574
656
  api: apiInitialized(),
575
657
  fieldName: "cmi.comments_from_lms.0.timestamp",
576
658
  valueToTest: scorm2004Values.validTimestamps[0],
577
659
  errorThrown: false,
578
- expectedError: scorm2004_error_codes.READ_ONLY_ELEMENT,
660
+ expectedError: scorm2004_errors.READ_ONLY_ELEMENT,
579
661
  });
580
662
  h.checkLMSSetValue({
581
663
  api: apiInitialized(),
582
664
  fieldName: "cmi.unknown",
583
665
  valueToTest: "uknown",
584
666
  errorThrown: false,
585
- expectedError: scorm2004_error_codes.UNDEFINED_DATA_MODEL,
667
+ expectedError: scorm2004_errors.UNDEFINED_DATA_MODEL,
586
668
  });
587
669
  });
588
670
  });
@@ -592,10 +674,13 @@ describe("SCORM 2004 API Tests", () => {
592
674
  const scorm2004API = api();
593
675
  scorm2004API.cmi.learner_id = "student_1";
594
676
  scorm2004API.cmi.session_time = "PT1H0M0S";
677
+ scorm2004API.adl.nav.request = "continue";
595
678
 
596
679
  scorm2004API.reset();
597
680
 
598
- expect(scorm2004API.cmi).toEqual(new CMI());
681
+ expect(scorm2004API.cmi.interactions).toEqual(new CMIInteractions());
682
+ expect(scorm2004API.cmi.learner_id).toEqual("student_1");
683
+ expect(scorm2004API.adl.nav).toEqual(new ADLNav());
599
684
  });
600
685
 
601
686
  it("should keep original settings", () => {
@@ -663,9 +748,9 @@ describe("SCORM 2004 API Tests", () => {
663
748
  it("should call internalFinish and return SCORM_TRUE", async () => {
664
749
  const internalFinishStub = sinon
665
750
  .stub(scorm2004API, "internalFinish")
666
- .resolves(APIConstants.global.SCORM_TRUE);
751
+ .resolves(global_constants.SCORM_TRUE);
667
752
  const result = scorm2004API.lmsFinish();
668
- expect(result).toEqual(APIConstants.global.SCORM_TRUE);
753
+ expect(result).toEqual(global_constants.SCORM_TRUE);
669
754
  expect(internalFinishStub.calledOnce).toBe(true);
670
755
  internalFinishStub.restore();
671
756
  });
@@ -685,14 +770,14 @@ describe("SCORM 2004 API Tests", () => {
685
770
  };
686
771
 
687
772
  it("should call terminate with 'Terminate' and true", async () => {
688
- terminateStub.resolves(APIConstants.global.SCORM_TRUE);
773
+ terminateStub.resolves(global_constants.SCORM_TRUE);
689
774
  await scorm2004API.internalFinish();
690
775
  expect(terminateStub.calledWith("Terminate", true)).toBe(true);
691
776
  });
692
777
 
693
778
  for (const navRequest of Object.keys(navActions)) {
694
779
  it(`should process the correct navigation action based on adl.nav.request = ${navRequest}`, async () => {
695
- terminateStub.resolves(APIConstants.global.SCORM_TRUE);
780
+ terminateStub.resolves(global_constants.SCORM_TRUE);
696
781
  scorm2004API.adl.nav.request = navRequest;
697
782
  await scorm2004API.internalFinish();
698
783
  expect(processListenersSpy.calledWith(navActions[navRequest])).toBe(
@@ -702,7 +787,7 @@ describe("SCORM 2004 API Tests", () => {
702
787
  }
703
788
 
704
789
  it("should process 'SequenceNext' if adl.nav.request is '_none_' and autoProgress is true", async () => {
705
- terminateStub.resolves(APIConstants.global.SCORM_TRUE);
790
+ terminateStub.resolves(global_constants.SCORM_TRUE);
706
791
  scorm2004API.adl.nav.request = "_none_";
707
792
  scorm2004API.settings.autoProgress = true;
708
793
  await scorm2004API.internalFinish();
@@ -710,7 +795,7 @@ describe("SCORM 2004 API Tests", () => {
710
795
  });
711
796
 
712
797
  it("should not process any action if adl.nav.request is '_none_' and autoProgress is false", async () => {
713
- terminateStub.resolves(APIConstants.global.SCORM_TRUE);
798
+ terminateStub.resolves(global_constants.SCORM_TRUE);
714
799
  scorm2004API.adl.nav.request = "_none_";
715
800
  scorm2004API.settings.autoProgress = false;
716
801
  await scorm2004API.internalFinish();
@@ -718,9 +803,9 @@ describe("SCORM 2004 API Tests", () => {
718
803
  });
719
804
 
720
805
  it("should return the result of terminate", async () => {
721
- terminateStub.resolves(APIConstants.global.SCORM_TRUE);
806
+ terminateStub.resolves(global_constants.SCORM_TRUE);
722
807
  const result = await scorm2004API.internalFinish();
723
- expect(result).toEqual(APIConstants.global.SCORM_TRUE);
808
+ expect(result).toEqual(global_constants.SCORM_TRUE);
724
809
  });
725
810
  });
726
811
  });
@@ -731,9 +816,9 @@ describe("SCORM 2004 API Tests", () => {
731
816
  it("should call commit and return SCORM_TRUE", async () => {
732
817
  const commitStub = sinon
733
818
  .stub(scorm2004API, "commit")
734
- .resolves(APIConstants.global.SCORM_TRUE);
819
+ .resolves(global_constants.SCORM_TRUE);
735
820
  const result = scorm2004API.lmsCommit();
736
- expect(result).toEqual(APIConstants.global.SCORM_TRUE);
821
+ expect(result).toEqual(global_constants.SCORM_TRUE);
737
822
  expect(commitStub.calledOnce).toBe(true);
738
823
  commitStub.restore();
739
824
  });
@@ -900,10 +985,10 @@ describe("SCORM 2004 API Tests", () => {
900
985
  describe("lmsGetDiagnostic()", () => {
901
986
  it("should return diagnostic information for a given error code", () => {
902
987
  const scorm2004API = api();
903
- const errorCode = scorm2004_error_codes.GENERAL;
988
+ const errorCode = scorm2004_errors.GENERAL;
904
989
  const diagnosticInfo = scorm2004API.lmsGetDiagnostic(errorCode);
905
990
  expect(diagnosticInfo).toEqual(
906
- APIConstants.scorm2004.error_descriptions[errorCode].detailMessage,
991
+ scorm2004_constants.error_descriptions[errorCode].detailMessage,
907
992
  );
908
993
  });
909
994
 
@@ -918,7 +1003,7 @@ describe("SCORM 2004 API Tests", () => {
918
1003
  describe("lmsGetErrorString()", () => {
919
1004
  it("should return the error string for a given error code", () => {
920
1005
  const scorm2004API = api();
921
- const errorCode = scorm2004_error_codes.GENERAL;
1006
+ const errorCode = scorm2004_errors.GENERAL;
922
1007
  const errorString = scorm2004API.lmsGetErrorString(errorCode);
923
1008
  expect(errorString).toEqual("General Exception");
924
1009
  });
@@ -952,7 +1037,7 @@ describe("SCORM 2004 API Tests", () => {
952
1037
  const scorm2004API = new Scorm2004Impl();
953
1038
  scorm2004API.checkCorrectResponseValue("true-false", ["unknown"], "true");
954
1039
  expect(scorm2004API.lmsGetLastError()).toEqual(
955
- String(scorm2004_error_codes.TYPE_MISMATCH),
1040
+ String(scorm2004_errors.TYPE_MISMATCH),
956
1041
  );
957
1042
  });
958
1043
 
@@ -970,7 +1055,7 @@ describe("SCORM 2004 API Tests", () => {
970
1055
  "true",
971
1056
  );
972
1057
  expect(scorm2004API.lmsGetLastError()).toEqual(
973
- String(scorm2004_error_codes.TYPE_MISMATCH),
1058
+ String(scorm2004_errors.TYPE_MISMATCH),
974
1059
  );
975
1060
  });
976
1061
 
@@ -1038,7 +1123,7 @@ describe("SCORM 2004 API Tests", () => {
1038
1123
  const input = "{order_matters=invalid}correctResponse";
1039
1124
  scorm2004API.removeCorrectResponsePrefixes(input);
1040
1125
  expect(scorm2004API.lmsGetLastError()).toEqual(
1041
- String(scorm2004_error_codes.TYPE_MISMATCH),
1126
+ String(scorm2004_errors.TYPE_MISMATCH),
1042
1127
  );
1043
1128
  });
1044
1129
 
@@ -1047,7 +1132,7 @@ describe("SCORM 2004 API Tests", () => {
1047
1132
  const input = "{case_matters=invalid}correctResponse";
1048
1133
  scorm2004API.removeCorrectResponsePrefixes(input);
1049
1134
  expect(scorm2004API.lmsGetLastError()).toEqual(
1050
- String(scorm2004_error_codes.TYPE_MISMATCH),
1135
+ String(scorm2004_errors.TYPE_MISMATCH),
1051
1136
  );
1052
1137
  });
1053
1138
 
@@ -1063,7 +1148,7 @@ describe("SCORM 2004 API Tests", () => {
1063
1148
  const input = "{lang=xyz}correctResponse";
1064
1149
  scorm2004API.removeCorrectResponsePrefixes(input);
1065
1150
  expect(scorm2004API.lmsGetLastError()).toEqual(
1066
- String(scorm2004_error_codes.TYPE_MISMATCH),
1151
+ String(scorm2004_errors.TYPE_MISMATCH),
1067
1152
  );
1068
1153
  });
1069
1154
  });
@@ -1084,7 +1169,7 @@ describe("SCORM 2004 API Tests", () => {
1084
1169
  );
1085
1170
  expect(result).toBeNull();
1086
1171
  expect(scorm2004API.lmsGetLastError()).toEqual(
1087
- String(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED),
1172
+ String(scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED),
1088
1173
  );
1089
1174
  });
1090
1175
 
@@ -1117,7 +1202,7 @@ describe("SCORM 2004 API Tests", () => {
1117
1202
 
1118
1203
  expect(
1119
1204
  throwSCORMErrorSpy.calledWith(
1120
- ErrorCodes.scorm2004.GENERAL_SET_FAILURE,
1205
+ scorm2004_errors.GENERAL_SET_FAILURE,
1121
1206
  "Incorrect Response Type: " + interaction.type,
1122
1207
  ),
1123
1208
  ).toBe(true);