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,2313 +0,0 @@
1
- "use strict";
2
- exports.id = 1567;
3
- exports.ids = [1567,2715,2379];
4
- exports.modules = {
5
-
6
- /***/ 1567:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ I: () => (/* binding */ Activity),
11
- /* harmony export */ S: () => (/* binding */ ActivityPanel),
12
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
13
- /* harmony export */ });
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
15
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
16
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
17
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
18
- /* harmony import */ var _media_EventSounds_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5338);
19
- /* harmony import */ var _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9072);
20
- /* harmony import */ var _boxes_ActiveBagContent_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9409);
21
- /* harmony import */ var _boxes_BoxBase_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3018);
22
- /* harmony import */ var _automation_AutoContentProvider_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2379);
23
- /* harmony import */ var _boxes_TextGridContent_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1842);
24
- /* harmony import */ var _activities_text_Evaluator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2715);
25
- /* harmony import */ var _activities_text_TextActivityDocument_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3019);
26
- /**
27
- * File : Activity.js
28
- * Created : 07/04/2015
29
- * By : Francesc Busquets <francesc@gmail.com>
30
- *
31
- * JClic.js
32
- * An HTML5 player of JClic activities
33
- * https://projectestac.github.io/jclic.js
34
- *
35
- * @source https://github.com/projectestac/jclic.js
36
- *
37
- * @license EUPL-1.2
38
- * @licstart
39
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
40
- *
41
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
42
- * the European Commission- subsequent versions of the EUPL (the "Licence");
43
- * You may not use this work except in compliance with the Licence.
44
- *
45
- * You may obtain a copy of the Licence at:
46
- * https://joinup.ec.europa.eu/software/page/eupl
47
- *
48
- * Unless required by applicable law or agreed to in writing, software
49
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
50
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
51
- * Licence for the specific language governing permissions and limitations
52
- * under the Licence.
53
- * @licend
54
- * @module
55
- */
56
-
57
- /* global window */
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
- // Event used for detecting touch devices
72
- const TOUCH_TEST_EVENT = 'touchstart';
73
-
74
- /**
75
- * Activity is the abstract base class of JClic activities. It defines also the inner class
76
- * {@link module:Activity.ActivityPanel ActivityPanel}, wich is responsible for user interaction with the activity
77
- * content.
78
- * Activities should extend both `Activity` and `ActivityPanel` classes in order to become fully
79
- * operative.
80
- * @abstract
81
- */
82
- class Activity {
83
- /**
84
- * Activity constructor
85
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
86
- */
87
- constructor(project) {
88
- this.project = project;
89
- this.eventSounds = new _media_EventSounds_js__WEBPACK_IMPORTED_MODULE_3__["default"](this.project.settings.eventSounds);
90
- this.messages = {};
91
- this.abc = {};
92
- }
93
-
94
- /**
95
- * Registers a new type of activity
96
- * @param {string} activityName - The name used to identify this activity
97
- * @param {function} activityClass - The activity class, usually extending Activity
98
- * @returns {module:Activity.Activity} - The provided activity class
99
- */
100
- static registerClass(activityName, activityClass) {
101
- Activity.CLASSES[activityName] = activityClass;
102
- return activityClass;
103
- }
104
-
105
- /**
106
- * Factory constructor that returns a specific type of Activity based on the `class` attribute
107
- * declared in `data`.
108
- * @param {object|external:jQuery} data - Can be a jQuery XML element, or an object obtained with a call to `getAttributes`
109
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
110
- * @returns {module:Activity.Activity}
111
- */
112
- static getActivity(data, project) {
113
- let act = null;
114
- const isXml = data.jquery && true;
115
- if (data && project) {
116
- const className = isXml ? (data.attr('class') || '').replace(/^edu\.xtec\.jclic\.activities\./, '@') : data.className;
117
- const cl = Activity.CLASSES[className];
118
- if (cl) {
119
- act = new cl(project);
120
- if (isXml)
121
- act.setProperties(data);
122
- else
123
- act.setAttributes(data);
124
- } else
125
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('error', `Unknown activity class: ${className}`);
126
- }
127
- return act;
128
- }
129
-
130
- /**
131
- * Loads this object settings from an XML element
132
- * @param {external:jQuery} $xml - The jQuery XML element to parse
133
- */
134
- setProperties($xml) {
135
-
136
- // Read attributes
137
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, val) => {
138
- switch (name) {
139
- // Generic attributes:
140
- case 'name':
141
- val = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .nSlash */ .c4)(val);
142
- /* falls through */
143
- case 'code':
144
- case 'type':
145
- case 'description':
146
- this[name] = val;
147
- break;
148
-
149
- case 'class':
150
- this.className = val.replace(/^edu\.xtec\.jclic\.activities\./, '@');
151
- break;
152
-
153
- case 'inverse':
154
- this.invAss = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val, false);
155
- break;
156
-
157
- case 'autoJump':
158
- case 'forceOkToAdvance':
159
- case 'amongParagraphs':
160
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val, false);
161
- break;
162
- }
163
- });
164
-
165
- // Read specific nodes
166
- $xml.children().each((_n, child) => {
167
- const $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
168
- switch (child.nodeName) {
169
- case 'settings':
170
- // Read more attributes
171
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($node.get(0).attributes, (name, val) => {
172
- switch (name) {
173
- case 'infoUrl':
174
- case 'infoCmd':
175
- this[name] = val;
176
- break;
177
-
178
- case 'margin':
179
- case 'maxTime':
180
- case 'maxActions':
181
- this[name] = Number(val);
182
- break;
183
-
184
- case 'report':
185
- this.includeInReports = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val, false);
186
- break;
187
- case 'countDownTime':
188
- case 'countDownActions':
189
- case 'reportActions':
190
- case 'useOrder':
191
- case 'dragCells':
192
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val, false);
193
- break;
194
- }
195
- });
196
-
197
- // Read elements of _settings_
198
- $node.children().each((_n, child) => {
199
- const $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
200
- switch (child.nodeName) {
201
- case 'skin':
202
- this.skinFileName = $node.attr('file');
203
- break;
204
-
205
- case 'helpWindow':
206
- this.helpMsg = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getXmlText */ .HC)(this);
207
- this.showSolution = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($node.attr('showSolution'), false);
208
- this.helpWindow = this.helpMsg !== null || this.showSolution;
209
- break;
210
-
211
- case 'container':
212
- // Read settings related to the 'container'
213
- // (the main panel containing the activity and other elements)
214
- this.bgColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('bgColor'), _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.BoxBase.BACK_COLOR);
215
-
216
- $node.children().each((_n, child) => {
217
- const $child = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
218
- switch (child.nodeName) {
219
- case 'image':
220
- this.bgImageFile = $child.attr('name');
221
- this.tiledBgImg = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($child.attr('tiled'), false);
222
- break;
223
- case 'counters':
224
- this.bTimeCounter = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($child.attr('time'), true);
225
- this.bActionsCounter = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($child.attr('actions'), true);
226
- this.bScoreCounter = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($child.attr('score'), true);
227
- break;
228
- case 'gradient':
229
- this.bgGradient = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf().setProperties($child);
230
- break;
231
- }
232
- });
233
- break;
234
-
235
- case 'window':
236
- // Read settings related to the 'window'
237
- // (the panel where the activity deploys its content)
238
- this.activityBgColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('bgColor'), _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_BG_COLOR);
239
- this.transparentBg = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($node.attr('transparent'), false);
240
- this.border = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($node.attr('border'), false);
241
- $node.children().each((_n, child) => {
242
- const $child = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
243
- switch (child.nodeName) {
244
- case 'gradient':
245
- this.activityBgGradient = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf().setProperties($child);
246
- break;
247
- case 'position':
248
- this.absolutePosition = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR().setProperties($child);
249
- this.absolutePositioned = true;
250
- break;
251
- case 'size':
252
- this.windowSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg().setProperties($child);
253
- break;
254
- }
255
- });
256
- break;
257
-
258
- case 'eventSounds':
259
- // eventSounds is already created in constructor,
260
- // just read properties
261
- this.eventSounds.setProperties($node);
262
- break;
263
- }
264
- });
265
- break;
266
-
267
- case 'messages':
268
- $node.children('cell').each((_n, child) => {
269
- const m = this.readMessage(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child));
270
- // Possible message types are: `initial`, `final`, `previous`, `finalError`
271
- this.messages[m.type] = m;
272
- });
273
- break;
274
-
275
- case 'automation':
276
- // Read the automation settings ('Arith' or other automation engines)
277
- this.acp = _automation_AutoContentProvider_js__WEBPACK_IMPORTED_MODULE_7__["default"].getProvider($node, this.project);
278
- if (this.acp)
279
- this.numericContent = this.acp.numericContent;
280
- break;
281
-
282
- // Settings specific to panel-type activities (puzzles, associations...)
283
- case 'cells':
284
- // Read the [ActiveBagContent](ActiveBagContent.html) objects
285
- const cellSet = new _boxes_ActiveBagContent_js__WEBPACK_IMPORTED_MODULE_5__["default"]().setProperties($node, this.project.mediaBag);
286
- // Valid ids:
287
- // - Panel activities: 'primary', 'secondary', solvedPrimary'
288
- // - Textpanel activities: 'acrossClues', 'downClues', 'answers'
289
- this.abc[cellSet.id] = cellSet;
290
- break;
291
-
292
- case 'scramble':
293
- // Read the 'shuffle' mode
294
- this.shuffles = Number($node.attr('times'));
295
- this.shuffleA = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($node.attr('primary'));
296
- this.shuffleB = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)($node.attr('secondary'));
297
- break;
298
-
299
- case 'layout':
300
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($node.get(0).attributes, (name, value) => {
301
- switch (name) {
302
- case 'position':
303
- this.boxGridPos = value;
304
- break;
305
- case 'wildTransparent':
306
- case 'upperCase':
307
- case 'checkCase':
308
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(value);
309
- }
310
- });
311
- break;
312
-
313
- // Element specific to 'Menu' activities:
314
- case 'menuElement':
315
- this.menuElements.push({
316
- caption: $node.attr('caption') || '',
317
- icon: $node.attr('icon') || null,
318
- projectPath: $node.attr('path') || null,
319
- sequence: $node.attr('sequence') || null,
320
- description: $node.attr('description') || ''
321
- });
322
- break;
323
-
324
- // Element specific to 'CrossWord' and
325
- // 'WordSearch' activities:
326
- case 'textGrid':
327
- // Read the 'textGrid' element into a 'TextGridContent'
328
- this.tgc = new _boxes_TextGridContent_js__WEBPACK_IMPORTED_MODULE_8__["default"]().setProperties($node);
329
- break;
330
-
331
- // Read the clues of 'WordSearch' activities
332
- case 'clues':
333
- // Read the array of clues
334
- this.clues = [];
335
- this.clueItems = [];
336
- $node.children('clue').each((n, child) => {
337
- this.clueItems[n] = Number(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child).attr('id'));
338
- this.clues[n] = child.textContent;
339
- });
340
- break;
341
-
342
- // Elements specific to text activities:
343
- case 'checkButton':
344
- this.checkButtonText = child.textContent || 'check';
345
- break;
346
-
347
- case 'prevScreen':
348
- this.prevScreen = true;
349
- this.prevScreenMaxTime = $node.attr('maxTime') || -1;
350
- $node.children().each((_n, child) => {
351
- switch (child.nodeName) {
352
- case 'style':
353
- this.prevScreenStyle = new _boxes_BoxBase_js__WEBPACK_IMPORTED_MODULE_6__["default"]().setProperties(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child));
354
- break;
355
- case 'p':
356
- if (this.prevScreenText === null)
357
- this.prevScreenText = '';
358
- this.prevScreenText += `<p>${child.textContent}</p>`;
359
- break;
360
- }
361
- });
362
- break;
363
-
364
- case 'evaluator':
365
- this.ev = _activities_text_Evaluator_js__WEBPACK_IMPORTED_MODULE_9__["default"].getEvaluator($node);
366
- break;
367
-
368
- case 'document':
369
- // Read main document of text activities
370
- this.document = new _activities_text_TextActivityDocument_js__WEBPACK_IMPORTED_MODULE_10__["default"]().setProperties($node, this.project.mediaBag);
371
- break;
372
- }
373
- });
374
- return this;
375
- }
376
-
377
- /**
378
- * Read an activity message from an XML element
379
- * @param {external:jQuery} $xml - The XML element to be parsed
380
- * @returns {module:boxes/ActiveBoxContent.ActiveBoxContent}
381
- */
382
- readMessage($xml) {
383
- const msg = new _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_4__["default"]().setProperties($xml, this.project.mediaBag);
384
- //
385
- // Allowed types are: `initial`, `final`, `previous`, `finalError`
386
- msg.type = $xml.attr('type');
387
- if ((0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isNullOrUndef */ .Pj)(msg.style))
388
- msg.style = new _boxes_BoxBase_js__WEBPACK_IMPORTED_MODULE_6__["default"](null);
389
- return msg;
390
- }
391
-
392
- /**
393
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
394
- * parent references, constants and also attributes retaining the default value.
395
- * The resulting object is commonly usued to serialize elements in JSON format.
396
- * @returns {object} - The resulting object, with minimal attrributes
397
- */
398
- getAttributes() {
399
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, [
400
- 'name', 'className', 'code', 'type', 'description',
401
- 'invAss', 'numericContent',
402
- 'autoJump', 'forceOkToAdvance', 'amongParagraphs',
403
- 'infoUrl', 'infoCmd',
404
- `margin|${_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_MARGIN}`, 'maxTime', 'maxActions',
405
- 'includeInReports|true', 'reportActions|false',
406
- 'countDownTime', 'countDownActions',
407
- 'useOrder', 'dragCells',
408
- 'skinFileName',
409
- 'showSolution|false', 'helpMsg',
410
- `bgColor|${_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_BG_COLOR}`, 'bgImageFile', 'tiledBgImg',
411
- 'bTimeCounter|true', 'bActionsCounter|true', 'bScoreCounter|true',
412
- `activityBgColor|${_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_BG_COLOR}`, 'transparentBg|false', 'border|true',
413
- 'shuffleA', 'shuffleB', 'shuffles', 'boxGridPos',
414
- 'wildTransparent', 'upperCase', 'checkCase',
415
- 'checkButtonText',
416
- 'prevScreen', 'prevScreenMaxTime', 'prevScreenText',
417
- 'bgGradient', 'activityBgGradient', // Gradient
418
- 'absolutePosition', // Point
419
- 'windowSize', // Dimension
420
- 'eventSounds', // EventSounds
421
- 'messages', // ActiveBoxContent{}
422
- 'acp', // AutoContentProvider
423
- 'abc', // ActiveBagContent{}
424
- 'menuElements', // Activity~menuElement
425
- 'tgc', // TextGridContent
426
- 'clues', // string[]
427
- 'clueItems', // number[]
428
- 'prevScreenStyle', // BoxBase
429
- 'ev', // Evaluator
430
- 'document', // TextActivityDocument
431
- ]);
432
- }
433
-
434
- /**
435
- * Load the activity settings from a data object
436
- * @param {object} data - The data object to parse
437
- */
438
- setAttributes(data, mediaBag = this.project.mediaBag) {
439
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, [
440
- 'name', 'className', 'code', 'type', 'description', 'invAss', 'numericContent',
441
- 'autoJump', 'forceOkToAdvance', 'amongParagraphs', 'infoUrl', 'infoCmd',
442
- 'margin', 'maxTime', 'maxActions', 'includeInReports', 'reportActions',
443
- 'countDownTime', 'countDownActions', 'useOrder', 'dragCells', 'skinFileName',
444
- 'showSolution', 'helpMsg', 'bgColor', 'bgImageFile', 'tiledBgImg',
445
- 'bTimeCounter', 'bActionsCounter', 'bScoreCounter',
446
- 'activityBgColor', 'transparentBg', 'border',
447
- 'shuffleA', 'shuffleB', 'shuffles', 'boxGridPos',
448
- 'wildTransparent', 'upperCase', 'checkCase', 'checkButtonText',
449
- 'prevScreen', 'prevScreenMaxTime', 'prevScreenText',
450
- { key: 'bgGradient', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf },
451
- { key: 'activityBgGradient', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf },
452
- { key: 'absolutePosition', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR },
453
- { key: 'windowSize', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg },
454
- { key: 'messages', fn: _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_4__["default"], group: 'object', init: 'key', params: [mediaBag] },
455
- { key: 'abc', fn: _boxes_ActiveBagContent_js__WEBPACK_IMPORTED_MODULE_5__["default"], group: 'object', init: 'key', params: [mediaBag] },
456
- { key: 'acp', fn: _automation_AutoContentProvider_js__WEBPACK_IMPORTED_MODULE_7__["default"], params: [mediaBag] },
457
- 'menuElements',
458
- { key: 'tgc', fn: _boxes_TextGridContent_js__WEBPACK_IMPORTED_MODULE_8__["default"] },
459
- 'clues',
460
- 'clueItems',
461
- { key: 'prevScreenStyle', fn: _boxes_BoxBase_js__WEBPACK_IMPORTED_MODULE_6__["default"] },
462
- { key: 'ev', fn: _activities_text_Evaluator_js__WEBPACK_IMPORTED_MODULE_9__["default"] },
463
- { key: 'document', fn: _activities_text_TextActivityDocument_js__WEBPACK_IMPORTED_MODULE_10__["default"], params: [mediaBag] },
464
- ]);
465
-
466
- // Reused objects
467
- if (data.eventSounds)
468
- this.eventSounds.setAttributes(data.eventSounds);
469
-
470
- // Manual settings
471
- if (this.absolutePosition)
472
- this.absolutePositioned = true;
473
-
474
- return this;
475
- }
476
-
477
- /**
478
- * Initialises the {@link module:automation/AutoContentProvider.AutoContentProvider AutoContentProvider}, when defined.
479
- */
480
- initAutoContentProvider() {
481
- if (this.acp !== null)
482
- this.acp.init();
483
- }
484
-
485
- /**
486
- * Preloads the media content of the activity.
487
- * @param {module:JClicPlayer.JClicPlayer} ps - The {@link module:JClicPlayer.JClicPlayer} used to realize the media objects.
488
- */
489
- prepareMedia(ps) {
490
- this.eventSounds.realize(ps, this.project.mediaBag);
491
- jquery__WEBPACK_IMPORTED_MODULE_0___default().each(this.messages, (_key, msg) => {
492
- if (msg !== null) msg.prepareMedia(ps);
493
- });
494
- jquery__WEBPACK_IMPORTED_MODULE_0___default().each(this.abc, (_key, abc) => {
495
- if (abc !== null)
496
- abc.prepareMedia(ps);
497
- });
498
- return true;
499
- }
500
-
501
- /**
502
- * Whether the activity allows the user to request the solution.
503
- * @returns {boolean}
504
- */
505
- helpSolutionAllowed() {
506
- return false;
507
- }
508
-
509
- /**
510
- * Whether the activity allows the user to request help.
511
- * @returns {boolean}
512
- */
513
- helpWindowAllowed() {
514
- return this.helpWindow &&
515
- (this.helpSolutionAllowed() && this.showSolution || this.helpMsg !== null);
516
- }
517
-
518
- /**
519
- * Retrieves the minimum number of actions needed to solve this activity.
520
- * @returns {number}
521
- */
522
- getMinNumActions() {
523
- return 0;
524
- }
525
-
526
- /**
527
- * When this method returns `true`, the automatic jump to the next activity must be paused at
528
- * this activity.
529
- * @returns {boolean}
530
- */
531
- mustPauseSequence() {
532
- return this.getMinNumActions() !== 0;
533
- }
534
-
535
- /**
536
- * Whether or not the activity can be reset
537
- * @returns {boolean}
538
- */
539
- canReinit() {
540
- return true;
541
- }
542
-
543
- /**
544
- * Whether or not the activity has additional information to be shown.
545
- * @returns {boolean}
546
- */
547
- hasInfo() {
548
- return this.infoUrl !== null && this.infoUrl.length > 0 ||
549
- this.infoCmd !== null && this.infoCmd.length > 0;
550
- }
551
-
552
- /**
553
- * Whether or not the activity uses random to shuffle internal components
554
- * @returns {boolean}
555
- */
556
- hasRandom() {
557
- return false;
558
- }
559
-
560
- /**
561
- * When `true`, the activity must always be shuffled
562
- * @returns {boolean}
563
- */
564
- shuffleAlways() {
565
- return false;
566
- }
567
-
568
- /**
569
- * When `true`, the activity makes use of the keyboard
570
- * @returns {boolean}
571
- */
572
- needsKeyboard() {
573
- return false;
574
- }
575
-
576
- /**
577
- * Called when the activity must be disposed
578
- */
579
- end() {
580
- this.eventSounds.close();
581
- this.clear();
582
- }
583
-
584
- /**
585
- * Called when the activity must reset its internal components
586
- */
587
- clear() {
588
- }
589
-
590
- /**
591
- *
592
- * Getter method for `windowSize`
593
- * @returns {module:AWT.Dimension}
594
- */
595
- getWindowSize() {
596
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(this.windowSize);
597
- }
598
-
599
- /**
600
- * Setter method for `windowSize`
601
- * @param {module:AWT.Dimension} windowSize
602
- */
603
- setWindowSize(windowSize) {
604
- this.windowSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(windowSize);
605
- }
606
-
607
- /**
608
- * Builds the {@link module:Activity.ActivityPanel ActivityPanel} object.
609
- * Subclasses must update the `Panel` member of its prototypes to produce specific panels.
610
- * @param {module:JClicPlayer.JClicPlayer} ps - The {@link module:JClicPlayer.JClicPlayer JClicPlayer} used to build media objects.
611
- * @returns {module:Activity.ActivityPanel}
612
- */
613
- getActivityPanel(ps) {
614
- return new this.constructor.Panel(this, ps);
615
- }
616
- }
617
-
618
- /**
619
- * Classes derived from `Activity` should register themselves by adding a field to
620
- * `Activity.CLASSES` using `Activity.registerClass`
621
- * @type {object}
622
- */
623
- Activity.CLASSES = {
624
- '@panels.Menu': Activity
625
- };
626
-
627
- Object.assign(Activity.prototype, {
628
- /**
629
- * The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
630
- * @name module:Activity.Activity#project
631
- * @type {module:project/JClicProject.JClicProject} */
632
- project: null,
633
- /**
634
- * The Activity name
635
- * @name module:Activity.Activity#name
636
- * @type {string} */
637
- name: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_NAME,
638
- /**
639
- * The class name of this Activity
640
- * @name module:Activity.Activity#className
641
- * @type {string} */
642
- className: null,
643
- /**
644
- * Code used in reports to filter queries. Default is `null`.
645
- * @name module:Activity.Activity#code
646
- * @type {string} */
647
- code: null,
648
- /**
649
- * Type of activity, used in text activities to distinguish between different variants of the
650
- * same activity. Possible values are: `orderWords`, `orderParagraphs`, `identifyWords` and
651
- * `identifyChars`.
652
- * @name module:Activity.Activity#type
653
- * @type {string} */
654
- type: null,
655
- /**
656
- * A short description of the activity
657
- * @name module:Activity.Activity#description
658
- * @type {string} */
659
- description: null,
660
- /**
661
- * The space between the activity components measured in pixels.
662
- * @name module:Activity.Activity#margin
663
- * @type {number} */
664
- margin: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_MARGIN,
665
- /**
666
- * The background color of the activity panel
667
- * @name module:Activity.Activity#bgColor
668
- * @type {string} */
669
- bgColor: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_BG_COLOR,
670
- /**
671
- * When set, gradient used to draw the activity window background
672
- * @name module:Activity.Activity#bgGradient
673
- * @type {module:AWT.Gradient} */
674
- bgGradient: null,
675
- /**
676
- * Whether the bgImage (if any) has to be tiled across the panel background
677
- * @name module:Activity.Activity#tiledBgImg
678
- * @type {boolean} */
679
- tiledBgImg: false,
680
- /**
681
- * Filename of the image used as a panel background.
682
- * @name module:Activity.Activity#bgImageFile
683
- * @type {string} */
684
- bgImageFile: null,
685
- /**
686
- * Whether to draw a border around the activity panel
687
- * @name module:Activity.Activity#border
688
- * @type {boolean} */
689
- border: true,
690
- /**
691
- * Whether to place the activity panel at the point specified by `absolutePosition` or leave
692
- * it centered on the main player's window.
693
- * @name module:Activity.Activity#absolutePositioned
694
- * @type {boolean} */
695
- absolutePositioned: false,
696
- /**
697
- * The position of the activity panel on the player.
698
- * @name module:Activity.Activity#absolutePosition
699
- * @type {module:AWT.Point} */
700
- absolutePosition: null,
701
- /**
702
- * Whether to generate usage reports
703
- * @name module:Activity.Activity#includeInReports
704
- * @type {boolean} */
705
- includeInReports: true,
706
- /**
707
- * Whether to send action events to the {@link module:Reporter.Reporter Reporter}
708
- * @name module:Activity.Activity#reportActions
709
- * @type {boolean} */
710
- reportActions: false,
711
- /**
712
- * Whether to allow help about the activity or not.
713
- * @name module:Activity.Activity#helpWindow
714
- * @type {boolean} */
715
- helpWindow: false,
716
- /**
717
- * Whether to show the solution on the help window.
718
- * @name module:Activity.Activity#showSolution
719
- * @type {boolean} */
720
- showSolution: false,
721
- /**
722
- * Message to be shown in the help window when `showSolution` is `false`.
723
- * @name module:Activity.Activity#helpMsg
724
- * @type {string} */
725
- helpMsg: '',
726
- /**
727
- * Specific set of {@link module:media/EventSounds.EventSounds EventSounds} used in the activity. The default is `null`, meaning
728
- * to use the default event sounds.
729
- * @name module:Activity.Activity#eventSounds
730
- * @type {module:media/EventSounds.EventSounds} */
731
- eventSounds: null,
732
- /**
733
- * Wheter the activity must be solved in a specific order or not.
734
- * @name module:Activity.Activity#useOrder
735
- * @type {boolean} */
736
- useOrder: false,
737
- /**
738
- * Wheter the cells of the activity will be dragged across the screen.
739
- * When `false`, a line will be painted to link elements.
740
- * @name module:Activity.Activity#dragCells
741
- * @type {boolean} */
742
- dragCells: false,
743
- /**
744
- * File name of the Skin used by the activity. The default value is `null`, meaning that the
745
- * activity will use the skin specified for the project.
746
- * @name module:Activity.Activity#skinFileName
747
- * @type {string} */
748
- skinFileName: null,
749
- /**
750
- * Maximum amount of time (seconds) to solve the activity. The default value is 0, meaning
751
- * unlimited time.
752
- * @name module:Activity.Activity#maxTime
753
- * @type {number}*/
754
- maxTime: 0,
755
- /**
756
- * Whether the time counter should display a countdown when `maxTime > 0`
757
- * @name module:Activity.Activity#countDownTime
758
- * @type {boolean} */
759
- countDownTime: false,
760
- /**
761
- * Maximum number of actions allowed to solve the activity. The default value is 0, meaning
762
- * unlimited actions.
763
- * @name module:Activity.Activity#maxActions
764
- * @type {number}*/
765
- maxActions: 0,
766
- /**
767
- * Whether the actions counter should display a countdown when `maxActions > 0`
768
- * @name module:Activity.Activity#countDownActions
769
- * @type {boolean} */
770
- countDownActions: false,
771
- /**
772
- * URL to be launched when the user clicks on the 'info' button. Default is `null`.
773
- * @name module:Activity.Activity#infoUrl
774
- * @type {string} */
775
- infoUrl: null,
776
- /**
777
- * System command to be launched when the user clicks on the 'info' button. Default is `null`.
778
- * Important: this parameter is currently not being used
779
- * @name module:Activity.Activity#infoCmd
780
- * @type {string} */
781
- infoCmd: null,
782
- /**
783
- * The content of the initial, final, previous and error messages shown by the activity.
784
- * @name module:Activity.Activity#messages
785
- * @type {module:boxes/ActiveBoxContent.ActiveBoxContent[]} */
786
- messages: null,
787
- /**
788
- * Preferred dimension of the activity window
789
- * @name module:Activity.Activity#windowSize
790
- * @type {module:AWT.Dimension} */
791
- windowSize: new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_WIDTH, _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_HEIGHT),
792
- /**
793
- * Whether the activity window has transparent background.
794
- * @name module:Activity.Activity#transparentBg
795
- * @type {boolean} */
796
- transparentBg: false,
797
- /**
798
- * The background color of the activity
799
- * @name module:Activity.Activity#activityBgColor
800
- * @type {string} */
801
- activityBgColor: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_BG_COLOR,
802
- /**
803
- * Gradient used to draw backgrounds inside the activity.
804
- * @name module:Activity.Activity#activityBgGradient
805
- * @type {module:AWT.Gradient} */
806
- activityBgGradient: null,
807
- /**
808
- * Whether to display or not the 'time' counter
809
- * @name module:Activity.Activity#bTimeCounter
810
- * @type {boolean} */
811
- bTimeCounter: true,
812
- /**
813
- * Whether to display or not the 'score' counter
814
- * @name module:Activity.Activity#bScoreCounter
815
- * @type {boolean} */
816
- bScoreCounter: true,
817
- /**
818
- * Whether to display or not the 'actions' counter
819
- * @name module:Activity.Activity#bActionsCounter
820
- * @type {boolean} */
821
- bActionsCounter: true,
822
- /**
823
- * Special object used to generate random content at the start of the activity
824
- * @name module:Activity.Activity#acp
825
- * @type {module:automation/AutoContentProvider.AutoContentProvider} */
826
- acp: null,
827
- //
828
- // Fields used only in certain activity types
829
- // ------------------------------------------
830
- //
831
- /**
832
- * Array of bags with the description of the content to be displayed on panels and cells.
833
- * @name module:Activity.Activity#abc
834
- * @type {module:boxes/ActiveBagContent.ActiveBagContent[]} */
835
- abc: null,
836
- /**
837
- * Content of the grid of letters used in crosswords and shuffled letters
838
- * @name module:Activity.Activity#tgc
839
- * @type {module:boxes/TextGridContent.TextGridContent} */
840
- tgc: null,
841
- /**
842
- * The main document used in text activities
843
- * @name module:Activity.Activity#document
844
- * @type {module:activities/text/TextActivityDocument.TextActivityDocument} */
845
- document: null,
846
- /**
847
- * Relative position of the text grid (uses the same position codes as box grids)
848
- * @name module:Activity.Activity#boxGridPos
849
- * @type {string} */
850
- boxGridPos: 'AB',
851
- /**
852
- * Number of times to shuffle the cells at the beginning of the activity
853
- * @name module:Activity.Activity#shuffles
854
- * @type {number} */
855
- shuffles: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.DEFAULT_SHUFFLES,
856
- /**
857
- * Box grid A must be shuffled.
858
- * @name module:Activity.Activity#shuffleA
859
- * @type {boolean} */
860
- shuffleA: true,
861
- /**
862
- * Box grid B must be shuffled.
863
- * @name module:Activity.Activity#shuffleB
864
- * @type {boolean} */
865
- shuffleB: true,
866
- /**
867
- * Flag to indicate "inverse resolution" in complex associations
868
- * @name module:Activity.Activity#invAss
869
- * @type {boolean} */
870
- invAss: false,
871
- /**
872
- * Array of menu elements, used in activities of type {@link module:activities/panels/Menu.Menu Menu}
873
- * @name module:Activity.Activity#menuElements
874
- * @type {object[]} */
875
- menuElements: null,
876
- /**
877
- * This activity uses numeric expressions, so text literals should be
878
- * converted to numbers for comparisions, taking in account the
879
- * number format of the current locale (dot or comma as decimal separator)
880
- * @name module:Activity.Activity#numericContent
881
- * @type {boolean} */
882
- numericContent: false,
883
- });
884
-
885
- /**
886
- * This object is responsible for rendering the contents of the activity on the screen and
887
- * managing user's interaction.
888
- * Each type of Activity must implement its own `ActivityPanel`.
889
- * In JClic, {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/Activity.Panel.html Activity.Panel}
890
- * extends {@link http://docs.oracle.com/javase/7/docs/api/javax/swing/JPanel.html javax.swing.JPanel}.
891
- * On this implementation, the JPanel will be replaced by an HTML `div` tag.
892
- * @extends module:AWT.Container
893
- */
894
- class ActivityPanel extends _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Container */ .mc {
895
- /**
896
- * ActivityPanel constructor
897
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
898
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
899
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html PlayStation}
900
- * Java interface.
901
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
902
- */
903
- constructor(act, ps, $div) {
904
- // ActivityPanel extends Container
905
- super();
906
- this.act = act;
907
- this.ps = ps;
908
- this.minimumSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(100, 100);
909
- this.preferredSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(500, 400);
910
- if ($div)
911
- this.$div = $div;
912
- else
913
- this.$div = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<div/>', { class: 'JClicActivity', 'aria-label': (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getMsg */ .qG)('Activity panel') });
914
- this.act.initAutoContentProvider();
915
- }
916
-
917
- /**
918
- * Sets the size and position of this activity panel
919
- * @param {module:AWT.Rectangle} rect
920
- */
921
- setBounds(rect) {
922
- this.pos.x = rect.pos.x;
923
- this.pos.y = rect.pos.y;
924
- this.dim.width = rect.dim.width;
925
- this.dim.height = rect.dim.height;
926
-
927
- this.invalidate(rect);
928
- this.$div.css({
929
- position: 'relative',
930
- left: rect.pos.x,
931
- top: rect.pos.y,
932
- width: rect.dim.width,
933
- height: rect.dim.height
934
- });
935
- }
936
-
937
- /**
938
- * Prepares the visual components of the activity
939
- */
940
- buildVisualComponents() {
941
- this.playing = false;
942
- this.skin = null;
943
- if (this.act.skinFileName && this.act.skinFileName.length > 0 && this.act.skinFileName !== this.act.project.settings.skinFileName)
944
- this.skin = this.act.project.mediaBag.getSkinElement(this.act.skinFileName, this.ps);
945
-
946
- this.bgImage = null;
947
- if (this.act.bgImageFile && this.act.bgImageFile.length > 0) {
948
- const mbe = this.act.project.mediaBag.getElement(this.act.bgImageFile, true);
949
- if (mbe)
950
- this.bgImage = mbe.data;
951
- }
952
-
953
- this.backgroundColor = this.act.activityBgColor;
954
-
955
- if (this.act.transparentBg)
956
- this.backgroundTransparent = true;
957
-
958
- // TODO: fix bevel-border type
959
- if (this.act.border)
960
- this.border = true;
961
-
962
- const cssAct = {
963
- display: 'block',
964
- 'background-color': this.backgroundTransparent ? 'transparent' : this.backgroundColor
965
- };
966
-
967
- // Border shadow style Material Design, inspired in [http://codepen.io/Stenvh/pen/EaeWqW]
968
- if (this.border) {
969
- cssAct['box-shadow'] = '0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12)';
970
- cssAct['border-radius'] = '2px';
971
- cssAct['color'] = '#272727';
972
- }
973
-
974
- if (this.act.activityBgGradient)
975
- cssAct['background-image'] = this.act.activityBgGradient.getCss();
976
-
977
- this.$div.css(cssAct);
978
- }
979
-
980
- /**
981
- * Activities should implement this method to update the graphic content of its panel. The method
982
- * will be called from {@link module:AWT.Container#update} when needed.
983
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
984
- * it's the whole panel.
985
- */
986
- updateContent(dirtyRegion) {
987
- // To be overridden by subclasses. Here does nothing.
988
- return super.updateContent(dirtyRegion);
989
- }
990
-
991
- /**
992
- * Plays the specified event sound
993
- * @param {string} event - The type of event to be performed
994
- */
995
- playEvent(event) {
996
- this.act.eventSounds.play(event);
997
- }
998
-
999
- /**
1000
- * Basic initialization procedure, common to all activities.
1001
- */
1002
- initActivity() {
1003
- if (this.playing) {
1004
- this.playing = false;
1005
- this.ps.reportEndActivity(this.act, this.solved);
1006
- }
1007
- this.solved = false;
1008
- this.ps.reportNewActivity(this.act, 0);
1009
- this.attachEvents();
1010
- this.enableCounters();
1011
- }
1012
-
1013
- /**
1014
- * Called when the activity starts playing
1015
- */
1016
- startActivity() {
1017
- this.playing = true;
1018
- }
1019
-
1020
- /**
1021
- * Called by {@link module:JClicPlayer.JClicPlayer JClicPlayer} when this activity panel is fully visible, just after the
1022
- * initialization process.
1023
- */
1024
- activityReady() {
1025
- // To be overrided by subclasses
1026
- }
1027
-
1028
- /**
1029
- * Displays help about the activity
1030
- */
1031
- showHelp() {
1032
- // To be overrided by subclasses
1033
- }
1034
-
1035
- /**
1036
- * Sets the real dimension of this ActivityPanel.
1037
- * @param {module:AWT.Dimension} maxSize - The maximum surface available for the activity panel
1038
- * @returns {module:AWT.Dimension}
1039
- */
1040
- setDimension(maxSize) {
1041
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
1042
- Math.min(maxSize.width, this.act.windowSize.width),
1043
- Math.min(maxSize.height, this.act.windowSize.height));
1044
- }
1045
-
1046
- /**
1047
- * Attaches the events specified in the `events` member to the `$div` member
1048
- */
1049
- attachEvents() {
1050
- this.events.forEach(ev => this.attachEvent(this.$div, ev));
1051
- // Prepare handler to check if we are in a touch device
1052
- if (!_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.TOUCH_DEVICE && jquery__WEBPACK_IMPORTED_MODULE_0___default().inArray(TOUCH_TEST_EVENT, this.events) === -1)
1053
- this.attachEvent(this.$div, TOUCH_TEST_EVENT);
1054
- }
1055
-
1056
- /**
1057
- * Attaches a single event to the specified object
1058
- * @param {external:jQuery} $obj - The object to which the event will be attached
1059
- * @param {string} evt - The event name
1060
- */
1061
- attachEvent($obj, evt) {
1062
- $obj.on(evt, this, event => {
1063
- if (event.type === TOUCH_TEST_EVENT) {
1064
- if (!_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.TOUCH_DEVICE)
1065
- _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.TOUCH_DEVICE = true;
1066
- if (jquery__WEBPACK_IMPORTED_MODULE_0___default().inArray(TOUCH_TEST_EVENT, this.events) === -1) {
1067
- // Disconnect handler
1068
- $obj.off(TOUCH_TEST_EVENT);
1069
- return;
1070
- }
1071
- }
1072
- return event.data.processEvent.call(event.data, event);
1073
- });
1074
- }
1075
-
1076
- /**
1077
- * Main handler used to process mouse, touch, keyboard and edit events.
1078
- * @param {external:Event} event - The HTML event to be processed
1079
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
1080
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
1081
- */
1082
- processEvent(_event) {
1083
- return false;
1084
- }
1085
-
1086
- /**
1087
- * Fits the panel within the `proposed` rectangle. The panel can occupy more space, but always
1088
- * not surpassing the `bounds` rectangle.
1089
- * @param {module:AWT.Rectangle} proposed - The proposed rectangle
1090
- * @param {module:AWT.Rectangle} bounds - The maximum allowed bounds
1091
- */
1092
- fitTo(proposed, bounds) {
1093
- const origin = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR();
1094
- if (this.act.absolutePositioned && this.act.absolutePosition !== null) {
1095
- origin.x = Math.max(0, this.act.absolutePosition.x + proposed.pos.x);
1096
- origin.y = Math.max(0, this.act.absolutePosition.y + proposed.pos.y);
1097
- proposed.dim.width -= this.act.absolutePosition.x;
1098
- proposed.dim.height -= this.act.absolutePosition.y;
1099
- }
1100
- const d = this.setDimension(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
1101
- Math.max(2 * this.act.margin + _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.MINIMUM_WIDTH, proposed.dim.width),
1102
- Math.max(2 * this.act.margin + _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.MINIMUM_HEIGHT, proposed.dim.height)));
1103
- if (!this.act.absolutePositioned) {
1104
- origin.moveTo(
1105
- Math.max(0, proposed.pos.x + (proposed.dim.width - d.width) / 2),
1106
- Math.max(0, proposed.pos.y + (proposed.dim.height - d.height) / 2));
1107
- }
1108
- if (origin.x + d.width > bounds.dim.width)
1109
- origin.x = Math.max(0, bounds.dim.width - d.width);
1110
- if (origin.y + d.height > bounds.dim.height)
1111
- origin.y = Math.max(0, bounds.dim.height - d.height);
1112
- this.setBounds(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(origin.x, origin.y, d.width, d.height));
1113
-
1114
- // Build accessible components at the end of current tree
1115
- window.setTimeout(() => this.buildAccessibleComponents(), 0);
1116
- }
1117
-
1118
- /**
1119
- *
1120
- * Builds the accessible components needed for this ActivityPanel
1121
- * This method is called when all main elements are placed and visible, when the activity is ready
1122
- * to start or when resized.
1123
- */
1124
- buildAccessibleComponents() {
1125
- // Clear existing elements
1126
- if (this.accessibleCanvas && this.$canvas && this.$canvas.children().length > 0) {
1127
- // UPDATED May 2020: clearHitRegions has been deprecated!
1128
- // this.$canvas.get(-1).getContext('2d').clearHitRegions();
1129
- this.$canvas.empty();
1130
- }
1131
- // Create accessible elements in subclasses
1132
- }
1133
-
1134
- /**
1135
- * Forces the ending of the activity.
1136
- */
1137
- forceFinishActivity() {
1138
- // to be overrided by subclasses
1139
- }
1140
-
1141
- /**
1142
- * Ordinary ending of the activity, usually called form `processEvent`
1143
- * @param {boolean} result - `true` if the activity was successfully completed, `false` otherwise
1144
- */
1145
- finishActivity(result) {
1146
- this.playing = false;
1147
- this.solved = result;
1148
-
1149
- if (this.bc !== null)
1150
- this.bc.end();
1151
-
1152
- if (result) {
1153
- this.setAndPlayMsg('final', 'finishedOk');
1154
- } else {
1155
- this.setAndPlayMsg('finalError', 'finishedError');
1156
- }
1157
- this.ps.activityFinished(this.solved);
1158
- this.ps.reportEndActivity(this.act, this.solved);
1159
- }
1160
-
1161
- /**
1162
- * Sets the message to be displayed in the skin message box and optionally plays a sound event.
1163
- * @param {string} msgCode - Type of message (initial, final, finalError...)
1164
- * @param {string} [eventSoundsCode] - Optional name of the event sound to be played.
1165
- */
1166
- setAndPlayMsg(msgCode, eventSoundsCode) {
1167
- const msg = this.act.messages[msgCode] || null;
1168
- this.ps.setMsg(msg);
1169
- if (msg === null || msg.mediaContent === null)
1170
- this.playEvent(eventSoundsCode);
1171
- }
1172
-
1173
- /**
1174
- * Ends the activity
1175
- */
1176
- end() {
1177
- this.forceFinishActivity();
1178
- if (this.playing) {
1179
- if (this.bc !== null)
1180
- this.bc.end();
1181
- this.ps.reportEndActivity(this.act, this.solved);
1182
- this.playing = false;
1183
- this.solved = false;
1184
- }
1185
- this.clear();
1186
- }
1187
-
1188
- /**
1189
- * Miscellaneous cleaning operations
1190
- */
1191
- clear() {
1192
- // to be overridden by subclasses
1193
- }
1194
-
1195
- /**
1196
- * Enables or disables the three counters (time, score and actions)
1197
- * @param {boolean} eTime - Whether to enable or disable the time counter
1198
- * @param {boolean} eScore - Whether to enable or disable the score counter
1199
- * @param {boolean} eActions - Whether to enable or disable the actions counter
1200
- */
1201
- enableCounters(eTime, eScore, eActions) {
1202
- if (typeof eTime === 'undefined')
1203
- eTime = this.act.bTimeCounter;
1204
- if (typeof eScore === 'undefined')
1205
- eScore = this.act.bScoreCounter;
1206
- if (typeof eActions === 'undefined')
1207
- eActions = this.act.bActionsCounter;
1208
-
1209
- this.ps.setCounterEnabled('time', eTime);
1210
- if (this.act.countDownTime)
1211
- this.ps.setCountDown('time', this.act.maxTime);
1212
- this.ps.setCounterEnabled('score', eScore);
1213
- this.ps.setCounterEnabled('actions', eActions);
1214
- if (this.act.countDownActions)
1215
- this.ps.setCountDown('actions', this.act.maxActions);
1216
- }
1217
-
1218
- /**
1219
- * Shuffles the contents of the activity
1220
- * @param {module:boxes/ActiveBoxBag.ActiveBoxBag[]} bg - The sets of boxes to be shuffled
1221
- * @param {boolean} visible - The shuffle process must be animated on the screen (not yet implemented!)
1222
- * @param {boolean} fitInArea - Shuffled pieces cannot go out of the current area
1223
- */
1224
- shuffle(bg, visible, fitInArea) {
1225
- const steps = this.act.shuffles;
1226
- let i = steps;
1227
- while (i > 0) {
1228
- const k = i > steps ? steps : i;
1229
- bg.forEach(abb => { if (abb) abb.shuffleCells(k, fitInArea); });
1230
- i -= steps;
1231
- }
1232
- }
1233
- }
1234
-
1235
- Object.assign(ActivityPanel.prototype, {
1236
- /**
1237
- * The Activity this panel is related to
1238
- * @name module:Activity.ActivityPanel#act
1239
- * @type {module:Activity.Activity} */
1240
- act: null,
1241
- /**
1242
- * The jQuery div element used by this panel
1243
- * @name module:Activity.ActivityPanel#$div
1244
- * @type {external:jQuery} */
1245
- $div: null,
1246
- /**
1247
- * The jQuery main canvas element used by this panel
1248
- * @name module:Activity.ActivityPanel#$canvas
1249
- * @type {external:jQuery} */
1250
- $canvas: null,
1251
- /**
1252
- * Always true, since canvas hit regions have been deprecated!
1253
- * See: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility
1254
- * @name module:Activity.ActivityPanel#accessibleCanvas
1255
- * @type {boolean}
1256
- */
1257
- accessibleCanvas: true,
1258
- /**
1259
- * The realized current {@link module:skins/Skin.Skin Skin}
1260
- * @name module:Activity.ActivityPanel#skin
1261
- * @type {module:skins/Skin.Skin} */
1262
- skin: null,
1263
- /**
1264
- * Background element (currently a `span`) used to place animated GIFs when needed
1265
- * @name module:Activity.ActivityPanel#$animatedBg
1266
- * @type {external:jQuery} */
1267
- $animatedBg: null,
1268
- /**
1269
- * Additional background element for animated GIFs, used in associations
1270
- * @name module:Activity.ActivityPanel#$animatedBgB
1271
- * @type {external:jQuery} */
1272
- $animatedBgB: null,
1273
- /**
1274
- * `true` when the activity is solved, `false` otherwise
1275
- * @name module:Activity.ActivityPanel#solved
1276
- * @type {boolean} */
1277
- solved: false,
1278
- /**
1279
- * The realized image used as a background
1280
- * @name module:Activity.ActivityPanel#bgImage
1281
- * @type {external:HTMLImageElement} */
1282
- bgImage: null,
1283
- /**
1284
- * `true` while the activity is playing
1285
- * @name module:Activity.ActivityPanel#playing
1286
- * @type {boolean} */
1287
- playing: false,
1288
- /**
1289
- * `true` if the activity is running for first time (not due to a click on the `replay` button)
1290
- * @name module:Activity.ActivityPanel#firstRun
1291
- * @type {boolean} */
1292
- firstRun: true,
1293
- /**
1294
- * Currently selected item. Used in some types of activities.
1295
- * @name module:Activity.ActivityPanel#currentItem
1296
- * @type {number} */
1297
- currentItem: 0,
1298
- /**
1299
- * The object used to connect cells and other elements in some types of activity
1300
- * @name module:Activity.ActivityPanel#bc
1301
- * @type {module:boxes/BoxConnector.BoxConnector} */
1302
- bc: null,
1303
- /**
1304
- * The PlayStation used to realize media objects and communicate with the player services
1305
- * (usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}
1306
- * @name module:Activity.ActivityPanel#ps
1307
- * @type {module:JClicPlayer.JClicPlayer} */
1308
- ps: null,
1309
- /**
1310
- * The minimum size of this kind of ActivityPanel
1311
- * @name module:Activity.ActivityPanel#minimumSize
1312
- * @type {module:AWT.Dimension} */
1313
- minimumSize: null,
1314
- /**
1315
- * The preferred size of this kind of ActivityPanel
1316
- * @name module:Activity.ActivityPanel#preferredSize
1317
- * @type {module:AWT.Dimension} */
1318
- preferredSize: null,
1319
- /**
1320
- * List of events intercepted by this ActivityPanel. Current events are: 'keydown', 'keyup',
1321
- * 'keypress', 'mousedown', 'mouseup', 'click', 'dblclick', 'mousemove', 'mouseenter',
1322
- * 'mouseleave', 'mouseover', 'mouseout', 'touchstart', 'touchend', 'touchmove' and 'touchcancel'.
1323
- * @name module:Activity.ActivityPanel#events
1324
- * @type {string[]} */
1325
- events: ['click'],
1326
- backgroundColor: null,
1327
- backgroundTransparent: false,
1328
- border: null,
1329
- });
1330
-
1331
- /**
1332
- * The panel class associated to each type of activity
1333
- * @type {module:Activity.ActivityPanel} */
1334
- Activity.Panel = ActivityPanel;
1335
-
1336
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Activity);
1337
-
1338
-
1339
- /***/ }),
1340
-
1341
- /***/ 2715:
1342
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1343
-
1344
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1345
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1346
- /* harmony export */ });
1347
- /* unused harmony exports Evaluator, BasicEvaluator, ComplexEvaluator */
1348
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1253);
1349
- /**
1350
- * File : activities/text/Evaluator.js
1351
- * Created : 14/04/2015
1352
- * By : Francesc Busquets <francesc@gmail.com>
1353
- *
1354
- * JClic.js
1355
- * An HTML5 player of JClic activities
1356
- * https://projectestac.github.io/jclic.js
1357
- *
1358
- * @source https://github.com/projectestac/jclic.js
1359
- *
1360
- * @license EUPL-1.2
1361
- * @licstart
1362
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
1363
- *
1364
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
1365
- * the European Commission- subsequent versions of the EUPL (the "Licence");
1366
- * You may not use this work except in compliance with the Licence.
1367
- *
1368
- * You may obtain a copy of the Licence at:
1369
- * https://joinup.ec.europa.eu/software/page/eupl
1370
- *
1371
- * Unless required by applicable law or agreed to in writing, software
1372
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
1373
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1374
- * Licence for the specific language governing permissions and limitations
1375
- * under the Licence.
1376
- * @licend
1377
- * @module
1378
- */
1379
-
1380
- /* global window */
1381
-
1382
-
1383
-
1384
- /**
1385
- * This class and its derivatives {@link module:activities/text/Evaluator.BasicEvaluator BasicEvaluator} and
1386
- * {@link module:activities/text/Evaluator.ComplexEvaluator ComplexEvaluator} are used to evaluate the answers written by the final users
1387
- * in text activities.
1388
- */
1389
- class Evaluator {
1390
- /**
1391
- * Evaluator constructor
1392
- * @param {string} className - The class name of this evaluator.
1393
- */
1394
- constructor(className) {
1395
- this.className = className;
1396
- this.collator = (window.Intl && window.Intl.Collator) ?
1397
- new window.Intl.Collator() :
1398
- { compare: (a, b) => this.checkCase ? a === b : a.toUpperCase() === b.toUpperCase() };
1399
- }
1400
-
1401
- /**
1402
- * Factory constructor that returns a specific type of {@link module:activities/text/Evaluator.Evaluator Evaluator} based on the `class`
1403
- * attribute declared in the $xml element.
1404
- * @param {external:jQuery} $xml - The XML element to be parsed.
1405
- * @returns {module:activities/text/Evaluator.Evaluator}
1406
- */
1407
- static getEvaluator($xml) {
1408
- let ev = null;
1409
- if ($xml) {
1410
- const className = $xml.attr('class');
1411
- const cl = Evaluator.CLASSES[className];
1412
- if (cl) {
1413
- ev = new cl(className);
1414
- ev.setProperties($xml);
1415
- } else
1416
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('error', `Unknown evaluator class: "${className}"`);
1417
- }
1418
- return ev;
1419
- }
1420
-
1421
- /**
1422
- * Loads the object settings from a specific JQuery XML element
1423
- * @param {external:jQuery} $xml - The jQuery XML element to parse
1424
- */
1425
- setProperties($xml) {
1426
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, value) => {
1427
- switch (name) {
1428
- case 'class':
1429
- this.className = value;
1430
- break;
1431
- case 'checkCase':
1432
- case 'checkAccents':
1433
- case 'checkPunctuation':
1434
- case 'checkDoubleSpaces':
1435
- case 'detail':
1436
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .getBoolean */ .pW)(value);
1437
- break;
1438
- case 'checkSteps':
1439
- case 'checkScope':
1440
- this[name] = Number(value);
1441
- break;
1442
- }
1443
- });
1444
- return this;
1445
- }
1446
-
1447
- /**
1448
- * Builds a new Evaluator, based on the properties specified in a data object
1449
- * @param {object} data - The data object to be parsed
1450
- * @returns {module:activities/text/Evaluator.Evaluator}
1451
- */
1452
- static factory(data) {
1453
- const cl = Evaluator.CLASSES[data.className];
1454
- if (cl) {
1455
- const result = new cl(data.className);
1456
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .setAttr */ .ob)(result, data, [
1457
- 'className',
1458
- 'checkCase', 'checkAccents', 'checkPunctuation', 'checkDoubleSpaces', 'detail',
1459
- 'checkSteps', 'checkScope',
1460
- ]);
1461
- }
1462
- return null;
1463
- }
1464
-
1465
- /**
1466
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
1467
- * parent references, constants and also attributes retaining the default value.
1468
- * The resulting object is commonly usued to serialize elements in JSON format.
1469
- * @returns {object} - The resulting object, with minimal attrributes
1470
- */
1471
- getAttributes() {
1472
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .getAttr */ .iu)(this, [
1473
- 'className',
1474
- 'checkCase', 'checkAccents', 'checkPunctuation', 'checkDoubleSpaces', 'detail',
1475
- 'checkSteps', 'checkScope',
1476
- ]);
1477
- }
1478
-
1479
- /**
1480
- * Initializes this evaluator
1481
- * @param {string[]} _locales - An array of valid locales, to be used by Intl.Collator
1482
- */
1483
- init(_locales) {
1484
- this.initiated = true;
1485
- }
1486
-
1487
- /**
1488
- * Checks the given text against a set of valid matches
1489
- * @param {string} text - The text to be checked
1490
- * @param {string|string[]} match - The valid expression or expressions with which to compare.
1491
- * @returns {boolean} - `true` if the checked expression is valid, `false` otherwise.
1492
- */
1493
- checkText(text, match) {
1494
- if (match instanceof Array)
1495
- return match.some(m => this._checkText(text, m));
1496
- else if (match)
1497
- return this._checkText(text, match);
1498
- else
1499
- return false;
1500
- }
1501
-
1502
- /**
1503
- * Abstract method to be implemented in subclasses.
1504
- * Performs the validation of a string against a single match.
1505
- * @param {string} _text - The text to be checked
1506
- * @param {string} _match - A valid expression with which to compare.
1507
- * @returns {boolean} - `true` when the two expressions can be considered equivalent.
1508
- */
1509
- _checkText(_text, _match) {
1510
- return false;
1511
- }
1512
-
1513
- /**
1514
- * Evaluates the given text against a set of valid matches, returning an array of flags useful
1515
- * to indicate where the mistakes are located.
1516
- * @param {string} text - The text to be checked
1517
- * @param {string|string[]} match - The valid expression or expressions with which to compare.
1518
- * @returns {number[]} - An array of flags (one number for character) indicating whether each
1519
- * position is erroneous or ok.
1520
- */
1521
- evalText(text, match) {
1522
- if (!(match instanceof Array))
1523
- match = [match];
1524
- return this._evalText(text, match);
1525
- }
1526
-
1527
- /**
1528
- * Abstract method to be implemented in subclasses.
1529
- * Performs the evaluation of a string against an array of valid matches, returning an array of
1530
- * flags useful to indicate where the mistakes are located.
1531
- * @param {string} _text - The text to be checked
1532
- * @param {string} _match - A valid expression with which to compare.
1533
- * @returns {number[]} - An array of flags (one number for character) indicating whether each
1534
- * position is erroneous or OK.
1535
- */
1536
- _evalText(_text, _match) {
1537
- return [];
1538
- }
1539
-
1540
- /**
1541
- * Checks if the given array of flags (usually returned by `evalText`) can be considered as a
1542
- * valid or erroneous answer.
1543
- * @param {number[]} flags
1544
- * @returns {boolean} - `true` when there is at least one flag and all flags are 0 (meaning no error).
1545
- */
1546
- isOk(flags) {
1547
- return flags && flags.length > 0 && !flags.some(f => f !== 0);
1548
- }
1549
- }
1550
-
1551
- Object.assign(Evaluator.prototype, {
1552
- /**
1553
- * The type of evaluator.
1554
- * @name module:activities/text/Evaluator.Evaluator#className
1555
- * @type {string} */
1556
- className: null,
1557
- /**
1558
- * Whether this evaluator has been initialized or not.
1559
- * @name module:activities/text/Evaluator.Evaluator#initiated
1560
- * @type {boolean} */
1561
- initiated: false,
1562
- /**
1563
- * The Intl.Collator object used to compare strings, when available.
1564
- * @name module:activities/text/Evaluator.Evaluator#collator
1565
- * @type {external:Collator} */
1566
- collator: null,
1567
- /**
1568
- * Whether uppercase and lowercase expressions must be considered equivalent or not.
1569
- * @name module:activities/text/Evaluator.Evaluator#checkcase
1570
- * @type {boolean} */
1571
- checkCase: false,
1572
- });
1573
-
1574
- /**
1575
- * A basic evaluator that just compares texts, without looking for possible coincidences of text
1576
- * fragments once erroneous characters removed.
1577
- * @extends module:activities/text/Evaluator.Evaluator
1578
- */
1579
- class BasicEvaluator extends Evaluator {
1580
- /**
1581
- * BasicEvaluator constructor
1582
- * @param {string} className - The class name of this evaluator.
1583
- */
1584
- constructor(className) {
1585
- super(className);
1586
- }
1587
-
1588
- /**
1589
- * Initializes the {@link module:activities/text/Evaluator.Evaluator#collator collator}.
1590
- * @override
1591
- * @param {string[]} locales - An array of valid locales to be used by the Inlt.Collator object
1592
- */
1593
- init(locales) {
1594
- // Call `init` method on ancestor
1595
- super.init([locales]);
1596
-
1597
- // Get canonical locales
1598
- if (window.Intl && window.Intl.Collator) {
1599
- this.collator = new window.Intl.Collator(locales, {
1600
- sensitivity: this.checkAccents ? this.checkCase ? 'case' : 'accent' : 'base',
1601
- ignorePunctuation: !this.checkPunctuation
1602
- });
1603
- }
1604
- }
1605
-
1606
- /**
1607
- * Performs the validation of a string against a single match.
1608
- * @override
1609
- * @param {string} text - The text to be checked
1610
- * @param {string} match - A valid expression with which to compare.
1611
- * @returns {boolean} - `true` when the two expressions can be considered equivalent.
1612
- */
1613
- _checkText(text, match) {
1614
- return this.collator.compare(this.getClearedText(text), this.getClearedText(match)) === 0;
1615
- }
1616
-
1617
- /**
1618
- * Performs the evaluation of a string against an array of valid matches, returning an array of
1619
- * flags useful to indicate where the mistakes are located.
1620
- * In BasicEvaluator, all characters are just marked as 1 (error) or 0 (OK). See
1621
- * {@link module:activities/text/Evaluator.ComplexEvaluator ComplexEvaluator} for more detailed analysis of answers.
1622
- * @override
1623
- * @param {string} text - The text to be checked
1624
- * @param {string} match - A valid expression with which to compare.
1625
- * @returns {number[]} - An array of flags (one number for character) indicating whether each
1626
- * position is erroneous or OK.
1627
- */
1628
- _evalText(text, match) {
1629
- return Array(text.length).fill(this._checkText(text, match[0]) ? 0 : 1);
1630
- }
1631
-
1632
- /**
1633
- * Removes double spaces and erroneous characters from a given text expression.
1634
- * @param {string} src - The text to be processed.
1635
- * @param {boolean[]} skipped - An array of boolean indicating which characters should be removed
1636
- * from the string.
1637
- * @returns {string}
1638
- */
1639
- getClearedText(src, skipped) {
1640
- if (this.checkPunctuation && this.checkDoubleSpaces)
1641
- return src;
1642
-
1643
- if (!skipped)
1644
- skipped = Array(src.length).fill(false);
1645
-
1646
- let sb = '';
1647
- for (let i = 0, wasSpace = false; i < src.length; i++) {
1648
- const ch = src.charAt(i);
1649
- if (this.PUNCTUATION.indexOf(ch) >= 0 && !this.checkPunctuation) {
1650
- if (!wasSpace)
1651
- sb += ' ';
1652
- else
1653
- skipped[i] = true;
1654
- wasSpace = true;
1655
- } else if (ch === ' ') {
1656
- if (this.checkDoubleSpaces || !wasSpace)
1657
- sb += ch;
1658
- else
1659
- skipped[i] = true;
1660
- wasSpace = true;
1661
- } else {
1662
- wasSpace = false;
1663
- sb += ch;
1664
- }
1665
- }
1666
- return sb;
1667
- }
1668
- }
1669
-
1670
- Object.assign(BasicEvaluator.prototype, {
1671
- /**
1672
- * Whether accented letters must be considered equivalent or not.
1673
- * @name module:activities/text/Evaluator.BasicEvaluator#checkAccents
1674
- * @type {boolean} */
1675
- checkAccents: true,
1676
- /**
1677
- * Whether to check or not dots, commas and other punctuation marks when comparing texts.
1678
- * @name module:activities/text/Evaluator.BasicEvaluator#checkPunctuation
1679
- * @type {boolean} */
1680
- checkPunctuation: true,
1681
- /**
1682
- * Whether to check or not the extra spaces added between words.
1683
- * @name module:activities/text/Evaluator.BasicEvaluator#checkDoubleSpaces
1684
- * @type {boolean} */
1685
- checkDoubleSpaces: false,
1686
- /**
1687
- * String containing all the characters considered as punctuation marks (currently ".,;:")
1688
- * @name module:activities/text/Evaluator.BasicEvaluator#PUNCTUATION
1689
- * @type {string} */
1690
- PUNCTUATION: '.,;:',
1691
- });
1692
-
1693
- /**
1694
- * ComplexEvaluator acts like {@link module:activities/text/Evaluator.BasicEvaluator BasicEvaluator}, but providing feedback about
1695
- * the location of mistakes on the user's answer.
1696
- * @extends module:activities/text/Evaluator.BasicEvaluator
1697
- */
1698
- class ComplexEvaluator extends BasicEvaluator {
1699
- /**
1700
- * ComplexEvaluator constructor
1701
- * @param {string} className - The class name of this evaluator.
1702
- */
1703
- constructor(className) {
1704
- super(className);
1705
- }
1706
-
1707
- /**
1708
- * Performs the evaluation of a string against an array of valid matches, returning an array of
1709
- * flags useful to indicate where the mistakes are located.
1710
- * In BasicEvaluator, all characters are just marked as 1 (error) or 0 (OK). See
1711
- * {@link module:activities/text/Evaluator.ComplexEvaluator ComplexEvaluator} for more detailed analysis of answers.
1712
- * @override
1713
- * @param {string} text - The text to be checked
1714
- * @param {string} match - A valid expression with which to compare.
1715
- * @returns {number[]} - An array of flags (one number for character) indicating whether each
1716
- * position is erroneous or OK.
1717
- */
1718
- _evalText(text, match) {
1719
-
1720
- if (!this.detail)
1721
- return super._evalText(text, match);
1722
-
1723
- const
1724
- skipped = Array(text.length).fill(false),
1725
- sText = this.getClearedText(text, skipped),
1726
- numChecks = Array(match.length),
1727
- flags = Array(match.length),
1728
- returnFlags = Array(text.length);
1729
- let
1730
- maxCheck = -1,
1731
- maxCheckIndex = -1;
1732
-
1733
- for (let i = 0; i < match.length; i++) {
1734
- flags[i] = Array(text.length).fill(0);
1735
- const ok = this.compareSegment(sText, sText.length, match[i], match[i].length, flags[i], false);
1736
- numChecks[i] = this.countFlagsOk(flags[i]);
1737
- if (ok) {
1738
- maxCheckIndex = i;
1739
- maxCheck = numChecks[i];
1740
- }
1741
- }
1742
-
1743
- if (maxCheckIndex === -1) {
1744
- for (let i = 0; i < match.length; i++) {
1745
- if (numChecks[i] > maxCheck) {
1746
- maxCheck = numChecks[i];
1747
- maxCheckIndex = i;
1748
- }
1749
- }
1750
- }
1751
-
1752
- for (let i = 0, k = 0; i < text.length; i++)
1753
- returnFlags[i] = skipped[i] ? 0 : flags[maxCheckIndex][k++];
1754
-
1755
- return returnFlags;
1756
- }
1757
-
1758
- /**
1759
- * Counts the number of flags on the provided array that are zero.
1760
- * @param {number[]} flags
1761
- * @returns {number}
1762
- */
1763
- countFlagsOk(flags) {
1764
- return flags.reduce((n, v) => v == 0 ? ++n : n, 0);
1765
- }
1766
-
1767
- /**
1768
- * Compares two segments of text.
1769
- * This function should make recursive calls.
1770
- * @param {string} src - Text to be compared
1771
- * @param {number} ls - Offset in `src` where to start the comparison
1772
- * @param {string} ok - Text to match against.
1773
- * @param {number} lok - Offset in `ok` where to start the comparison.
1774
- * @param {number[]} attr - Array of integers that will be filled with information about the
1775
- * validity or error of each character in `src`.
1776
- * @param {boolean} iterate - When `true`, the segment will be iterated looking for other
1777
- * coincident fragments.
1778
- * @returns {boolean} - `true` if the comparison was valid.
1779
- */
1780
- compareSegment(src, ls, ok, lok, attr, iterate) {
1781
- let
1782
- is = 0,
1783
- iok = 0,
1784
- lastIs = 0,
1785
- lastiok = true,
1786
- result = true,
1787
- chs = '',
1788
- chok = '';
1789
-
1790
- if (ls === 0 || lok === 0 || src === null || ok === null)
1791
- return false;
1792
-
1793
- for (; is < ls; is++, iok++) {
1794
- chs = src.charAt(is);
1795
- lastIs = is;
1796
- if (iok >= 0 && iok < lok)
1797
- chok = ok.charAt(iok);
1798
- else
1799
- chok = 0;
1800
- if (this.collator.compare(chs, chok) === 0) {
1801
- attr[is] = 0;
1802
- lastiok = true;
1803
- } else {
1804
- result = false;
1805
- attr[is] = 1;
1806
- if (!iterate && lastiok && chok !== 0 && this.checkSteps > 0 && this.checkScope > 0) {
1807
- const
1808
- lbloc = 2 * this.checkSteps + 1,
1809
- itcoinc = [];
1810
- let i = 0, j = 0;
1811
- for (; j < lbloc; j++) {
1812
- itcoinc[j] = 0;
1813
- i = iok + Math.floor((j + 1) / 2) * ((j & 1) !== 0 ? 1 : -1);
1814
- if (i >= lok)
1815
- continue;
1816
- const is2 = i < 0 ? is - i : is;
1817
- if (is2 >= ls)
1818
- continue;
1819
- const
1820
- ls2 = Math.min(ls - is2, this.checkScope),
1821
- iok2 = i < 0 ? 0 : i,
1822
- lok2 = Math.min(lok - iok2, this.checkScope),
1823
- flags2 = Array(src.length - is2).fill(0),
1824
- result2 = this.compareSegment(src.substring(is2), ls2, ok.substring(iok2), lok2, flags2, true);
1825
- itcoinc[j] = this.countFlagsOk(flags2);
1826
- if (result2)
1827
- break;
1828
- }
1829
- if (j === lbloc) {
1830
- let jmax = this.checkSteps;
1831
- for (j = 0; j < lbloc; j++)
1832
- if (itcoinc[j] > itcoinc[jmax])
1833
- jmax = j;
1834
- i = iok + Math.floor((jmax + 1) / 2) * ((jmax & 1) !== 0 ? 1 : -1);
1835
- }
1836
- iok = i;
1837
- lastiok = false;
1838
- }
1839
- }
1840
- }
1841
- if (iok !== lok) {
1842
- result = false;
1843
- attr[lastIs] = 1;
1844
- }
1845
- return result;
1846
- }
1847
- }
1848
-
1849
- Object.assign(ComplexEvaluator.prototype, {
1850
- /**
1851
- * Whether to detail or not the location of errors found on the analyzed text.
1852
- * @name module:activities/text/Evaluator.ComplexEvaluator#detail
1853
- * @type {boolean} */
1854
- detail: true,
1855
- /**
1856
- * Number of times to repeat the evaluation process if an error is found, eliminating in each
1857
- * cycle the extra characters that caused the error.
1858
- * @name module:activities/text/Evaluator.ComplexEvaluator#checkSteps
1859
- * @type {number} */
1860
- checkSteps: 3,
1861
- /**
1862
- * When an eror is detected in the analyzed expression, this variable indicates the number of
1863
- * characters the checking pointer will be moved forward and back looking for a coincident
1864
- * expression.
1865
- *
1866
- * For example, comparing the answer "_one lardzy dog_" with the correct answer "_one lazy dog_"
1867
- * will detect an error at position 6 (an "r" instead of "z"). If `checkSteps` is set to 2 or
1868
- * greater, the "_zy dog_" expression at position 8 will be found and evaluated as valid, while
1869
- * a value of 1 or less will not found any coincident expression beyond the error position, thus
1870
- * evaluating all the remaining sentence as erroneous.
1871
- * @name module:activities/text/Evaluator.ComplexEvaluator#checkScope
1872
- * @type {number} */
1873
- checkScope: 6,
1874
- });
1875
-
1876
- // List of known Evaluator classes
1877
- Evaluator.CLASSES = {
1878
- '@BasicEvaluator': BasicEvaluator,
1879
- '@ComplexEvaluator': ComplexEvaluator
1880
- };
1881
-
1882
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Evaluator);
1883
-
1884
-
1885
- /***/ }),
1886
-
1887
- /***/ 2379:
1888
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1889
-
1890
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1891
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1892
- /* harmony export */ });
1893
- /* unused harmony export AutoContentProvider */
1894
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1253);
1895
- /**
1896
- * File : automation/AutoContentProvider.js
1897
- * Created : 13/04/2015
1898
- * By : Francesc Busquets <francesc@gmail.com>
1899
- *
1900
- * JClic.js
1901
- * An HTML5 player of JClic activities
1902
- * https://projectestac.github.io/jclic.js
1903
- *
1904
- * @source https://github.com/projectestac/jclic.js
1905
- *
1906
- * @license EUPL-1.2
1907
- * @licstart
1908
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
1909
- *
1910
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
1911
- * the European Commission- subsequent versions of the EUPL (the "Licence");
1912
- * You may not use this work except in compliance with the Licence.
1913
- *
1914
- * You may obtain a copy of the Licence at:
1915
- * https://joinup.ec.europa.eu/software/page/eupl
1916
- *
1917
- * Unless required by applicable law or agreed to in writing, software
1918
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
1919
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1920
- * Licence for the specific language governing permissions and limitations
1921
- * under the Licence.
1922
- * @licend
1923
- * @module
1924
- */
1925
-
1926
-
1927
-
1928
- /**
1929
- * This abstract class is the base for classes that create on-time automatic content for JClic
1930
- * activities, usually using random parameters to assure different content in each session.
1931
- *
1932
- * Activities with `AutoContentProvider` objects rely on them to build new content on every start.
1933
- */
1934
- class AutoContentProvider {
1935
- /**
1936
- * AutoContentProvider constructor
1937
- */
1938
- constructor() {
1939
- }
1940
-
1941
- /**
1942
- * Dynamic constructor that returns a specific type of AutoContentProvider based on the `class`
1943
- * attribute declared on an $xml element.
1944
- * It should be called only from {@link module:Activity.Activity#setProperties Activity.setProperties}
1945
- * @param {external.jQuery} $xml - The XML element to parse
1946
- * @returns {module:automation/AutoContentProvider.AutoContentProvider}
1947
- */
1948
- static getProvider($xml) {
1949
- let automation = null;
1950
- if ($xml) {
1951
- const
1952
- className = ($xml.attr('class') || '').replace(/^edu\.xtec\.jclic\.automation\./, '@'),
1953
- cl = AutoContentProvider.CLASSES[className];
1954
- if (cl) {
1955
- automation = new cl();
1956
- automation.setProperties($xml);
1957
- } else
1958
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('error', `Unknown AutoContentProvider class: ${className}`);
1959
- }
1960
- return automation;
1961
- }
1962
-
1963
- /**
1964
- * Loads the object settings from a specific jQuery XML element
1965
- * @param {external:jQuery} $xml - The XML element to parse
1966
- */
1967
- setProperties($xml) {
1968
- this.className = ($xml.attr('class') || '').replace(/^edu\.xtec\.jclic\.automation\./, '@');
1969
- return this;
1970
- }
1971
-
1972
- /**
1973
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
1974
- * parent references, constants and also attributes retaining the default value.
1975
- * The resulting object is commonly usued to serialize elements in JSON format.
1976
- * @returns {object} - The resulting object, with minimal attrributes
1977
- */
1978
- getAttributes() {
1979
- // To be overrided!
1980
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .getAttr */ .iu)(this, ['className']);
1981
- }
1982
-
1983
- /**
1984
- * Builds a new AutoContentProvider, based on the properties specified in a data object
1985
- * @param {object} data - The data object to be parsed
1986
- * @param {object[]} params - Optional parameters to be passed to `setAttributes`
1987
- * @returns {module:shapers/Shaper.Shaper}
1988
- */
1989
- static factory(data, params = []) {
1990
- const cl = AutoContentProvider.CLASSES[data.className];
1991
- return (new cl()).setAttributes(data, ...params);
1992
- }
1993
-
1994
- /**
1995
- * Initializes the content provider
1996
- */
1997
- init() {
1998
- // To be implemented in real content providers
1999
- }
2000
-
2001
- /**
2002
- * Builds an {@link module:automation/AutoContentProvider/ActiveBagContentKit ActiveBagContentKit} and generates the automatized content.
2003
- * @param {number} nRows - Number of rows to be processed
2004
- * @param {number} nCols - Number of columns to be processed
2005
- * @param {module:boxes/ActiveBagContent.ActiveBagContent[]} content - Array with one or more containers of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent}
2006
- * objects to be filled with new content.
2007
- * @param {boolean} useIds - When `true`, the `id` field of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects is significant
2008
- * @returns {boolean} - `true` if the process was OK. `false` otherwise.
2009
- */
2010
- generateContent(nRows, nCols, content, useIds) {
2011
- return this.process(new AutoContentProvider.ActiveBagContentKit(nRows, nCols, content, useIds));
2012
- }
2013
-
2014
- /**
2015
- * Generates the automatized content
2016
- * @param {module:automation/AutoContentProvider.ActiveBagContentKit} _kit - The objects to be filled with content
2017
- * @returns {boolean} - `true` if the process was OK. `false` otherwise.
2018
- */
2019
- process(_kit) {
2020
- // To be implemented in subclasses
2021
- return false;
2022
- }
2023
-
2024
- /**
2025
- * Registers a new type of AutoContentProvider
2026
- * @param {string} providerName - The name used to identify this AutoContentProvider
2027
- * @param {function} providerClass - The activity class, usually extending AutoContentProvider
2028
- * @returns {module:automation/AutoContentProvider.AutoContentProvider} - The provider class
2029
- */
2030
- static registerClass(providerName, providerClass) {
2031
- AutoContentProvider.CLASSES[providerName] = providerClass;
2032
- return providerClass;
2033
- }
2034
- }
2035
-
2036
- Object.assign(AutoContentProvider.prototype, {
2037
- /**
2038
- * This AutoContentProvider manages numeric expressions, so text literals should be
2039
- * converted to numbers for comparisions, taking in account the
2040
- * number format of the current locale (dot or comma as decimal separator)
2041
- * @name module:automation/AutoContentProvider.AutoContentProvider#numericContent
2042
- * @type {boolean} */
2043
- numericContent: false,
2044
- });
2045
-
2046
- /**
2047
- * Utility class used to encapsulate multiple sets of box contents
2048
- * @param {number} nRows - Number of rows to be processed
2049
- * @param {number} nCols - Number of columns to be processed
2050
- * @param {module:boxes/ActiveBagContent.ActiveBagContent[]} content - Array with one or more containers of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent}
2051
- * objects to be filled with new content.
2052
- * @param {boolean} useIds - `true` when the `id` field of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects is significant.
2053
- */
2054
- AutoContentProvider.ActiveBagContentKit = class {
2055
- constructor(nRows, nCols, content, useIds) {
2056
- this.nRows = nRows;
2057
- this.nCols = nCols;
2058
- this.content = content;
2059
- this.useIds = useIds;
2060
- }
2061
- };
2062
-
2063
- /**
2064
- * Contains the current list of classes derived from AutoContentProvider.
2065
- * This object should be updated by real automation classes at declaration time.
2066
- * Currently, only two types of "AutoContentProvider" are defined: {@link module:automation/arith/Arith.Arith Arith} and TagReplace.
2067
- * @type {object} */
2068
- AutoContentProvider.CLASSES = {
2069
- // TODO: Implement TagReplace
2070
- '@tagreplace.TagReplace': AutoContentProvider
2071
- };
2072
-
2073
- // TODO: Implement TagReplace
2074
- AutoContentProvider.registerClass('@tagreplace.TagReplace', AutoContentProvider);
2075
-
2076
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AutoContentProvider);
2077
-
2078
-
2079
- /***/ }),
2080
-
2081
- /***/ 1842:
2082
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2083
-
2084
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2085
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2086
- /* harmony export */ });
2087
- /* unused harmony export TextGridContent */
2088
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
2089
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
2090
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
2091
- /* harmony import */ var _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3018);
2092
- /**
2093
- * File : boxes/TextGridContent.js
2094
- * Created : 14/04/2015
2095
- * By : Francesc Busquets <francesc@gmail.com>
2096
- *
2097
- * JClic.js
2098
- * An HTML5 player of JClic activities
2099
- * https://projectestac.github.io/jclic.js
2100
- *
2101
- * @source https://github.com/projectestac/jclic.js
2102
- *
2103
- * @license EUPL-1.2
2104
- * @licstart
2105
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
2106
- *
2107
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
2108
- * the European Commission- subsequent versions of the EUPL (the "Licence");
2109
- * You may not use this work except in compliance with the Licence.
2110
- *
2111
- * You may obtain a copy of the Licence at:
2112
- * https://joinup.ec.europa.eu/software/page/eupl
2113
- *
2114
- * Unless required by applicable law or agreed to in writing, software
2115
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
2116
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
2117
- * Licence for the specific language governing permissions and limitations
2118
- * under the Licence.
2119
- * @licend
2120
- * @module
2121
- */
2122
-
2123
-
2124
-
2125
-
2126
-
2127
- /**
2128
- * This class encapsulates the content of {@link module:boxes/TextGrid.TextGrid TextGrid} objects.
2129
- *
2130
- * It implements methods to set and retrieve individual characters on the grid, and parsing of
2131
- * XML objects. It also contains information about the optimal size and other graphic properties
2132
- * (fonts, colors, etc.) of the grid.
2133
- */
2134
- class TextGridContent {
2135
- /**
2136
- * TextGridContent constructor
2137
- */
2138
- constructor() {
2139
- this.style = new _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"](null);
2140
- this.text = [];
2141
- }
2142
-
2143
- /**
2144
- * Loads the object settings from a specific JQuery XML element
2145
- * @param {external:jQuery} $xml
2146
- */
2147
- setProperties($xml) {
2148
- // Read attributes
2149
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, val) => {
2150
- switch (name) {
2151
- case 'rows':
2152
- // WARNING: Due to a bug in JClic, the meaning of "rows" and "columns" must be
2153
- // interchanged:
2154
- this.ncw = Number(val);
2155
- break;
2156
- case 'columns':
2157
- this.nch = Number(val);
2158
- break;
2159
- case 'cellWidth':
2160
- this.w = Number(val);
2161
- break;
2162
- case 'cellHeight':
2163
- this.h = Number(val);
2164
- break;
2165
- case 'border':
2166
- this.border = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val);
2167
- break;
2168
- case 'wild':
2169
- case 'randomChars':
2170
- this[name] = val;
2171
- break;
2172
- }
2173
- });
2174
-
2175
- // Read inner elements
2176
- $xml.children('style:first').each((_n, child) => {
2177
- this.style = new _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"]().setProperties(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child));
2178
- });
2179
-
2180
- $xml.find('text:first > row').each((_n, el) => this.text.push(el.textContent));
2181
-
2182
- for (let i = this.text.length; i < this.nch; i++)
2183
- this.text[i] = '';
2184
-
2185
- return this;
2186
- }
2187
-
2188
- /**
2189
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
2190
- * parent references, constants and also attributes retaining the default value.
2191
- * The resulting object is commonly usued to serialize elements in JSON format.
2192
- * @returns {object} - The resulting object, with minimal attrributes
2193
- */
2194
- getAttributes() {
2195
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, [
2196
- 'ncw', 'nch',
2197
- 'w', 'h',
2198
- 'text',
2199
- 'style', // BoxBase
2200
- 'border',
2201
- 'wild|*',
2202
- `randomChars|${_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.RANDOM_CHARS}`,
2203
- ]);
2204
- }
2205
-
2206
- /**
2207
- * Reads the properties of this TextGridContent from a data object
2208
- * @param {object|string} data - The data object to be parsed, or just the text content
2209
- * @returns {module:boxes/TextGridContent.TextGridContent}
2210
- */
2211
- setAttributes(data) {
2212
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, [
2213
- 'ncw', 'nch',
2214
- 'w', 'h',
2215
- 'text',
2216
- { key: 'style', fn: _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"] },
2217
- 'border',
2218
- 'wild',
2219
- `randomChars`,
2220
- ]);
2221
- }
2222
-
2223
- /**
2224
- * Counts the number of wildcard characters present in this TextGrid
2225
- * @returns {number}
2226
- */
2227
- countWildChars() {
2228
- let result = 0;
2229
- if (this.text)
2230
- for (let y = 0; y < this.nch; y++)
2231
- for (let x = 0; x < this.ncw; x++)
2232
- if (this.text[y].charAt(x) === this.wild)
2233
- result++;
2234
- return result;
2235
- }
2236
-
2237
- /**
2238
- * Counts the total number of characters, including wildcard characters.
2239
- * @returns {number}
2240
- */
2241
- getNumChars() {
2242
- return this.ncw * this.nch;
2243
- }
2244
-
2245
- /**
2246
- * Sets the specified character as a content of the cell located at specific coordinates
2247
- * @param {number} x - The X coordinate of the cell
2248
- * @param {number} y - The X coordinate of the cell
2249
- * @param {string} ch - The character to be placed on the specified cell
2250
- */
2251
- setCharAt(x, y, ch) {
2252
- if (x >= 0 && x < this.ncw && y >= 0 && y < this.nch)
2253
- this.text[y] = this.text[y].substring(0, x) + ch + this.text[y].substring(x + 1);
2254
- }
2255
- }
2256
-
2257
- Object.assign(TextGridContent.prototype, {
2258
- /**
2259
- * Grid columns
2260
- * @name module:boxes/TextGridContent.TextGridContent#ncw
2261
- * @type {number} */
2262
- ncw: 1,
2263
- /**
2264
- * Grid rows
2265
- * @name module:boxes/TextGridContent.TextGridContent#nch
2266
- * @type {number} */
2267
- nch: 1,
2268
- /**
2269
- * Width of cells
2270
- * @name module:boxes/TextGridContent.TextGridContent#w
2271
- * @type {number} */
2272
- w: 20,
2273
- /**
2274
- * Height of cells
2275
- * @name module:boxes/TextGridContent.TextGridContent#h
2276
- * @type {number} */
2277
- h: 20,
2278
- /**
2279
- * Whether the cells must be surrounded by a border or not
2280
- * @name module:boxes/TextGridContent.TextGridContent#border
2281
- * @type {boolean} */
2282
- border: false,
2283
- /**
2284
- * The {@link module:boxes/BoxBase.BoxBase BoxBase} object with visual settings of the text grid
2285
- * @name module:boxes/TextGridContent.TextGridContent#style
2286
- * @type {module:boxes/BoxBase.BoxBase} */
2287
- style: null,
2288
- /**
2289
- * An array of String objects textning the chars of cells. One string per row, one character of
2290
- * this string per cell.
2291
- * @name module:boxes/TextGridContent.TextGridContent#text
2292
- * @type {string[]} */
2293
- text: null,
2294
- /**
2295
- * The letter used as wildcardtext
2296
- * @name module:boxes/TextGridContent.TextGridContent#wild
2297
- * @type {string} */
2298
- wild: '*',
2299
- /**
2300
- * A String with the chars to take as source when randomly filling empty cells
2301
- * @name module:boxes/TextGridContent.TextGridContent#randomChars
2302
- * @type {string} */
2303
- randomChars: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.RANDOM_CHARS,
2304
- });
2305
-
2306
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextGridContent);
2307
-
2308
-
2309
- /***/ })
2310
-
2311
- };
2312
- ;
2313
- //# sourceMappingURL=1567.jclic-node.js.map