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.
- package/dist/aicc.js +648 -485
- 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 +664 -488
- 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 +1111 -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 +506 -393
- 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 +672 -451
- 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 +1087 -717
- 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 +493 -392
- 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 +658 -450
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/package.json +14 -14
- package/src/AICC.ts +3 -0
- package/src/BaseAPI.ts +33 -30
- package/src/Scorm12API.ts +14 -14
- package/src/Scorm2004API.ts +99 -33
- 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 +37 -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 +4 -0
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);
|
|
@@ -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:
|
|
178
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
181
179
|
});
|
|
182
180
|
h.checkSetCMIValue({
|
|
183
181
|
api: api(),
|
|
184
182
|
fieldName: "cmi._children",
|
|
185
|
-
expectedError:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
398
|
+
expectedError: scorm12_errors.STORE_BEFORE_INIT,
|
|
401
399
|
});
|
|
402
400
|
});
|
|
403
401
|
|