jclic 2.2.0 → 2.3.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 (177) hide show
  1. package/README.md +5 -7
  2. package/dist-node/jclic-node.js +14157 -0
  3. package/dist-node/jclic-node.umd.cjs +530 -0
  4. package/package.json +38 -26
  5. package/.vscode/launch.json +0 -33
  6. package/.vscode/settings.json +0 -13
  7. package/CHANGELOG.md +0 -664
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31678
  11. package/dist/jclic-node.js.map +0 -1
  12. package/dist/jclic.components.LICENSE +0 -2254
  13. package/dist/jclic.min.js +0 -27
  14. package/dist/jclic.min.js.map +0 -1
  15. package/eslint.config.mjs +0 -31
  16. package/jsdoc.config.js +0 -71
  17. package/locales/ar.po +0 -244
  18. package/locales/ast.po +0 -246
  19. package/locales/bs.po +0 -247
  20. package/locales/ca.po +0 -248
  21. package/locales/ca_ES@valencia.po +0 -248
  22. package/locales/cs.po +0 -244
  23. package/locales/da.po +0 -244
  24. package/locales/de.po +0 -246
  25. package/locales/el.po +0 -244
  26. package/locales/es.po +0 -248
  27. package/locales/eu.po +0 -244
  28. package/locales/fr.po +0 -244
  29. package/locales/gl.po +0 -244
  30. package/locales/he.po +0 -244
  31. package/locales/hr.po +0 -245
  32. package/locales/it.po +0 -246
  33. package/locales/ja.po +0 -242
  34. package/locales/jclic.js.pot +0 -241
  35. package/locales/nb_NO.po +0 -244
  36. package/locales/nl.po +0 -244
  37. package/locales/pl.po +0 -244
  38. package/locales/pt.po +0 -244
  39. package/locales/pt_BR.po +0 -248
  40. package/locales/ro.po +0 -248
  41. package/locales/ru.po +0 -245
  42. package/locales/ta.po +0 -244
  43. package/locales/tr.po +0 -246
  44. package/locales/uk.po +0 -247
  45. package/locales/vec.po +0 -244
  46. package/locales/zh_TW.po +0 -246
  47. package/patches/po2json+1.0.0-beta-3.patch +0 -12
  48. package/src/AWT.js +0 -2067
  49. package/src/Activity.js +0 -1311
  50. package/src/Deps.js +0 -232
  51. package/src/GlobalData.js +0 -5
  52. package/src/JClic.js +0 -196
  53. package/src/JClicPlayer.js +0 -1308
  54. package/src/PlayerHistory.js +0 -305
  55. package/src/Utils.js +0 -1355
  56. package/src/activities/associations/ComplexAssociation.js +0 -321
  57. package/src/activities/associations/SimpleAssociation.js +0 -519
  58. package/src/activities/memory/MemoryGame.js +0 -423
  59. package/src/activities/panels/Explore.js +0 -349
  60. package/src/activities/panels/Identify.js +0 -356
  61. package/src/activities/panels/InformationScreen.js +0 -262
  62. package/src/activities/panels/Menu.js +0 -209
  63. package/src/activities/panels/icons/ico00.png +0 -0
  64. package/src/activities/panels/icons/ico01.png +0 -0
  65. package/src/activities/panels/icons/ico02.png +0 -0
  66. package/src/activities/panels/icons/ico03.png +0 -0
  67. package/src/activities/panels/icons/icofolder.png +0 -0
  68. package/src/activities/puzzles/DoublePuzzle.js +0 -424
  69. package/src/activities/puzzles/ExchangePuzzle.js +0 -374
  70. package/src/activities/puzzles/HolePuzzle.js +0 -360
  71. package/src/activities/text/Complete.js +0 -127
  72. package/src/activities/text/Evaluator.js +0 -534
  73. package/src/activities/text/FillInBlanks.js +0 -426
  74. package/src/activities/text/IdentifyText.js +0 -253
  75. package/src/activities/text/OrderText.js +0 -421
  76. package/src/activities/text/TextActivityBase.js +0 -557
  77. package/src/activities/text/TextActivityDocument.js +0 -658
  78. package/src/activities/text/WrittenAnswer.js +0 -557
  79. package/src/activities/textGrid/CrossWord.js +0 -565
  80. package/src/activities/textGrid/WordSearch.js +0 -458
  81. package/src/activities/textGrid/icons/hIcon.svg +0 -3
  82. package/src/activities/textGrid/icons/vIcon.svg +0 -3
  83. package/src/automation/AutoContentProvider.js +0 -182
  84. package/src/automation/arith/Arith.js +0 -864
  85. package/src/bags/ActivitySequence.js +0 -318
  86. package/src/bags/ActivitySequenceElement.js +0 -161
  87. package/src/bags/ActivitySequenceJump.js +0 -140
  88. package/src/bags/ConditionalJumpInfo.js +0 -113
  89. package/src/bags/JumpInfo.js +0 -136
  90. package/src/bags/MediaBag.js +0 -215
  91. package/src/bags/MediaBagElement.js +0 -516
  92. package/src/boxes/AbstractBox.js +0 -699
  93. package/src/boxes/ActiveBagContent.js +0 -494
  94. package/src/boxes/ActiveBox.js +0 -810
  95. package/src/boxes/ActiveBoxBag.js +0 -357
  96. package/src/boxes/ActiveBoxContent.js +0 -484
  97. package/src/boxes/ActiveBoxGrid.js +0 -179
  98. package/src/boxes/BoxBag.js +0 -500
  99. package/src/boxes/BoxBase.js +0 -398
  100. package/src/boxes/BoxConnector.js +0 -325
  101. package/src/boxes/TextGrid.js +0 -887
  102. package/src/boxes/TextGridContent.js +0 -215
  103. package/src/init-jsdom.js +0 -65
  104. package/src/jclic-node.js +0 -219
  105. package/src/media/ActiveMediaBag.js +0 -145
  106. package/src/media/ActiveMediaPlayer.js +0 -297
  107. package/src/media/AudioBuffer.js +0 -219
  108. package/src/media/EventSounds.js +0 -169
  109. package/src/media/EventSoundsElement.js +0 -155
  110. package/src/media/MediaContent.js +0 -328
  111. package/src/media/MidiAudioPlayer.js +0 -254
  112. package/src/media/icons/audio.svg +0 -3
  113. package/src/media/icons/generic.svg +0 -3
  114. package/src/media/icons/mic.svg +0 -3
  115. package/src/media/icons/movie.svg +0 -3
  116. package/src/media/icons/music.svg +0 -3
  117. package/src/media/icons/url.svg +0 -3
  118. package/src/media/sounds/actionError.mp3 +0 -0
  119. package/src/media/sounds/actionOk.mp3 +0 -0
  120. package/src/media/sounds/click.mp3 +0 -0
  121. package/src/media/sounds/finishedError.mp3 +0 -0
  122. package/src/media/sounds/finishedOk.mp3 +0 -0
  123. package/src/media/sounds/start.mp3 +0 -0
  124. package/src/project/JClicProject.js +0 -282
  125. package/src/project/ProjectSettings.js +0 -273
  126. package/src/report/ActionReg.js +0 -123
  127. package/src/report/ActivityReg.js +0 -271
  128. package/src/report/EncryptMin.js +0 -210
  129. package/src/report/Reporter.js +0 -727
  130. package/src/report/SCORM.js +0 -272
  131. package/src/report/SequenceReg.js +0 -275
  132. package/src/report/SessionReg.js +0 -340
  133. package/src/report/SessionStorageReporter.js +0 -131
  134. package/src/report/TCPReporter.js +0 -628
  135. package/src/shapers/ClassicJigSaw.js +0 -138
  136. package/src/shapers/Holes.js +0 -77
  137. package/src/shapers/JigSaw.js +0 -161
  138. package/src/shapers/Rectangular.js +0 -78
  139. package/src/shapers/Shaper.js +0 -386
  140. package/src/shapers/TriangularJigSaw.js +0 -121
  141. package/src/skins/BlueSkin.js +0 -80
  142. package/src/skins/Counter.js +0 -152
  143. package/src/skins/CustomSkin.js +0 -412
  144. package/src/skins/DefaultSkin.js +0 -376
  145. package/src/skins/EmptySkin.js +0 -82
  146. package/src/skins/GreenSkin.js +0 -94
  147. package/src/skins/MiniSkin.js +0 -130
  148. package/src/skins/OrangeSkin.js +0 -78
  149. package/src/skins/SimpleSkin.js +0 -92
  150. package/src/skins/Skin.js +0 -1021
  151. package/src/skins/assets/actionsIcon.svg +0 -3
  152. package/src/skins/assets/appLogo.svg +0 -8
  153. package/src/skins/assets/basic.css +0 -41
  154. package/src/skins/assets/closeDialogIcon.svg +0 -3
  155. package/src/skins/assets/closeIcon.svg +0 -3
  156. package/src/skins/assets/copyIcon.svg +0 -3
  157. package/src/skins/assets/fullScreenExitIcon.svg +0 -3
  158. package/src/skins/assets/fullScreenIcon.svg +0 -3
  159. package/src/skins/assets/infoIcon.svg +0 -3
  160. package/src/skins/assets/main.css +0 -43
  161. package/src/skins/assets/mainHalf.css +0 -23
  162. package/src/skins/assets/mainTwoThirds.css +0 -23
  163. package/src/skins/assets/mini.css +0 -15
  164. package/src/skins/assets/nextIcon.svg +0 -3
  165. package/src/skins/assets/okDialogIcon.svg +0 -3
  166. package/src/skins/assets/prevIcon.svg +0 -3
  167. package/src/skins/assets/reports.css +0 -156
  168. package/src/skins/assets/reportsIcon.svg +0 -3
  169. package/src/skins/assets/scoreIcon.svg +0 -3
  170. package/src/skins/assets/simple.css +0 -16
  171. package/src/skins/assets/simpleHalf.css +0 -11
  172. package/src/skins/assets/simpleTwoThirds.css +0 -11
  173. package/src/skins/assets/timeIcon.svg +0 -4
  174. package/src/skins/assets/waitAnim.css +0 -54
  175. package/src/skins/assets/waitImgBig.svg +0 -3
  176. package/src/skins/assets/waitImgSmall.svg +0 -3
  177. package/webpack.config.mjs +0 -169
@@ -1,272 +0,0 @@
1
- /**
2
- * File : report/SCORM.js
3
- * Created : 18/07/2016
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- /* global window */
33
-
34
- import $ from 'jquery';
35
- import { log } from '../Utils.js';
36
-
37
- /**
38
- * This class detects if JClic.js is running in an SCORM environment and, if true,
39
- * exposes the methods needed to notify the results of activities.
40
- * Both SCORM 1.2 and 2004 are supported.
41
- */
42
- export class SCORM {
43
- /**
44
- * SCORM constructor
45
- * @param {object} API - The global SCORM API object
46
- * @param {module:report/Reporter.Reporter} reporter - The {@link module:Reporter.Reporter Reporter} associated to this SCORM object
47
- */
48
- constructor(API, reporter) {
49
- this.API = API;
50
- // Check if 'API' has a function named 'Initialized'
51
- if (typeof API.Initialize === 'function')
52
- this.is2004 = true;
53
- else {
54
- // SCORM 1.2
55
- this.prefix = 'LMS';
56
- this.core = 'cmi.core.';
57
- }
58
- this.reporter = reporter;
59
- }
60
-
61
- /**
62
- * Recursive function used to find the SCORM "API" object
63
- * @param {object} win - The 'window' object to scan for global SCORM API objects
64
- * @param {number} tries - Recursive attempts currently achieved
65
- * @returns {object} - The global SCORM API object, or `null` if not found
66
- */
67
- static scanForAPI(win, tries) {
68
- if (win.API_1484_11 && win.API_1184_11.Initialize && win.API_1184_11.SetValue && win.API_1184_11.Commit)
69
- return win.API_1184_11;
70
- else if (win.API && win.API.LMSInitialize && win.API.LMSSetValue && win.API.LMSCommit)
71
- return win.API;
72
- else if (win.parent && win.parent !== win && tries++ < SCORM.DISCOVER_MAX_TRIES)
73
- return SCORM.scanForAPI(win.parent, tries);
74
- else
75
- return null;
76
- }
77
-
78
- /**
79
- * Checks for the presence of a SCORM API on the current browser session.
80
- * @param {module:report/Reporter.Reporter} reporter - The {@link module:Reporter.Reporter Reporter} linked to the requested SCORM object
81
- * @returns {module:report/SCORM.SCORM} - A valid SCORM object, or `null` if no SCORM API was found.
82
- */
83
- static getSCORM(reporter) {
84
- let result = null;
85
- try {
86
- let api = SCORM.scanForAPI(window, 0);
87
- if (api === null && window.opener)
88
- api = SCORM.scanForAPI(window.opener, 0);
89
-
90
- if (api) {
91
- result = new SCORM(api, reporter);
92
- if (!result.initialize())
93
- result = null;
94
- }
95
- } catch (ex) {
96
- result = null;
97
- log('warn', 'Unable to use SCORM: %s', ex.toString());
98
- }
99
- return result;
100
- }
101
-
102
- /**
103
- * Initializes communication with the SCORM API
104
- * @returns {boolean}
105
- */
106
- initialize() {
107
- let result = false;
108
- try {
109
- result = this.API[this.prefix + 'Initialize']('');
110
- if (result) {
111
- this.studentId = this.getValue(this.core + (this.is2004 ? 'learner_id' : 'student_id'));
112
- this.studentName = this.getValue(this.core + (this.is2004 ? 'learner_name' : 'student_name'));
113
- this.setValue(this.core + 'score.min', 0);
114
- this.setValue(this.core + 'score.max', 100);
115
- $(window).on('unload', () => {
116
- this.commitInfo();
117
- this.terminate();
118
- this.API = null;
119
- });
120
- }
121
- log('debug', 'SCORM initialized');
122
- } catch (ex) {
123
- log('error', `Error initializing SCORM API: ${ex.message}`);
124
- }
125
- return result;
126
- }
127
-
128
- /**
129
- * Terminates communication with the SCORM API
130
- * @returns {boolean}
131
- */
132
- terminate() {
133
- let result = false;
134
- try {
135
- result = this.API[this.is2004 ? 'Terminate' : 'LMSFinish']('');
136
- } catch (ex) {
137
- log('error', `Error terminating SCORM API: ${ex.message}`);
138
- }
139
- return result;
140
- }
141
-
142
- /**
143
- * Commits the current information to the SCORM API
144
- */
145
- commitInfo() {
146
- const
147
- info = this.reporter.getInfo(),
148
- score = Math.round(info.globalScore * 100),
149
- time = this.getTimeExpression(info.tTime);
150
-
151
- this.setValue(this.core + 'score.raw', score);
152
- this.setValue(this.core + 'session_time', time);
153
- this.commit();
154
- log('debug', `SCORM results reported: ${score} (${time})`);
155
- }
156
-
157
- /**
158
- * Commits current pending data to the SCORM API
159
- * @returns {boolean}
160
- */
161
- commit() {
162
- let result = false;
163
- try {
164
- result = this.API[this.prefix + 'Commit']('');
165
- } catch (ex) {
166
- log('error', `Error commiting data to the SCORM API: ${ex.message}`);
167
- }
168
- return result;
169
- }
170
-
171
- /**
172
- * Sends a specific value to the SCORM API
173
- * @param {string} key - A SCORM valid key
174
- * @param {string|number} value - The value associated with this key
175
- * @returns {string}
176
- */
177
- setValue(key, value) {
178
- let result = false;
179
- try {
180
- result = this.API[this.prefix + 'SetValue'](key, value);
181
- } catch (ex) {
182
- log('error', `Error setting value "${value}" to "${key}" in SCORM API: ${ex.message}`);
183
- }
184
- return result;
185
- }
186
-
187
- /**
188
- * Gets a specific value from the SCORM API
189
- * @param {string} key - A SCORM valid key
190
- * @returns {string} - The value associated with the provided key, or `null` if not found
191
- */
192
- getValue(key) {
193
- let result = false;
194
- try {
195
- result = this.API[this.prefix + 'GetValue'](key);
196
- } catch (ex) {
197
- log('error', `Error retrieving "${key}" from SCORM API: ${ex.message}`);
198
- }
199
- return result;
200
- }
201
-
202
- /**
203
- * Gets a string expression of the given time (in milliseconds) suitable for a SCORM transaction.
204
- * @see {@link http://www.ostyn.com/standards/scorm/samples/ISOTimeForSCORM.htm}
205
- * @param {number} millis - The amount of time, in milliseconds
206
- * @returns {string} - An ISO8601 valid expression
207
- */
208
- getTimeExpression(millis) {
209
- const
210
- d = new Date(millis),
211
- h = d.getUTCHours(),
212
- m = d.getUTCMinutes(),
213
- s = d.getUTCSeconds();
214
-
215
- return this.is2004 ?
216
- `PT${h}H${m}M${s}S` :
217
- `${('0000' + h).slice(-4)}:${('00' + m).slice(-2)}:${('00' + s).slice(-2)}`;
218
- }
219
-
220
- /**
221
- * Gets the SCORM type of this SCORM object
222
- * @returns {string}
223
- */
224
- getScormType() {
225
- return `SCORM ${this.is2004 ? '2004' : '1.2'}`;
226
- }
227
- }
228
-
229
- Object.assign(SCORM.prototype, {
230
- /**
231
- * True when the API is of type SCORM 2004, false for SCORM 1.2
232
- * @name module:report/SCORM.SCORM#is2004
233
- * @type {boolean} */
234
- is2004: false,
235
- /**
236
- * The Reporter associated to this SCORM object
237
- * @name module:report/SCORM.SCORM#reporter
238
- * @type {module:report/Reporter.Reporter} */
239
- reporter: null,
240
- /**
241
- * Prefix to be used in SCORM function names. Should be 'LMS' for SCORM 1.2
242
- * @name module:report/SCORM.SCORM#prefix
243
- * @type {string} */
244
- prefix: '',
245
- /**
246
- * Prefix used in core SCORM keys. Should be 'cmi.core.' for 1.2 and 'cmi.' for 2004
247
- * @name module:report/SCORM.SCORM#core
248
- * @type {string} */
249
- core: 'cmi.',
250
- /**
251
- * SCORM API object used to communicate with the LMS
252
- * @name module:report/SCORM.SCORM#API
253
- * @type {object} */
254
- API: null,
255
- /**
256
- * The student ID retrieved from the SCORM API
257
- * @name module:report/SCORM.SCORM#studentId
258
- * @type {string} */
259
- studentId: '',
260
- /**
261
- * The student name retrieved from the SCORM API
262
- * @name module:report/SCORM.SCORM#studentName
263
- * @type {string} */
264
- studentName: '',
265
- });
266
-
267
- /**
268
- * Maximum recursive attempts allowed to find the global SCORM API object
269
- * @type {number} */
270
- SCORM.DISCOVER_MAX_TRIES = 50;
271
-
272
- export default SCORM;
@@ -1,275 +0,0 @@
1
- /**
2
- * File : report/SequenceReg.js
3
- * Created : 17/05/2016
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- import ActivityReg from './ActivityReg.js';
33
-
34
- /**
35
- * This class stores the results of the activities related to an {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement}.
36
- * It's main component is an array of {@link module:report/ActivityReg.ActivityReg ActivityReg} elements.
37
- */
38
- export class SequenceReg {
39
- /**
40
- * SequenceReg constructor
41
- * @param {module:bags/ActivitySequenceElement.ActivitySequenceElement} ase - The {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement} related to this sequence.
42
- */
43
- constructor(ase) {
44
- this.name = ase.tag;
45
- this.description = ase.description;
46
- this.activities = [];
47
- this.currentActivity = null;
48
- this.totalTime = 0;
49
- this.closed = false;
50
- this.info = new SequenceRegInfo(this);
51
- }
52
-
53
- /**
54
- * Builds a complex object with data about the results of the activities done in this sequence
55
- * @returns {object} - The sequence results
56
- */
57
- getData() {
58
- const result = {
59
- sequence: this.name,
60
- activities: []
61
- };
62
- this.activities.forEach(act => result.activities.push(act.getData()));
63
- return result;
64
- }
65
-
66
- /**
67
- * Returns the `info` element associated to this SequenceReg.
68
- * @returns {module:report/SequenceReg.SequenceRegInfo}
69
- */
70
- getInfo() {
71
- return this.info.recalc();
72
- }
73
-
74
- /**
75
- * This method should be called when the current working session finishes.
76
- */
77
- endSequence() {
78
- if (this.currentActivity && this.activities.length > 0) {
79
- if (!this.currentActivity.closed)
80
- this.currentActivity.closeActivity();
81
- this.totalTime = this.currentActivity.startTime + this.currentActivity.totalTime - this.activities[0].startTime;
82
- this.info.valid = false;
83
- }
84
- }
85
-
86
- /**
87
- * This method should be invoked when the user starts a new activity
88
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} that has just started
89
- */
90
- newActivity(act) {
91
- if (!this.closed) {
92
- this.currentActivity = new ActivityReg(act);
93
- this.activities.push(this.currentActivity);
94
- this.info.valid = false;
95
- }
96
- }
97
-
98
- /**
99
- * This method should be called when the current activity finishes. Data about user's final results
100
- * on the activity will then be saved.
101
- * @param {number} score - The final score, usually in a 0-100 scale.
102
- * @param {number} numActions - The total number of actions done by the user to solve the activity
103
- * @param {boolean} solved - `true` if the activity was finally solved, `false` otherwise.
104
- */
105
- endActivity(score, numActions, solved) {
106
- if (this.currentActivity) {
107
- this.currentActivity.endActivity(score, numActions, solved);
108
- this.info.valid = false;
109
- }
110
- }
111
-
112
- /**
113
- * Reports a new action done by the user while playing the current activity
114
- * @param {string} type - Type of action (`click`, `write`, `move`, `select`...)
115
- * @param {string}+ source - Description of the object on which the action is done.
116
- * @param {string}+ dest - Description of the object that acts as a target of the action (used in pairings)
117
- * @param {boolean} ok - `true` if the action was OK, `false`, `null` or `undefined` otherwise
118
- */
119
- newAction(type, source, dest, ok) {
120
- if (this.currentActivity) {
121
- this.currentActivity.newAction(type, source, dest, ok);
122
- this.info.valid = false;
123
- }
124
- }
125
- }
126
-
127
- Object.assign(SequenceReg.prototype, {
128
- /**
129
- * The `tag` member of the associated {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement}
130
- * @name module:report/SequenceReg.SequenceReg#name
131
- * @type {string} */
132
- name: '',
133
- /**
134
- * Optional description given to the {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement}
135
- * @name module:report/SequenceReg.SequenceReg#description
136
- * @type {string} */
137
- description: '',
138
- /**
139
- * Collection of all the {@link module:report/ActivityReg.ActivityReg ActivityReg} elements done during this sequence.
140
- * @name module:report/SequenceReg.SequenceReg#activities
141
- * @type {module:report/ActivityReg.ActivityReg[]} */
142
- activities: [],
143
- /**
144
- * Registry linked to the {@link module:Activity.Activity Activity} that is currently running
145
- * @name module:report/SequenceReg.SequenceReg#currentActivity
146
- * @type {module:report/ActivityReg.ActivityReg} */
147
- currentActivity: null,
148
- /**
149
- * Total time spent on the activities of this sequence
150
- * @name module:report/SequenceReg.SequenceReg#totalTime
151
- * @type {number} */
152
- totalTime: 0,
153
- /**
154
- * Flag indicating if the sequence is closed or already available for more activities
155
- * @name module:report/SequenceReg.SequenceReg#closed
156
- * @type {boolean} */
157
- closed: false,
158
- /**
159
- * Object with global information associated to this sequence
160
- * @name module:report/SequenceReg.SequenceReg#info
161
- * @type {module:report/SequenceReg.SequenceRegInfo} */
162
- info: null,
163
- });
164
-
165
- /**
166
- * This object stores the global results of a {@link module:report/SequenceReg.SequenceReg SequenceReg}
167
- */
168
- export class SequenceRegInfo {
169
- /**
170
- * SequenceRegInfo constructor
171
- * @param {module:report/SequenceReg.SequenceReg} sqReg - The {@link module:report/SequenceReg.SequenceReg SequenceReg} associated tho this `Info` object.
172
- */
173
- constructor(sqReg) {
174
- this.sqReg = sqReg;
175
- }
176
-
177
- /**
178
- * Clears all global data associated with this sequence
179
- */
180
- clear() {
181
- this.nActivities = this.nActClosed = this.nActSolved = this.nActScore = 0;
182
- this.ratioSolved = this.nActions = this.tScore = this.tTime = 0;
183
- this.valid = false;
184
- }
185
-
186
- /**
187
- * Computes the value of all global variables based on the data stored in `activities`
188
- * @returns {module:report/SequenceReg.SequenceRegInfo} - This "info" object
189
- */
190
- recalc() {
191
- if (!this.valid) {
192
- this.clear();
193
- this.nActivities = this.sqReg.activities.length;
194
- if (this.nActivities > 0) {
195
- this.sqReg.activities.forEach(ar => {
196
- if (ar.closed) {
197
- this.nActClosed++;
198
- this.tTime += ar.totalTime;
199
- this.nActions += ar.numActions;
200
- if (ar.solved)
201
- this.nActSolved++;
202
- const r = ar.getPrecision();
203
- if (r >= 0) {
204
- this.tScore += r;
205
- this.nActScore++;
206
- }
207
- }
208
- });
209
- if (this.nActClosed > 0)
210
- this.ratioSolved = this.nActSolved / this.nActClosed;
211
- if (this.nActScore > 0)
212
- this.tScore = Math.round(this.tScore / this.nActScore);
213
- }
214
- this.valid = true;
215
- }
216
- return this;
217
- }
218
- }
219
-
220
- Object.assign(SequenceRegInfo.prototype, {
221
- /**
222
- * The {@link module:report/SequenceReg.SequenceReg SequenceReg} associated to this "info" object
223
- * @name module:report/SequenceReg.SequenceRegInfo#sqReg
224
- * @type {module:report/SequenceReg.SequenceReg} */
225
- sqReg: null,
226
- /**
227
- * When `false`, data must be recalculated
228
- * @name module:report/SequenceReg.SequenceRegInfo#valid
229
- * @type {boolean} */
230
- valid: false,
231
- /**
232
- * Number of activities played in this sequence
233
- * @name module:report/SequenceReg.SequenceRegInfo#nActivities
234
- * @type {number} */
235
- nActivities: 0,
236
- /**
237
- * Number of activities already closed
238
- * @name module:report/SequenceReg.SequenceRegInfo#nActClosed
239
- * @type {number} */
240
- nActClosed: 0,
241
- /**
242
- * Number of activities solved
243
- * @name module:report/SequenceReg.SequenceRegInfo#nActSolved
244
- * @type {number} */
245
- nActSolved: 0,
246
- /**
247
- * Number of activities with score > 0
248
- * @name module:report/SequenceReg.SequenceRegInfo#nActScore
249
- * @type {number} */
250
- nActScore: 0,
251
- /**
252
- * Percentage of solved activities
253
- * @name module:report/SequenceReg.SequenceRegInfo#ratioSolved
254
- * @type {number} */
255
- ratioSolved: 0,
256
- /**
257
- * Number of actions done by the user while in this sequence
258
- * @name module:report/SequenceReg.SequenceRegInfo#nActions
259
- * @type {number} */
260
- nActions: 0,
261
- /**
262
- * Sum of the scores of all the activities played
263
- * @name module:report/SequenceReg.SequenceRegInfo#tScore
264
- * @type {number} */
265
- tScore: 0,
266
- /**
267
- * Sum of the playing time reported by each activity (not always equals to the sequence's total time)
268
- * @name module:report/SequenceReg.SequenceRegInfo#tTime
269
- * @type {number} */
270
- tTime: 0,
271
- });
272
-
273
- SequenceReg.Info = SequenceRegInfo;
274
-
275
- export default SequenceReg;