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.
Files changed (87) hide show
  1. package/dist/aicc.js +657 -489
  2. package/dist/aicc.js.map +1 -1
  3. package/dist/aicc.min.js +1 -1
  4. package/dist/aicc.min.js.map +1 -1
  5. package/dist/esm/aicc.js +670 -489
  6. package/dist/esm/aicc.js.map +1 -1
  7. package/dist/esm/aicc.min.js +1 -1
  8. package/dist/esm/aicc.min.js.map +1 -1
  9. package/dist/esm/scorm-again.js +1113 -729
  10. package/dist/esm/scorm-again.js.map +1 -1
  11. package/dist/esm/scorm-again.min.js +1 -1
  12. package/dist/esm/scorm-again.min.js.map +1 -1
  13. package/dist/esm/scorm12.js +512 -394
  14. package/dist/esm/scorm12.js.map +1 -1
  15. package/dist/esm/scorm12.min.js +1 -1
  16. package/dist/esm/scorm12.min.js.map +1 -1
  17. package/dist/esm/scorm2004.js +678 -452
  18. package/dist/esm/scorm2004.js.map +1 -1
  19. package/dist/esm/scorm2004.min.js +1 -1
  20. package/dist/esm/scorm2004.min.js.map +1 -1
  21. package/dist/scorm-again.js +1100 -728
  22. package/dist/scorm-again.js.map +1 -1
  23. package/dist/scorm-again.min.js +1 -1
  24. package/dist/scorm-again.min.js.map +1 -1
  25. package/dist/scorm12.js +500 -394
  26. package/dist/scorm12.js.map +1 -1
  27. package/dist/scorm12.min.js +1 -1
  28. package/dist/scorm12.min.js.map +1 -1
  29. package/dist/scorm2004.js +665 -452
  30. package/dist/scorm2004.js.map +1 -1
  31. package/dist/scorm2004.min.js +1 -1
  32. package/dist/scorm2004.min.js.map +1 -1
  33. package/dist_test.html +208 -0
  34. package/package.json +14 -14
  35. package/src/AICC.ts +6 -3
  36. package/src/BaseAPI.ts +43 -37
  37. package/src/Scorm12API.ts +17 -23
  38. package/src/Scorm2004API.ts +99 -42
  39. package/src/ScormAgain.ts +3 -7
  40. package/src/cmi/aicc/attempts.ts +22 -12
  41. package/src/cmi/aicc/cmi.ts +2 -2
  42. package/src/cmi/aicc/core.ts +44 -26
  43. package/src/cmi/aicc/evaluation.ts +31 -12
  44. package/src/cmi/aicc/paths.ts +29 -15
  45. package/src/cmi/aicc/student_data.ts +14 -5
  46. package/src/cmi/aicc/student_demographics.ts +31 -24
  47. package/src/cmi/aicc/student_preferences.ts +11 -11
  48. package/src/cmi/aicc/tries.ts +24 -14
  49. package/src/cmi/aicc/validation.ts +3 -4
  50. package/src/cmi/common/array.ts +17 -5
  51. package/src/cmi/common/base_cmi.ts +3 -1
  52. package/src/cmi/common/score.ts +16 -13
  53. package/src/cmi/scorm12/cmi.ts +25 -10
  54. package/src/cmi/scorm12/interactions.ts +62 -28
  55. package/src/cmi/scorm12/nav.ts +13 -5
  56. package/src/cmi/scorm12/objectives.ts +28 -18
  57. package/src/cmi/scorm12/student_data.ts +15 -8
  58. package/src/cmi/scorm12/student_preference.ts +20 -13
  59. package/src/cmi/scorm12/validation.ts +7 -7
  60. package/src/cmi/scorm2004/adl.ts +141 -25
  61. package/src/cmi/scorm2004/cmi.ts +50 -55
  62. package/src/cmi/scorm2004/comments.ts +21 -20
  63. package/src/cmi/scorm2004/interactions.ts +73 -32
  64. package/src/cmi/scorm2004/learner_preference.ts +20 -13
  65. package/src/cmi/scorm2004/objectives.ts +41 -16
  66. package/src/cmi/scorm2004/score.ts +22 -11
  67. package/src/cmi/scorm2004/validation.ts +4 -4
  68. package/src/constants/api_constants.ts +8 -19
  69. package/src/constants/default_settings.ts +6 -5
  70. package/src/constants/error_codes.ts +5 -12
  71. package/src/constants/regex.ts +4 -10
  72. package/src/constants/response_constants.ts +1 -2
  73. package/src/exceptions/aicc_exceptions.ts +29 -0
  74. package/src/exceptions/scorm12_exceptions.ts +29 -0
  75. package/src/exceptions/scorm2004_exceptions.ts +29 -0
  76. package/src/exceptions.ts +0 -81
  77. package/src/types/api_types.ts +3 -2
  78. package/test/AICC.spec.ts +114 -43
  79. package/test/Scorm12API.spec.ts +60 -39
  80. package/test/Scorm2004API.spec.ts +165 -80
  81. package/test/cmi/aicc_cmi.spec.ts +6 -9
  82. package/test/cmi/scorm12_cmi.spec.ts +8 -8
  83. package/test/cmi/scorm2004_cmi.spec.ts +8 -9
  84. package/test/exceptions.spec.ts +11 -9
  85. package/test/types/api_types.spec.ts +3 -3
  86. package/test/utilities.spec.ts +1 -4
  87. package/webpack.config.js +5 -1
@@ -1,10 +1,10 @@
1
1
  import { CMIArray } from "../common/array";
2
- import { AICCValidationError } from "../../exceptions";
2
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
3
3
  import { BaseCMI } from "../common/base_cmi";
4
- import APIConstants from "../../constants/api_constants";
5
- import ErrorCodes from "../../constants/error_codes";
4
+ import { aicc_constants } from "../../constants/api_constants";
5
+ import { scorm12_errors } from "../../constants/error_codes";
6
6
  import { checkAICCValidFormat } from "./validation";
7
- import Regex from "../../constants/regex";
7
+ import { aicc_regex } from "../../constants/regex";
8
8
 
9
9
  /**
10
10
  * AICC Evaluation object
@@ -28,6 +28,14 @@ export class CMIEvaluation extends BaseCMI {
28
28
  this.comments?.initialize();
29
29
  }
30
30
 
31
+ /**
32
+ * Called when the API has been reset
33
+ */
34
+ reset(): void {
35
+ this._initialized = false;
36
+ this.comments?.reset();
37
+ }
38
+
31
39
  /**
32
40
  * toJSON for cmi.evaluation object
33
41
  * @return {{comments: CMIEvaluationComments}}
@@ -54,8 +62,8 @@ class CMIEvaluationComments extends CMIArray {
54
62
  */
55
63
  constructor() {
56
64
  super({
57
- children: APIConstants.aicc.comments_children,
58
- errorCode: ErrorCodes.scorm12.INVALID_SET_VALUE,
65
+ children: aicc_constants.comments_children,
66
+ errorCode: scorm12_errors.INVALID_SET_VALUE,
59
67
  errorClass: AICCValidationError,
60
68
  });
61
69
  }
@@ -65,6 +73,10 @@ class CMIEvaluationComments extends CMIArray {
65
73
  * Class for AICC Evaluation Comments
66
74
  */
67
75
  export class CMIEvaluationCommentsObject extends BaseCMI {
76
+ private _content = "";
77
+ private _location = "";
78
+ private _time = "";
79
+
68
80
  /**
69
81
  * Constructor for Evaluation Comments
70
82
  */
@@ -72,9 +84,16 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
72
84
  super();
73
85
  }
74
86
 
75
- private _content = "";
76
- private _location = "";
77
- private _time = "";
87
+ /**
88
+ * Called when the API has been reset
89
+ */
90
+ reset(): void {
91
+ this._initialized = false;
92
+
93
+ this._content = "";
94
+ this._location = "";
95
+ this._time = "";
96
+ }
78
97
 
79
98
  /**
80
99
  * Getter for _content
@@ -89,7 +108,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
89
108
  * @param {string} content
90
109
  */
91
110
  set content(content: string) {
92
- if (checkAICCValidFormat(content, Regex.aicc.CMIString256)) {
111
+ if (checkAICCValidFormat(content, aicc_regex.CMIString256)) {
93
112
  this._content = content;
94
113
  }
95
114
  }
@@ -107,7 +126,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
107
126
  * @param {string} location
108
127
  */
109
128
  set location(location: string) {
110
- if (checkAICCValidFormat(location, Regex.aicc.CMIString256)) {
129
+ if (checkAICCValidFormat(location, aicc_regex.CMIString256)) {
111
130
  this._location = location;
112
131
  }
113
132
  }
@@ -125,7 +144,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
125
144
  * @param {string} time
126
145
  */
127
146
  set time(time: string) {
128
- if (checkAICCValidFormat(time, Regex.aicc.CMITime)) {
147
+ if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
129
148
  this._time = time;
130
149
  }
131
150
  }
@@ -1,8 +1,8 @@
1
1
  import { BaseCMI } from "../common/base_cmi";
2
2
  import { checkAICCValidFormat } from "./validation";
3
3
  import { CMIArray } from "../common/array";
4
- import Regex from "../../constants/regex";
5
- import APIConstants from "../../constants/api_constants";
4
+ import { aicc_regex } from "../../constants/regex";
5
+ import { aicc_constants } from "../../constants/api_constants";
6
6
 
7
7
  /**
8
8
  * Class representing the AICC `cmi.paths` object
@@ -13,7 +13,7 @@ export class CMIPaths extends CMIArray {
13
13
  */
14
14
  constructor() {
15
15
  super({
16
- children: APIConstants.aicc.paths_children,
16
+ children: aicc_constants.paths_children,
17
17
  });
18
18
  }
19
19
  }
@@ -22,6 +22,13 @@ export class CMIPaths extends CMIArray {
22
22
  * Class for AICC Paths
23
23
  */
24
24
  export class CMIPathsObject extends BaseCMI {
25
+ private _location_id = "";
26
+ private _date = "";
27
+ private _time = "";
28
+ private _status = "";
29
+ private _why_left = "";
30
+ private _time_in_element = "";
31
+
25
32
  /**
26
33
  * Constructor for AICC Paths objects
27
34
  */
@@ -29,12 +36,19 @@ export class CMIPathsObject extends BaseCMI {
29
36
  super();
30
37
  }
31
38
 
32
- private _location_id = "";
33
- private _date = "";
34
- private _time = "";
35
- private _status = "";
36
- private _why_left = "";
37
- private _time_in_element = "";
39
+ /**
40
+ * Called when the API has been reset
41
+ */
42
+ reset(): void {
43
+ this._initialized = false;
44
+
45
+ this._location_id = "";
46
+ this._date = "";
47
+ this._time = "";
48
+ this._status = "";
49
+ this._why_left = "";
50
+ this._time_in_element = "";
51
+ }
38
52
 
39
53
  /**
40
54
  * Getter for _location_id
@@ -49,7 +63,7 @@ export class CMIPathsObject extends BaseCMI {
49
63
  * @param {string} location_id
50
64
  */
51
65
  set location_id(location_id: string) {
52
- if (checkAICCValidFormat(location_id, Regex.aicc.CMIString256)) {
66
+ if (checkAICCValidFormat(location_id, aicc_regex.CMIString256)) {
53
67
  this._location_id = location_id;
54
68
  }
55
69
  }
@@ -67,7 +81,7 @@ export class CMIPathsObject extends BaseCMI {
67
81
  * @param {string} date
68
82
  */
69
83
  set date(date: string) {
70
- if (checkAICCValidFormat(date, Regex.aicc.CMIString256)) {
84
+ if (checkAICCValidFormat(date, aicc_regex.CMIString256)) {
71
85
  this._date = date;
72
86
  }
73
87
  }
@@ -85,7 +99,7 @@ export class CMIPathsObject extends BaseCMI {
85
99
  * @param {string} time
86
100
  */
87
101
  set time(time: string) {
88
- if (checkAICCValidFormat(time, Regex.aicc.CMITime)) {
102
+ if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
89
103
  this._time = time;
90
104
  }
91
105
  }
@@ -103,7 +117,7 @@ export class CMIPathsObject extends BaseCMI {
103
117
  * @param {string} status
104
118
  */
105
119
  set status(status: string) {
106
- if (checkAICCValidFormat(status, Regex.aicc.CMIStatus2)) {
120
+ if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
107
121
  this._status = status;
108
122
  }
109
123
  }
@@ -121,7 +135,7 @@ export class CMIPathsObject extends BaseCMI {
121
135
  * @param {string} why_left
122
136
  */
123
137
  set why_left(why_left: string) {
124
- if (checkAICCValidFormat(why_left, Regex.aicc.CMIString256)) {
138
+ if (checkAICCValidFormat(why_left, aicc_regex.CMIString256)) {
125
139
  this._why_left = why_left;
126
140
  }
127
141
  }
@@ -139,7 +153,7 @@ export class CMIPathsObject extends BaseCMI {
139
153
  * @param {string} time_in_element
140
154
  */
141
155
  set time_in_element(time_in_element: string) {
142
- if (checkAICCValidFormat(time_in_element, Regex.aicc.CMITime)) {
156
+ if (checkAICCValidFormat(time_in_element, aicc_regex.CMITime)) {
143
157
  this._time_in_element = time_in_element;
144
158
  }
145
159
  }
@@ -1,6 +1,6 @@
1
- import { AICCValidationError } from "../../exceptions";
2
- import ErrorCodes from "../../constants/error_codes";
3
- import APIConstants from "../../constants/api_constants";
1
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
2
+ import { scorm12_errors } from "../../constants/error_codes";
3
+ import { aicc_constants } from "../../constants/api_constants";
4
4
  import { CMITries } from "./tries";
5
5
  import { CMIStudentData } from "../scorm12/student_data";
6
6
  import { CMIAttemptRecords } from "./attempts";
@@ -13,7 +13,7 @@ export class AICCCMIStudentData extends CMIStudentData {
13
13
  * Constructor for AICC StudentData object
14
14
  */
15
15
  constructor() {
16
- super(APIConstants.aicc.student_data_children);
16
+ super(aicc_constants.student_data_children);
17
17
  this.tries = new CMITries();
18
18
  this.attempt_records = new CMIAttemptRecords();
19
19
  }
@@ -30,6 +30,15 @@ export class AICCCMIStudentData extends CMIStudentData {
30
30
  this.attempt_records?.initialize();
31
31
  }
32
32
 
33
+ /**
34
+ * Called when the API has been reset
35
+ */
36
+ override reset(): void {
37
+ this._initialized = false;
38
+ this.tries?.reset(true);
39
+ this.attempt_records?.reset(true);
40
+ }
41
+
33
42
  private _tries_during_lesson = "";
34
43
 
35
44
  /**
@@ -47,7 +56,7 @@ export class AICCCMIStudentData extends CMIStudentData {
47
56
  */
48
57
  set tries_during_lesson(tries_during_lesson: string) {
49
58
  if (this.initialized) {
50
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
59
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
51
60
  } else {
52
61
  this._tries_during_lesson = tries_during_lesson;
53
62
  }
@@ -1,20 +1,13 @@
1
1
  import { BaseCMI } from "../common/base_cmi";
2
- import { AICCValidationError } from "../../exceptions";
3
- import APIConstants from "../../constants/api_constants";
4
- import ErrorCodes from "../../constants/error_codes";
2
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
3
+ import { aicc_constants } from "../../constants/api_constants";
4
+ import { scorm12_errors } from "../../constants/error_codes";
5
5
 
6
6
  /**
7
7
  * Class representing the AICC cmi.student_demographics object
8
8
  */
9
9
  export class CMIStudentDemographics extends BaseCMI {
10
- /**
11
- * Constructor for AICC StudentDemographics object
12
- */
13
- constructor() {
14
- super();
15
- }
16
-
17
- private __children = APIConstants.aicc.student_demographics_children;
10
+ private __children = aicc_constants.student_demographics_children;
18
11
  private _city = "";
19
12
  private _class = "";
20
13
  private _company = "";
@@ -29,6 +22,20 @@ export class CMIStudentDemographics extends BaseCMI {
29
22
  private _telephone = "";
30
23
  private _years_experience = "";
31
24
 
25
+ /**
26
+ * Constructor for AICC StudentDemographics object
27
+ */
28
+ constructor() {
29
+ super();
30
+ }
31
+
32
+ /**
33
+ * Called when the API has been reset
34
+ */
35
+ reset(): void {
36
+ this._initialized = false;
37
+ }
38
+
32
39
  /**
33
40
  * Getter for _children
34
41
  * @return {string}
@@ -52,7 +59,7 @@ export class CMIStudentDemographics extends BaseCMI {
52
59
  */
53
60
  set city(city: string) {
54
61
  if (this.initialized) {
55
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
62
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
56
63
  } else {
57
64
  this._city = city;
58
65
  }
@@ -73,7 +80,7 @@ export class CMIStudentDemographics extends BaseCMI {
73
80
  */
74
81
  set class(clazz: string) {
75
82
  if (this.initialized) {
76
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
83
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
77
84
  } else {
78
85
  this._class = clazz;
79
86
  }
@@ -94,7 +101,7 @@ export class CMIStudentDemographics extends BaseCMI {
94
101
  */
95
102
  set company(company: string) {
96
103
  if (this.initialized) {
97
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
104
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
98
105
  } else {
99
106
  this._company = company;
100
107
  }
@@ -115,7 +122,7 @@ export class CMIStudentDemographics extends BaseCMI {
115
122
  */
116
123
  set country(country: string) {
117
124
  if (this.initialized) {
118
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
125
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
119
126
  } else {
120
127
  this._country = country;
121
128
  }
@@ -136,7 +143,7 @@ export class CMIStudentDemographics extends BaseCMI {
136
143
  */
137
144
  set experience(experience: string) {
138
145
  if (this.initialized) {
139
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
146
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
140
147
  } else {
141
148
  this._experience = experience;
142
149
  }
@@ -157,7 +164,7 @@ export class CMIStudentDemographics extends BaseCMI {
157
164
  */
158
165
  set familiar_name(familiar_name: string) {
159
166
  if (this.initialized) {
160
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
167
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
161
168
  } else {
162
169
  this._familiar_name = familiar_name;
163
170
  }
@@ -178,7 +185,7 @@ export class CMIStudentDemographics extends BaseCMI {
178
185
  */
179
186
  set instructor_name(instructor_name: string) {
180
187
  if (this.initialized) {
181
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
188
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
182
189
  } else {
183
190
  this._instructor_name = instructor_name;
184
191
  }
@@ -199,7 +206,7 @@ export class CMIStudentDemographics extends BaseCMI {
199
206
  */
200
207
  set title(title: string) {
201
208
  if (this.initialized) {
202
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
209
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
203
210
  } else {
204
211
  this._title = title;
205
212
  }
@@ -220,7 +227,7 @@ export class CMIStudentDemographics extends BaseCMI {
220
227
  */
221
228
  set native_language(native_language: string) {
222
229
  if (this.initialized) {
223
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
230
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
224
231
  } else {
225
232
  this._native_language = native_language;
226
233
  }
@@ -241,7 +248,7 @@ export class CMIStudentDemographics extends BaseCMI {
241
248
  */
242
249
  set state(state: string) {
243
250
  if (this.initialized) {
244
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
251
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
245
252
  } else {
246
253
  this._state = state;
247
254
  }
@@ -262,7 +269,7 @@ export class CMIStudentDemographics extends BaseCMI {
262
269
  */
263
270
  set street_address(street_address: string) {
264
271
  if (this.initialized) {
265
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
272
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
266
273
  } else {
267
274
  this._street_address = street_address;
268
275
  }
@@ -283,7 +290,7 @@ export class CMIStudentDemographics extends BaseCMI {
283
290
  */
284
291
  set telephone(telephone: string) {
285
292
  if (this.initialized) {
286
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
293
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
287
294
  } else {
288
295
  this._telephone = telephone;
289
296
  }
@@ -304,7 +311,7 @@ export class CMIStudentDemographics extends BaseCMI {
304
311
  */
305
312
  set years_experience(years_experience: string) {
306
313
  if (this.initialized) {
307
- throw new AICCValidationError(ErrorCodes.scorm12.READ_ONLY_ELEMENT);
314
+ throw new AICCValidationError(scorm12_errors.READ_ONLY_ELEMENT);
308
315
  } else {
309
316
  this._years_experience = years_experience;
310
317
  }
@@ -1,9 +1,9 @@
1
1
  import { CMIArray } from "../common/array";
2
- import { AICCValidationError } from "../../exceptions";
2
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
3
3
  import { checkAICCValidFormat } from "./validation";
4
- import ErrorCodes from "../../constants/error_codes";
5
- import Regex from "../../constants/regex";
6
- import APIConstants from "../../constants/api_constants";
4
+ import { scorm12_errors } from "../../constants/error_codes";
5
+ import { aicc_regex } from "../../constants/regex";
6
+ import { aicc_constants } from "../../constants/api_constants";
7
7
  import { CMIStudentPreference } from "../scorm12/student_preference";
8
8
 
9
9
  /**
@@ -14,9 +14,9 @@ export class AICCStudentPreferences extends CMIStudentPreference {
14
14
  * Constructor for AICC Student Preferences object
15
15
  */
16
16
  constructor() {
17
- super(APIConstants.aicc.student_preference_children);
17
+ super(aicc_constants.student_preference_children);
18
18
  this.windows = new CMIArray({
19
- errorCode: ErrorCodes.scorm12.INVALID_SET_VALUE,
19
+ errorCode: scorm12_errors.INVALID_SET_VALUE,
20
20
  errorClass: AICCValidationError,
21
21
  children: "",
22
22
  });
@@ -51,7 +51,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
51
51
  * @param {string} lesson_type
52
52
  */
53
53
  set lesson_type(lesson_type: string) {
54
- if (checkAICCValidFormat(lesson_type, Regex.aicc.CMIString256)) {
54
+ if (checkAICCValidFormat(lesson_type, aicc_regex.CMIString256)) {
55
55
  this._lesson_type = lesson_type;
56
56
  }
57
57
  }
@@ -69,7 +69,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
69
69
  * @param {string} text_color
70
70
  */
71
71
  set text_color(text_color: string) {
72
- if (checkAICCValidFormat(text_color, Regex.aicc.CMIString256)) {
72
+ if (checkAICCValidFormat(text_color, aicc_regex.CMIString256)) {
73
73
  this._text_color = text_color;
74
74
  }
75
75
  }
@@ -87,7 +87,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
87
87
  * @param {string} text_location
88
88
  */
89
89
  set text_location(text_location: string) {
90
- if (checkAICCValidFormat(text_location, Regex.aicc.CMIString256)) {
90
+ if (checkAICCValidFormat(text_location, aicc_regex.CMIString256)) {
91
91
  this._text_location = text_location;
92
92
  }
93
93
  }
@@ -105,7 +105,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
105
105
  * @param {string} text_size
106
106
  */
107
107
  set text_size(text_size: string) {
108
- if (checkAICCValidFormat(text_size, Regex.aicc.CMIString256)) {
108
+ if (checkAICCValidFormat(text_size, aicc_regex.CMIString256)) {
109
109
  this._text_size = text_size;
110
110
  }
111
111
  }
@@ -123,7 +123,7 @@ export class AICCStudentPreferences extends CMIStudentPreference {
123
123
  * @param {string} video
124
124
  */
125
125
  set video(video: string) {
126
- if (checkAICCValidFormat(video, Regex.aicc.CMIString256)) {
126
+ if (checkAICCValidFormat(video, aicc_regex.CMIString256)) {
127
127
  this._video = video;
128
128
  }
129
129
  }
@@ -1,10 +1,10 @@
1
1
  import { CMIArray } from "../common/array";
2
- import APIConstants from "../../constants/api_constants";
2
+ import { aicc_constants } from "../../constants/api_constants";
3
3
  import { BaseCMI } from "../common/base_cmi";
4
4
  import { CMIScore } from "../common/score";
5
- import Regex from "../../constants/regex";
6
- import ErrorCodes from "../../constants/error_codes";
7
- import { AICCValidationError } from "../../exceptions";
5
+ import { aicc_regex } from "../../constants/regex";
6
+ import { scorm12_errors } from "../../constants/error_codes";
7
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
8
8
  import { checkAICCValidFormat } from "./validation";
9
9
 
10
10
  /**
@@ -16,7 +16,7 @@ export class CMITries extends CMIArray {
16
16
  */
17
17
  constructor() {
18
18
  super({
19
- children: APIConstants.aicc.tries_children,
19
+ children: aicc_constants.tries_children,
20
20
  });
21
21
  }
22
22
  }
@@ -25,17 +25,20 @@ export class CMITries extends CMIArray {
25
25
  * Class for AICC Tries
26
26
  */
27
27
  export class CMITriesObject extends BaseCMI {
28
+ private _status = "";
29
+ private _time = "";
30
+
28
31
  /**
29
32
  * Constructor for AICC Tries object
30
33
  */
31
34
  constructor() {
32
35
  super();
33
36
  this.score = new CMIScore({
34
- score_children: APIConstants.aicc.score_children,
35
- score_range: Regex.aicc.score_range,
36
- invalidErrorCode: ErrorCodes.scorm12.INVALID_SET_VALUE,
37
- invalidTypeCode: ErrorCodes.scorm12.TYPE_MISMATCH,
38
- invalidRangeCode: ErrorCodes.scorm12.VALUE_OUT_OF_RANGE,
37
+ score_children: aicc_constants.score_children,
38
+ score_range: aicc_regex.score_range,
39
+ invalidErrorCode: scorm12_errors.INVALID_SET_VALUE,
40
+ invalidTypeCode: scorm12_errors.TYPE_MISMATCH,
41
+ invalidRangeCode: scorm12_errors.VALUE_OUT_OF_RANGE,
39
42
  errorClass: AICCValidationError,
40
43
  });
41
44
  }
@@ -50,8 +53,15 @@ export class CMITriesObject extends BaseCMI {
50
53
  this.score?.initialize();
51
54
  }
52
55
 
53
- private _status = "";
54
- private _time = "";
56
+ /**
57
+ * Called when the API has been reset
58
+ */
59
+ reset(): void {
60
+ this._initialized = false;
61
+ this._status = "";
62
+ this._time = "";
63
+ this.score?.reset();
64
+ }
55
65
 
56
66
  /**
57
67
  * Getter for _status
@@ -66,7 +76,7 @@ export class CMITriesObject extends BaseCMI {
66
76
  * @param {string} status
67
77
  */
68
78
  set status(status: string) {
69
- if (checkAICCValidFormat(status, Regex.aicc.CMIStatus2)) {
79
+ if (checkAICCValidFormat(status, aicc_regex.CMIStatus2)) {
70
80
  this._status = status;
71
81
  }
72
82
  }
@@ -84,7 +94,7 @@ export class CMITriesObject extends BaseCMI {
84
94
  * @param {string} time
85
95
  */
86
96
  set time(time: string) {
87
- if (checkAICCValidFormat(time, Regex.aicc.CMITime)) {
97
+ if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
88
98
  this._time = time;
89
99
  }
90
100
  }
@@ -1,7 +1,6 @@
1
1
  import { checkValidFormat } from "../common/validation";
2
- import { AICCValidationError } from "../../exceptions";
3
- import ErrorCodes from "../../constants/error_codes";
4
- const aicc_error_codes = ErrorCodes.scorm12;
2
+ import { AICCValidationError } from "../../exceptions/aicc_exceptions";
3
+ import { scorm12_errors } from "../../constants/error_codes";
5
4
 
6
5
  /**
7
6
  * Helper method, no reason to have to pass the same error codes every time
@@ -18,7 +17,7 @@ export function checkAICCValidFormat(
18
17
  return checkValidFormat(
19
18
  value,
20
19
  regexPattern,
21
- aicc_error_codes.TYPE_MISMATCH,
20
+ scorm12_errors.TYPE_MISMATCH,
22
21
  AICCValidationError,
23
22
  allowEmptyString,
24
23
  );
@@ -1,8 +1,6 @@
1
1
  import { BaseCMI } from "./base_cmi";
2
- import ErrorCodes from "../../constants/error_codes";
3
2
  import { BaseScormValidationError } from "../../exceptions";
4
-
5
- export const scorm12_error_codes = ErrorCodes.scorm12;
3
+ import { scorm12_errors } from "../../constants/error_codes";
6
4
 
7
5
  /**
8
6
  * Base class for cmi *.n objects
@@ -11,7 +9,7 @@ export class CMIArray extends BaseCMI {
11
9
  private readonly _errorCode: number;
12
10
  private readonly _errorClass: typeof BaseScormValidationError;
13
11
  private readonly __children: string;
14
- childArray: any[];
12
+ public childArray: any[];
15
13
 
16
14
  /**
17
15
  * Constructor cmi *.n arrays
@@ -24,11 +22,25 @@ export class CMIArray extends BaseCMI {
24
22
  }) {
25
23
  super();
26
24
  this.__children = params.children;
27
- this._errorCode = params.errorCode || scorm12_error_codes.GENERAL;
25
+ this._errorCode = params.errorCode || scorm12_errors.GENERAL;
28
26
  this._errorClass = params.errorClass || BaseScormValidationError;
29
27
  this.childArray = [];
30
28
  }
31
29
 
30
+ /**
31
+ * Called when the API has been reset
32
+ */
33
+ reset(wipe: boolean = false): void {
34
+ this._initialized = false;
35
+ if (wipe) {
36
+ this.childArray = [];
37
+ } else {
38
+ // Reset all children
39
+ for (let i = 0; i < this.childArray.length; i++) {
40
+ this.childArray[i].reset();
41
+ }
42
+ }
43
+ }
32
44
  /**
33
45
  * Getter for _children
34
46
  * @return {string}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export abstract class BaseCMI {
5
5
  jsonString? = false;
6
- private _initialized = false;
6
+ protected _initialized = false;
7
7
  private _start_time: number | undefined;
8
8
 
9
9
  /**
@@ -36,6 +36,8 @@ export abstract class BaseCMI {
36
36
  setStartTime(): void {
37
37
  this._start_time = new Date().getTime();
38
38
  }
39
+
40
+ abstract reset(): void;
39
41
  }
40
42
 
41
43
  /**