jclic 2.1.21 → 2.1.22

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 (173) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/jclic-node.js +1 -1
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/GlobalData.js +1 -1
  8. package/dist/1078.jclic-node.js +0 -282
  9. package/dist/1078.jclic-node.js.map +0 -1
  10. package/dist/1196.jclic-node.js +0 -808
  11. package/dist/1196.jclic-node.js.map +0 -1
  12. package/dist/1253.jclic-node.js +0 -1432
  13. package/dist/1253.jclic-node.js.map +0 -1
  14. package/dist/13.jclic-node.js +0 -103
  15. package/dist/13.jclic-node.js.map +0 -1
  16. package/dist/1567.jclic-node.js +0 -2313
  17. package/dist/1567.jclic-node.js.map +0 -1
  18. package/dist/1588.jclic-node.js +0 -602
  19. package/dist/1588.jclic-node.js.map +0 -1
  20. package/dist/1725.jclic-node.js +0 -836
  21. package/dist/1725.jclic-node.js.map +0 -1
  22. package/dist/1731.jclic-node.js +0 -438
  23. package/dist/1731.jclic-node.js.map +0 -1
  24. package/dist/1842.jclic-node.js +0 -651
  25. package/dist/1842.jclic-node.js.map +0 -1
  26. package/dist/2160.jclic-node.js +0 -1016
  27. package/dist/2160.jclic-node.js.map +0 -1
  28. package/dist/222.jclic-node.js +0 -129
  29. package/dist/222.jclic-node.js.map +0 -1
  30. package/dist/2316.jclic-node.js +0 -949
  31. package/dist/2316.jclic-node.js.map +0 -1
  32. package/dist/2355.jclic-node.js +0 -371
  33. package/dist/2355.jclic-node.js.map +0 -1
  34. package/dist/2366.jclic-node.js +0 -431
  35. package/dist/2366.jclic-node.js.map +0 -1
  36. package/dist/2379.jclic-node.js +0 -202
  37. package/dist/2379.jclic-node.js.map +0 -1
  38. package/dist/2437.jclic-node.js +0 -450
  39. package/dist/2437.jclic-node.js.map +0 -1
  40. package/dist/2531.jclic-node.js +0 -869
  41. package/dist/2531.jclic-node.js.map +0 -1
  42. package/dist/2608.jclic-node.js +0 -160
  43. package/dist/2608.jclic-node.js.map +0 -1
  44. package/dist/2715.jclic-node.js +0 -554
  45. package/dist/2715.jclic-node.js.map +0 -1
  46. package/dist/277.jclic-node.js +0 -22
  47. package/dist/277.jclic-node.js.map +0 -1
  48. package/dist/2921.jclic-node.js +0 -660
  49. package/dist/2921.jclic-node.js.map +0 -1
  50. package/dist/2952.jclic-node.js +0 -101
  51. package/dist/2952.jclic-node.js.map +0 -1
  52. package/dist/3018.jclic-node.js +0 -421
  53. package/dist/3018.jclic-node.js.map +0 -1
  54. package/dist/3019.jclic-node.js +0 -682
  55. package/dist/3019.jclic-node.js.map +0 -1
  56. package/dist/3231.jclic-node.js +0 -274
  57. package/dist/3231.jclic-node.js.map +0 -1
  58. package/dist/331.jclic-node.js +0 -115
  59. package/dist/331.jclic-node.js.map +0 -1
  60. package/dist/3391.jclic-node.js +0 -276
  61. package/dist/3391.jclic-node.js.map +0 -1
  62. package/dist/3502.jclic-node.js +0 -671
  63. package/dist/3502.jclic-node.js.map +0 -1
  64. package/dist/3653.jclic-node.js +0 -982
  65. package/dist/3653.jclic-node.js.map +0 -1
  66. package/dist/371.jclic.min.js +0 -2
  67. package/dist/371.jclic.min.js.map +0 -1
  68. package/dist/3856.jclic-node.js +0 -575
  69. package/dist/3856.jclic-node.js.map +0 -1
  70. package/dist/4112.jclic-node.js +0 -659
  71. package/dist/4112.jclic-node.js.map +0 -1
  72. package/dist/4123.jclic-node.js +0 -910
  73. package/dist/4123.jclic-node.js.map +0 -1
  74. package/dist/427.jclic-node.js +0 -894
  75. package/dist/427.jclic-node.js.map +0 -1
  76. package/dist/4483.jclic-node.js +0 -327
  77. package/dist/4483.jclic-node.js.map +0 -1
  78. package/dist/4548.jclic-node.js +0 -1078
  79. package/dist/4548.jclic-node.js.map +0 -1
  80. package/dist/466.jclic-node.js +0 -99
  81. package/dist/466.jclic-node.js.map +0 -1
  82. package/dist/485.jclic-node.js +0 -783
  83. package/dist/485.jclic-node.js.map +0 -1
  84. package/dist/4921.jclic-node.js +0 -500
  85. package/dist/4921.jclic-node.js.map +0 -1
  86. package/dist/5091.jclic-node.js +0 -239
  87. package/dist/5091.jclic-node.js.map +0 -1
  88. package/dist/520.jclic-node.js +0 -550
  89. package/dist/520.jclic-node.js.map +0 -1
  90. package/dist/5312.jclic-node.js +0 -1126
  91. package/dist/5312.jclic-node.js.map +0 -1
  92. package/dist/5338.jclic-node.js +0 -212
  93. package/dist/5338.jclic-node.js.map +0 -1
  94. package/dist/5344.jclic-node.js +0 -229
  95. package/dist/5344.jclic-node.js.map +0 -1
  96. package/dist/5550.jclic-node.js +0 -238
  97. package/dist/5550.jclic-node.js.map +0 -1
  98. package/dist/5626.jclic-node.js +0 -614
  99. package/dist/5626.jclic-node.js.map +0 -1
  100. package/dist/5977.jclic-node.js +0 -1081
  101. package/dist/5977.jclic-node.js.map +0 -1
  102. package/dist/6148.jclic-node.js +0 -345
  103. package/dist/6148.jclic-node.js.map +0 -1
  104. package/dist/6176.jclic-node.js +0 -481
  105. package/dist/6176.jclic-node.js.map +0 -1
  106. package/dist/6221.jclic-node.js +0 -1072
  107. package/dist/6221.jclic-node.js.map +0 -1
  108. package/dist/6238.jclic-node.js +0 -718
  109. package/dist/6238.jclic-node.js.map +0 -1
  110. package/dist/6454.jclic-node.js +0 -1413
  111. package/dist/6454.jclic-node.js.map +0 -1
  112. package/dist/6565.jclic-node.js +0 -294
  113. package/dist/6565.jclic-node.js.map +0 -1
  114. package/dist/6579.jclic-node.js +0 -719
  115. package/dist/6579.jclic-node.js.map +0 -1
  116. package/dist/6715.jclic-node.js +0 -148
  117. package/dist/6715.jclic-node.js.map +0 -1
  118. package/dist/6777.jclic-node.js +0 -171
  119. package/dist/6777.jclic-node.js.map +0 -1
  120. package/dist/6782.jclic-node.js +0 -1611
  121. package/dist/6782.jclic-node.js.map +0 -1
  122. package/dist/6847.jclic-node.js +0 -601
  123. package/dist/6847.jclic-node.js.map +0 -1
  124. package/dist/6856.jclic-node.js +0 -252
  125. package/dist/6856.jclic-node.js.map +0 -1
  126. package/dist/696.jclic-node.js +0 -1821
  127. package/dist/696.jclic-node.js.map +0 -1
  128. package/dist/698.jclic-node.js +0 -583
  129. package/dist/698.jclic-node.js.map +0 -1
  130. package/dist/704.jclic-node.js +0 -80
  131. package/dist/704.jclic-node.js.map +0 -1
  132. package/dist/7046.jclic-node.js +0 -735
  133. package/dist/7046.jclic-node.js.map +0 -1
  134. package/dist/7220.jclic-node.js +0 -156
  135. package/dist/7220.jclic-node.js.map +0 -1
  136. package/dist/7257.jclic-node.js +0 -931
  137. package/dist/7257.jclic-node.js.map +0 -1
  138. package/dist/743.jclic-node.js +0 -583
  139. package/dist/743.jclic-node.js.map +0 -1
  140. package/dist/757.jclic-node.js +0 -1072
  141. package/dist/757.jclic-node.js.map +0 -1
  142. package/dist/7781.jclic-node.js +0 -202
  143. package/dist/7781.jclic-node.js.map +0 -1
  144. package/dist/7912.jclic-node.js +0 -2103
  145. package/dist/7912.jclic-node.js.map +0 -1
  146. package/dist/827.jclic-node.js +0 -708
  147. package/dist/827.jclic-node.js.map +0 -1
  148. package/dist/8276.jclic-node.js +0 -409
  149. package/dist/8276.jclic-node.js.map +0 -1
  150. package/dist/8322.jclic-node.js +0 -498
  151. package/dist/8322.jclic-node.js.map +0 -1
  152. package/dist/8641.jclic-node.js +0 -360
  153. package/dist/8641.jclic-node.js.map +0 -1
  154. package/dist/8837.jclic-node.js +0 -651
  155. package/dist/8837.jclic-node.js.map +0 -1
  156. package/dist/8895.jclic-node.js +0 -151
  157. package/dist/8895.jclic-node.js.map +0 -1
  158. package/dist/9072.jclic-node.js +0 -1285
  159. package/dist/9072.jclic-node.js.map +0 -1
  160. package/dist/9078.jclic-node.js +0 -935
  161. package/dist/9078.jclic-node.js.map +0 -1
  162. package/dist/9103.jclic-node.js +0 -718
  163. package/dist/9103.jclic-node.js.map +0 -1
  164. package/dist/9359.jclic-node.js +0 -145
  165. package/dist/9359.jclic-node.js.map +0 -1
  166. package/dist/9409.jclic-node.js +0 -921
  167. package/dist/9409.jclic-node.js.map +0 -1
  168. package/dist/9513.jclic-node.js +0 -720
  169. package/dist/9513.jclic-node.js.map +0 -1
  170. package/dist/9704.jclic-node.js +0 -81
  171. package/dist/9704.jclic-node.js.map +0 -1
  172. package/dist/9950.jclic-node.js +0 -827
  173. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,651 +0,0 @@
1
- "use strict";
2
- exports.id = 8837;
3
- exports.ids = [8837];
4
- exports.modules = {
5
-
6
- /***/ 8837:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony exports TCPReporter, ReportBean */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Reporter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6782);
16
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1253);
17
- /**
18
- * File : report/TCPReporter.js
19
- * Created : 08/06/2016
20
- * By : Francesc Busquets <francesc@gmail.com>
21
- *
22
- * JClic.js
23
- * An HTML5 player of JClic activities
24
- * https://projectestac.github.io/jclic.js
25
- *
26
- * @source https://github.com/projectestac/jclic.js
27
- *
28
- * @license EUPL-1.2
29
- * @licstart
30
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
31
- *
32
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
33
- * the European Commission- subsequent versions of the EUPL (the "Licence");
34
- * You may not use this work except in compliance with the Licence.
35
- *
36
- * You may obtain a copy of the Licence at:
37
- * https://joinup.ec.europa.eu/software/page/eupl
38
- *
39
- * Unless required by applicable law or agreed to in writing, software
40
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
41
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
42
- * Licence for the specific language governing permissions and limitations
43
- * under the Licence.
44
- * @licend
45
- * @module
46
- */
47
-
48
- /* global Promise, document, window, XMLSerializer */
49
-
50
-
51
-
52
-
53
-
54
- /**
55
- * This special case of {@link module:Reporter.Reporter Reporter} connects with an external service reporter providing
56
- * the {@link https://github.com/projectestac/jclic/wiki/JClic-Reports-developers-guide JClic Reports API}.
57
- * Connection parameters to the reports server (`path`, `service`, `userId`, `key`, `context`...)
58
- * are passed through the `options` element of {@link module:JClicPlayer.JClicPlayer JClicPlayer} (acting as {@link module:JClicPlayer.JClicPlayer JClicPlayer}).
59
- * @extends module:reports/Reporter.Reporter
60
- */
61
- class TCPReporter extends _Reporter_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
62
- /**
63
- * TCPReporter constructor
64
- * @param {module:JClicPlayer.JClicPlayer} ps - The {@link module:JClicPlayer.JClicPlayer JClicPlayer} used to retrieve settings and localized messages
65
- */
66
- constructor(ps) {
67
- super(ps);
68
- this.tasks = [];
69
- }
70
-
71
- /**
72
- * Gets a specific property from this reporting system
73
- * @override
74
- * @param {string} key - Requested property
75
- * @param {string}+ defaultValue - Default return value when requested property does not exist
76
- * @returns {string}
77
- */
78
- getProperty(key, defaultValue) {
79
- return this.dbProperties !== null && this.dbProperties.hasOwnProperty(key) ?
80
- this.dbProperties[key] :
81
- defaultValue;
82
- }
83
-
84
- /**
85
- * Adds a new element to the list of report beans pending to be transmitted.
86
- * @param {module:report/TCPReporter.ReportBean} bean
87
- */
88
- addTask(bean) {
89
- if (this.processingTasks) {
90
- if (this.waitingTasks === null)
91
- this.waitingTasks = [bean];
92
- else
93
- this.waitingTasks.push(bean);
94
- } else
95
- this.tasks.push(bean);
96
- }
97
-
98
- /**
99
- * Transmits all report beans currently stored in `tasks` to the reports server
100
- * @returns {external:Promise}
101
- */
102
- flushTasksPromise() {
103
- if (this.processingTasks || this.currentSessionId === null ||
104
- this.tasks.length === 0 || this.serviceUrl === null) {
105
- // The task list cannot be processed now. Pass and wait until the next timer cycle:
106
- if (this.processingTasks)
107
- this.forceFlush = true;
108
- return Promise.resolve(true);
109
- }
110
- else {
111
- // Set up the `processingTasks` flag to avoid re-entrant processing
112
- this.processingTasks = true;
113
-
114
- const reportBean = new ReportBean('multiple');
115
- for (let i = 0; i < this.tasks.length; i++)
116
- reportBean.appendData(this.tasks[i].$bean);
117
-
118
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .log */ .Rm)('debug', 'Reporting:', reportBean.$bean[0]);
119
-
120
- return new Promise((resolve, reject) => {
121
- this.transaction(reportBean.$bean)
122
- .done((_data, _textStatus, _jqXHR) => {
123
- // TODO: Check returned message for possible errors on the server side
124
- this.failCount = 0;
125
-
126
- // Clear waiting tasks
127
- if (this.waitingTasks) {
128
- this.tasks = this.waitingTasks;
129
- this.waitingTasks = null;
130
- }
131
- else {
132
- this.forceFlush = false;
133
- this.tasks = [];
134
- }
135
-
136
- if (this.forceFlush && this.tasks.length > 0) {
137
- this.forceFlush = false;
138
- this.processingTasks = false;
139
- this.flushTasksPromise().then(() => {
140
- resolve(true);
141
- });
142
- }
143
- else {
144
- this.forceFlush = false;
145
- resolve(true);
146
- this.processingTasks = false;
147
- }
148
- })
149
- .fail((jqXHR, textStatus, errorThrown) => {
150
- if (++this.failCount > this.maxFails)
151
- this.stopReporting().then();
152
- reject(`Error reporting results to ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
153
- this.processingTasks = false;
154
- });
155
- });
156
- }
157
- }
158
-
159
- /**
160
- * Initializes this report system with an optional set of parameters.
161
- * Returns a Promise, fulfilled when the reporter is fully initialized.
162
- * @override
163
- * @param {object} [options] - Initial settings passed to the reporting system
164
- * @returns {external:Promise}
165
- */
166
- init(options) {
167
- if (typeof options === 'undefined' || options === null)
168
- options = this.ps.options;
169
- super.init(options);
170
- this.initiated = false;
171
- this.stopReporting();
172
-
173
- this.serverPath = options.path || this.DEFAULT_SERVER_PATH;
174
- this.descriptionDetail = this.serverPath;
175
- let serverService = options.service || this.DEFAULT_SERVER_SERVICE;
176
- if (!(0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .startsWith */ .w1)(serverService, '/'))
177
- serverService = `/${serverService}`;
178
- const serverProtocol = options.protocol || this.DEFAULT_SERVER_PROTOCOL;
179
- this.serviceUrl = `${serverProtocol}://${this.serverPath}${serverService}`;
180
-
181
- const bean = new ReportBean('get_properties');
182
- return new Promise((resolve, reject) => {
183
- this.transaction(bean.$bean)
184
- .done((data, _textStatus, _jqXHR) => {
185
- this.dbProperties = {};
186
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(data).find('param').each((_n, param) => {
187
- const $param = jquery__WEBPACK_IMPORTED_MODULE_0___default()(param);
188
- this.dbProperties[$param.attr('name')] = $param.attr('value');
189
- });
190
- this.promptUserId(false).then(userId => {
191
- this.userId = userId;
192
- const tl = options.lap || this.getProperty('TIME_LAP', this.DEFAULT_TIMER_LAP);
193
- this.timerLap = Math.min(30, Math.max(1, parseInt(tl)));
194
- this.timer = window.setInterval(() => this.flushTasksPromise().then(), this.timerLap * 1000);
195
- // Warn before leaving the current page with unsaved data:
196
- this.beforeUnloadFunction = event => {
197
- if (this.serviceUrl !== null &&
198
- (this.tasks.length > 0 || this.processingTasks)) {
199
- this.flushTasksPromise().then();
200
- const result = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .getMsg */ .qG)('Please wait until the results of your activities are sent to the reports system');
201
- if (event)
202
- event.returnValue = result;
203
- return result;
204
- }
205
- };
206
- window.addEventListener('beforeunload', this.beforeUnloadFunction);
207
- this.initiated = true;
208
- resolve(true);
209
- }).catch(msg => {
210
- this.stopReporting();
211
- reject(`Error getting the user ID: ${msg}`);
212
- });
213
- })
214
- .fail((jqXHR, textStatus, errorThrown) => {
215
- this.stopReporting();
216
- reject(`Error initializing reports service ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
217
- });
218
- });
219
- }
220
-
221
- /**
222
- * This method should be invoked when a new session starts.
223
- * @override
224
- * @param {module:project/JClicProject.JClicProject} jcp - The {@link module:project/JClicProject.JClicProject JClicProject} this session refers to.
225
- */
226
- newSession(jcp) {
227
- super.newSession(jcp);
228
- if (this.serviceUrl && this.userId !== null) {
229
- // Session ID will be obtained when reporting first activity
230
- this.currentSessionId = null;
231
- }
232
- }
233
-
234
- /**
235
- * Creates a new session in the remote database and records its ID for future use
236
- * @param {boolean} forceNewSession - When `true`, a new session will always be created.
237
- * @returns {external:Promise} - A Promise reporter will be successfully resolved
238
- * only when `currentSessionId` have a valid value.
239
- */
240
- createDBSession(forceNewSession) {
241
- if (this.currentSessionId !== null && !forceNewSession)
242
- // A valid session is available, so just return it
243
- return Promise.resolve(this.currentSessionId);
244
- else
245
- // A new session must be created:
246
- return new Promise((resolve, reject) => {
247
- if (this.initiated && this.userId !== null && this.currentSession !== null) {
248
- this.flushTasksPromise().then(() => {
249
- this.currentSessionId = null;
250
- const bean = new ReportBean('add session');
251
-
252
- bean.setParam('project', this.currentSession.projectName);
253
- bean.setParam('activities', Number(this.currentSession.reportableActs));
254
- bean.setParam('time', Number(this.currentSession.started));
255
- bean.setParam('code', this.currentSession.code);
256
- bean.setParam('user', this.userId);
257
- bean.setParam('key', this.sessionKey);
258
- bean.setParam('context', this.sessionContext);
259
-
260
- this.transaction(bean.$bean)
261
- .done((data, _textStatus, _jqXHR) => {
262
- this.currentSessionId = jquery__WEBPACK_IMPORTED_MODULE_0___default()(data).find('param[name="session"]').attr('value');
263
- resolve(this.currentSessionId);
264
- })
265
- .fail((jqXHR, textStatus, errorThrown) => {
266
- this.stopReporting();
267
- reject(`Error creating new reports session in ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
268
- });
269
- });
270
- } else
271
- reject('Unable to start session in remote server!');
272
- });
273
- }
274
-
275
- /**
276
- * Closes this reporting system
277
- * @override
278
- * @returns {external:Promise} - A promise to be fullfilled when all pending tasks are finished, or _null_ if not active.
279
- */
280
- end() {
281
- this.reportActivity(true);
282
- return this.stopReporting().then(super.end());
283
- }
284
-
285
- /**
286
- * Performs a transaction on the remote server
287
- * @param {external:jQuery} $xml - The XML element to be transmited, wrapped into a jQuery object
288
- * @returns {external:jqXHR} - The {@link external:jqXHR} obtained as a result of a call to `$.ajax`.
289
- * This object should be treated as a Promise or
290
- * as a JQuery {@link https://api.jquery.com/category/deferred-object|Deferred} object.
291
- */
292
- transaction($xml) {
293
- return this.serviceUrl === null ?
294
- null :
295
- jquery__WEBPACK_IMPORTED_MODULE_0___default().ajax({
296
- method: 'POST',
297
- url: this.serviceUrl,
298
- data: '<?xml version="1.0" encoding="UTF-8"?>' +
299
- (new XMLSerializer()).serializeToString($xml.get(0)).replace('minactions', 'minActions').replace('reportactions', 'reportActions'),
300
- contentType: 'text/xml',
301
- dataType: 'xml'
302
- });
303
- }
304
-
305
- /**
306
- * Gets the list of current groups or organizations registered on this reporting system.
307
- * @override
308
- * @returns {external:Promise} - When fulfilled, an array of group data is returned as a result
309
- */
310
- getGroups() {
311
- return new Promise((resolve, reject) => {
312
- if (!this.userBased())
313
- reject('This system does not manage users!');
314
- else {
315
- const bean = new ReportBean('get groups');
316
- this.transaction(bean.$bean)
317
- .done((data, _textStatus, _jqXHR) => {
318
- const currentGroups = [];
319
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(data).find('group').each((_n, gr) => {
320
- const $group = jquery__WEBPACK_IMPORTED_MODULE_0___default()(gr);
321
- currentGroups.push({ id: $group.attr('id'), name: $group.attr('name') });
322
- });
323
- resolve(currentGroups);
324
- })
325
- .fail((jqXHR, textStatus, errorThrown) => {
326
- reject(`Error retrieving groups list from ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
327
- });
328
- }
329
- });
330
- }
331
-
332
- /**
333
- * Gets the list of users currently registered in the system, optionally filtered by
334
- * a specific group ID.
335
- * @override
336
- * @param {string}+ groupId - Optional group ID to be used as a filter criteria
337
- * @returns {external:Promise} - When fulfilled, an object with a collection of user data records
338
- * is returned
339
- */
340
- getUsers(groupId) {
341
- return new Promise((resolve, reject) => {
342
- if (!this.userBased())
343
- reject('This system does not manage users!');
344
- else {
345
- const bean = new ReportBean('get users');
346
- if (typeof groupId !== 'undefined' && groupId !== null)
347
- bean.setParam('group', groupId);
348
- this.transaction(bean.$bean)
349
- .done((data, _textStatus, _jqXHR) => {
350
- const currentUsers = [];
351
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(data).find('user').each((_n, usr) => {
352
- const $user = jquery__WEBPACK_IMPORTED_MODULE_0___default()(usr);
353
- const user = { id: $user.attr('id'), name: $user.attr('name') };
354
- if ($user.attr('pwd'))
355
- user.pwd = $user.attr('pwd');
356
- currentUsers.push(user);
357
- });
358
- resolve(currentUsers);
359
- })
360
- .fail((jqXHR, textStatus, errorThrown) => {
361
- reject(`Error retrieving users list from ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
362
- });
363
- }
364
- });
365
- }
366
-
367
- /**
368
- * Gets extended data associated with a specific user.
369
- * @param {string} userId - The requested user ID
370
- * @returns {external:Promise} - When fulfilled, an object with user data is returned.
371
- */
372
- getUserData(userId) {
373
- return new Promise((resolve, reject) => {
374
- if (!this.userBased())
375
- reject('This system does not manage users!');
376
- else {
377
- const bean = new ReportBean('get user data');
378
-
379
- if (typeof userId !== 'undefined' && userId !== null)
380
- bean.setParam('user', userId);
381
- else
382
- reject('Invalid user ID');
383
-
384
- this.transaction(bean.$bean)
385
- .done((data, _textStatus, _jqXHR) => {
386
- const $user = jquery__WEBPACK_IMPORTED_MODULE_0___default()(data).find('user');
387
- if ($user.length !== 1) {
388
- window.alert((0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .getMsg */ .qG)('Invalid user'));
389
- resolve('Invalid user ID');
390
- } else {
391
- const user = { id: $user.attr('id'), name: $user.attr('name') };
392
- if ($user.attr('pwd'))
393
- user.pwd = $user.attr('pwd');
394
- resolve(user);
395
- }
396
- })
397
- .fail((jqXHR, textStatus, errorThrown) => {
398
- reject(`Error retrieving user data from ${this.serviceUrl} [${textStatus} ${errorThrown}]`);
399
- });
400
- }
401
- });
402
- }
403
-
404
- /**
405
- * Stops the reporting system, usually as a result of repeated errors or because the player
406
- * shuts down.
407
- * @returns {external:Promise} - A promise to be fullfilled when all pending tasks are finished.
408
- */
409
- stopReporting() {
410
- let result = null;
411
- if (this.timer >= 0) {
412
- window.clearInterval(this.timer);
413
- this.timer = -1;
414
- }
415
- if (this.beforeUnloadFunction) {
416
- window.removeEventListener('beforeunload', this.beforeUnloadFunction);
417
- this.beforeUnloadFunction = null;
418
- }
419
- if (this.initiated) {
420
- result = this.flushTasksPromise().then(() => {
421
- this.serviceUrl = null;
422
- this.descriptionDetail = `${this.serverPath} (${(0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .getMsg */ .qG)('not connected')})`;
423
- this.initiated = false;
424
- });
425
- }
426
- return result || Promise.resolve(true);
427
- }
428
-
429
- /**
430
- * Prepares a {@link module:report/TCPReporter.ReportBean ReportBean} object with information related to the current
431
- * activity, and pushes it into the list of pending `tasks`, to be processed by the main `timer`.
432
- * @param {boolean} flushNow - When `true`, the activity data will be sent to server as soon as possible
433
- */
434
- reportActivity(flushNow) {
435
- if (this.lastActivity) {
436
- if (!this.lastActivity.closed)
437
- this.lastActivity.closeActivity();
438
- const
439
- actCount = this.actCount++,
440
- act = this.lastActivity;
441
- this.createDBSession(false).then(() => {
442
- const bean = new ReportBean('add activity');
443
- bean.setParam('session', this.currentSessionId);
444
- bean.setParam('num', actCount);
445
- bean.appendData(act.$getXML());
446
- this.addTask(bean);
447
- if (flushNow)
448
- this.flushTasksPromise().then();
449
- });
450
- }
451
- if (this.currentSession !== null &&
452
- this.currentSession.currentSequence !== null &&
453
- this.currentSession.currentSequence.currentActivity !== this.lastActivity) {
454
- this.lastActivity = this.currentSession.currentSequence.currentActivity;
455
- } else
456
- this.lastActivity = null;
457
- }
458
-
459
- /**
460
- * This method should be invoked when the user starts a new activity
461
- * @override
462
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} reporter has just started
463
- */
464
- newActivity(act) {
465
- super.newActivity(act);
466
- this.reportActivity(false);
467
- }
468
-
469
- /**
470
- * This method should be called when the current activity finishes. Data about user's final results
471
- * on the activity will then be saved.
472
- * @override
473
- * @param {number} score - The final score, usually in a 0-100 scale.
474
- * @param {number} numActions - The total number of actions done by the user to solve the activity
475
- * @param {boolean} solved - `true` if the activity was finally solved, `false` otherwise.
476
- */
477
- endActivity(score, numActions, solved) {
478
- super.endActivity(score, numActions, solved);
479
- this.reportActivity(true);
480
- }
481
- }
482
-
483
- Object.assign(TCPReporter.prototype, {
484
- /**
485
- * Description of this reporting system
486
- * @name module:report/TCPReporter.TCPReporter#descriptionKey
487
- * @override
488
- * @type {string} */
489
- descriptionKey: 'Reporting to remote server',
490
- /**
491
- * Additional info to display after the reporter's `description`
492
- * @name module:report/TCPReporter.TCPReporter#descriptionDetail
493
- * @override
494
- * @type {string} */
495
- descriptionDetail: '(not connected)',
496
- /**
497
- * Main path of the reports server (without protocol nor service)
498
- * @name module:report/TCPReporter.TCPReporter#serverPath
499
- * @type {string} */
500
- serverPath: '',
501
- /**
502
- * Function to be called by the browser before leaving the current page
503
- * @name module:report/TCPReporter.TCPReporter#beforeUnloadFunction
504
- * @type {function} */
505
- beforeUnloadFunction: null,
506
- /**
507
- * Identifier of the current session, provided by the server
508
- * @name module:report/TCPReporter.TCPReporter#currentSessionId
509
- * @type {string} */
510
- currentSessionId: '',
511
- /**
512
- * Last activity reported
513
- * @name module:report/TCPReporter.TCPReporter#lastActivity
514
- * @type {module:report/ActivityReg.ActivityReg} */
515
- lastActivity: null,
516
- /**
517
- * Number of activities processed
518
- * @name module:report/TCPReporter.TCPReporter#actCount
519
- * @type {number} */
520
- actCount: 0,
521
- /**
522
- * Service URL of the JClic Reports server
523
- * @name module:report/TCPReporter.TCPReporter#serviceUrl
524
- * @type {string} */
525
- serviceUrl: null,
526
- /**
527
- * Object used to store specific properties of the connected reports system
528
- * @name module:report/TCPReporter.TCPReporter#dbProperties
529
- * @type {object} */
530
- dbProperties: null,
531
- /**
532
- * List of {@link module:report/TCPReporter.ReportBean ReportBean} objects pending to be processed
533
- * @name module:report/TCPReporter.TCPReporter#tasks
534
- * @type {module:report/TCPReporter.ReportBean[]} */
535
- tasks: null,
536
- /**
537
- * Waiting list of tasks, to be used while `tasks` is being processed
538
- * @name module:report/TCPReporter.TCPReporter#waitingTasks
539
- * @type {module:report/TCPReporter.ReportBean[]} */
540
- waitingTasks: null,
541
- /**
542
- * Flag used to indicate if `transaction` is currently running
543
- * @name module:report/TCPReporter.TCPReporter#processingTasks
544
- * @type {boolean} */
545
- processingTasks: false,
546
- /**
547
- * Force processing of pending tasks as soon as possible
548
- * @name module:report/TCPReporter.TCPReporter#forceFlush
549
- * @type {boolean} */
550
- forceFlush: false,
551
- /**
552
- * Identifier of the background function obtained with a call to `window.setInterval`
553
- * @name module:report/TCPReporter.TCPReporter#timer
554
- * @type {number} */
555
- timer: -1,
556
- /**
557
- * Time between calls to the background function, in seconds
558
- * @name module:report/TCPReporter.TCPReporter#timerLap
559
- * @type {number} */
560
- timerLap: 5,
561
- /**
562
- * Counter of unsuccessful connection attempts with the report server
563
- * @name module:report/TCPReporter.TCPReporter#failCount
564
- * @type {number} */
565
- failCount: 0,
566
- /**
567
- * Maximum number of failed attempts allowed before disconnecting
568
- * @name module:report/TCPReporter.TCPReporter#maxFails
569
- * @type {number} */
570
- maxFails: 5,
571
- /**
572
- * Default path of JClic Reports Server
573
- * @name module:report/TCPReporter.TCPReporter#DEFAULT_SERVER_PATH
574
- * @type {string} */
575
- DEFAULT_SERVER_PATH: 'localhost:9000',
576
- /**
577
- * Default name for the reports service
578
- * @name module:report/TCPReporter.TCPReporter#DEFAULT_SERVER_SERVICE
579
- * @type {string} */
580
- DEFAULT_SERVER_SERVICE: '/JClicReportService',
581
- /**
582
- * Default server protocol
583
- * Use always 'https' except when in 'http' and protocol not set in options
584
- * @name module:report/TCPReporter.TCPReporter#DEFAULT_SERVER_PROTOCOL
585
- * @type {string} */
586
- DEFAULT_SERVER_PROTOCOL: (document && document.location && document.location.protocol === 'http:') ? 'http' : 'https',
587
- /**
588
- * Default lap between calls to `flushTasks`, in seconds
589
- * @name module:report/TCPReporter.TCPReporter#DEFAULT_TIMER_LAP
590
- * @type {number} */
591
- DEFAULT_TIMER_LAP: 20,
592
- });
593
-
594
- /**
595
- * This inner class encapsulates a chunk of information in XML format, ready to be
596
- * transmitted to the remote reports server.
597
- */
598
- class ReportBean {
599
- /**
600
- * ReportBean constructor
601
- * @param id {string} - The main identifier of this ReportBean. Current valid values are:
602
- * `get property`, `get_properties`, `add session`, `add activity`, `get groups`, `get users`,
603
- * `get user data`, `get group data`, `new group`, `new user` and `multiple`.
604
- * @param $data {external:jQuery}+ - Optional XML data to be added to this bean
605
- */
606
- constructor(id, $data) {
607
- this.$bean = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<bean/>').attr({ id: id });
608
- if ($data)
609
- this.appendData($data);
610
- }
611
-
612
- /**
613
- * Adds an XML element to the bean
614
- * @param {external:jQuery} $data - The XML element to be added to this bean
615
- */
616
- appendData($data) {
617
- if ($data) {
618
- this.$bean.append($data);
619
- }
620
- }
621
-
622
- /**
623
- * Adds an XML element of type `param` to this ReportBean
624
- * @param {string} name - The key name of the parameter
625
- * @param {string|number|boolean} value - The value of the parameter
626
- */
627
- setParam(name, value) {
628
- if (typeof value !== 'undefined' && value !== null)
629
- this.appendData(jquery__WEBPACK_IMPORTED_MODULE_0___default()('<param/>').attr({ name: name, value: value }));
630
- }
631
- }
632
-
633
- Object.assign(ReportBean.prototype, {
634
- /**
635
- * The main jQuery XML object managed by this ReportBean
636
- * @name module:report/TCPReporter.ReportBean#$bean
637
- * @type {external:jQuery} */
638
- $bean: null,
639
- });
640
-
641
- TCPReporter.ReportBean = ReportBean;
642
-
643
- // Register class in Reporter.CLASSES
644
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Reporter_js__WEBPACK_IMPORTED_MODULE_1__["default"].registerClass('TCPReporter', TCPReporter));
645
-
646
-
647
- /***/ })
648
-
649
- };
650
- ;
651
- //# sourceMappingURL=8837.jclic-node.js.map