scorm-again 1.7.0 → 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.
Files changed (85) hide show
  1. package/.babelrc +18 -7
  2. package/.github/dependabot.yml +5 -0
  3. package/.github/workflows/main.yml +79 -0
  4. package/.jsdoc.json +4 -5
  5. package/.mocharc.json +8 -0
  6. package/.run/Mocha Unit Tests.run.xml +5 -2
  7. package/CONTRIBUTING.md +1 -1
  8. package/README.md +14 -1
  9. package/dist/aicc.js +3661 -7170
  10. package/dist/aicc.js.map +1 -1
  11. package/dist/aicc.min.js +2 -40
  12. package/dist/aicc.min.js.map +1 -0
  13. package/dist/scorm-again.js +5671 -10695
  14. package/dist/scorm-again.js.map +1 -1
  15. package/dist/scorm-again.min.js +2 -52
  16. package/dist/scorm-again.min.js.map +1 -0
  17. package/dist/scorm12.js +2871 -5433
  18. package/dist/scorm12.js.map +1 -1
  19. package/dist/scorm12.min.js +2 -34
  20. package/dist/scorm12.min.js.map +1 -0
  21. package/dist/scorm2004.js +3868 -6797
  22. package/dist/scorm2004.js.map +1 -1
  23. package/dist/scorm2004.min.js +2 -40
  24. package/dist/scorm2004.min.js.map +1 -0
  25. package/eslint.config.js +21 -0
  26. package/package.json +73 -35
  27. package/results.json +34254 -0
  28. package/src/{AICC.js → AICC.ts} +27 -21
  29. package/src/BaseAPI.ts +1449 -0
  30. package/src/Scorm12API.ts +360 -0
  31. package/src/{Scorm2004API.js → Scorm2004API.ts} +245 -163
  32. package/src/cmi/aicc_cmi.ts +1248 -0
  33. package/src/cmi/common.ts +411 -0
  34. package/src/cmi/scorm12_cmi.ts +1426 -0
  35. package/src/cmi/scorm2004_cmi.ts +1874 -0
  36. package/src/constants/api_constants.ts +318 -0
  37. package/src/constants/error_codes.ts +88 -0
  38. package/src/constants/language_constants.ts +394 -0
  39. package/src/constants/regex.ts +97 -0
  40. package/src/constants/{response_constants.js → response_constants.ts} +67 -62
  41. package/src/exceptions.ts +133 -0
  42. package/src/exports/aicc.js +1 -1
  43. package/src/exports/scorm-again.js +3 -3
  44. package/src/exports/scorm12.js +1 -1
  45. package/src/exports/scorm2004.js +1 -1
  46. package/src/{utilities.js → utilities.ts} +114 -74
  47. package/tea.yaml +6 -0
  48. package/test/{AICC.spec.js → AICC.spec.ts} +70 -72
  49. package/test/Scorm12API.spec.ts +580 -0
  50. package/test/Scorm2004API.spec.ts +812 -0
  51. package/test/api_helpers.ts +176 -0
  52. package/test/cmi/{aicc_cmi.spec.js → aicc_cmi.spec.ts} +193 -209
  53. package/test/cmi/{scorm12_cmi.spec.js → scorm12_cmi.spec.ts} +251 -269
  54. package/test/cmi/scorm2004_cmi.spec.ts +1031 -0
  55. package/test/cmi_helpers.ts +207 -0
  56. package/test/exceptions.spec.ts +79 -0
  57. package/test/field_values.ts +202 -0
  58. package/test/utilities.spec.ts +322 -0
  59. package/tsconfig.json +18 -0
  60. package/webpack.config.js +65 -0
  61. package/.circleci/config.yml +0 -99
  62. package/.codeclimate.yml +0 -7
  63. package/.eslintrc.js +0 -36
  64. package/src/.flowconfig +0 -11
  65. package/src/BaseAPI.js +0 -1275
  66. package/src/Scorm12API.js +0 -308
  67. package/src/cmi/aicc_cmi.js +0 -1141
  68. package/src/cmi/common.js +0 -328
  69. package/src/cmi/scorm12_cmi.js +0 -1312
  70. package/src/cmi/scorm2004_cmi.js +0 -1692
  71. package/src/constants/api_constants.js +0 -218
  72. package/src/constants/error_codes.js +0 -87
  73. package/src/constants/language_constants.js +0 -76
  74. package/src/constants/regex.js +0 -84
  75. package/src/exceptions.js +0 -104
  76. package/test/Scorm12API.spec.js +0 -528
  77. package/test/Scorm2004API.spec.js +0 -775
  78. package/test/abstract_classes.spec.js +0 -17
  79. package/test/api_helpers.js +0 -128
  80. package/test/cmi/scorm2004_cmi.spec.js +0 -1066
  81. package/test/cmi_helpers.js +0 -161
  82. package/test/exceptions.spec.js +0 -71
  83. package/test/field_values.js +0 -353
  84. package/test/utilities.spec.js +0 -339
  85. package/webpack.js +0 -78
@@ -1,14 +1,14 @@
1
- import {expect} from 'chai';
2
- import {describe, it} from 'mocha';
3
- import * as h from './api_helpers';
4
- import ErrorCodes from '../src/constants/error_codes';
5
- import AICC from '../src/AICC';
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 = 1;
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('AICC API Tests', () => {
21
- describe('setCMIValue()', () => {
22
- describe('Invalid Sets - Should Always Fail', () => {
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: 'cmi._version',
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: 'cmi._children',
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: 'cmi.core._children',
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: 'cmi.core.score._children',
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: 'cmi.objectives._children',
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: 'cmi.objectives._count',
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: 'cmi.interactions._children',
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: 'cmi.interactions._count',
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: 'cmi.interactions.0.objectives._count',
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: 'cmi.interactions.0.correct_responses._count',
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('Invalid Sets - Should Fail After Initialization', () => {
75
+ describe("Invalid Sets - Should Fail After Initialization", () => {
76
76
  h.checkSetCMIValue({
77
77
  api: apiInitialized(),
78
- fieldName: 'cmi.launch_data',
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: 'cmi.comments_from_lms',
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: 'cmi.core.student_id',
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: 'cmi.core.student_name',
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: 'cmi.core.credit',
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: 'cmi.core.entry',
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: 'cmi.core.total_time',
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: 'cmi.core.lesson_mode',
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: 'cmi.student_data.mastery_score',
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: 'cmi.student_data.max_time_allowed',
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: 'cmi.student_data.time_limit_action',
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('LMSGetValue()', () => {
135
- describe('Invalid Properties - Should Always Fail', () => {
134
+ describe("LMSGetValue()", () => {
135
+ describe("Invalid Properties - Should Always Fail", () => {
136
136
  h.checkLMSGetValue({
137
137
  api: apiInitialized(),
138
- fieldName: 'cmi.core.close',
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: 'cmi.exit',
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: 'cmi.entry',
150
+ fieldName: "cmi.entry",
151
151
  expectedError: scorm12_error_codes.GENERAL,
152
152
  errorThrown: false,
153
153
  });
154
154
  });
155
155
 
156
- describe('Write-Only Properties - Should Always Fail', () => {
156
+ describe("Write-Only Properties - Should Always Fail", () => {
157
157
  h.checkLMSGetValue({
158
158
  api: apiInitialized(),
159
- fieldName: 'cmi.core.exit',
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: 'cmi.core.session_time',
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: 'cmi.interactions.0.id',
169
+ fieldName: "cmi.interactions.0.id",
170
170
  initializeFirst: true,
171
- initializationValue: 'AAA',
171
+ initializationValue: "AAA",
172
172
  expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
173
173
  });
174
174
  h.checkLMSGetValue({
175
175
  api: apiInitialized(),
176
- fieldName: 'cmi.interactions.0.time',
176
+ fieldName: "cmi.interactions.0.time",
177
177
  initializeFirst: true,
178
- initializationValue: '12:59:59',
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: 'cmi.interactions.0.type',
183
+ fieldName: "cmi.interactions.0.type",
184
184
  initializeFirst: true,
185
- initializationValue: 'true-false',
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: 'cmi.interactions.0.weighting',
190
+ fieldName: "cmi.interactions.0.weighting",
191
191
  initializeFirst: true,
192
- initializationValue: '0',
192
+ initializationValue: "0",
193
193
  expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
194
194
  });
195
195
  h.checkLMSGetValue({
196
196
  api: apiInitialized(),
197
- fieldName: 'cmi.interactions.0.student_response',
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: 'cmi.interactions.0.result',
203
+ fieldName: "cmi.interactions.0.result",
204
204
  initializeFirst: true,
205
- initializationValue: 'correct',
205
+ initializationValue: "correct",
206
206
  expectedError: scorm12_error_codes.WRITE_ONLY_ELEMENT,
207
207
  });
208
208
  h.checkLMSGetValue({
209
209
  api: apiInitialized(),
210
- fieldName: 'cmi.interactions.0.latency',
210
+ fieldName: "cmi.interactions.0.latency",
211
211
  initializeFirst: true,
212
- initializationValue: '01:59:59.99',
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: 'cmi.interactions.0.correct_responses.0.pattern',
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('LMSSetValue()', () => {
225
- describe('Uninitialized - Should Fail', () => {
224
+ describe("LMSSetValue()", () => {
225
+ describe("Uninitialized - Should Fail", () => {
226
226
  h.checkLMSSetValue({
227
227
  api: api(),
228
- fieldName: 'cmi.objectives.0.id',
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: 'cmi.interactions.0.id',
233
+ fieldName: "cmi.interactions.0.id",
234
234
  expectedError: scorm12_error_codes.STORE_BEFORE_INIT,
235
235
  });
236
236
  });
237
237
 
238
- describe('Initialized - Should Succeed', () => {
238
+ describe("Initialized - Should Succeed", () => {
239
239
  h.checkLMSSetValue({
240
240
  api: apiInitialized(),
241
- fieldName: 'cmi.objectives.0.id',
242
- valueToTest: 'AAA',
241
+ fieldName: "cmi.objectives.0.id",
242
+ valueToTest: "AAA",
243
243
  });
244
244
  h.checkLMSSetValue({
245
245
  api: apiInitialized(),
246
- fieldName: 'cmi.interactions.0.id',
247
- valueToTest: 'AAA',
246
+ fieldName: "cmi.interactions.0.id",
247
+ valueToTest: "AAA",
248
248
  });
249
249
  h.checkLMSSetValue({
250
250
  api: apiInitialized(),
251
- fieldName: 'cmi.evaluation.comments.0.content',
252
- valueToTest: 'AAA',
251
+ fieldName: "cmi.evaluation.comments.0.content",
252
+ valueToTest: "AAA",
253
253
  });
254
254
  h.checkLMSSetValue({
255
255
  api: apiInitialized(),
256
- fieldName: 'cmi.student_data.tries.0.score.max',
257
- valueToTest: '100',
256
+ fieldName: "cmi.student_data.tries.0.score.max",
257
+ valueToTest: "100",
258
258
  });
259
259
  });
260
260
  });
261
261
 
262
- describe('replaceWithAnotherScormAPI()', () => {
262
+ describe("replaceWithAnotherScormAPI()", () => {
263
263
  const firstAPI = api();
264
264
  const secondAPI = api();
265
265
 
266
- firstAPI.cmi.core.student_id = 'student_1';
267
- secondAPI.cmi.core.student_id = 'student_2';
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
  });