scorm-again 2.5.0 → 2.6.1
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.
- package/dist/aicc.js +657 -489
- package/dist/aicc.js.map +1 -1
- package/dist/aicc.min.js +1 -1
- package/dist/aicc.min.js.map +1 -1
- package/dist/esm/aicc.js +670 -489
- package/dist/esm/aicc.js.map +1 -1
- package/dist/esm/aicc.min.js +1 -1
- package/dist/esm/aicc.min.js.map +1 -1
- package/dist/esm/scorm-again.js +1113 -729
- package/dist/esm/scorm-again.js.map +1 -1
- package/dist/esm/scorm-again.min.js +1 -1
- package/dist/esm/scorm-again.min.js.map +1 -1
- package/dist/esm/scorm12.js +512 -394
- package/dist/esm/scorm12.js.map +1 -1
- package/dist/esm/scorm12.min.js +1 -1
- package/dist/esm/scorm12.min.js.map +1 -1
- package/dist/esm/scorm2004.js +678 -452
- package/dist/esm/scorm2004.js.map +1 -1
- package/dist/esm/scorm2004.min.js +1 -1
- package/dist/esm/scorm2004.min.js.map +1 -1
- package/dist/scorm-again.js +1100 -728
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +1 -1
- package/dist/scorm-again.min.js.map +1 -1
- package/dist/scorm12.js +500 -394
- package/dist/scorm12.js.map +1 -1
- package/dist/scorm12.min.js +1 -1
- package/dist/scorm12.min.js.map +1 -1
- package/dist/scorm2004.js +665 -452
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/dist_test.html +208 -0
- package/package.json +14 -14
- package/src/AICC.ts +6 -3
- package/src/BaseAPI.ts +43 -37
- package/src/Scorm12API.ts +17 -23
- package/src/Scorm2004API.ts +99 -42
- package/src/ScormAgain.ts +3 -7
- package/src/cmi/aicc/attempts.ts +22 -12
- package/src/cmi/aicc/cmi.ts +2 -2
- package/src/cmi/aicc/core.ts +44 -26
- package/src/cmi/aicc/evaluation.ts +31 -12
- package/src/cmi/aicc/paths.ts +29 -15
- package/src/cmi/aicc/student_data.ts +14 -5
- package/src/cmi/aicc/student_demographics.ts +31 -24
- package/src/cmi/aicc/student_preferences.ts +11 -11
- package/src/cmi/aicc/tries.ts +24 -14
- package/src/cmi/aicc/validation.ts +3 -4
- package/src/cmi/common/array.ts +17 -5
- package/src/cmi/common/base_cmi.ts +3 -1
- package/src/cmi/common/score.ts +16 -13
- package/src/cmi/scorm12/cmi.ts +25 -10
- package/src/cmi/scorm12/interactions.ts +62 -28
- package/src/cmi/scorm12/nav.ts +13 -5
- package/src/cmi/scorm12/objectives.ts +28 -18
- package/src/cmi/scorm12/student_data.ts +15 -8
- package/src/cmi/scorm12/student_preference.ts +20 -13
- package/src/cmi/scorm12/validation.ts +7 -7
- package/src/cmi/scorm2004/adl.ts +141 -25
- package/src/cmi/scorm2004/cmi.ts +50 -55
- package/src/cmi/scorm2004/comments.ts +21 -20
- package/src/cmi/scorm2004/interactions.ts +73 -32
- package/src/cmi/scorm2004/learner_preference.ts +20 -13
- package/src/cmi/scorm2004/objectives.ts +41 -16
- package/src/cmi/scorm2004/score.ts +22 -11
- package/src/cmi/scorm2004/validation.ts +4 -4
- package/src/constants/api_constants.ts +8 -19
- package/src/constants/default_settings.ts +6 -5
- package/src/constants/error_codes.ts +5 -12
- package/src/constants/regex.ts +4 -10
- package/src/constants/response_constants.ts +1 -2
- package/src/exceptions/aicc_exceptions.ts +29 -0
- package/src/exceptions/scorm12_exceptions.ts +29 -0
- package/src/exceptions/scorm2004_exceptions.ts +29 -0
- package/src/exceptions.ts +0 -81
- package/src/types/api_types.ts +3 -2
- package/test/AICC.spec.ts +114 -43
- package/test/Scorm12API.spec.ts +60 -39
- package/test/Scorm2004API.spec.ts +165 -80
- package/test/cmi/aicc_cmi.spec.ts +6 -9
- package/test/cmi/scorm12_cmi.spec.ts +8 -8
- package/test/cmi/scorm2004_cmi.spec.ts +8 -9
- package/test/exceptions.spec.ts +11 -9
- package/test/types/api_types.spec.ts +3 -3
- package/test/utilities.spec.ts +1 -4
- package/webpack.config.js +5 -1
package/test/Scorm12API.spec.ts
CHANGED
|
@@ -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
|
|
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);
|
|
@@ -120,6 +118,29 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
120
118
|
expect(scorm12API.cmi.objectives.childArray[0].score.max).toEqual("100");
|
|
121
119
|
});
|
|
122
120
|
|
|
121
|
+
it("should load nested JSON data into the CMI object in a backwards compatible way with v1", () => {
|
|
122
|
+
const scorm12API = api();
|
|
123
|
+
const jsonData = {
|
|
124
|
+
objectives: {
|
|
125
|
+
"0": {
|
|
126
|
+
id: "obj_1",
|
|
127
|
+
score: {
|
|
128
|
+
raw: "85",
|
|
129
|
+
min: "0",
|
|
130
|
+
max: "100",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
scorm12API.loadFromJSON(jsonData);
|
|
137
|
+
|
|
138
|
+
expect(scorm12API.cmi.objectives.childArray[0].id).toEqual("obj_1");
|
|
139
|
+
expect(scorm12API.cmi.objectives.childArray[0].score.raw).toEqual("85");
|
|
140
|
+
expect(scorm12API.cmi.objectives.childArray[0].score.min).toEqual("0");
|
|
141
|
+
expect(scorm12API.cmi.objectives.childArray[0].score.max).toEqual("100");
|
|
142
|
+
});
|
|
143
|
+
|
|
123
144
|
it("should handle empty JSON data", () => {
|
|
124
145
|
const scorm12API = api();
|
|
125
146
|
const jsonData = {};
|
|
@@ -177,52 +198,52 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
177
198
|
h.checkSetCMIValue({
|
|
178
199
|
api: api(),
|
|
179
200
|
fieldName: "cmi._version",
|
|
180
|
-
expectedError:
|
|
201
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
181
202
|
});
|
|
182
203
|
h.checkSetCMIValue({
|
|
183
204
|
api: api(),
|
|
184
205
|
fieldName: "cmi._children",
|
|
185
|
-
expectedError:
|
|
206
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
186
207
|
});
|
|
187
208
|
h.checkSetCMIValue({
|
|
188
209
|
api: api(),
|
|
189
210
|
fieldName: "cmi.core._children",
|
|
190
|
-
expectedError:
|
|
211
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
191
212
|
});
|
|
192
213
|
h.checkSetCMIValue({
|
|
193
214
|
api: api(),
|
|
194
215
|
fieldName: "cmi.core.score._children",
|
|
195
|
-
expectedError:
|
|
216
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
196
217
|
});
|
|
197
218
|
h.checkSetCMIValue({
|
|
198
219
|
api: api(),
|
|
199
220
|
fieldName: "cmi.objectives._children",
|
|
200
|
-
expectedError:
|
|
221
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
201
222
|
});
|
|
202
223
|
h.checkSetCMIValue({
|
|
203
224
|
api: api(),
|
|
204
225
|
fieldName: "cmi.objectives._count",
|
|
205
|
-
expectedError:
|
|
226
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
206
227
|
});
|
|
207
228
|
h.checkSetCMIValue({
|
|
208
229
|
api: api(),
|
|
209
230
|
fieldName: "cmi.interactions._children",
|
|
210
|
-
expectedError:
|
|
231
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
211
232
|
});
|
|
212
233
|
h.checkSetCMIValue({
|
|
213
234
|
api: api(),
|
|
214
235
|
fieldName: "cmi.interactions._count",
|
|
215
|
-
expectedError:
|
|
236
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
216
237
|
});
|
|
217
238
|
h.checkSetCMIValue({
|
|
218
239
|
api: api(),
|
|
219
240
|
fieldName: "cmi.interactions.0.objectives._count",
|
|
220
|
-
expectedError:
|
|
241
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
221
242
|
});
|
|
222
243
|
h.checkSetCMIValue({
|
|
223
244
|
api: api(),
|
|
224
245
|
fieldName: "cmi.interactions.0.correct_responses._count",
|
|
225
|
-
expectedError:
|
|
246
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
226
247
|
});
|
|
227
248
|
});
|
|
228
249
|
|
|
@@ -230,57 +251,57 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
230
251
|
h.checkSetCMIValue({
|
|
231
252
|
api: apiInitialized(),
|
|
232
253
|
fieldName: "cmi.launch_data",
|
|
233
|
-
expectedError:
|
|
254
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
234
255
|
});
|
|
235
256
|
h.checkSetCMIValue({
|
|
236
257
|
api: apiInitialized(),
|
|
237
258
|
fieldName: "cmi.comments_from_lms",
|
|
238
|
-
expectedError:
|
|
259
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
239
260
|
});
|
|
240
261
|
h.checkSetCMIValue({
|
|
241
262
|
api: apiInitialized(),
|
|
242
263
|
fieldName: "cmi.core.student_id",
|
|
243
|
-
expectedError:
|
|
264
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
244
265
|
});
|
|
245
266
|
h.checkSetCMIValue({
|
|
246
267
|
api: apiInitialized(),
|
|
247
268
|
fieldName: "cmi.core.student_name",
|
|
248
|
-
expectedError:
|
|
269
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
249
270
|
});
|
|
250
271
|
h.checkSetCMIValue({
|
|
251
272
|
api: apiInitialized(),
|
|
252
273
|
fieldName: "cmi.core.credit",
|
|
253
|
-
expectedError:
|
|
274
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
254
275
|
});
|
|
255
276
|
h.checkSetCMIValue({
|
|
256
277
|
api: apiInitialized(),
|
|
257
278
|
fieldName: "cmi.core.entry",
|
|
258
|
-
expectedError:
|
|
279
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
259
280
|
});
|
|
260
281
|
h.checkSetCMIValue({
|
|
261
282
|
api: apiInitialized(),
|
|
262
283
|
fieldName: "cmi.core.total_time",
|
|
263
|
-
expectedError:
|
|
284
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
264
285
|
});
|
|
265
286
|
h.checkSetCMIValue({
|
|
266
287
|
api: apiInitialized(),
|
|
267
288
|
fieldName: "cmi.core.lesson_mode",
|
|
268
|
-
expectedError:
|
|
289
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
269
290
|
});
|
|
270
291
|
h.checkSetCMIValue({
|
|
271
292
|
api: apiInitialized(),
|
|
272
293
|
fieldName: "cmi.student_data.mastery_score",
|
|
273
|
-
expectedError:
|
|
294
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
274
295
|
});
|
|
275
296
|
h.checkSetCMIValue({
|
|
276
297
|
api: apiInitialized(),
|
|
277
298
|
fieldName: "cmi.student_data.max_time_allowed",
|
|
278
|
-
expectedError:
|
|
299
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
279
300
|
});
|
|
280
301
|
h.checkSetCMIValue({
|
|
281
302
|
api: apiInitialized(),
|
|
282
303
|
fieldName: "cmi.student_data.time_limit_action",
|
|
283
|
-
expectedError:
|
|
304
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
284
305
|
});
|
|
285
306
|
});
|
|
286
307
|
});
|
|
@@ -290,19 +311,19 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
290
311
|
h.checkLMSGetValue({
|
|
291
312
|
api: apiInitialized(),
|
|
292
313
|
fieldName: "cmi.core.close",
|
|
293
|
-
expectedError:
|
|
314
|
+
expectedError: scorm12_errors.GENERAL,
|
|
294
315
|
errorThrown: false,
|
|
295
316
|
});
|
|
296
317
|
h.checkLMSGetValue({
|
|
297
318
|
api: apiInitialized(),
|
|
298
319
|
fieldName: "cmi.exit",
|
|
299
|
-
expectedError:
|
|
320
|
+
expectedError: scorm12_errors.GENERAL,
|
|
300
321
|
errorThrown: false,
|
|
301
322
|
});
|
|
302
323
|
h.checkLMSGetValue({
|
|
303
324
|
api: apiInitialized(),
|
|
304
325
|
fieldName: "cmi.entry",
|
|
305
|
-
expectedError:
|
|
326
|
+
expectedError: scorm12_errors.GENERAL,
|
|
306
327
|
errorThrown: false,
|
|
307
328
|
});
|
|
308
329
|
});
|
|
@@ -321,60 +342,60 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
321
342
|
h.checkLMSGetValue({
|
|
322
343
|
api: apiInitialized(),
|
|
323
344
|
fieldName: "cmi.core.exit",
|
|
324
|
-
expectedError:
|
|
345
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
325
346
|
});
|
|
326
347
|
h.checkLMSGetValue({
|
|
327
348
|
api: apiInitialized(),
|
|
328
349
|
fieldName: "cmi.core.session_time",
|
|
329
|
-
expectedError:
|
|
350
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
330
351
|
});
|
|
331
352
|
h.checkLMSGetValue({
|
|
332
353
|
api: apiInitialized(),
|
|
333
354
|
fieldName: "cmi.interactions.0.id",
|
|
334
355
|
initializeFirst: true,
|
|
335
356
|
initializationValue: "AAA",
|
|
336
|
-
expectedError:
|
|
357
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
337
358
|
});
|
|
338
359
|
h.checkLMSGetValue({
|
|
339
360
|
api: apiInitialized(),
|
|
340
361
|
fieldName: "cmi.interactions.0.time",
|
|
341
362
|
initializeFirst: true,
|
|
342
363
|
initializationValue: "12:59:59",
|
|
343
|
-
expectedError:
|
|
364
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
344
365
|
});
|
|
345
366
|
h.checkLMSGetValue({
|
|
346
367
|
api: apiInitialized(),
|
|
347
368
|
fieldName: "cmi.interactions.0.type",
|
|
348
369
|
initializeFirst: true,
|
|
349
370
|
initializationValue: "true-false",
|
|
350
|
-
expectedError:
|
|
371
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
351
372
|
});
|
|
352
373
|
h.checkLMSGetValue({
|
|
353
374
|
api: apiInitialized(),
|
|
354
375
|
fieldName: "cmi.interactions.0.weighting",
|
|
355
376
|
initializeFirst: true,
|
|
356
377
|
initializationValue: "0",
|
|
357
|
-
expectedError:
|
|
378
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
358
379
|
});
|
|
359
380
|
h.checkLMSGetValue({
|
|
360
381
|
api: apiInitialized(),
|
|
361
382
|
fieldName: "cmi.interactions.0.student_response",
|
|
362
383
|
initializeFirst: true,
|
|
363
|
-
expectedError:
|
|
384
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
364
385
|
});
|
|
365
386
|
h.checkLMSGetValue({
|
|
366
387
|
api: apiInitialized(),
|
|
367
388
|
fieldName: "cmi.interactions.0.result",
|
|
368
389
|
initializeFirst: true,
|
|
369
390
|
initializationValue: "correct",
|
|
370
|
-
expectedError:
|
|
391
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
371
392
|
});
|
|
372
393
|
h.checkLMSGetValue({
|
|
373
394
|
api: apiInitialized(),
|
|
374
395
|
fieldName: "cmi.interactions.0.latency",
|
|
375
396
|
initializeFirst: true,
|
|
376
397
|
initializationValue: "01:59:59.99",
|
|
377
|
-
expectedError:
|
|
398
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
378
399
|
});
|
|
379
400
|
h.checkLMSGetValue({
|
|
380
401
|
api: apiInitialized(),
|
|
@@ -382,7 +403,7 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
382
403
|
initializeFirst: true,
|
|
383
404
|
initializationValue: "AAA",
|
|
384
405
|
expectedValue: "AAA",
|
|
385
|
-
expectedError:
|
|
406
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
386
407
|
});
|
|
387
408
|
});
|
|
388
409
|
});
|
|
@@ -392,12 +413,12 @@ describe("SCORM 1.2 API Tests", () => {
|
|
|
392
413
|
h.checkLMSSetValue({
|
|
393
414
|
api: api(),
|
|
394
415
|
fieldName: "cmi.objectives.0.id",
|
|
395
|
-
expectedError:
|
|
416
|
+
expectedError: scorm12_errors.STORE_BEFORE_INIT,
|
|
396
417
|
});
|
|
397
418
|
h.checkLMSSetValue({
|
|
398
419
|
api: api(),
|
|
399
420
|
fieldName: "cmi.interactions.0.id",
|
|
400
|
-
expectedError:
|
|
421
|
+
expectedError: scorm12_errors.STORE_BEFORE_INIT,
|
|
401
422
|
});
|
|
402
423
|
});
|
|
403
424
|
|