scorm-again 2.5.0 → 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 (85) hide show
  1. package/dist/aicc.js +648 -485
  2. package/dist/aicc.js.map +1 -1
  3. package/dist/aicc.min.js +1 -1
  4. package/dist/aicc.min.js.map +1 -1
  5. package/dist/esm/aicc.js +664 -488
  6. package/dist/esm/aicc.js.map +1 -1
  7. package/dist/esm/aicc.min.js +1 -1
  8. package/dist/esm/aicc.min.js.map +1 -1
  9. package/dist/esm/scorm-again.js +1111 -729
  10. package/dist/esm/scorm-again.js.map +1 -1
  11. package/dist/esm/scorm-again.min.js +1 -1
  12. package/dist/esm/scorm-again.min.js.map +1 -1
  13. package/dist/esm/scorm12.js +506 -393
  14. package/dist/esm/scorm12.js.map +1 -1
  15. package/dist/esm/scorm12.min.js +1 -1
  16. package/dist/esm/scorm12.min.js.map +1 -1
  17. package/dist/esm/scorm2004.js +672 -451
  18. package/dist/esm/scorm2004.js.map +1 -1
  19. package/dist/esm/scorm2004.min.js +1 -1
  20. package/dist/esm/scorm2004.min.js.map +1 -1
  21. package/dist/scorm-again.js +1087 -717
  22. package/dist/scorm-again.js.map +1 -1
  23. package/dist/scorm-again.min.js +1 -1
  24. package/dist/scorm-again.min.js.map +1 -1
  25. package/dist/scorm12.js +493 -392
  26. package/dist/scorm12.js.map +1 -1
  27. package/dist/scorm12.min.js +1 -1
  28. package/dist/scorm12.min.js.map +1 -1
  29. package/dist/scorm2004.js +658 -450
  30. package/dist/scorm2004.js.map +1 -1
  31. package/dist/scorm2004.min.js +1 -1
  32. package/dist/scorm2004.min.js.map +1 -1
  33. package/package.json +14 -14
  34. package/src/AICC.ts +3 -0
  35. package/src/BaseAPI.ts +33 -30
  36. package/src/Scorm12API.ts +14 -14
  37. package/src/Scorm2004API.ts +99 -33
  38. package/src/cmi/aicc/attempts.ts +22 -12
  39. package/src/cmi/aicc/cmi.ts +2 -2
  40. package/src/cmi/aicc/core.ts +44 -26
  41. package/src/cmi/aicc/evaluation.ts +31 -12
  42. package/src/cmi/aicc/paths.ts +29 -15
  43. package/src/cmi/aicc/student_data.ts +14 -5
  44. package/src/cmi/aicc/student_demographics.ts +31 -24
  45. package/src/cmi/aicc/student_preferences.ts +11 -11
  46. package/src/cmi/aicc/tries.ts +24 -14
  47. package/src/cmi/aicc/validation.ts +3 -4
  48. package/src/cmi/common/array.ts +17 -5
  49. package/src/cmi/common/base_cmi.ts +3 -1
  50. package/src/cmi/common/score.ts +16 -13
  51. package/src/cmi/scorm12/cmi.ts +25 -10
  52. package/src/cmi/scorm12/interactions.ts +62 -28
  53. package/src/cmi/scorm12/nav.ts +13 -5
  54. package/src/cmi/scorm12/objectives.ts +28 -18
  55. package/src/cmi/scorm12/student_data.ts +15 -8
  56. package/src/cmi/scorm12/student_preference.ts +20 -13
  57. package/src/cmi/scorm12/validation.ts +7 -7
  58. package/src/cmi/scorm2004/adl.ts +141 -25
  59. package/src/cmi/scorm2004/cmi.ts +50 -55
  60. package/src/cmi/scorm2004/comments.ts +21 -20
  61. package/src/cmi/scorm2004/interactions.ts +73 -32
  62. package/src/cmi/scorm2004/learner_preference.ts +20 -13
  63. package/src/cmi/scorm2004/objectives.ts +41 -16
  64. package/src/cmi/scorm2004/score.ts +22 -11
  65. package/src/cmi/scorm2004/validation.ts +4 -4
  66. package/src/constants/api_constants.ts +8 -19
  67. package/src/constants/default_settings.ts +6 -5
  68. package/src/constants/error_codes.ts +5 -12
  69. package/src/constants/regex.ts +4 -10
  70. package/src/constants/response_constants.ts +1 -2
  71. package/src/exceptions/aicc_exceptions.ts +29 -0
  72. package/src/exceptions/scorm12_exceptions.ts +29 -0
  73. package/src/exceptions/scorm2004_exceptions.ts +29 -0
  74. package/src/exceptions.ts +0 -81
  75. package/src/types/api_types.ts +3 -2
  76. package/test/AICC.spec.ts +114 -43
  77. package/test/Scorm12API.spec.ts +37 -39
  78. package/test/Scorm2004API.spec.ts +165 -80
  79. package/test/cmi/aicc_cmi.spec.ts +6 -9
  80. package/test/cmi/scorm12_cmi.spec.ts +8 -8
  81. package/test/cmi/scorm2004_cmi.spec.ts +8 -9
  82. package/test/exceptions.spec.ts +11 -9
  83. package/test/types/api_types.spec.ts +3 -3
  84. package/test/utilities.spec.ts +1 -4
  85. package/webpack.config.js +4 -0
@@ -2,15 +2,13 @@ import { expect } from "expect";
2
2
  import { after, before, describe, it } from "mocha";
3
3
  import { Scorm12Impl } from "../src/Scorm12API";
4
4
  import * as h from "./api_helpers";
5
- import ErrorCodes from "../src/constants/error_codes";
5
+ import { scorm12_errors } from "../src/constants/error_codes";
6
6
  import { scorm12Values } from "./field_values";
7
7
  import * as sinon from "sinon";
8
8
  import Pretender from "fetch-pretender";
9
9
  import { RefObject, Settings } from "../src/types/api_types";
10
10
  import { DefaultSettings } from "../src/constants/default_settings";
11
11
 
12
- const scorm12_error_codes = ErrorCodes.scorm12;
13
-
14
12
  let clock: sinon.SinonFakeTimers;
15
13
  const api = (settings?: Settings, startingData: RefObject = {}) => {
16
14
  const API = new Scorm12Impl(settings);
@@ -177,52 +175,52 @@ describe("SCORM 1.2 API Tests", () => {
177
175
  h.checkSetCMIValue({
178
176
  api: api(),
179
177
  fieldName: "cmi._version",
180
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
178
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
181
179
  });
182
180
  h.checkSetCMIValue({
183
181
  api: api(),
184
182
  fieldName: "cmi._children",
185
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
183
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
186
184
  });
187
185
  h.checkSetCMIValue({
188
186
  api: api(),
189
187
  fieldName: "cmi.core._children",
190
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
188
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
191
189
  });
192
190
  h.checkSetCMIValue({
193
191
  api: api(),
194
192
  fieldName: "cmi.core.score._children",
195
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
193
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
196
194
  });
197
195
  h.checkSetCMIValue({
198
196
  api: api(),
199
197
  fieldName: "cmi.objectives._children",
200
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
198
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
201
199
  });
202
200
  h.checkSetCMIValue({
203
201
  api: api(),
204
202
  fieldName: "cmi.objectives._count",
205
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
203
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
206
204
  });
207
205
  h.checkSetCMIValue({
208
206
  api: api(),
209
207
  fieldName: "cmi.interactions._children",
210
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
208
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
211
209
  });
212
210
  h.checkSetCMIValue({
213
211
  api: api(),
214
212
  fieldName: "cmi.interactions._count",
215
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
213
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
216
214
  });
217
215
  h.checkSetCMIValue({
218
216
  api: api(),
219
217
  fieldName: "cmi.interactions.0.objectives._count",
220
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
218
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
221
219
  });
222
220
  h.checkSetCMIValue({
223
221
  api: api(),
224
222
  fieldName: "cmi.interactions.0.correct_responses._count",
225
- expectedError: scorm12_error_codes.INVALID_SET_VALUE,
223
+ expectedError: scorm12_errors.INVALID_SET_VALUE,
226
224
  });
227
225
  });
228
226
 
@@ -230,57 +228,57 @@ describe("SCORM 1.2 API Tests", () => {
230
228
  h.checkSetCMIValue({
231
229
  api: apiInitialized(),
232
230
  fieldName: "cmi.launch_data",
233
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
231
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
234
232
  });
235
233
  h.checkSetCMIValue({
236
234
  api: apiInitialized(),
237
235
  fieldName: "cmi.comments_from_lms",
238
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
236
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
239
237
  });
240
238
  h.checkSetCMIValue({
241
239
  api: apiInitialized(),
242
240
  fieldName: "cmi.core.student_id",
243
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
241
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
244
242
  });
245
243
  h.checkSetCMIValue({
246
244
  api: apiInitialized(),
247
245
  fieldName: "cmi.core.student_name",
248
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
246
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
249
247
  });
250
248
  h.checkSetCMIValue({
251
249
  api: apiInitialized(),
252
250
  fieldName: "cmi.core.credit",
253
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
251
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
254
252
  });
255
253
  h.checkSetCMIValue({
256
254
  api: apiInitialized(),
257
255
  fieldName: "cmi.core.entry",
258
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
256
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
259
257
  });
260
258
  h.checkSetCMIValue({
261
259
  api: apiInitialized(),
262
260
  fieldName: "cmi.core.total_time",
263
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
261
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
264
262
  });
265
263
  h.checkSetCMIValue({
266
264
  api: apiInitialized(),
267
265
  fieldName: "cmi.core.lesson_mode",
268
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
266
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
269
267
  });
270
268
  h.checkSetCMIValue({
271
269
  api: apiInitialized(),
272
270
  fieldName: "cmi.student_data.mastery_score",
273
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
271
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
274
272
  });
275
273
  h.checkSetCMIValue({
276
274
  api: apiInitialized(),
277
275
  fieldName: "cmi.student_data.max_time_allowed",
278
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
276
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
279
277
  });
280
278
  h.checkSetCMIValue({
281
279
  api: apiInitialized(),
282
280
  fieldName: "cmi.student_data.time_limit_action",
283
- expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
281
+ expectedError: scorm12_errors.READ_ONLY_ELEMENT,
284
282
  });
285
283
  });
286
284
  });
@@ -290,19 +288,19 @@ describe("SCORM 1.2 API Tests", () => {
290
288
  h.checkLMSGetValue({
291
289
  api: apiInitialized(),
292
290
  fieldName: "cmi.core.close",
293
- expectedError: scorm12_error_codes.GENERAL,
291
+ expectedError: scorm12_errors.GENERAL,
294
292
  errorThrown: false,
295
293
  });
296
294
  h.checkLMSGetValue({
297
295
  api: apiInitialized(),
298
296
  fieldName: "cmi.exit",
299
- expectedError: scorm12_error_codes.GENERAL,
297
+ expectedError: scorm12_errors.GENERAL,
300
298
  errorThrown: false,
301
299
  });
302
300
  h.checkLMSGetValue({
303
301
  api: apiInitialized(),
304
302
  fieldName: "cmi.entry",
305
- expectedError: scorm12_error_codes.GENERAL,
303
+ expectedError: scorm12_errors.GENERAL,
306
304
  errorThrown: false,
307
305
  });
308
306
  });
@@ -321,60 +319,60 @@ describe("SCORM 1.2 API Tests", () => {
321
319
  h.checkLMSGetValue({
322
320
  api: apiInitialized(),
323
321
  fieldName: "cmi.core.exit",
324
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
322
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
325
323
  });
326
324
  h.checkLMSGetValue({
327
325
  api: apiInitialized(),
328
326
  fieldName: "cmi.core.session_time",
329
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
327
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
330
328
  });
331
329
  h.checkLMSGetValue({
332
330
  api: apiInitialized(),
333
331
  fieldName: "cmi.interactions.0.id",
334
332
  initializeFirst: true,
335
333
  initializationValue: "AAA",
336
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
334
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
337
335
  });
338
336
  h.checkLMSGetValue({
339
337
  api: apiInitialized(),
340
338
  fieldName: "cmi.interactions.0.time",
341
339
  initializeFirst: true,
342
340
  initializationValue: "12:59:59",
343
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
341
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
344
342
  });
345
343
  h.checkLMSGetValue({
346
344
  api: apiInitialized(),
347
345
  fieldName: "cmi.interactions.0.type",
348
346
  initializeFirst: true,
349
347
  initializationValue: "true-false",
350
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
348
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
351
349
  });
352
350
  h.checkLMSGetValue({
353
351
  api: apiInitialized(),
354
352
  fieldName: "cmi.interactions.0.weighting",
355
353
  initializeFirst: true,
356
354
  initializationValue: "0",
357
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
355
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
358
356
  });
359
357
  h.checkLMSGetValue({
360
358
  api: apiInitialized(),
361
359
  fieldName: "cmi.interactions.0.student_response",
362
360
  initializeFirst: true,
363
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
361
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
364
362
  });
365
363
  h.checkLMSGetValue({
366
364
  api: apiInitialized(),
367
365
  fieldName: "cmi.interactions.0.result",
368
366
  initializeFirst: true,
369
367
  initializationValue: "correct",
370
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
368
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
371
369
  });
372
370
  h.checkLMSGetValue({
373
371
  api: apiInitialized(),
374
372
  fieldName: "cmi.interactions.0.latency",
375
373
  initializeFirst: true,
376
374
  initializationValue: "01:59:59.99",
377
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
375
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
378
376
  });
379
377
  h.checkLMSGetValue({
380
378
  api: apiInitialized(),
@@ -382,7 +380,7 @@ describe("SCORM 1.2 API Tests", () => {
382
380
  initializeFirst: true,
383
381
  initializationValue: "AAA",
384
382
  expectedValue: "AAA",
385
- expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
383
+ expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
386
384
  });
387
385
  });
388
386
  });
@@ -392,12 +390,12 @@ describe("SCORM 1.2 API Tests", () => {
392
390
  h.checkLMSSetValue({
393
391
  api: api(),
394
392
  fieldName: "cmi.objectives.0.id",
395
- expectedError: scorm12_error_codes.STORE_BEFORE_INIT,
393
+ expectedError: scorm12_errors.STORE_BEFORE_INIT,
396
394
  });
397
395
  h.checkLMSSetValue({
398
396
  api: api(),
399
397
  fieldName: "cmi.interactions.0.id",
400
- expectedError: scorm12_error_codes.STORE_BEFORE_INIT,
398
+ expectedError: scorm12_errors.STORE_BEFORE_INIT,
401
399
  });
402
400
  });
403
401