scorm-again 2.0.0 → 2.1.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 +171 -72
  5. package/dist/aicc.js +1441 -1140
  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 +2703 -2212
  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 +1069 -852
  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 +1861 -1571
  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 +10 -6
  22. package/src/AICC.ts +15 -17
  23. package/src/BaseAPI.ts +268 -417
  24. package/src/Scorm12API.ts +65 -38
  25. package/src/Scorm2004API.ts +151 -117
  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 +81 -0
  56. package/src/constants/enums.ts +5 -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 +32 -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 +262 -9
  67. package/test/Scorm2004API.spec.ts +488 -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,149 @@
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
30
38
  <script type="text/javascript" src="/dist/scorm-again.js"></script>
31
39
  ```
32
40
 
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:
41
+ Or, if you would like to only pull in one API, you include either the `aicc.js`, `scorm12.js` or `scorm2004.js` files or
42
+ their minified versions on your launching page:
43
+
34
44
  ```html
35
45
  <script type="text/javascript" src="/dist/scorm2004.js"></script>
36
46
  ```
37
47
 
38
48
  Or, if you would like to install the library using your package manager, you can do the following:
49
+
39
50
  ```sh
40
51
  npm install scorm-again
41
52
  ```
53
+
42
54
  or
55
+
43
56
  ```sh
44
57
  yarn add scorm-again
45
58
  ```
46
59
 
47
60
  You would then initialize the APIs using the following JS statements:
61
+
48
62
  ```javascript
49
- var settings = {}
50
- # AICC
63
+ import { AICC, Scorm12API, Scorm2004API } from 'scorm-again'; // you only do this if you're using the package manager
64
+
65
+ var settings = {};
66
+
67
+ // AICC
51
68
  window.API = new AICC(settings);
52
69
 
53
- # SCORM 1.2
70
+ // SCORM 1.2
54
71
  window.API = new Scorm12API(settings);
55
72
 
56
- # SCORM 2004
73
+ // SCORM 2004
57
74
  window.API_1484_11 = new Scorm2004API(settings);
58
75
  ```
59
76
 
77
+ ### A Note About API Discovery
78
+ Before creating a ticket about your module not being able to communicate with the LMS, please make sure you've looked over my examples in the `gh-pages` branch, as well as reading the [SCORM API Discovery Algorithms](https://scorm.com/scorm-explained/technical-scorm/run-time/api-discovery-algorithms/) 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 way this library can be loaded into your application. The main thing to remember is that it should always be attached to the `window` object, because that's where modules are supposed to look.
79
+
60
80
  ### Available Settings
81
+
61
82
  The APIs include several settings to customize the functionality of each API:
62
83
 
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} |
84
+ | Setting | Default | Values | Description |
85
+ |-------------------------|:--------------------------------:|:--------------------------------------------------------------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
86
+ | `autocommit` | false | true/false | Determines whether the API schedules an autocommit to the LMS after setting a value. |
87
+ | `autocommitSeconds` | 60 | int | Number of seconds to wait before autocommiting. Timer is restarted if another value is set. |
88
+ | `asyncCommit` | false | true/false | Determines whether the API should send the request to the `lmsCommitUrl` asynchronously. |
89
+ | `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. |
90
+ | `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. |
91
+ | `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...` |
92
+ | `commitRequestDataType` | 'application/json;charset=UTF-8' | string | This setting is provided in case your LMS expects a different content type or character set. |
93
+ | `autoProgress` | false | true/false | In case Sequencing is being used, you can tell the API to automatically throw the `SequenceNext` event. |
94
+ | `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. |
95
+ | `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. |
96
+ | `selfReportSessionTime` | false | true/false | Should the API override the default `session_time` reported by the module? Useful when modules don't properly report time. |
97
+ | `alwaysSendTotalTime` | false | true/false | Should the API always send `total_time` when committing to the LMS |
98
+ | `xhrWithCredentials` | false | true/false | Sets the withCredentials flag on the request to the LMS |
99
+ | `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 |
100
+ | `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 }` |
101
+ | `requestHandler` | function | | A function to transform the commit object before sending it to `lmsCommitUrl`. By default it's the identity function (no transformation). |
102
+ | `onLogMessage` | function | | A function to be called whenever a message is logged. Defaults to console.{error,warn,info,debug,log} |
103
+ | `scoItemIds` | [] | string[] | A list of valid SCO IDs to be used for choice/jump sequence validation. |
104
+ | `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. |
105
+
106
+ ## Settings Function Examples
107
+
108
+ ### responseHandler
109
+
110
+ The responseHandler function is used to transform the response from the LMS to the correct format. The APIs expect the
111
+ result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }`
112
+
113
+ ```javascript
114
+ var settings = {
115
+ responseHandler: function (response: Response): ResultObject {
116
+ const responseObj = JSON.parse(response.text());
117
+ return {
118
+ result: responseObj.success,
119
+ errorCode: responseObj.error
120
+ };
121
+ }
122
+ };
123
+ ```
124
+
125
+ ### requestHandler
126
+
127
+ The requestHandler function is used to transform the commit object before sending it to `lmsCommitUrl`. By default, it's
128
+ the identity function (no transformation).
129
+
130
+ ```javascript
131
+ var settings = {
132
+ requestHandler: function (commitObject: CommitObject): CommitObject {
133
+ commitObject.cmi.core.lesson_status = 'completed';
134
+ return commitObject;
135
+ }
136
+ };
137
+ ```
138
+
139
+ ### onLogMessage
140
+
141
+ The onLogMessage function is used to log messages. By default, it logs messages to the console.
142
+
143
+ ```javascript
144
+ var settings = {
145
+ onLogMessage: function (level: LogLevel, message: string): void {
146
+ console.log(`[${level}] ${message}`);
147
+ }
148
+ };
149
+ ```
80
150
 
81
151
  ## Initial Values
82
152
 
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.
153
+ If you want to initially load data from your backend API, you must do it before launching your SCORM/AICC player. After
154
+ the player has initialized, you will not be able to change any read-only values.
84
155
 
85
156
  You can initialize your variables on the CMI object individually:
86
157
 
@@ -88,7 +159,8 @@ You can initialize your variables on the CMI object individually:
88
159
  window.API_1484_11.cmi.learner_id = "123";
89
160
  ```
90
161
 
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:
162
+ You can also initialize the CMI object in bulk by supplying a JSON object. Note that it can be a partial CMI JSON
163
+ object:
92
164
 
93
165
  ```javascript
94
166
  window.API_1484_11.loadFromJSON(json);
@@ -103,31 +175,33 @@ window.API_1484_11.loadFromJSON(json);
103
175
  "learner_name": "Bob The Builder",
104
176
  "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
177
  "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
- }
178
+ "0": {
179
+ "id": "Question14_1",
180
+ "type": "choice",
181
+ "timestamp": "2018-08-26T11:05:21",
182
+ "weighting": "1",
183
+ "learner_response": "HTH",
184
+ "result": "wrong",
185
+ "latency": "PT2M30S",
186
+ "objectives": {
187
+ "0": {
188
+ "id": "Question14_1"
189
+ }
190
+ },
191
+ "correct_responses": {
192
+ "0": {
193
+ "pattern": "CPR"
194
+ }
195
+ }
123
196
  }
124
- }
125
197
  }
126
- };
198
+ };
127
199
  ```
200
+
128
201
  </details>
129
202
 
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:
203
+ Another option for initializing the CMI object in bulk is by supplying a "flattened" JSON object. Note that it can be a
204
+ partial CMI JSON object:
131
205
 
132
206
  ```javascript
133
207
  window.API_1484_11.loadFromFlattenedJSON(json);
@@ -150,13 +224,16 @@ window.API_1484_11.loadFromFlattenedJSON(json);
150
224
  "cmi.interactions.0.latency": "PT2M30S",
151
225
  "cmi.interactions.0.objectives.0.id": "Question14_1"
152
226
  "cmi.interactions.0.objectives.0.correct_responses.0.pattern": "CPR"
153
- };
227
+ };
154
228
  ```
229
+
155
230
  </details>
156
231
 
157
232
  ### Accessing CMI Data
158
233
 
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:
234
+ The CMI data stored by the API can be accessed directly through the `API.cmi` object or `API_1484_11.cmi` object. For
235
+ example, to get the Student Name in SCORM 1.2, you would do the following:
236
+
160
237
  ```javascript
161
238
  var studentName = window.API.cmi.core.student_name;
162
239
  ```
@@ -178,33 +255,35 @@ For convenience, hooks are available for all the SCORM 1.2/AICC API Signature fu
178
255
  You can add your hook into these by adding a listener to the `window.API` object:
179
256
 
180
257
  ```javascript
181
- window.API.on("LMSInitialize", function() {
182
- [...]
258
+ window.API.on("LMSInitialize", function () {
259
+ [...]
183
260
  });
184
261
  ```
185
262
 
186
263
  You can also listen for events on specific SCORM CMI elements:
187
264
 
188
265
  ```javascript
189
- window.API.on("LMSSetValue.cmi.core.student_id", function(CMIElement, value) {
190
- [...]
266
+ window.API.on("LMSSetValue.cmi.core.student_id", function (CMIElement, value) {
267
+ [...]
191
268
  });
192
269
  ```
193
270
 
194
271
  Finally, you can listen for events using a wildcard:
195
272
 
196
273
  ```javascript
197
- window.API.on("LMSSetValue.cmi.*", function(CMIElement, value) {
198
- [...]
274
+ window.API.on("LMSSetValue.cmi.*", function (CMIElement, value) {
275
+ [...]
199
276
  });
200
277
  ```
201
278
 
202
279
  You also have to ability to remove specific callback listeners:
280
+
203
281
  ```javascript
204
282
  window.API.off("LMSInitialize", callback);
205
283
  ```
206
284
 
207
285
  Or, you can clear all callbacks for a particular event:
286
+
208
287
  ```javascript
209
288
  window.API.clear("LMSInitialize");
210
289
  ```
@@ -231,60 +310,80 @@ For convenience, hooks are available for all the SCORM API Signature functions:
231
310
  You can add your hook into these by adding a listener to the `window.API_1484_11` object:
232
311
 
233
312
  ```javascript
234
- window.API_1484_11.on("Initialize", function() {
235
- [...]
313
+ window.API_1484_11.on("Initialize", function () {
314
+ [...]
236
315
  });
237
316
  ```
238
317
 
239
318
  You can also listen for events on specific SCORM CMI elements:
240
319
 
241
320
  ```javascript
242
- window.API_1484_11.on("SetValue.cmi.learner_id ", function(CMIElement, value) {
243
- [...]
321
+ window.API_1484_11.on("SetValue.cmi.learner_id ", function (CMIElement, value) {
322
+ [...]
244
323
  });
245
324
  ```
246
325
 
247
326
  Finally, you can listen for events using a wildcard:
248
327
 
249
328
  ```javascript
250
- window.API_1484_11.on("SetValue.cmi.* ", function(CMIElement, value) {
251
- [...]
329
+ window.API_1484_11.on("SetValue.cmi.* ", function (CMIElement, value) {
330
+ [...]
252
331
  });
253
332
  ```
254
333
 
255
334
  You also have to ability to remove specific callback listeners:
335
+
256
336
  ```javascript
257
337
  window.API_1484_11.off("Initialize", callback);
258
338
  ```
259
339
 
260
340
  Or, you can clear all callbacks for a particular event:
341
+
261
342
  ```javascript
262
343
  window.API_1484_11.clear("Initialize");
263
344
  ```
264
345
 
265
346
  ### 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.
347
+
348
+ The APIs provide a convenience method `getCurrentTotalTime()` that can be used for calculating the current `total_time`
349
+ value, based on the current `session_time` and the `total_time` supplied when the module was launched. This works for
350
+ 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
351
+ correct format based on the version used.
267
352
 
268
353
  ### 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.
354
+
355
+ The APIs will calculate the proper completion status to send back to an LMS. This status is usually based on completion
356
+ threshold, progress measure, and lesson mode, but please see the `mastery_override` setting for how statuses can be
357
+ changed based on scores, as well.
270
358
 
271
359
  ### 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
360
 
361
+ The APIs provide some hooks for the sequencing of modules, but this is primarily handled by the LMS, so no functionality
362
+ beyond event listeners is provided. More work can be done in this area, but I'm primarily focused on the stability of
363
+ the rest of the APIs at this point.
274
364
 
275
365
  ### 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
366
 
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.
367
+ This project was heavily influenced by the [simplify-scorm](https://github.com/gabrieldoty/simplify-scorm) project by
368
+ @gabrieldoty, but ended up being pretty much a ground-up rewrite. The big influence from this project was the inclusion
369
+ of event listeners.
370
+
371
+ I also drew from the [Moodle SCORM module](https://github.com/moodle/moodle/tree/master/mod/scorm), but avoided directly
372
+ copying their code because it is...not very clean.
279
373
 
280
374
  ### 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.
375
+
376
+ I welcome any and all feedback and contributions to this project! I'm sure it would do with some cleanup and
377
+ refactoring, and could definitely use some more test cases.
282
378
 
283
379
  #### 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.
380
+
381
+ You will need `node` installed on your local machine, and you'll have to run `npm install` in the repo directory before
382
+ starting development.
285
383
 
286
384
  To run a build, you need to just run the `yarn run compile` command in the root of the project.
287
385
 
288
386
  Similarly, to run the tests, you just run the `yarn test` command.
289
387
 
290
- Before submitting pull requests, please also run `eslint ./src --fix` against your code first, otherwise your pull request build could fail.
388
+ Before submitting pull requests, please also run `eslint ./src --fix` against your code first, otherwise your pull
389
+ request build could fail.