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.
- package/README.md +23 -23
- package/dist/aicc.js +676 -493
- 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 +692 -496
- 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 +1151 -743
- 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 +534 -401
- 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 +712 -465
- 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 +1127 -731
- 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 +521 -400
- 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 +698 -464
- 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 +15 -15
- package/src/AICC.ts +3 -0
- package/src/BaseAPI.ts +60 -95
- package/src/Scorm12API.ts +14 -14
- package/src/Scorm2004API.ts +107 -37
- 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 -29
- package/src/constants/default_settings.ts +26 -12
- package/src/constants/enums.ts +9 -0
- package/src/constants/error_codes.ts +5 -12
- package/src/constants/regex.ts +5 -11
- 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 +1 -86
- package/src/types/api_types.ts +29 -5
- 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 +40 -47
- package/test/utilities.spec.ts +1 -4
- package/webpack.config.js +4 -0
package/test/AICC.spec.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { expect } from "expect";
|
|
2
|
-
import { describe } from "mocha";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
3
|
import * as h from "./api_helpers";
|
|
4
|
-
import
|
|
4
|
+
import { scorm12_errors } from "../src/constants/error_codes";
|
|
5
5
|
import { AICCImpl } from "../src/AICC";
|
|
6
|
+
import { DefaultSettings } from "../src/constants/default_settings";
|
|
7
|
+
import * as sinon from "sinon";
|
|
8
|
+
import { CMITries } from "../src/cmi/aicc/tries";
|
|
9
|
+
import { CMIInteractions } from "../src/cmi/scorm12/interactions";
|
|
10
|
+
import { RefObject, Settings } from "../src/types/api_types";
|
|
6
11
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const api = () => {
|
|
10
|
-
const API = new AICCImpl();
|
|
12
|
+
const api = (settings?: Settings, startingData: RefObject = {}) => {
|
|
13
|
+
const API = new AICCImpl(settings);
|
|
11
14
|
API.apiLogLevel = 1;
|
|
15
|
+
if (startingData) {
|
|
16
|
+
API.startingData = startingData;
|
|
17
|
+
}
|
|
12
18
|
return API;
|
|
13
19
|
};
|
|
14
|
-
const apiInitialized = () => {
|
|
20
|
+
const apiInitialized = (startingData?: RefObject) => {
|
|
15
21
|
const API = api();
|
|
22
|
+
API.loadFromJSON(startingData ? startingData : {}, "");
|
|
16
23
|
API.lmsInitialize();
|
|
17
24
|
return API;
|
|
18
25
|
};
|
|
@@ -23,52 +30,52 @@ describe("AICC API Tests", () => {
|
|
|
23
30
|
h.checkSetCMIValue({
|
|
24
31
|
api: api(),
|
|
25
32
|
fieldName: "cmi._version",
|
|
26
|
-
expectedError:
|
|
33
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
27
34
|
});
|
|
28
35
|
h.checkSetCMIValue({
|
|
29
36
|
api: api(),
|
|
30
37
|
fieldName: "cmi._children",
|
|
31
|
-
expectedError:
|
|
38
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
32
39
|
});
|
|
33
40
|
h.checkSetCMIValue({
|
|
34
41
|
api: api(),
|
|
35
42
|
fieldName: "cmi.core._children",
|
|
36
|
-
expectedError:
|
|
43
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
37
44
|
});
|
|
38
45
|
h.checkSetCMIValue({
|
|
39
46
|
api: api(),
|
|
40
47
|
fieldName: "cmi.core.score._children",
|
|
41
|
-
expectedError:
|
|
48
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
42
49
|
});
|
|
43
50
|
h.checkSetCMIValue({
|
|
44
51
|
api: api(),
|
|
45
52
|
fieldName: "cmi.objectives._children",
|
|
46
|
-
expectedError:
|
|
53
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
47
54
|
});
|
|
48
55
|
h.checkSetCMIValue({
|
|
49
56
|
api: api(),
|
|
50
57
|
fieldName: "cmi.objectives._count",
|
|
51
|
-
expectedError:
|
|
58
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
52
59
|
});
|
|
53
60
|
h.checkSetCMIValue({
|
|
54
61
|
api: api(),
|
|
55
62
|
fieldName: "cmi.interactions._children",
|
|
56
|
-
expectedError:
|
|
63
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
57
64
|
});
|
|
58
65
|
h.checkSetCMIValue({
|
|
59
66
|
api: api(),
|
|
60
67
|
fieldName: "cmi.interactions._count",
|
|
61
|
-
expectedError:
|
|
68
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
62
69
|
});
|
|
63
70
|
h.checkSetCMIValue({
|
|
64
71
|
api: api(),
|
|
65
72
|
fieldName: "cmi.interactions.0.objectives._count",
|
|
66
|
-
expectedError:
|
|
73
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
67
74
|
});
|
|
68
75
|
h.checkSetCMIValue({
|
|
69
76
|
api: api(),
|
|
70
77
|
fieldName: "cmi.interactions.0.correct_responses._count",
|
|
71
|
-
expectedError:
|
|
78
|
+
expectedError: scorm12_errors.INVALID_SET_VALUE,
|
|
72
79
|
});
|
|
73
80
|
});
|
|
74
81
|
|
|
@@ -76,57 +83,57 @@ describe("AICC API Tests", () => {
|
|
|
76
83
|
h.checkSetCMIValue({
|
|
77
84
|
api: apiInitialized(),
|
|
78
85
|
fieldName: "cmi.launch_data",
|
|
79
|
-
expectedError:
|
|
86
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
80
87
|
});
|
|
81
88
|
h.checkSetCMIValue({
|
|
82
89
|
api: apiInitialized(),
|
|
83
90
|
fieldName: "cmi.comments_from_lms",
|
|
84
|
-
expectedError:
|
|
91
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
85
92
|
});
|
|
86
93
|
h.checkSetCMIValue({
|
|
87
94
|
api: apiInitialized(),
|
|
88
95
|
fieldName: "cmi.core.student_id",
|
|
89
|
-
expectedError:
|
|
96
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
90
97
|
});
|
|
91
98
|
h.checkSetCMIValue({
|
|
92
99
|
api: apiInitialized(),
|
|
93
100
|
fieldName: "cmi.core.student_name",
|
|
94
|
-
expectedError:
|
|
101
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
95
102
|
});
|
|
96
103
|
h.checkSetCMIValue({
|
|
97
104
|
api: apiInitialized(),
|
|
98
105
|
fieldName: "cmi.core.credit",
|
|
99
|
-
expectedError:
|
|
106
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
100
107
|
});
|
|
101
108
|
h.checkSetCMIValue({
|
|
102
109
|
api: apiInitialized(),
|
|
103
110
|
fieldName: "cmi.core.entry",
|
|
104
|
-
expectedError:
|
|
111
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
105
112
|
});
|
|
106
113
|
h.checkSetCMIValue({
|
|
107
114
|
api: apiInitialized(),
|
|
108
115
|
fieldName: "cmi.core.total_time",
|
|
109
|
-
expectedError:
|
|
116
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
110
117
|
});
|
|
111
118
|
h.checkSetCMIValue({
|
|
112
119
|
api: apiInitialized(),
|
|
113
120
|
fieldName: "cmi.core.lesson_mode",
|
|
114
|
-
expectedError:
|
|
121
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
115
122
|
});
|
|
116
123
|
h.checkSetCMIValue({
|
|
117
124
|
api: apiInitialized(),
|
|
118
125
|
fieldName: "cmi.student_data.mastery_score",
|
|
119
|
-
expectedError:
|
|
126
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
120
127
|
});
|
|
121
128
|
h.checkSetCMIValue({
|
|
122
129
|
api: apiInitialized(),
|
|
123
130
|
fieldName: "cmi.student_data.max_time_allowed",
|
|
124
|
-
expectedError:
|
|
131
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
125
132
|
});
|
|
126
133
|
h.checkSetCMIValue({
|
|
127
134
|
api: apiInitialized(),
|
|
128
135
|
fieldName: "cmi.student_data.time_limit_action",
|
|
129
|
-
expectedError:
|
|
136
|
+
expectedError: scorm12_errors.READ_ONLY_ELEMENT,
|
|
130
137
|
});
|
|
131
138
|
});
|
|
132
139
|
});
|
|
@@ -136,19 +143,19 @@ describe("AICC API Tests", () => {
|
|
|
136
143
|
h.checkLMSGetValue({
|
|
137
144
|
api: apiInitialized(),
|
|
138
145
|
fieldName: "cmi.core.close",
|
|
139
|
-
expectedError:
|
|
146
|
+
expectedError: scorm12_errors.GENERAL,
|
|
140
147
|
errorThrown: false,
|
|
141
148
|
});
|
|
142
149
|
h.checkLMSGetValue({
|
|
143
150
|
api: apiInitialized(),
|
|
144
151
|
fieldName: "cmi.exit",
|
|
145
|
-
expectedError:
|
|
152
|
+
expectedError: scorm12_errors.GENERAL,
|
|
146
153
|
errorThrown: false,
|
|
147
154
|
});
|
|
148
155
|
h.checkLMSGetValue({
|
|
149
156
|
api: apiInitialized(),
|
|
150
157
|
fieldName: "cmi.entry",
|
|
151
|
-
expectedError:
|
|
158
|
+
expectedError: scorm12_errors.GENERAL,
|
|
152
159
|
errorThrown: false,
|
|
153
160
|
});
|
|
154
161
|
});
|
|
@@ -157,66 +164,66 @@ describe("AICC API Tests", () => {
|
|
|
157
164
|
h.checkLMSGetValue({
|
|
158
165
|
api: apiInitialized(),
|
|
159
166
|
fieldName: "cmi.core.exit",
|
|
160
|
-
expectedError:
|
|
167
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
161
168
|
});
|
|
162
169
|
h.checkLMSGetValue({
|
|
163
170
|
api: apiInitialized(),
|
|
164
171
|
fieldName: "cmi.core.session_time",
|
|
165
|
-
expectedError:
|
|
172
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
166
173
|
});
|
|
167
174
|
h.checkLMSGetValue({
|
|
168
175
|
api: apiInitialized(),
|
|
169
176
|
fieldName: "cmi.interactions.0.id",
|
|
170
177
|
initializeFirst: true,
|
|
171
178
|
initializationValue: "AAA",
|
|
172
|
-
expectedError:
|
|
179
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
173
180
|
});
|
|
174
181
|
h.checkLMSGetValue({
|
|
175
182
|
api: apiInitialized(),
|
|
176
183
|
fieldName: "cmi.interactions.0.time",
|
|
177
184
|
initializeFirst: true,
|
|
178
185
|
initializationValue: "12:59:59",
|
|
179
|
-
expectedError:
|
|
186
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
180
187
|
});
|
|
181
188
|
h.checkLMSGetValue({
|
|
182
189
|
api: apiInitialized(),
|
|
183
190
|
fieldName: "cmi.interactions.0.type",
|
|
184
191
|
initializeFirst: true,
|
|
185
192
|
initializationValue: "true-false",
|
|
186
|
-
expectedError:
|
|
193
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
187
194
|
});
|
|
188
195
|
h.checkLMSGetValue({
|
|
189
196
|
api: apiInitialized(),
|
|
190
197
|
fieldName: "cmi.interactions.0.weighting",
|
|
191
198
|
initializeFirst: true,
|
|
192
199
|
initializationValue: "0",
|
|
193
|
-
expectedError:
|
|
200
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
194
201
|
});
|
|
195
202
|
h.checkLMSGetValue({
|
|
196
203
|
api: apiInitialized(),
|
|
197
204
|
fieldName: "cmi.interactions.0.student_response",
|
|
198
205
|
initializeFirst: true,
|
|
199
|
-
expectedError:
|
|
206
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
200
207
|
});
|
|
201
208
|
h.checkLMSGetValue({
|
|
202
209
|
api: apiInitialized(),
|
|
203
210
|
fieldName: "cmi.interactions.0.result",
|
|
204
211
|
initializeFirst: true,
|
|
205
212
|
initializationValue: "correct",
|
|
206
|
-
expectedError:
|
|
213
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
207
214
|
});
|
|
208
215
|
h.checkLMSGetValue({
|
|
209
216
|
api: apiInitialized(),
|
|
210
217
|
fieldName: "cmi.interactions.0.latency",
|
|
211
218
|
initializeFirst: true,
|
|
212
219
|
initializationValue: "01:59:59.99",
|
|
213
|
-
expectedError:
|
|
220
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
214
221
|
});
|
|
215
222
|
h.checkLMSGetValue({
|
|
216
223
|
api: apiInitialized(),
|
|
217
224
|
fieldName: "cmi.interactions.0.correct_responses.0.pattern",
|
|
218
225
|
initializeFirst: true,
|
|
219
|
-
expectedError:
|
|
226
|
+
expectedError: scorm12_errors.WRITE_ONLY_ELEMENT,
|
|
220
227
|
});
|
|
221
228
|
});
|
|
222
229
|
});
|
|
@@ -226,12 +233,12 @@ describe("AICC API Tests", () => {
|
|
|
226
233
|
h.checkLMSSetValue({
|
|
227
234
|
api: api(),
|
|
228
235
|
fieldName: "cmi.objectives.0.id",
|
|
229
|
-
expectedError:
|
|
236
|
+
expectedError: scorm12_errors.STORE_BEFORE_INIT,
|
|
230
237
|
});
|
|
231
238
|
h.checkLMSSetValue({
|
|
232
239
|
api: api(),
|
|
233
240
|
fieldName: "cmi.interactions.0.id",
|
|
234
|
-
expectedError:
|
|
241
|
+
expectedError: scorm12_errors.STORE_BEFORE_INIT,
|
|
235
242
|
});
|
|
236
243
|
});
|
|
237
244
|
|
|
@@ -269,6 +276,70 @@ describe("AICC API Tests", () => {
|
|
|
269
276
|
});
|
|
270
277
|
});
|
|
271
278
|
|
|
279
|
+
describe("reset()", () => {
|
|
280
|
+
it("should reset all CMI values to their default state", () => {
|
|
281
|
+
const aiccAPI = api();
|
|
282
|
+
aiccAPI.cmi.core.student_id = "student_1";
|
|
283
|
+
aiccAPI.lmsInitialize();
|
|
284
|
+
|
|
285
|
+
aiccAPI.cmi.core.session_time = "01:00:00";
|
|
286
|
+
aiccAPI.setCMIValue("cmi.student_data.tries.0.score.max", "99");
|
|
287
|
+
|
|
288
|
+
aiccAPI.reset();
|
|
289
|
+
expect(aiccAPI.cmi.interactions).toEqual(new CMIInteractions());
|
|
290
|
+
expect(aiccAPI.cmi.core.student_id).toEqual("student_1");
|
|
291
|
+
expect(aiccAPI.getCMIValue("cmi.student_data.tries")).toEqual(
|
|
292
|
+
new CMITries(),
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("should keep original settings", () => {
|
|
297
|
+
const aiccAPI = api({
|
|
298
|
+
dataCommitFormat: "flattened",
|
|
299
|
+
autocommit: true,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
aiccAPI.reset();
|
|
303
|
+
|
|
304
|
+
expect(aiccAPI.settings.sendFullCommit).toEqual(
|
|
305
|
+
DefaultSettings.sendFullCommit,
|
|
306
|
+
);
|
|
307
|
+
expect(aiccAPI.settings.dataCommitFormat).toEqual("flattened");
|
|
308
|
+
expect(aiccAPI.settings.autocommit).toEqual(true);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("should be able to override original settings", () => {
|
|
312
|
+
const aiccAPI = api({
|
|
313
|
+
...DefaultSettings,
|
|
314
|
+
dataCommitFormat: "flattened",
|
|
315
|
+
autocommit: true,
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
aiccAPI.reset({
|
|
319
|
+
alwaysSendTotalTime: !DefaultSettings.alwaysSendTotalTime,
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
expect(aiccAPI.settings.sendFullCommit).toEqual(
|
|
323
|
+
DefaultSettings.sendFullCommit,
|
|
324
|
+
);
|
|
325
|
+
expect(aiccAPI.settings.dataCommitFormat).toEqual("flattened");
|
|
326
|
+
expect(aiccAPI.settings.autocommit).toEqual(true);
|
|
327
|
+
expect(aiccAPI.settings.alwaysSendTotalTime).toEqual(
|
|
328
|
+
!DefaultSettings.alwaysSendTotalTime,
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it("should call commonReset from the superclass", () => {
|
|
333
|
+
const aiccAPI = api();
|
|
334
|
+
const commonResetSpy = sinon.spy(aiccAPI, "commonReset");
|
|
335
|
+
|
|
336
|
+
aiccAPI.reset();
|
|
337
|
+
|
|
338
|
+
expect(commonResetSpy.calledOnce).toBe(true);
|
|
339
|
+
commonResetSpy.restore();
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
272
343
|
describe("replaceWithAnotherScormAPI()", () => {
|
|
273
344
|
const firstAPI = api();
|
|
274
345
|
const secondAPI = api();
|
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
|
|