scorm-again 2.0.0 → 2.2.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 (77) hide show
  1. package/.github/workflows/stale.yml +14 -0
  2. package/.run/{Mocha Unit Tests.run.xml → Mocha Unit Tests (watch).run.xml } +1 -1
  3. package/.run/Template Mocha.run.xml +17 -0
  4. package/README.md +180 -72
  5. package/dist/aicc.js +1520 -1149
  6. package/dist/aicc.js.map +1 -1
  7. package/dist/aicc.min.js +1 -1
  8. package/dist/aicc.min.js.map +1 -1
  9. package/dist/scorm-again.js +2812 -2205
  10. package/dist/scorm-again.js.map +1 -1
  11. package/dist/scorm-again.min.js +1 -1
  12. package/dist/scorm-again.min.js.map +1 -1
  13. package/dist/scorm12.js +1129 -842
  14. package/dist/scorm12.js.map +1 -1
  15. package/dist/scorm12.min.js +1 -1
  16. package/dist/scorm12.min.js.map +1 -1
  17. package/dist/scorm2004.js +1921 -1564
  18. package/dist/scorm2004.js.map +1 -1
  19. package/dist/scorm2004.min.js +1 -1
  20. package/dist/scorm2004.min.js.map +1 -1
  21. package/package.json +20 -17
  22. package/src/AICC.ts +15 -17
  23. package/src/BaseAPI.ts +283 -420
  24. package/src/Scorm12API.ts +133 -41
  25. package/src/Scorm2004API.ts +224 -120
  26. package/src/cmi/aicc/attempts.ts +94 -0
  27. package/src/cmi/aicc/cmi.ts +100 -0
  28. package/src/cmi/aicc/core.ts +360 -0
  29. package/src/cmi/aicc/evaluation.ts +157 -0
  30. package/src/cmi/aicc/paths.ts +180 -0
  31. package/src/cmi/aicc/student_data.ts +86 -0
  32. package/src/cmi/aicc/student_demographics.ts +367 -0
  33. package/src/cmi/aicc/student_preferences.ts +176 -0
  34. package/src/cmi/aicc/tries.ts +116 -0
  35. package/src/cmi/aicc/validation.ts +25 -0
  36. package/src/cmi/common/array.ts +77 -0
  37. package/src/cmi/common/base_cmi.ts +46 -0
  38. package/src/cmi/common/score.ts +203 -0
  39. package/src/cmi/common/validation.ts +60 -0
  40. package/src/cmi/scorm12/cmi.ts +224 -0
  41. package/src/cmi/scorm12/interactions.ts +368 -0
  42. package/src/cmi/scorm12/nav.ts +54 -0
  43. package/src/cmi/scorm12/objectives.ts +112 -0
  44. package/src/cmi/scorm12/student_data.ts +130 -0
  45. package/src/cmi/scorm12/student_preference.ts +158 -0
  46. package/src/cmi/scorm12/validation.ts +48 -0
  47. package/src/cmi/scorm2004/adl.ts +272 -0
  48. package/src/cmi/scorm2004/cmi.ts +599 -0
  49. package/src/cmi/scorm2004/comments.ts +163 -0
  50. package/src/cmi/scorm2004/interactions.ts +466 -0
  51. package/src/cmi/scorm2004/learner_preference.ts +152 -0
  52. package/src/cmi/scorm2004/objectives.ts +212 -0
  53. package/src/cmi/scorm2004/score.ts +78 -0
  54. package/src/cmi/scorm2004/validation.ts +42 -0
  55. package/src/constants/default_settings.ts +82 -0
  56. package/src/constants/enums.ts +17 -0
  57. package/src/constants/regex.ts +2 -2
  58. package/src/constants/response_constants.ts +2 -0
  59. package/src/exceptions.ts +22 -1
  60. package/src/helpers/scheduled_commit.ts +42 -0
  61. package/src/interfaces/IBaseAPI.ts +35 -0
  62. package/src/types/api_types.ts +50 -0
  63. package/src/utilities/debounce.ts +31 -0
  64. package/src/utilities.ts +56 -0
  65. package/test/AICC.spec.ts +11 -1
  66. package/test/Scorm12API.spec.ts +372 -9
  67. package/test/Scorm2004API.spec.ts +558 -2
  68. package/test/cmi/aicc_cmi.spec.ts +188 -11
  69. package/test/cmi/scorm12_cmi.spec.ts +5 -5
  70. package/test/cmi/scorm2004_cmi.spec.ts +8 -8
  71. package/test/cmi_helpers.ts +1 -1
  72. package/test/types/api_types.spec.ts +126 -0
  73. package/test/utilities/debounce.spec.ts +56 -0
  74. package/src/cmi/aicc_cmi.ts +0 -1248
  75. package/src/cmi/common.ts +0 -411
  76. package/src/cmi/scorm12_cmi.ts +0 -1426
  77. package/src/cmi/scorm2004_cmi.ts +0 -1874
@@ -0,0 +1,14 @@
1
+ name: 'Close stale issues'
2
+ on:
3
+ schedule:
4
+ - cron: '30 1 * * *'
5
+
6
+ jobs:
7
+ stale:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/stale@v9
11
+ with:
12
+ stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
13
+ days-before-stale: 30
14
+ days-before-close: 5
@@ -1,5 +1,5 @@
1
1
  <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="Mocha Unit Tests" type="mocha-javascript-test-runner">
2
+ <configuration default="false" name="Mocha Unit Tests (watch)" type="mocha-javascript-test-runner">
3
3
  <node-interpreter>project</node-interpreter>
4
4
  <node-options />
5
5
  <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
@@ -0,0 +1,17 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="true" type="mocha-javascript-test-runner">
3
+ <node-interpreter>project</node-interpreter>
4
+ <node-options />
5
+ <working-directory />
6
+ <pass-parent-env>true</pass-parent-env>
7
+ <envs>
8
+ <env name="TS_NODE_COMPILER_OPTIONS" value="&quot;{\&quot;module\&quot;:\&quot;commonjs\&quot;}&quot;" />
9
+ </envs>
10
+ <ui />
11
+ <extra-mocha-options>--import=tsx</extra-mocha-options>
12
+ <test-kind>DIRECTORY</test-kind>
13
+ <test-directory />
14
+ <recursive>false</recursive>
15
+ <method v="2" />
16
+ </configuration>
17
+ </component>
package/README.md CHANGED
@@ -9,78 +9,158 @@
9
9
  ![GitHub License](https://img.shields.io/github/license/jcputney/scorm-again?style=for-the-badge)
10
10
  [![donate](https://img.shields.io/badge/paypal-donate-success?style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NF5MPZJAV26LE)
11
11
 
12
-
13
12
  # SCORM Again
14
- This project was created to modernize the SCORM JavaScript runtime, and to provide a stable, tested platform for running AICC, SCORM 1.2, and SCORM 2004 modules. This module is designed to be LMS agnostic, and is written to be able to be run without a backing LMS, logging all function calls and data instead of committing, if an LMS endpoint is not configured.
13
+
14
+ This project was created to modernize the SCORM JavaScript runtime, and to provide a stable, tested platform for running
15
+ AICC, SCORM 1.2, and SCORM 2004 modules. This module is designed to be LMS agnostic, and is written to be able to be run
16
+ without a backing LMS, logging all function calls and data instead of committing, if an LMS endpoint is not configured.
15
17
 
16
18
  ## Potential Breaking Change!
17
- Version 2.0.0 of scorm-again switches to using `fetch`, as well as async-only for reporting to the LMS. Since `fetch` is not supported by IE11, you will need to provide your own polyfill for this functionality if you need to support it.
19
+
20
+ Version 2.0.0 of scorm-again switches to using `fetch`, as well as async-only for reporting to the LMS. Since `fetch` is
21
+ not supported by IE11, you will need to provide your own polyfill for this functionality if you need to support it.
18
22
 
19
23
  ### What is this not and what doesn't it do?
24
+
20
25
  1. This is not an LMS
21
26
  1. This does not handle the uploading and verification of SCORM/AICC modules
22
- 1. This project does not **currently** support TinCan/xAPI/CMI5, and I'm not sure if I will ever get around to it. However, I would welcome merge requests to add support for any additional specifications.
27
+ 1. This project does not **currently** support TinCan/xAPI/CMI5, and I'm not sure if I will ever get around to it.
28
+ However, I would welcome merge requests to add support for any additional specifications.
23
29
  1. This library does not setup communication between an external AICC module and an LMS.
24
- 1. This project is not complete! I'm still working on AICC testing, and continuing to write proper test cases for all APIs
25
-
30
+ 1. This project is not complete! I'm still working on AICC testing, and continuing to write proper test cases for all
31
+ APIs
26
32
 
27
33
  ### Setup
34
+
28
35
  To begin with, you include either the `scorm-again.js` or `scorm-again.min.js` file on your launching page:
36
+
29
37
  ```html
38
+
30
39
  <script type="text/javascript" src="/dist/scorm-again.js"></script>
31
40
  ```
32
41
 
33
- Or, if you would like to only pull in one API, you include either the `aicc.js`, `scorm12.js` or `scorm2004.js` files or their minified versions on your launching page:
42
+ Or, if you would like to only pull in one API, you include either the `aicc.js`, `scorm12.js` or `scorm2004.js` files or
43
+ their minified versions on your launching page:
44
+
34
45
  ```html
46
+
35
47
  <script type="text/javascript" src="/dist/scorm2004.js"></script>
36
48
  ```
37
49
 
38
50
  Or, if you would like to install the library using your package manager, you can do the following:
51
+
39
52
  ```sh
40
53
  npm install scorm-again
41
54
  ```
55
+
42
56
  or
57
+
43
58
  ```sh
44
59
  yarn add scorm-again
45
60
  ```
46
61
 
47
62
  You would then initialize the APIs using the following JS statements:
63
+
48
64
  ```javascript
49
- var settings = {}
50
- # AICC
65
+ import {AICC, Scorm12API, Scorm2004API} from 'scorm-again'; // you only do this if you're using the package manager
66
+
67
+ var settings = {};
68
+
69
+ // AICC
51
70
  window.API = new AICC(settings);
52
71
 
53
- # SCORM 1.2
72
+ // SCORM 1.2
54
73
  window.API = new Scorm12API(settings);
55
74
 
56
- # SCORM 2004
75
+ // SCORM 2004
57
76
  window.API_1484_11 = new Scorm2004API(settings);
58
77
  ```
59
78
 
79
+ ### A Note About API Discovery
80
+
81
+ Before creating a ticket about your module not being able to communicate with the LMS, please make sure you've looked
82
+ over my examples in the `gh-pages` branch, as well as reading
83
+ the [SCORM API Discovery Algorithms](https://scorm.com/scorm-explained/technical-scorm/run-time/api-discovery-algorithms/)
84
+ page. I get that some of this stuff can be hard to implement at first, but I can't give an example for every possible
85
+ way this library can be loaded into your application. The main thing to remember is that it should always be attached to
86
+ the `window` object, because that's where modules are supposed to look.
87
+
60
88
  ### Available Settings
89
+
61
90
  The APIs include several settings to customize the functionality of each API:
62
91
 
63
- | Setting | Default | Values | Description |
64
- | ------------- |:-------------:| :-----:| --- |
65
- | `autocommit` | false | true/false | Determines whether the API schedules an autocommit to the LMS after setting a value. |
66
- | `autocommitSeconds` | 60 | int | Number of seconds to wait before autocommiting. Timer is restarted if another value is set. |
67
- | `lmsCommitUrl` | false | url | The URL endpoint of the LMS where data should be sent upon commit. If no value is provided, modules will run as usual, but all method calls will be logged to the console. |
68
- | `dataCommitFormat` | `json` | `json`, `flattened`, `params` | `json` will send a JSON object to the lmsCommitUrl in the format of <br>`{'cmi': {'core': {...}}`<br><br> `flattened` will send the data in the format <br>`{'cmi.core.exit': 'suspend', 'cmi.core.mode': 'normal'...}`<br><br> `params` will send the data as <br>`?cmi.core.exit=suspend&cmi.core.mode=normal...` |
69
- | `commitRequestDataType` | 'application/json;charset=UTF-8' | string | This setting is provided in case your LMS expects a different content type or character set. |
70
- | `autoProgress` | false | true/false | In case Sequencing is being used, you can tell the API to automatically throw the `SequenceNext` event.|
71
- | `logLevel` | 4 | int<br><br>1 => DEBUG<br>2 => INFO<br>3 => WARN<br>4 => ERROR<br>5 => NONE | By default, the APIs only log error messages. |
72
- | `mastery_override` | false | true/false | (SCORM 1.2) Used to override a module's `cmi.core.lesson_status` so that a pass/fail is determined based on a mastery score and the user's raw score, rather than using whatever status is provided by the module. An example of this would be if a module is published using a `Complete/Incomplete` final status, but the LMS always wants to receive a `Passed/Failed` for quizzes, then we can use this setting to override the given final status. |
73
- | `selfReportSessionTime` | false | true/false | Should the API override the default `session_time` reported by the module? Useful when modules don't properly report time. |
74
- | `alwaysSendTotalTime` | false | true/false | Should the API always send `total_time` when committing to the LMS |
75
- | `xhrWithCredentials` | false | true/false | Sets the withCredentials flag on the request to the LMS |
76
- | `xhrHeaders` | {} | Object | This allows setting of additional headers on the request to the LMS where the key should be the header name and the value is the value of the header you want to send |
77
- | `responseHandler` | function | | A function to properly tranform the response from the LMS to the correct format. The APIs expect the result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }` |
78
- | `requestHandler` | function | | A function to transform the commit object before sending it to `lmsCommitUrl`. By default it's the identity function (no transformation). |
79
- | `onLogMessage` | function | | A function to be called whenever a message is logged. Defaults to console.{error,warn,info,debug,log} |
92
+ | Setting | Default | Values | Description |
93
+ |----------------------------|:--------------------------------:|:--------------------------------------------------------------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
94
+ | `autocommit` | false | true/false | Determines whether the API schedules an autocommit to the LMS after setting a value. |
95
+ | `autocommitSeconds` | 60 | int | Number of seconds to wait before autocommiting. Timer is restarted if another value is set. |
96
+ | `asyncCommit` | false | true/false | Determines whether the API should send the request to the `lmsCommitUrl` asynchronously. |
97
+ | `sendFullCommit` | true | true/false | Determines whether the API sends the full CMI object as part of the commit, or of it only sends the fields that actually contains values. |
98
+ | `lmsCommitUrl` | false | url | The URL endpoint of the LMS where data should be sent upon commit. If no value is provided, modules will run as usual, but all method calls will be logged to the console. |
99
+ | `dataCommitFormat` | `json` | `json`, `flattened`, `params` | `json` will send a JSON object to the lmsCommitUrl in the format of <br>`{'cmi': {'core': {...}}`<br><br> `flattened` will send the data in the format <br>`{'cmi.core.exit': 'suspend', 'cmi.core.mode': 'normal'...}`<br><br> `params` will send the data as <br>`?cmi.core.exit=suspend&cmi.core.mode=normal...` |
100
+ | `commitRequestDataType` | 'application/json;charset=UTF-8' | string | This setting is provided in case your LMS expects a different content type or character set. |
101
+ | `renderCommonCommitFields` | false | true/false | Determines whether the API should render the common fields in the commit object. Common fields are `successStatus`, `completionStatus`, `totalTimeSeconds`, `score`, and `runtimeData`. The `runtimeData` field contains the render CMI object. This allows for easier processing on the LMS. |
102
+ | `autoProgress` | false | true/false | In case Sequencing is being used, you can tell the API to automatically throw the `SequenceNext` event. |
103
+ | `logLevel` | 4 | int<br><br>1 => DEBUG<br>2 => INFO<br>3 => WARN<br>4 => ERROR<br>5 => NONE | By default, the APIs only log error messages. |
104
+ | `mastery_override` | false | true/false | (SCORM 1.2) Used to override a module's `cmi.core.lesson_status` so that a pass/fail is determined based on a mastery score and the user's raw score, rather than using whatever status is provided by the module. An example of this would be if a module is published using a `Complete/Incomplete` final status, but the LMS always wants to receive a `Passed/Failed` for quizzes, then we can use this setting to override the given final status. |
105
+ | `selfReportSessionTime` | false | true/false | Should the API override the default `session_time` reported by the module? Useful when modules don't properly report time. |
106
+ | `alwaysSendTotalTime` | false | true/false | Should the API always send `total_time` when committing to the LMS |
107
+ | `xhrWithCredentials` | false | true/false | Sets the withCredentials flag on the request to the LMS |
108
+ | `xhrHeaders` | {} | Object | This allows setting of additional headers on the request to the LMS where the key should be the header name and the value is the value of the header you want to send |
109
+ | `responseHandler` | function | | A function to properly tranform the response from the LMS to the correct format. The APIs expect the result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }` |
110
+ | `requestHandler` | function | | A function to transform the commit object before sending it to `lmsCommitUrl`. By default it's the identity function (no transformation). |
111
+ | `onLogMessage` | function | | A function to be called whenever a message is logged. Defaults to console.{error,warn,info,debug,log} |
112
+ | `scoItemIds` | [] | string[] | A list of valid SCO IDs to be used for choice/jump sequence validation. |
113
+ | `scoItemIdValidator` | false | false / function | A function to be called during choice/jump sequence checks to determine if a SCO ID is valid. Could be used to call an API to check validity. |
114
+
115
+ ## Settings Function Examples
116
+
117
+ ### responseHandler
118
+
119
+ The responseHandler function is used to transform the response from the LMS to the correct format. The APIs expect the
120
+ result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }`
121
+
122
+ ```javascript
123
+ var settings = {
124
+ responseHandler: function (response: Response): ResultObject {
125
+ const responseObj = JSON.parse(response.text());
126
+ return {
127
+ result: responseObj.success,
128
+ errorCode: responseObj.error
129
+ };
130
+ }
131
+ };
132
+ ```
133
+
134
+ ### requestHandler
135
+
136
+ The requestHandler function is used to transform the commit object before sending it to `lmsCommitUrl`. By default, it's
137
+ the identity function (no transformation).
138
+
139
+ ```javascript
140
+ var settings = {
141
+ requestHandler: function (commitObject: CommitObject): CommitObject {
142
+ commitObject.cmi.core.lesson_status = 'completed';
143
+ return commitObject;
144
+ }
145
+ };
146
+ ```
147
+
148
+ ### onLogMessage
149
+
150
+ The onLogMessage function is used to log messages. By default, it logs messages to the console.
151
+
152
+ ```javascript
153
+ var settings = {
154
+ onLogMessage: function (level: LogLevel, message: string): void {
155
+ console.log(`[${level}] ${message}`);
156
+ }
157
+ };
158
+ ```
80
159
 
81
160
  ## Initial Values
82
161
 
83
- If you want to initially load data from your backend API, you must do it before launching your SCORM/AICC player. After the player has initialized, you will not be able to change any read-only values.
162
+ If you want to initially load data from your backend API, you must do it before launching your SCORM/AICC player. After
163
+ the player has initialized, you will not be able to change any read-only values.
84
164
 
85
165
  You can initialize your variables on the CMI object individually:
86
166
 
@@ -88,7 +168,8 @@ You can initialize your variables on the CMI object individually:
88
168
  window.API_1484_11.cmi.learner_id = "123";
89
169
  ```
90
170
 
91
- You can also initialize the CMI object in bulk by supplying a JSON object. Note that it can be a partial CMI JSON object:
171
+ You can also initialize the CMI object in bulk by supplying a JSON object. Note that it can be a partial CMI JSON
172
+ object:
92
173
 
93
174
  ```javascript
94
175
  window.API_1484_11.loadFromJSON(json);
@@ -103,31 +184,33 @@ window.API_1484_11.loadFromJSON(json);
103
184
  "learner_name": "Bob The Builder",
104
185
  "suspend_data": "viewed=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31|lastviewedslide=31|7#1##,3,3,3,7,3,3,7,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,11#0#b5e89fbb-7cfb-46f0-a7cb-758165d3fe7e=236~262~2542812732762722742772682802752822882852892872832862962931000~3579~32590001001010101010101010101001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001010010010010010010010010011010010010010010010010010010010010112101021000171000~236a71d398e-4023-4967-88fe-1af18721422d06passed6failed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000105wrong110000000000000000000000000000000000~3185000000000000000000000000000000000000000000000000000000000000000000000000000000000~283~2191w11~21113101w41689~256~2100723031840~21007230314509062302670~2110723031061120000000000000000000~240~234531618~21601011000100000002814169400,#-1",
105
186
  "interactions": {
106
- "0": {
107
- "id": "Question14_1",
108
- "type": "choice",
109
- "timestamp": "2018-08-26T11:05:21",
110
- "weighting": "1",
111
- "learner_response": "HTH",
112
- "result": "wrong",
113
- "latency": "PT2M30S",
114
- "objectives": {
115
- "0": {
116
- "id": "Question14_1"
117
- }
118
- },
119
- "correct_responses": {
120
- "0": {
121
- "pattern": "CPR"
122
- }
187
+ "0": {
188
+ "id": "Question14_1",
189
+ "type": "choice",
190
+ "timestamp": "2018-08-26T11:05:21",
191
+ "weighting": "1",
192
+ "learner_response": "HTH",
193
+ "result": "wrong",
194
+ "latency": "PT2M30S",
195
+ "objectives": {
196
+ "0": {
197
+ "id": "Question14_1"
198
+ }
199
+ },
200
+ "correct_responses": {
201
+ "0": {
202
+ "pattern": "CPR"
203
+ }
204
+ }
123
205
  }
124
- }
125
206
  }
126
- };
207
+ };
127
208
  ```
209
+
128
210
  </details>
129
211
 
130
- Another option for initializing the CMI object in bulk is by supplying a "flattened" JSON object. Note that it can be a partial CMI JSON object:
212
+ Another option for initializing the CMI object in bulk is by supplying a "flattened" JSON object. Note that it can be a
213
+ partial CMI JSON object:
131
214
 
132
215
  ```javascript
133
216
  window.API_1484_11.loadFromFlattenedJSON(json);
@@ -150,13 +233,16 @@ window.API_1484_11.loadFromFlattenedJSON(json);
150
233
  "cmi.interactions.0.latency": "PT2M30S",
151
234
  "cmi.interactions.0.objectives.0.id": "Question14_1"
152
235
  "cmi.interactions.0.objectives.0.correct_responses.0.pattern": "CPR"
153
- };
236
+ };
154
237
  ```
238
+
155
239
  </details>
156
240
 
157
241
  ### Accessing CMI Data
158
242
 
159
- The CMI data stored by the API can be accessed directly through the `API.cmi` object or `API_1484_11.cmi` object. For example, to get the Student Name in SCORM 1.2, you would do the following:
243
+ The CMI data stored by the API can be accessed directly through the `API.cmi` object or `API_1484_11.cmi` object. For
244
+ example, to get the Student Name in SCORM 1.2, you would do the following:
245
+
160
246
  ```javascript
161
247
  var studentName = window.API.cmi.core.student_name;
162
248
  ```
@@ -178,33 +264,35 @@ For convenience, hooks are available for all the SCORM 1.2/AICC API Signature fu
178
264
  You can add your hook into these by adding a listener to the `window.API` object:
179
265
 
180
266
  ```javascript
181
- window.API.on("LMSInitialize", function() {
182
- [...]
267
+ window.API.on("LMSInitialize", function () {
268
+ [...]
183
269
  });
184
270
  ```
185
271
 
186
272
  You can also listen for events on specific SCORM CMI elements:
187
273
 
188
274
  ```javascript
189
- window.API.on("LMSSetValue.cmi.core.student_id", function(CMIElement, value) {
190
- [...]
275
+ window.API.on("LMSSetValue.cmi.core.student_id", function (CMIElement, value) {
276
+ [...]
191
277
  });
192
278
  ```
193
279
 
194
280
  Finally, you can listen for events using a wildcard:
195
281
 
196
282
  ```javascript
197
- window.API.on("LMSSetValue.cmi.*", function(CMIElement, value) {
198
- [...]
283
+ window.API.on("LMSSetValue.cmi.*", function (CMIElement, value) {
284
+ [...]
199
285
  });
200
286
  ```
201
287
 
202
288
  You also have to ability to remove specific callback listeners:
289
+
203
290
  ```javascript
204
291
  window.API.off("LMSInitialize", callback);
205
292
  ```
206
293
 
207
294
  Or, you can clear all callbacks for a particular event:
295
+
208
296
  ```javascript
209
297
  window.API.clear("LMSInitialize");
210
298
  ```
@@ -231,60 +319,80 @@ For convenience, hooks are available for all the SCORM API Signature functions:
231
319
  You can add your hook into these by adding a listener to the `window.API_1484_11` object:
232
320
 
233
321
  ```javascript
234
- window.API_1484_11.on("Initialize", function() {
235
- [...]
322
+ window.API_1484_11.on("Initialize", function () {
323
+ [...]
236
324
  });
237
325
  ```
238
326
 
239
327
  You can also listen for events on specific SCORM CMI elements:
240
328
 
241
329
  ```javascript
242
- window.API_1484_11.on("SetValue.cmi.learner_id ", function(CMIElement, value) {
243
- [...]
330
+ window.API_1484_11.on("SetValue.cmi.learner_id ", function (CMIElement, value) {
331
+ [...]
244
332
  });
245
333
  ```
246
334
 
247
335
  Finally, you can listen for events using a wildcard:
248
336
 
249
337
  ```javascript
250
- window.API_1484_11.on("SetValue.cmi.* ", function(CMIElement, value) {
251
- [...]
338
+ window.API_1484_11.on("SetValue.cmi.* ", function (CMIElement, value) {
339
+ [...]
252
340
  });
253
341
  ```
254
342
 
255
343
  You also have to ability to remove specific callback listeners:
344
+
256
345
  ```javascript
257
346
  window.API_1484_11.off("Initialize", callback);
258
347
  ```
259
348
 
260
349
  Or, you can clear all callbacks for a particular event:
350
+
261
351
  ```javascript
262
352
  window.API_1484_11.clear("Initialize");
263
353
  ```
264
354
 
265
355
  ### Total Time Calculation
266
- The APIs provide a convenience method `getCurrentTotalTime()` that can be used for calculating the current `total_time` value, based on the current `session_time` and the `total_time` supplied when the module was launched. This works for both ISO 8601 duration time formats in SCORM 2004 as well as the HH:MM:SS format in SCORM 1.2 and AICC, and outputs the correct format based on the version used.
356
+
357
+ The APIs provide a convenience method `getCurrentTotalTime()` that can be used for calculating the current `total_time`
358
+ value, based on the current `session_time` and the `total_time` supplied when the module was launched. This works for
359
+ both ISO 8601 duration time formats in SCORM 2004 as well as the HH:MM:SS format in SCORM 1.2 and AICC, and outputs the
360
+ correct format based on the version used.
267
361
 
268
362
  ### Completion Status
269
- The APIs will calculate the proper completion status to send back to an LMS. This status is usually based on completion threshold, progress measure, and lesson mode, but please see the `mastery_override` setting for how statuses can be changed based on scores, as well.
363
+
364
+ The APIs will calculate the proper completion status to send back to an LMS. This status is usually based on completion
365
+ threshold, progress measure, and lesson mode, but please see the `mastery_override` setting for how statuses can be
366
+ changed based on scores, as well.
270
367
 
271
368
  ### Sequencing
272
- The APIs provide some hooks for the sequencing of modules, but this is primarily handled by the LMS, so no functionality beyond event listeners is provided. More work can be done in this area, but I'm primarily focused on the stability of the rest of the APIs at this point.
273
369
 
370
+ The APIs provide some hooks for the sequencing of modules, but this is primarily handled by the LMS, so no functionality
371
+ beyond event listeners is provided. More work can be done in this area, but I'm primarily focused on the stability of
372
+ the rest of the APIs at this point.
274
373
 
275
374
  ### Credits and Thanks!
276
- This project was heavily influenced by the [simplify-scorm](https://github.com/gabrieldoty/simplify-scorm) project by @gabrieldoty, but ended up being pretty much a ground-up rewrite. The big influence from this project was the inclusion of event listeners.
277
375
 
278
- I also drew from the [Moodle SCORM module](https://github.com/moodle/moodle/tree/master/mod/scorm), but avoided directly copying their code because it is...not very clean.
376
+ This project was heavily influenced by the [simplify-scorm](https://github.com/gabrieldoty/simplify-scorm) project by
377
+ @gabrieldoty, but ended up being pretty much a ground-up rewrite. The big influence from this project was the inclusion
378
+ of event listeners.
379
+
380
+ I also drew from the [Moodle SCORM module](https://github.com/moodle/moodle/tree/master/mod/scorm), but avoided directly
381
+ copying their code because it is...not very clean.
279
382
 
280
383
  ### Contributing
281
- I welcome any and all feedback and contributions to this project! I'm sure it would do with some cleanup and refactoring, and could definitely use some more test cases.
384
+
385
+ I welcome any and all feedback and contributions to this project! I'm sure it would do with some cleanup and
386
+ refactoring, and could definitely use some more test cases.
282
387
 
283
388
  #### Setup and Development
284
- You will need `node` installed on your local machine, and you'll have to run `npm install` in the repo directory before starting development.
389
+
390
+ You will need `node` installed on your local machine, and you'll have to run `npm install` in the repo directory before
391
+ starting development.
285
392
 
286
393
  To run a build, you need to just run the `yarn run compile` command in the root of the project.
287
394
 
288
395
  Similarly, to run the tests, you just run the `yarn test` command.
289
396
 
290
- Before submitting pull requests, please also run `eslint ./src --fix` against your code first, otherwise your pull request build could fail.
397
+ Before submitting pull requests, please also run `eslint ./src --fix` against your code first, otherwise your pull
398
+ request build could fail.