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,218 +0,0 @@
1
- // @flow
2
-
3
- const global = {
4
- SCORM_TRUE: 'true',
5
- SCORM_FALSE: 'false',
6
- STATE_NOT_INITIALIZED: 0,
7
- STATE_INITIALIZED: 1,
8
- STATE_TERMINATED: 2,
9
- LOG_LEVEL_DEBUG: 1,
10
- LOG_LEVEL_INFO: 2,
11
- LOG_LEVEL_WARNING: 3,
12
- LOG_LEVEL_ERROR: 4,
13
- LOG_LEVEL_NONE: 5,
14
- };
15
-
16
- const scorm12 = {
17
- // Children lists
18
- cmi_children: 'core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions',
19
- core_children: 'student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time',
20
- score_children: 'raw,min,max',
21
- comments_children: 'content,location,time',
22
- objectives_children: 'id,score,status',
23
- correct_responses_children: 'pattern',
24
- student_data_children: 'mastery_score,max_time_allowed,time_limit_action',
25
- student_preference_children: 'audio,language,speed,text',
26
- interactions_children: 'id,objectives,time,type,correct_responses,weighting,student_response,result,latency',
27
-
28
- error_descriptions: {
29
- '101': {
30
- basicMessage: 'General Exception',
31
- detailMessage: 'No specific error code exists to describe the error. Use LMSGetDiagnostic for more information',
32
- },
33
- '201': {
34
- basicMessage: 'Invalid argument error',
35
- detailMessage: 'Indicates that an argument represents an invalid data model element or is otherwise incorrect.',
36
- },
37
- '202': {
38
- basicMessage: 'Element cannot have children',
39
- detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.',
40
- },
41
- '203': {
42
- basicMessage: 'Element not an array - cannot have count',
43
- detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.',
44
- },
45
- '301': {
46
- basicMessage: 'Not initialized',
47
- detailMessage: 'Indicates that an API call was made before the call to lmsInitialize.',
48
- },
49
- '401': {
50
- basicMessage: 'Not implemented error',
51
- detailMessage: 'The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement.',
52
- },
53
- '402': {
54
- basicMessage: 'Invalid set value, element is a keyword',
55
- detailMessage: 'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").',
56
- },
57
- '403': {
58
- basicMessage: 'Element is read only',
59
- detailMessage: 'LMSSetValue was called with a data model element that can only be read.',
60
- },
61
- '404': {
62
- basicMessage: 'Element is write only',
63
- detailMessage: 'LMSGetValue was called on a data model element that can only be written to.',
64
- },
65
- '405': {
66
- basicMessage: 'Incorrect Data Type',
67
- detailMessage: 'LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element.',
68
- },
69
- '407': {
70
- basicMessage: 'Element Value Out Of Range',
71
- detailMessage: 'The numeric value supplied to a LMSSetValue call is outside of the numeric range allowed for the supplied data model element.',
72
- },
73
- '408': {
74
- basicMessage: 'Data Model Dependency Not Established',
75
- detailMessage: 'Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element.',
76
- },
77
- },
78
- };
79
-
80
- const aicc = {
81
- ...scorm12, ...{
82
- cmi_children: 'core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions,evaluation',
83
- student_preference_children: 'audio,language,lesson_type,speed,text,text_color,text_location,text_size,video,windows',
84
- student_data_children: 'attempt_number,tries,mastery_score,max_time_allowed,time_limit_action',
85
- student_demographics_children: 'city,class,company,country,experience,familiar_name,instructor_name,title,native_language,state,street_address,telephone,years_experience',
86
- tries_children: 'time,status,score',
87
- attempt_records_children: 'score,lesson_status',
88
- paths_children: 'location_id,date,time,status,why_left,time_in_element',
89
- },
90
- };
91
-
92
- const scorm2004 = {
93
- // Children lists
94
- cmi_children: '_version,comments_from_learner,comments_from_lms,completion_status,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time',
95
- comments_children: 'comment,timestamp,location',
96
- score_children: 'max,raw,scaled,min',
97
- objectives_children: 'progress_measure,completion_status,success_status,description,score,id',
98
- correct_responses_children: 'pattern',
99
- student_data_children: 'mastery_score,max_time_allowed,time_limit_action',
100
- student_preference_children: 'audio_level,audio_captioning,delivery_speed,language',
101
- interactions_children: 'id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description',
102
-
103
- error_descriptions: {
104
- '0': {
105
- basicMessage: 'No Error',
106
- detailMessage: 'No error occurred, the previous API call was successful.',
107
- },
108
- '101': {
109
- basicMessage: 'General Exception',
110
- detailMessage: 'No specific error code exists to describe the error. Use GetDiagnostic for more information.',
111
- },
112
- '102': {
113
- basicMessage: 'General Initialization Failure',
114
- detailMessage: 'Call to Initialize failed for an unknown reason.',
115
- },
116
- '103': {
117
- basicMessage: 'Already Initialized',
118
- detailMessage: 'Call to Initialize failed because Initialize was already called.',
119
- },
120
- '104': {
121
- basicMessage: 'Content Instance Terminated',
122
- detailMessage: 'Call to Initialize failed because Terminate was already called.',
123
- },
124
- '111': {
125
- basicMessage: 'General Termination Failure',
126
- detailMessage: 'Call to Terminate failed for an unknown reason.',
127
- },
128
- '112': {
129
- basicMessage: 'Termination Before Initialization',
130
- detailMessage: 'Call to Terminate failed because it was made before the call to Initialize.',
131
- },
132
- '113': {
133
- basicMessage: 'Termination After Termination',
134
- detailMessage: 'Call to Terminate failed because Terminate was already called.',
135
- },
136
- '122': {
137
- basicMessage: 'Retrieve Data Before Initialization',
138
- detailMessage: 'Call to GetValue failed because it was made before the call to Initialize.',
139
- },
140
- '123': {
141
- basicMessage: 'Retrieve Data After Termination',
142
- detailMessage: 'Call to GetValue failed because it was made after the call to Terminate.',
143
- },
144
- '132': {
145
- basicMessage: 'Store Data Before Initialization',
146
- detailMessage: 'Call to SetValue failed because it was made before the call to Initialize.',
147
- },
148
- '133': {
149
- basicMessage: 'Store Data After Termination',
150
- detailMessage: 'Call to SetValue failed because it was made after the call to Terminate.',
151
- },
152
- '142': {
153
- basicMessage: 'Commit Before Initialization',
154
- detailMessage: 'Call to Commit failed because it was made before the call to Initialize.',
155
- },
156
- '143': {
157
- basicMessage: 'Commit After Termination',
158
- detailMessage: 'Call to Commit failed because it was made after the call to Terminate.',
159
- },
160
- '201': {
161
- basicMessage: 'General Argument Error',
162
- detailMessage: 'An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument.',
163
- },
164
- '301': {
165
- basicMessage: 'General Get Failure',
166
- detailMessage: 'Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.',
167
- },
168
- '351': {
169
- basicMessage: 'General Set Failure',
170
- detailMessage: 'Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.',
171
- },
172
- '391': {
173
- basicMessage: 'General Commit Failure',
174
- detailMessage: 'Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information.',
175
- },
176
- '401': {
177
- basicMessage: 'Undefined Data Model Element',
178
- detailMessage: 'The data model element name passed to GetValue or SetValue is not a valid SCORM data model element.',
179
- },
180
- '402': {
181
- basicMessage: 'Unimplemented Data Model Element',
182
- detailMessage: 'The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant.',
183
- },
184
- '403': {
185
- basicMessage: 'Data Model Element Value Not Initialized',
186
- detailMessage: 'Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO.',
187
- },
188
- '404': {
189
- basicMessage: 'Data Model Element Is Read Only',
190
- detailMessage: 'SetValue was called with a data model element that can only be read.',
191
- },
192
- '405': {
193
- basicMessage: 'Data Model Element Is Write Only',
194
- detailMessage: 'GetValue was called on a data model element that can only be written to.',
195
- },
196
- '406': {
197
- basicMessage: 'Data Model Element Type Mismatch',
198
- detailMessage: 'SetValue was called with a value that is not consistent with the data format of the supplied data model element.',
199
- },
200
- '407': {
201
- basicMessage: 'Data Model Element Value Out Of Range',
202
- detailMessage: 'The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element.',
203
- },
204
- '408': {
205
- basicMessage: 'Data Model Dependency Not Established',
206
- detailMessage: 'Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element.',
207
- },
208
- },
209
- };
210
-
211
- const APIConstants = {
212
- global: global,
213
- scorm12: scorm12,
214
- aicc: aicc,
215
- scorm2004: scorm2004,
216
- };
217
-
218
- export default APIConstants;
@@ -1,87 +0,0 @@
1
- // @flow
2
- const global = {
3
- GENERAL: 101,
4
- INITIALIZATION_FAILED: 101,
5
- INITIALIZED: 101,
6
- TERMINATED: 101,
7
- TERMINATION_FAILURE: 101,
8
- TERMINATION_BEFORE_INIT: 101,
9
- MULTIPLE_TERMINATION: 101,
10
- RETRIEVE_BEFORE_INIT: 101,
11
- RETRIEVE_AFTER_TERM: 101,
12
- STORE_BEFORE_INIT: 101,
13
- STORE_AFTER_TERM: 101,
14
- COMMIT_BEFORE_INIT: 101,
15
- COMMIT_AFTER_TERM: 101,
16
- ARGUMENT_ERROR: 101,
17
- CHILDREN_ERROR: 101,
18
- COUNT_ERROR: 101,
19
- GENERAL_GET_FAILURE: 101,
20
- GENERAL_SET_FAILURE: 101,
21
- GENERAL_COMMIT_FAILURE: 101,
22
- UNDEFINED_DATA_MODEL: 101,
23
- UNIMPLEMENTED_ELEMENT: 101,
24
- VALUE_NOT_INITIALIZED: 101,
25
- INVALID_SET_VALUE: 101,
26
- READ_ONLY_ELEMENT: 101,
27
- WRITE_ONLY_ELEMENT: 101,
28
- TYPE_MISMATCH: 101,
29
- VALUE_OUT_OF_RANGE: 101,
30
- DEPENDENCY_NOT_ESTABLISHED: 101,
31
- };
32
-
33
- const scorm12 = {
34
- ...global, ...{
35
- RETRIEVE_BEFORE_INIT: 301,
36
- STORE_BEFORE_INIT: 301,
37
- COMMIT_BEFORE_INIT: 301,
38
- ARGUMENT_ERROR: 201,
39
- CHILDREN_ERROR: 202,
40
- COUNT_ERROR: 203,
41
- UNDEFINED_DATA_MODEL: 401,
42
- UNIMPLEMENTED_ELEMENT: 401,
43
- VALUE_NOT_INITIALIZED: 301,
44
- INVALID_SET_VALUE: 402,
45
- READ_ONLY_ELEMENT: 403,
46
- WRITE_ONLY_ELEMENT: 404,
47
- TYPE_MISMATCH: 405,
48
- VALUE_OUT_OF_RANGE: 407,
49
- DEPENDENCY_NOT_ESTABLISHED: 408,
50
- },
51
- };
52
-
53
- const scorm2004 = {
54
- ...global, ...{
55
- INITIALIZATION_FAILED: 102,
56
- INITIALIZED: 103,
57
- TERMINATED: 104,
58
- TERMINATION_FAILURE: 111,
59
- TERMINATION_BEFORE_INIT: 112,
60
- MULTIPLE_TERMINATIONS: 113,
61
- RETRIEVE_BEFORE_INIT: 122,
62
- RETRIEVE_AFTER_TERM: 123,
63
- STORE_BEFORE_INIT: 132,
64
- STORE_AFTER_TERM: 133,
65
- COMMIT_BEFORE_INIT: 142,
66
- COMMIT_AFTER_TERM: 143,
67
- ARGUMENT_ERROR: 201,
68
- GENERAL_GET_FAILURE: 301,
69
- GENERAL_SET_FAILURE: 351,
70
- GENERAL_COMMIT_FAILURE: 391,
71
- UNDEFINED_DATA_MODEL: 401,
72
- UNIMPLEMENTED_ELEMENT: 402,
73
- VALUE_NOT_INITIALIZED: 403,
74
- READ_ONLY_ELEMENT: 404,
75
- WRITE_ONLY_ELEMENT: 405,
76
- TYPE_MISMATCH: 406,
77
- VALUE_OUT_OF_RANGE: 407,
78
- DEPENDENCY_NOT_ESTABLISHED: 408,
79
- },
80
- };
81
-
82
- const ErrorCodes = {
83
- scorm12: scorm12,
84
- scorm2004: scorm2004,
85
- };
86
-
87
- export default ErrorCodes;
@@ -1,76 +0,0 @@
1
- const ValidLanguages = {
2
- 'aa': 'aa', 'ab': 'ab', 'ae': 'ae', 'af': 'af', 'ak': 'ak', 'am': 'am',
3
- 'an': 'an', 'ar': 'ar', 'as': 'as', 'av': 'av', 'ay': 'ay', 'az': 'az',
4
- 'ba': 'ba', 'be': 'be', 'bg': 'bg', 'bh': 'bh', 'bi': 'bi', 'bm': 'bm',
5
- 'bn': 'bn', 'bo': 'bo', 'br': 'br', 'bs': 'bs', 'ca': 'ca', 'ce': 'ce',
6
- 'ch': 'ch', 'co': 'co', 'cr': 'cr', 'cs': 'cs', 'cu': 'cu', 'cv': 'cv',
7
- 'cy': 'cy', 'da': 'da', 'de': 'de', 'dv': 'dv', 'dz': 'dz', 'ee': 'ee',
8
- 'el': 'el', 'en': 'en', 'eo': 'eo', 'es': 'es', 'et': 'et', 'eu': 'eu',
9
- 'fa': 'fa', 'ff': 'ff', 'fi': 'fi', 'fj': 'fj', 'fo': 'fo', 'fr': 'fr',
10
- 'fy': 'fy', 'ga': 'ga', 'gd': 'gd', 'gl': 'gl', 'gn': 'gn', 'gu': 'gu',
11
- 'gv': 'gv', 'ha': 'ha', 'he': 'he', 'hi': 'hi', 'ho': 'ho', 'hr': 'hr',
12
- 'ht': 'ht', 'hu': 'hu', 'hy': 'hy', 'hz': 'hz', 'ia': 'ia', 'id': 'id',
13
- 'ie': 'ie', 'ig': 'ig', 'ii': 'ii', 'ik': 'ik', 'io': 'io', 'is': 'is',
14
- 'it': 'it', 'iu': 'iu', 'ja': 'ja', 'jv': 'jv', 'ka': 'ka', 'kg': 'kg',
15
- 'ki': 'ki', 'kj': 'kj', 'kk': 'kk', 'kl': 'kl', 'km': 'km', 'kn': 'kn',
16
- 'ko': 'ko', 'kr': 'kr', 'ks': 'ks', 'ku': 'ku', 'kv': 'kv', 'kw': 'kw',
17
- 'ky': 'ky', 'la': 'la', 'lb': 'lb', 'lg': 'lg', 'li': 'li', 'ln': 'ln',
18
- 'lo': 'lo', 'lt': 'lt', 'lu': 'lu', 'lv': 'lv', 'mg': 'mg', 'mh': 'mh',
19
- 'mi': 'mi', 'mk': 'mk', 'ml': 'ml', 'mn': 'mn', 'mo': 'mo', 'mr': 'mr',
20
- 'ms': 'ms', 'mt': 'mt', 'my': 'my', 'na': 'na', 'nb': 'nb', 'nd': 'nd',
21
- 'ne': 'ne', 'ng': 'ng', 'nl': 'nl', 'nn': 'nn', 'no': 'no', 'nr': 'nr',
22
- 'nv': 'nv', 'ny': 'ny', 'oc': 'oc', 'oj': 'oj', 'om': 'om', 'or': 'or',
23
- 'os': 'os', 'pa': 'pa', 'pi': 'pi', 'pl': 'pl', 'ps': 'ps', 'pt': 'pt',
24
- 'qu': 'qu', 'rm': 'rm', 'rn': 'rn', 'ro': 'ro', 'ru': 'ru', 'rw': 'rw',
25
- 'sa': 'sa', 'sc': 'sc', 'sd': 'sd', 'se': 'se', 'sg': 'sg', 'sh': 'sh',
26
- 'si': 'si', 'sk': 'sk', 'sl': 'sl', 'sm': 'sm', 'sn': 'sn', 'so': 'so',
27
- 'sq': 'sq', 'sr': 'sr', 'ss': 'ss', 'st': 'st', 'su': 'su', 'sv': 'sv',
28
- 'sw': 'sw', 'ta': 'ta', 'te': 'te', 'tg': 'tg', 'th': 'th', 'ti': 'ti',
29
- 'tk': 'tk', 'tl': 'tl', 'tn': 'tn', 'to': 'to', 'tr': 'tr', 'ts': 'ts',
30
- 'tt': 'tt', 'tw': 'tw', 'ty': 'ty', 'ug': 'ug', 'uk': 'uk', 'ur': 'ur',
31
- 'uz': 'uz', 've': 've', 'vi': 'vi', 'vo': 'vo', 'wa': 'wa', 'wo': 'wo',
32
- 'xh': 'xh', 'yi': 'yi', 'yo': 'yo', 'za': 'za', 'zh': 'zh', 'zu': 'zu',
33
- 'aar': 'aar', 'abk': 'abk', 'ave': 'ave', 'afr': 'afr', 'aka': 'aka',
34
- 'amh': 'amh', 'arg': 'arg', 'ara': 'ara', 'asm': 'asm', 'ava': 'ava',
35
- 'aym': 'aym', 'aze': 'aze', 'bak': 'bak', 'bel': 'bel', 'bul': 'bul',
36
- 'bih': 'bih', 'bis': 'bis', 'bam': 'bam', 'ben': 'ben', 'tib': 'tib',
37
- 'bod': 'bod', 'bre': 'bre', 'bos': 'bos', 'cat': 'cat', 'che': 'che',
38
- 'cha': 'cha', 'cos': 'cos', 'cre': 'cre', 'cze': 'cze', 'ces': 'ces',
39
- 'chu': 'chu', 'chv': 'chv', 'wel': 'wel', 'cym': 'cym', 'dan': 'dan',
40
- 'ger': 'ger', 'deu': 'deu', 'div': 'div', 'dzo': 'dzo', 'ewe': 'ewe',
41
- 'gre': 'gre', 'ell': 'ell', 'eng': 'eng', 'epo': 'epo', 'spa': 'spa',
42
- 'est': 'est', 'baq': 'baq', 'eus': 'eus', 'per': 'per', 'fas': 'fas',
43
- 'ful': 'ful', 'fin': 'fin', 'fij': 'fij', 'fao': 'fao', 'fre': 'fre',
44
- 'fra': 'fra', 'fry': 'fry', 'gle': 'gle', 'gla': 'gla', 'glg': 'glg',
45
- 'grn': 'grn', 'guj': 'guj', 'glv': 'glv', 'hau': 'hau', 'heb': 'heb',
46
- 'hin': 'hin', 'hmo': 'hmo', 'hrv': 'hrv', 'hat': 'hat', 'hun': 'hun',
47
- 'arm': 'arm', 'hye': 'hye', 'her': 'her', 'ina': 'ina', 'ind': 'ind',
48
- 'ile': 'ile', 'ibo': 'ibo', 'iii': 'iii', 'ipk': 'ipk', 'ido': 'ido',
49
- 'ice': 'ice', 'isl': 'isl', 'ita': 'ita', 'iku': 'iku', 'jpn': 'jpn',
50
- 'jav': 'jav', 'geo': 'geo', 'kat': 'kat', 'kon': 'kon', 'kik': 'kik',
51
- 'kua': 'kua', 'kaz': 'kaz', 'kal': 'kal', 'khm': 'khm', 'kan': 'kan',
52
- 'kor': 'kor', 'kau': 'kau', 'kas': 'kas', 'kur': 'kur', 'kom': 'kom',
53
- 'cor': 'cor', 'kir': 'kir', 'lat': 'lat', 'ltz': 'ltz', 'lug': 'lug',
54
- 'lim': 'lim', 'lin': 'lin', 'lao': 'lao', 'lit': 'lit', 'lub': 'lub',
55
- 'lav': 'lav', 'mlg': 'mlg', 'mah': 'mah', 'mao': 'mao', 'mri': 'mri',
56
- 'mac': 'mac', 'mkd': 'mkd', 'mal': 'mal', 'mon': 'mon', 'mol': 'mol',
57
- 'mar': 'mar', 'may': 'may', 'msa': 'msa', 'mlt': 'mlt', 'bur': 'bur',
58
- 'mya': 'mya', 'nau': 'nau', 'nob': 'nob', 'nde': 'nde', 'nep': 'nep',
59
- 'ndo': 'ndo', 'dut': 'dut', 'nld': 'nld', 'nno': 'nno', 'nor': 'nor',
60
- 'nbl': 'nbl', 'nav': 'nav', 'nya': 'nya', 'oci': 'oci', 'oji': 'oji',
61
- 'orm': 'orm', 'ori': 'ori', 'oss': 'oss', 'pan': 'pan', 'pli': 'pli',
62
- 'pol': 'pol', 'pus': 'pus', 'por': 'por', 'que': 'que', 'roh': 'roh',
63
- 'run': 'run', 'rum': 'rum', 'ron': 'ron', 'rus': 'rus', 'kin': 'kin',
64
- 'san': 'san', 'srd': 'srd', 'snd': 'snd', 'sme': 'sme', 'sag': 'sag',
65
- 'slo': 'slo', 'sin': 'sin', 'slk': 'slk', 'slv': 'slv', 'smo': 'smo',
66
- 'sna': 'sna', 'som': 'som', 'alb': 'alb', 'sqi': 'sqi', 'srp': 'srp',
67
- 'ssw': 'ssw', 'sot': 'sot', 'sun': 'sun', 'swe': 'swe', 'swa': 'swa',
68
- 'tam': 'tam', 'tel': 'tel', 'tgk': 'tgk', 'tha': 'tha', 'tir': 'tir',
69
- 'tuk': 'tuk', 'tgl': 'tgl', 'tsn': 'tsn', 'ton': 'ton', 'tur': 'tur',
70
- 'tso': 'tso', 'tat': 'tat', 'twi': 'twi', 'tah': 'tah', 'uig': 'uig',
71
- 'ukr': 'ukr', 'urd': 'urd', 'uzb': 'uzb', 'ven': 'ven', 'vie': 'vie',
72
- 'vol': 'vol', 'wln': 'wln', 'wol': 'wol', 'xho': 'xho', 'yid': 'yid',
73
- 'yor': 'yor', 'zha': 'zha', 'chi': 'chi', 'zho': 'zho', 'zul': 'zul',
74
- };
75
-
76
- export default ValidLanguages;
@@ -1,84 +0,0 @@
1
- // @flow
2
-
3
- const scorm12 = {
4
- CMIString256: '^.{0,255}$',
5
- CMIString4096: '^.{0,4096}$',
6
- CMITime: '^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$', // eslint-disable-line
7
- CMITimespan: '^([0-9]{2,}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$', // eslint-disable-line
8
- CMIInteger: '^\\d+$',
9
- CMISInteger: '^-?([0-9]+)$',
10
- CMIDecimal: '^-?([0-9]{0,3})(\.[0-9]*)?$', // eslint-disable-line
11
- CMIIdentifier: '^[\\u0021-\\u007E\\s]{0,255}$',
12
- CMIFeedback: '^.{0,255}$', // This must be redefined
13
- CMIIndex: '[._](\\d+).',
14
-
15
- // Vocabulary Data Type Definition
16
- CMIStatus: '^(passed|completed|failed|incomplete|browsed)$',
17
- CMIStatus2: '^(passed|completed|failed|incomplete|browsed|not attempted)$',
18
- CMIExit: '^(time-out|suspend|logout|)$',
19
- CMIType: '^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$',
20
- CMIResult: '^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$', // eslint-disable-line
21
- NAVEvent: '^(previous|continue)$',
22
-
23
- // Data ranges
24
- score_range: '0#100',
25
- audio_range: '-1#100',
26
- speed_range: '-100#100',
27
- weighting_range: '-100#100',
28
- text_range: '-1#1',
29
- };
30
-
31
- const aicc = {
32
- ...scorm12, ...{
33
- CMIIdentifier: '^\\w{1,255}$',
34
- },
35
- };
36
-
37
- const scorm2004 = {
38
- CMIString200: '^[\\u0000-\\uFFFF]{0,200}$',
39
- CMIString250: '^[\\u0000-\\uFFFF]{0,250}$',
40
- CMIString1000: '^[\\u0000-\\uFFFF]{0,1000}$',
41
- CMIString4000: '^[\\u0000-\\uFFFF]{0,4000}$',
42
- CMIString64000: '^[\\u0000-\\uFFFF]{0,64000}$',
43
- CMILang: '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$', // eslint-disable-line
44
- CMILangString250: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?((?!\{.*$).{0,250}$)?$', // eslint-disable-line
45
- CMILangcr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\}))(.*?)$', // eslint-disable-line
46
- CMILangString250cr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\})?(.{0,250})?)?$', // eslint-disable-line
47
- CMILangString4000: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?((?!\{.*$).{0,4000}$)?$', // eslint-disable-line
48
- CMITime: '^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$',
49
- CMITimespan: '^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$',
50
- CMIInteger: '^\\d+$',
51
- CMISInteger: '^-?([0-9]+)$',
52
- CMIDecimal: '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$',
53
- CMIIdentifier: '^\\S{1,250}[a-zA-Z0-9]$',
54
- CMIShortIdentifier: '^[\\w\\.\\-\\_]{1,250}$', // eslint-disable-line
55
- CMILongIdentifier: '^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$', // need to re-examine this
56
- CMIFeedback: '^.*$', // This must be redefined
57
- CMIIndex: '[._](\\d+).',
58
- CMIIndexStore: '.N(\\d+).',
59
-
60
- // Vocabulary Data Type Definition
61
- CMICStatus: '^(completed|incomplete|not attempted|unknown)$',
62
- CMISStatus: '^(passed|failed|unknown)$',
63
- CMIExit: '^(time-out|suspend|logout|normal)$',
64
- CMIType: '^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$',
65
- CMIResult: '^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$',
66
- NAVEvent: '^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|\{target=\\S{0,200}[a-zA-Z0-9]\}choice|jump)$', // eslint-disable-line
67
- NAVBoolean: '^(unknown|true|false$)',
68
- NAVTarget: '^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$',
69
-
70
- // Data ranges
71
- scaled_range: '-1#1',
72
- audio_range: '0#*',
73
- speed_range: '0#*',
74
- text_range: '-1#1',
75
- progress_range: '0#1',
76
- };
77
-
78
- const Regex = {
79
- aicc: aicc,
80
- scorm12: scorm12,
81
- scorm2004: scorm2004,
82
- };
83
-
84
- export default Regex;
package/src/exceptions.js DELETED
@@ -1,104 +0,0 @@
1
- // @flow
2
-
3
- import APIConstants from './constants/api_constants';
4
-
5
- const scorm12_errors = APIConstants.scorm12.error_descriptions;
6
- const aicc_errors = APIConstants.aicc.error_descriptions;
7
- const scorm2004_errors = APIConstants.scorm2004.error_descriptions;
8
-
9
- /**
10
- * Base Validation Exception
11
- */
12
- export class ValidationError extends Error {
13
- /**
14
- * Constructor to take in an error message and code
15
- * @param {number} errorCode
16
- * @param {string} errorMessage
17
- * @param {string} detailedMessage
18
- */
19
- constructor(errorCode: number, errorMessage: String, detailedMessage: String) {
20
- super(errorMessage);
21
- this.#errorCode = errorCode;
22
- this.#errorMessage = errorMessage;
23
- this.#detailedMessage = detailedMessage;
24
- }
25
-
26
- #errorCode;
27
- #errorMessage;
28
- #detailedMessage;
29
-
30
- /**
31
- * Getter for #errorCode
32
- * @return {number}
33
- */
34
- get errorCode() {
35
- return this.#errorCode;
36
- }
37
-
38
- /**
39
- * Getter for #errorMessage
40
- * @return {string}
41
- */
42
- get errorMessage() {
43
- return this.#errorMessage;
44
- }
45
-
46
- /**
47
- * Getter for #detailedMessage
48
- * @return {string}
49
- */
50
- get detailedMessage() {
51
- return this.#detailedMessage;
52
- }
53
- }
54
-
55
- /**
56
- * SCORM 1.2 Validation Error
57
- */
58
- export class Scorm12ValidationError extends ValidationError {
59
- /**
60
- * Constructor to take in an error code
61
- * @param {number} errorCode
62
- */
63
- constructor(errorCode: number) {
64
- if ({}.hasOwnProperty.call(scorm12_errors, String(errorCode))) {
65
- super(errorCode, scorm12_errors[String(errorCode)].basicMessage, scorm12_errors[String(errorCode)].detailMessage);
66
- } else {
67
- super(101, scorm12_errors['101'].basicMessage, scorm12_errors['101'].detailMessage);
68
- }
69
- }
70
- }
71
-
72
- /**
73
- * AICC Validation Error
74
- */
75
- export class AICCValidationError extends ValidationError {
76
- /**
77
- * Constructor to take in an error code
78
- * @param {number} errorCode
79
- */
80
- constructor(errorCode: number) {
81
- if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
82
- super(errorCode, aicc_errors[String(errorCode)].basicMessage, aicc_errors[String(errorCode)].detailMessage);
83
- } else {
84
- super(101, aicc_errors['101'].basicMessage, aicc_errors['101'].detailMessage);
85
- }
86
- }
87
- }
88
-
89
- /**
90
- * SCORM 2004 Validation Error
91
- */
92
- export class Scorm2004ValidationError extends ValidationError {
93
- /**
94
- * Constructor to take in an error code
95
- * @param {number} errorCode
96
- */
97
- constructor(errorCode: number) {
98
- if ({}.hasOwnProperty.call(scorm2004_errors, String(errorCode))) {
99
- super(errorCode, scorm2004_errors[String(errorCode)].basicMessage, scorm2004_errors[String(errorCode)].detailMessage);
100
- } else {
101
- super(101, scorm2004_errors['101'].basicMessage, scorm2004_errors['101'].detailMessage);
102
- }
103
- }
104
- }