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
|
@@ -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
|
|
5
|
-
import
|
|
4
|
+
import { aicc_constants } from "../../constants/api_constants";
|
|
5
|
+
import { scorm12_errors } from "../../constants/error_codes";
|
|
6
6
|
import { checkAICCValidFormat } from "./validation";
|
|
7
|
-
import
|
|
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:
|
|
58
|
-
errorCode:
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
147
|
+
if (checkAICCValidFormat(time, aicc_regex.CMITime)) {
|
|
129
148
|
this._time = time;
|
|
130
149
|
}
|
|
131
150
|
}
|
package/src/cmi/aicc/paths.ts
CHANGED
|
@@ -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
|
|
5
|
-
import
|
|
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:
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
3
|
-
import
|
|
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(
|
|
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(
|
|
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
|
|
4
|
-
import
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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(
|
|
17
|
+
super(aicc_constants.student_preference_children);
|
|
18
18
|
this.windows = new CMIArray({
|
|
19
|
-
errorCode:
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
126
|
+
if (checkAICCValidFormat(video, aicc_regex.CMIString256)) {
|
|
127
127
|
this._video = video;
|
|
128
128
|
}
|
|
129
129
|
}
|
package/src/cmi/aicc/tries.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CMIArray } from "../common/array";
|
|
2
|
-
import
|
|
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
|
|
6
|
-
import
|
|
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:
|
|
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:
|
|
35
|
-
score_range:
|
|
36
|
-
invalidErrorCode:
|
|
37
|
-
invalidTypeCode:
|
|
38
|
-
invalidRangeCode:
|
|
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
|
-
|
|
54
|
-
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
|
|
20
|
+
scorm12_errors.TYPE_MISMATCH,
|
|
22
21
|
AICCValidationError,
|
|
23
22
|
allowEmptyString,
|
|
24
23
|
);
|
package/src/cmi/common/array.ts
CHANGED
|
@@ -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 ||
|
|
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
|
-
|
|
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
|
/**
|