scorm-again 1.7.1 → 2.0.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/.babelrc +18 -7
- package/.github/dependabot.yml +5 -0
- package/.github/workflows/main.yml +79 -0
- package/.jsdoc.json +4 -5
- package/.mocharc.json +8 -0
- package/.run/Mocha Unit Tests.run.xml +5 -2
- package/CONTRIBUTING.md +1 -1
- package/README.md +14 -1
- package/dist/aicc.js +3661 -7170
- package/dist/aicc.js.map +1 -1
- package/dist/aicc.min.js +2 -40
- package/dist/aicc.min.js.map +1 -0
- package/dist/scorm-again.js +5671 -10695
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +2 -52
- package/dist/scorm-again.min.js.map +1 -0
- package/dist/scorm12.js +2871 -5433
- package/dist/scorm12.js.map +1 -1
- package/dist/scorm12.min.js +2 -34
- package/dist/scorm12.min.js.map +1 -0
- package/dist/scorm2004.js +3868 -6797
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +2 -40
- package/dist/scorm2004.min.js.map +1 -0
- package/eslint.config.js +21 -0
- package/package.json +72 -34
- package/results.json +34254 -0
- package/src/{AICC.js → AICC.ts} +27 -21
- package/src/BaseAPI.ts +1449 -0
- package/src/Scorm12API.ts +360 -0
- package/src/{Scorm2004API.js → Scorm2004API.ts} +245 -163
- package/src/cmi/aicc_cmi.ts +1248 -0
- package/src/cmi/common.ts +411 -0
- package/src/cmi/scorm12_cmi.ts +1426 -0
- package/src/cmi/scorm2004_cmi.ts +1874 -0
- package/src/constants/api_constants.ts +318 -0
- package/src/constants/error_codes.ts +88 -0
- package/src/constants/language_constants.ts +394 -0
- package/src/constants/regex.ts +97 -0
- package/src/constants/{response_constants.js → response_constants.ts} +67 -62
- package/src/exceptions.ts +133 -0
- package/src/exports/aicc.js +1 -1
- package/src/exports/scorm-again.js +3 -3
- package/src/exports/scorm12.js +1 -1
- package/src/exports/scorm2004.js +1 -1
- package/src/{utilities.js → utilities.ts} +114 -74
- package/tea.yaml +6 -0
- package/test/{AICC.spec.js → AICC.spec.ts} +70 -72
- package/test/Scorm12API.spec.ts +580 -0
- package/test/Scorm2004API.spec.ts +812 -0
- package/test/api_helpers.ts +176 -0
- package/test/cmi/{aicc_cmi.spec.js → aicc_cmi.spec.ts} +193 -209
- package/test/cmi/{scorm12_cmi.spec.js → scorm12_cmi.spec.ts} +251 -269
- package/test/cmi/scorm2004_cmi.spec.ts +1031 -0
- package/test/cmi_helpers.ts +207 -0
- package/test/exceptions.spec.ts +79 -0
- package/test/field_values.ts +202 -0
- package/test/utilities.spec.ts +322 -0
- package/tsconfig.json +18 -0
- package/webpack.config.js +65 -0
- package/.circleci/config.yml +0 -99
- package/.codeclimate.yml +0 -7
- package/.eslintrc.js +0 -36
- package/src/.flowconfig +0 -11
- package/src/BaseAPI.js +0 -1275
- package/src/Scorm12API.js +0 -308
- package/src/cmi/aicc_cmi.js +0 -1141
- package/src/cmi/common.js +0 -328
- package/src/cmi/scorm12_cmi.js +0 -1312
- package/src/cmi/scorm2004_cmi.js +0 -1692
- package/src/constants/api_constants.js +0 -218
- package/src/constants/error_codes.js +0 -87
- package/src/constants/language_constants.js +0 -76
- package/src/constants/regex.js +0 -84
- package/src/exceptions.js +0 -104
- package/test/Scorm12API.spec.js +0 -528
- package/test/Scorm2004API.spec.js +0 -775
- package/test/abstract_classes.spec.js +0 -17
- package/test/api_helpers.js +0 -128
- package/test/cmi/scorm2004_cmi.spec.js +0 -1066
- package/test/cmi_helpers.js +0 -161
- package/test/exceptions.spec.js +0 -71
- package/test/field_values.js +0 -353
- package/test/utilities.spec.js +0 -339
- package/webpack.js +0 -78
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {expect} from
|
|
2
|
-
import {describe
|
|
3
|
-
import * as h from
|
|
4
|
-
import ErrorCodes from
|
|
5
|
-
import AICC from
|
|
1
|
+
import { expect } from "expect";
|
|
2
|
+
import { describe } from "mocha";
|
|
3
|
+
import * as h from "./api_helpers";
|
|
4
|
+
import ErrorCodes from "../src/constants/error_codes";
|
|
5
|
+
import AICC from "../src/AICC";
|
|
6
6
|
|
|
7
7
|
const scorm12_error_codes = ErrorCodes.scorm12;
|
|
8
8
|
|
|
9
9
|
const api = () => {
|
|
10
10
|
const API = new AICC();
|
|
11
|
-
API.apiLogLevel =
|
|
11
|
+
API.apiLogLevel = 5;
|
|
12
12
|
return API;
|
|
13
13
|
};
|
|
14
14
|
const apiInitialized = () => {
|
|
@@ -17,258 +17,256 @@ const apiInitialized = () => {
|
|
|
17
17
|
return API;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
describe(
|
|
21
|
-
describe(
|
|
22
|
-
describe(
|
|
20
|
+
describe("AICC API Tests", () => {
|
|
21
|
+
describe("setCMIValue()", () => {
|
|
22
|
+
describe("Invalid Sets - Should Always Fail", () => {
|
|
23
23
|
h.checkSetCMIValue({
|
|
24
24
|
api: api(),
|
|
25
|
-
fieldName:
|
|
25
|
+
fieldName: "cmi._version",
|
|
26
26
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
27
27
|
});
|
|
28
28
|
h.checkSetCMIValue({
|
|
29
29
|
api: api(),
|
|
30
|
-
fieldName:
|
|
30
|
+
fieldName: "cmi._children",
|
|
31
31
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
32
32
|
});
|
|
33
33
|
h.checkSetCMIValue({
|
|
34
34
|
api: api(),
|
|
35
|
-
fieldName:
|
|
35
|
+
fieldName: "cmi.core._children",
|
|
36
36
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
37
37
|
});
|
|
38
38
|
h.checkSetCMIValue({
|
|
39
39
|
api: api(),
|
|
40
|
-
fieldName:
|
|
40
|
+
fieldName: "cmi.core.score._children",
|
|
41
41
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
42
42
|
});
|
|
43
43
|
h.checkSetCMIValue({
|
|
44
44
|
api: api(),
|
|
45
|
-
fieldName:
|
|
45
|
+
fieldName: "cmi.objectives._children",
|
|
46
46
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
47
47
|
});
|
|
48
48
|
h.checkSetCMIValue({
|
|
49
49
|
api: api(),
|
|
50
|
-
fieldName:
|
|
50
|
+
fieldName: "cmi.objectives._count",
|
|
51
51
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
52
52
|
});
|
|
53
53
|
h.checkSetCMIValue({
|
|
54
54
|
api: api(),
|
|
55
|
-
fieldName:
|
|
55
|
+
fieldName: "cmi.interactions._children",
|
|
56
56
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
57
57
|
});
|
|
58
58
|
h.checkSetCMIValue({
|
|
59
59
|
api: api(),
|
|
60
|
-
fieldName:
|
|
60
|
+
fieldName: "cmi.interactions._count",
|
|
61
61
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
62
62
|
});
|
|
63
63
|
h.checkSetCMIValue({
|
|
64
64
|
api: api(),
|
|
65
|
-
fieldName:
|
|
65
|
+
fieldName: "cmi.interactions.0.objectives._count",
|
|
66
66
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
67
67
|
});
|
|
68
68
|
h.checkSetCMIValue({
|
|
69
69
|
api: api(),
|
|
70
|
-
fieldName:
|
|
70
|
+
fieldName: "cmi.interactions.0.correct_responses._count",
|
|
71
71
|
expectedError: scorm12_error_codes.INVALID_SET_VALUE,
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
describe(
|
|
75
|
+
describe("Invalid Sets - Should Fail After Initialization", () => {
|
|
76
76
|
h.checkSetCMIValue({
|
|
77
77
|
api: apiInitialized(),
|
|
78
|
-
fieldName:
|
|
78
|
+
fieldName: "cmi.launch_data",
|
|
79
79
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
80
80
|
});
|
|
81
81
|
h.checkSetCMIValue({
|
|
82
82
|
api: apiInitialized(),
|
|
83
|
-
fieldName:
|
|
83
|
+
fieldName: "cmi.comments_from_lms",
|
|
84
84
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
85
85
|
});
|
|
86
86
|
h.checkSetCMIValue({
|
|
87
87
|
api: apiInitialized(),
|
|
88
|
-
fieldName:
|
|
88
|
+
fieldName: "cmi.core.student_id",
|
|
89
89
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
90
90
|
});
|
|
91
91
|
h.checkSetCMIValue({
|
|
92
92
|
api: apiInitialized(),
|
|
93
|
-
fieldName:
|
|
93
|
+
fieldName: "cmi.core.student_name",
|
|
94
94
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
95
95
|
});
|
|
96
96
|
h.checkSetCMIValue({
|
|
97
97
|
api: apiInitialized(),
|
|
98
|
-
fieldName:
|
|
98
|
+
fieldName: "cmi.core.credit",
|
|
99
99
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
100
100
|
});
|
|
101
101
|
h.checkSetCMIValue({
|
|
102
102
|
api: apiInitialized(),
|
|
103
|
-
fieldName:
|
|
103
|
+
fieldName: "cmi.core.entry",
|
|
104
104
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
105
105
|
});
|
|
106
106
|
h.checkSetCMIValue({
|
|
107
107
|
api: apiInitialized(),
|
|
108
|
-
fieldName:
|
|
108
|
+
fieldName: "cmi.core.total_time",
|
|
109
109
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
110
110
|
});
|
|
111
111
|
h.checkSetCMIValue({
|
|
112
112
|
api: apiInitialized(),
|
|
113
|
-
fieldName:
|
|
113
|
+
fieldName: "cmi.core.lesson_mode",
|
|
114
114
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
115
115
|
});
|
|
116
116
|
h.checkSetCMIValue({
|
|
117
117
|
api: apiInitialized(),
|
|
118
|
-
fieldName:
|
|
118
|
+
fieldName: "cmi.student_data.mastery_score",
|
|
119
119
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
120
120
|
});
|
|
121
121
|
h.checkSetCMIValue({
|
|
122
122
|
api: apiInitialized(),
|
|
123
|
-
fieldName:
|
|
123
|
+
fieldName: "cmi.student_data.max_time_allowed",
|
|
124
124
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
125
125
|
});
|
|
126
126
|
h.checkSetCMIValue({
|
|
127
127
|
api: apiInitialized(),
|
|
128
|
-
fieldName:
|
|
128
|
+
fieldName: "cmi.student_data.time_limit_action",
|
|
129
129
|
expectedError: scorm12_error_codes.READ_ONLY_ELEMENT,
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
describe(
|
|
135
|
-
describe(
|
|
134
|
+
describe("LMSGetValue()", () => {
|
|
135
|
+
describe("Invalid Properties - Should Always Fail", () => {
|
|
136
136
|
h.checkLMSGetValue({
|
|
137
137
|
api: apiInitialized(),
|
|
138
|
-
fieldName:
|
|
138
|
+
fieldName: "cmi.core.close",
|
|
139
139
|
expectedError: scorm12_error_codes.GENERAL,
|
|
140
140
|
errorThrown: false,
|
|
141
141
|
});
|
|
142
142
|
h.checkLMSGetValue({
|
|
143
143
|
api: apiInitialized(),
|
|
144
|
-
fieldName:
|
|
144
|
+
fieldName: "cmi.exit",
|
|
145
145
|
expectedError: scorm12_error_codes.GENERAL,
|
|
146
146
|
errorThrown: false,
|
|
147
147
|
});
|
|
148
148
|
h.checkLMSGetValue({
|
|
149
149
|
api: apiInitialized(),
|
|
150
|
-
fieldName:
|
|
150
|
+
fieldName: "cmi.entry",
|
|
151
151
|
expectedError: scorm12_error_codes.GENERAL,
|
|
152
152
|
errorThrown: false,
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
describe(
|
|
156
|
+
describe("Write-Only Properties - Should Always Fail", () => {
|
|
157
157
|
h.checkLMSGetValue({
|
|
158
158
|
api: apiInitialized(),
|
|
159
|
-
fieldName:
|
|
159
|
+
fieldName: "cmi.core.exit",
|
|
160
160
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
161
161
|
});
|
|
162
162
|
h.checkLMSGetValue({
|
|
163
163
|
api: apiInitialized(),
|
|
164
|
-
fieldName:
|
|
164
|
+
fieldName: "cmi.core.session_time",
|
|
165
165
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
166
166
|
});
|
|
167
167
|
h.checkLMSGetValue({
|
|
168
168
|
api: apiInitialized(),
|
|
169
|
-
fieldName:
|
|
169
|
+
fieldName: "cmi.interactions.0.id",
|
|
170
170
|
initializeFirst: true,
|
|
171
|
-
initializationValue:
|
|
171
|
+
initializationValue: "AAA",
|
|
172
172
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
173
173
|
});
|
|
174
174
|
h.checkLMSGetValue({
|
|
175
175
|
api: apiInitialized(),
|
|
176
|
-
fieldName:
|
|
176
|
+
fieldName: "cmi.interactions.0.time",
|
|
177
177
|
initializeFirst: true,
|
|
178
|
-
initializationValue:
|
|
178
|
+
initializationValue: "12:59:59",
|
|
179
179
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
180
180
|
});
|
|
181
181
|
h.checkLMSGetValue({
|
|
182
182
|
api: apiInitialized(),
|
|
183
|
-
fieldName:
|
|
183
|
+
fieldName: "cmi.interactions.0.type",
|
|
184
184
|
initializeFirst: true,
|
|
185
|
-
initializationValue:
|
|
185
|
+
initializationValue: "true-false",
|
|
186
186
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
187
187
|
});
|
|
188
188
|
h.checkLMSGetValue({
|
|
189
189
|
api: apiInitialized(),
|
|
190
|
-
fieldName:
|
|
190
|
+
fieldName: "cmi.interactions.0.weighting",
|
|
191
191
|
initializeFirst: true,
|
|
192
|
-
initializationValue:
|
|
192
|
+
initializationValue: "0",
|
|
193
193
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
194
194
|
});
|
|
195
195
|
h.checkLMSGetValue({
|
|
196
196
|
api: apiInitialized(),
|
|
197
|
-
fieldName:
|
|
197
|
+
fieldName: "cmi.interactions.0.student_response",
|
|
198
198
|
initializeFirst: true,
|
|
199
199
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
200
200
|
});
|
|
201
201
|
h.checkLMSGetValue({
|
|
202
202
|
api: apiInitialized(),
|
|
203
|
-
fieldName:
|
|
203
|
+
fieldName: "cmi.interactions.0.result",
|
|
204
204
|
initializeFirst: true,
|
|
205
|
-
initializationValue:
|
|
205
|
+
initializationValue: "correct",
|
|
206
206
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
207
207
|
});
|
|
208
208
|
h.checkLMSGetValue({
|
|
209
209
|
api: apiInitialized(),
|
|
210
|
-
fieldName:
|
|
210
|
+
fieldName: "cmi.interactions.0.latency",
|
|
211
211
|
initializeFirst: true,
|
|
212
|
-
initializationValue:
|
|
212
|
+
initializationValue: "01:59:59.99",
|
|
213
213
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
214
214
|
});
|
|
215
215
|
h.checkLMSGetValue({
|
|
216
216
|
api: apiInitialized(),
|
|
217
|
-
fieldName:
|
|
217
|
+
fieldName: "cmi.interactions.0.correct_responses.0.pattern",
|
|
218
218
|
initializeFirst: true,
|
|
219
219
|
expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
describe(
|
|
225
|
-
describe(
|
|
224
|
+
describe("LMSSetValue()", () => {
|
|
225
|
+
describe("Uninitialized - Should Fail", () => {
|
|
226
226
|
h.checkLMSSetValue({
|
|
227
227
|
api: api(),
|
|
228
|
-
fieldName:
|
|
228
|
+
fieldName: "cmi.objectives.0.id",
|
|
229
229
|
expectedError: scorm12_error_codes.STORE_BEFORE_INIT,
|
|
230
230
|
});
|
|
231
231
|
h.checkLMSSetValue({
|
|
232
232
|
api: api(),
|
|
233
|
-
fieldName:
|
|
233
|
+
fieldName: "cmi.interactions.0.id",
|
|
234
234
|
expectedError: scorm12_error_codes.STORE_BEFORE_INIT,
|
|
235
235
|
});
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
describe(
|
|
238
|
+
describe("Initialized - Should Succeed", () => {
|
|
239
239
|
h.checkLMSSetValue({
|
|
240
240
|
api: apiInitialized(),
|
|
241
|
-
fieldName:
|
|
242
|
-
valueToTest:
|
|
241
|
+
fieldName: "cmi.objectives.0.id",
|
|
242
|
+
valueToTest: "AAA",
|
|
243
243
|
});
|
|
244
244
|
h.checkLMSSetValue({
|
|
245
245
|
api: apiInitialized(),
|
|
246
|
-
fieldName:
|
|
247
|
-
valueToTest:
|
|
246
|
+
fieldName: "cmi.interactions.0.id",
|
|
247
|
+
valueToTest: "AAA",
|
|
248
248
|
});
|
|
249
249
|
h.checkLMSSetValue({
|
|
250
250
|
api: apiInitialized(),
|
|
251
|
-
fieldName:
|
|
252
|
-
valueToTest:
|
|
251
|
+
fieldName: "cmi.evaluation.comments.0.content",
|
|
252
|
+
valueToTest: "AAA",
|
|
253
253
|
});
|
|
254
254
|
h.checkLMSSetValue({
|
|
255
255
|
api: apiInitialized(),
|
|
256
|
-
fieldName:
|
|
257
|
-
valueToTest:
|
|
256
|
+
fieldName: "cmi.student_data.tries.0.score.max",
|
|
257
|
+
valueToTest: "100",
|
|
258
258
|
});
|
|
259
259
|
});
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
-
describe(
|
|
262
|
+
describe("replaceWithAnotherScormAPI()", () => {
|
|
263
263
|
const firstAPI = api();
|
|
264
264
|
const secondAPI = api();
|
|
265
265
|
|
|
266
|
-
firstAPI.cmi.core.student_id =
|
|
267
|
-
secondAPI.cmi.core.student_id =
|
|
266
|
+
firstAPI.cmi.core.student_id = "student_1";
|
|
267
|
+
secondAPI.cmi.core.student_id = "student_2";
|
|
268
268
|
|
|
269
269
|
firstAPI.replaceWithAnotherScormAPI(secondAPI);
|
|
270
|
-
expect(
|
|
271
|
-
firstAPI.cmi.core.student_id,
|
|
272
|
-
).to.equal('student_2');
|
|
270
|
+
expect(firstAPI.cmi.core.student_id).toEqual("student_2");
|
|
273
271
|
});
|
|
274
272
|
});
|