jclic 2.1.21 → 2.1.23

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 (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/jclic-node.js +9 -8
  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 +4 -4
  7. package/src/GlobalData.js +1 -1
  8. package/src/JClicPlayer.js +2 -2
  9. package/src/bags/MediaBag.js +6 -5
  10. package/dist/1078.jclic-node.js +0 -282
  11. package/dist/1078.jclic-node.js.map +0 -1
  12. package/dist/1196.jclic-node.js +0 -808
  13. package/dist/1196.jclic-node.js.map +0 -1
  14. package/dist/1253.jclic-node.js +0 -1432
  15. package/dist/1253.jclic-node.js.map +0 -1
  16. package/dist/13.jclic-node.js +0 -103
  17. package/dist/13.jclic-node.js.map +0 -1
  18. package/dist/1567.jclic-node.js +0 -2313
  19. package/dist/1567.jclic-node.js.map +0 -1
  20. package/dist/1588.jclic-node.js +0 -602
  21. package/dist/1588.jclic-node.js.map +0 -1
  22. package/dist/1725.jclic-node.js +0 -836
  23. package/dist/1725.jclic-node.js.map +0 -1
  24. package/dist/1731.jclic-node.js +0 -438
  25. package/dist/1731.jclic-node.js.map +0 -1
  26. package/dist/1842.jclic-node.js +0 -651
  27. package/dist/1842.jclic-node.js.map +0 -1
  28. package/dist/2160.jclic-node.js +0 -1016
  29. package/dist/2160.jclic-node.js.map +0 -1
  30. package/dist/222.jclic-node.js +0 -129
  31. package/dist/222.jclic-node.js.map +0 -1
  32. package/dist/2316.jclic-node.js +0 -949
  33. package/dist/2316.jclic-node.js.map +0 -1
  34. package/dist/2355.jclic-node.js +0 -371
  35. package/dist/2355.jclic-node.js.map +0 -1
  36. package/dist/2366.jclic-node.js +0 -431
  37. package/dist/2366.jclic-node.js.map +0 -1
  38. package/dist/2379.jclic-node.js +0 -202
  39. package/dist/2379.jclic-node.js.map +0 -1
  40. package/dist/2437.jclic-node.js +0 -450
  41. package/dist/2437.jclic-node.js.map +0 -1
  42. package/dist/2531.jclic-node.js +0 -869
  43. package/dist/2531.jclic-node.js.map +0 -1
  44. package/dist/2608.jclic-node.js +0 -160
  45. package/dist/2608.jclic-node.js.map +0 -1
  46. package/dist/2715.jclic-node.js +0 -554
  47. package/dist/2715.jclic-node.js.map +0 -1
  48. package/dist/277.jclic-node.js +0 -22
  49. package/dist/277.jclic-node.js.map +0 -1
  50. package/dist/2921.jclic-node.js +0 -660
  51. package/dist/2921.jclic-node.js.map +0 -1
  52. package/dist/2952.jclic-node.js +0 -101
  53. package/dist/2952.jclic-node.js.map +0 -1
  54. package/dist/3018.jclic-node.js +0 -421
  55. package/dist/3018.jclic-node.js.map +0 -1
  56. package/dist/3019.jclic-node.js +0 -682
  57. package/dist/3019.jclic-node.js.map +0 -1
  58. package/dist/3231.jclic-node.js +0 -274
  59. package/dist/3231.jclic-node.js.map +0 -1
  60. package/dist/331.jclic-node.js +0 -115
  61. package/dist/331.jclic-node.js.map +0 -1
  62. package/dist/3391.jclic-node.js +0 -276
  63. package/dist/3391.jclic-node.js.map +0 -1
  64. package/dist/3502.jclic-node.js +0 -671
  65. package/dist/3502.jclic-node.js.map +0 -1
  66. package/dist/3653.jclic-node.js +0 -982
  67. package/dist/3653.jclic-node.js.map +0 -1
  68. package/dist/371.jclic.min.js +0 -2
  69. package/dist/371.jclic.min.js.map +0 -1
  70. package/dist/3856.jclic-node.js +0 -575
  71. package/dist/3856.jclic-node.js.map +0 -1
  72. package/dist/4112.jclic-node.js +0 -659
  73. package/dist/4112.jclic-node.js.map +0 -1
  74. package/dist/4123.jclic-node.js +0 -910
  75. package/dist/4123.jclic-node.js.map +0 -1
  76. package/dist/427.jclic-node.js +0 -894
  77. package/dist/427.jclic-node.js.map +0 -1
  78. package/dist/4483.jclic-node.js +0 -327
  79. package/dist/4483.jclic-node.js.map +0 -1
  80. package/dist/4548.jclic-node.js +0 -1078
  81. package/dist/4548.jclic-node.js.map +0 -1
  82. package/dist/466.jclic-node.js +0 -99
  83. package/dist/466.jclic-node.js.map +0 -1
  84. package/dist/485.jclic-node.js +0 -783
  85. package/dist/485.jclic-node.js.map +0 -1
  86. package/dist/4921.jclic-node.js +0 -500
  87. package/dist/4921.jclic-node.js.map +0 -1
  88. package/dist/5091.jclic-node.js +0 -239
  89. package/dist/5091.jclic-node.js.map +0 -1
  90. package/dist/520.jclic-node.js +0 -550
  91. package/dist/520.jclic-node.js.map +0 -1
  92. package/dist/5312.jclic-node.js +0 -1126
  93. package/dist/5312.jclic-node.js.map +0 -1
  94. package/dist/5338.jclic-node.js +0 -212
  95. package/dist/5338.jclic-node.js.map +0 -1
  96. package/dist/5344.jclic-node.js +0 -229
  97. package/dist/5344.jclic-node.js.map +0 -1
  98. package/dist/5550.jclic-node.js +0 -238
  99. package/dist/5550.jclic-node.js.map +0 -1
  100. package/dist/5626.jclic-node.js +0 -614
  101. package/dist/5626.jclic-node.js.map +0 -1
  102. package/dist/5977.jclic-node.js +0 -1081
  103. package/dist/5977.jclic-node.js.map +0 -1
  104. package/dist/6148.jclic-node.js +0 -345
  105. package/dist/6148.jclic-node.js.map +0 -1
  106. package/dist/6176.jclic-node.js +0 -481
  107. package/dist/6176.jclic-node.js.map +0 -1
  108. package/dist/6221.jclic-node.js +0 -1072
  109. package/dist/6221.jclic-node.js.map +0 -1
  110. package/dist/6238.jclic-node.js +0 -718
  111. package/dist/6238.jclic-node.js.map +0 -1
  112. package/dist/6454.jclic-node.js +0 -1413
  113. package/dist/6454.jclic-node.js.map +0 -1
  114. package/dist/6565.jclic-node.js +0 -294
  115. package/dist/6565.jclic-node.js.map +0 -1
  116. package/dist/6579.jclic-node.js +0 -719
  117. package/dist/6579.jclic-node.js.map +0 -1
  118. package/dist/6715.jclic-node.js +0 -148
  119. package/dist/6715.jclic-node.js.map +0 -1
  120. package/dist/6777.jclic-node.js +0 -171
  121. package/dist/6777.jclic-node.js.map +0 -1
  122. package/dist/6782.jclic-node.js +0 -1611
  123. package/dist/6782.jclic-node.js.map +0 -1
  124. package/dist/6847.jclic-node.js +0 -601
  125. package/dist/6847.jclic-node.js.map +0 -1
  126. package/dist/6856.jclic-node.js +0 -252
  127. package/dist/6856.jclic-node.js.map +0 -1
  128. package/dist/696.jclic-node.js +0 -1821
  129. package/dist/696.jclic-node.js.map +0 -1
  130. package/dist/698.jclic-node.js +0 -583
  131. package/dist/698.jclic-node.js.map +0 -1
  132. package/dist/704.jclic-node.js +0 -80
  133. package/dist/704.jclic-node.js.map +0 -1
  134. package/dist/7046.jclic-node.js +0 -735
  135. package/dist/7046.jclic-node.js.map +0 -1
  136. package/dist/7220.jclic-node.js +0 -156
  137. package/dist/7220.jclic-node.js.map +0 -1
  138. package/dist/7257.jclic-node.js +0 -931
  139. package/dist/7257.jclic-node.js.map +0 -1
  140. package/dist/743.jclic-node.js +0 -583
  141. package/dist/743.jclic-node.js.map +0 -1
  142. package/dist/757.jclic-node.js +0 -1072
  143. package/dist/757.jclic-node.js.map +0 -1
  144. package/dist/7781.jclic-node.js +0 -202
  145. package/dist/7781.jclic-node.js.map +0 -1
  146. package/dist/7912.jclic-node.js +0 -2103
  147. package/dist/7912.jclic-node.js.map +0 -1
  148. package/dist/827.jclic-node.js +0 -708
  149. package/dist/827.jclic-node.js.map +0 -1
  150. package/dist/8276.jclic-node.js +0 -409
  151. package/dist/8276.jclic-node.js.map +0 -1
  152. package/dist/8322.jclic-node.js +0 -498
  153. package/dist/8322.jclic-node.js.map +0 -1
  154. package/dist/8641.jclic-node.js +0 -360
  155. package/dist/8641.jclic-node.js.map +0 -1
  156. package/dist/8837.jclic-node.js +0 -651
  157. package/dist/8837.jclic-node.js.map +0 -1
  158. package/dist/8895.jclic-node.js +0 -151
  159. package/dist/8895.jclic-node.js.map +0 -1
  160. package/dist/9072.jclic-node.js +0 -1285
  161. package/dist/9072.jclic-node.js.map +0 -1
  162. package/dist/9078.jclic-node.js +0 -935
  163. package/dist/9078.jclic-node.js.map +0 -1
  164. package/dist/9103.jclic-node.js +0 -718
  165. package/dist/9103.jclic-node.js.map +0 -1
  166. package/dist/9359.jclic-node.js +0 -145
  167. package/dist/9359.jclic-node.js.map +0 -1
  168. package/dist/9409.jclic-node.js +0 -921
  169. package/dist/9409.jclic-node.js.map +0 -1
  170. package/dist/9513.jclic-node.js +0 -720
  171. package/dist/9513.jclic-node.js.map +0 -1
  172. package/dist/9704.jclic-node.js +0 -81
  173. package/dist/9704.jclic-node.js.map +0 -1
  174. package/dist/9950.jclic-node.js +0 -827
  175. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,869 +0,0 @@
1
- "use strict";
2
- exports.id = 2531;
3
- exports.ids = [2531,7781];
4
- exports.modules = {
5
-
6
- /***/ 2531:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony exports WrittenAnswer, WrittenAnswerPanel */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Activity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1567);
16
- /* harmony import */ var _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7781);
17
- /* harmony import */ var _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9205);
18
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7912);
19
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1253);
20
- /* harmony import */ var _shapers_Rectangular_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4921);
21
- /**
22
- * File : activities/text/WrittenAnswer.js
23
- * Created : 04/06/2015
24
- * By : Francesc Busquets <francesc@gmail.com>
25
- *
26
- * JClic.js
27
- * An HTML5 player of JClic activities
28
- * https://projectestac.github.io/jclic.js
29
- *
30
- * @source https://github.com/projectestac/jclic.js
31
- *
32
- * @license EUPL-1.2
33
- * @licstart
34
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
35
- *
36
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
37
- * the European Commission- subsequent versions of the EUPL (the "Licence");
38
- * You may not use this work except in compliance with the Licence.
39
- *
40
- * You may obtain a copy of the Licence at:
41
- * https://joinup.ec.europa.eu/software/page/eupl
42
- *
43
- * Unless required by applicable law or agreed to in writing, software
44
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
45
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
46
- * Licence for the specific language governing permissions and limitations
47
- * under the Licence.
48
- * @licend
49
- * @module
50
- */
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
- /**
61
- * This class of {@link module:Activity.Activity Activity} shows a panel with {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects acting as cells
62
- * with questions. The answers to these questions must be written in a separate text field.
63
- *
64
- * The ActiveBox objects are filled with data stored in {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} repositories.
65
- *
66
- * A second {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} can be used as alternative content, revealed as the questions
67
- * are solved.
68
- * @extends module:Activity.Activity
69
- */
70
- class WrittenAnswer extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I {
71
- /**
72
- * WrittenAnswer constructor
73
- * @param {module:project/JClicProject.JClicProject} project - The JClic project to which this activity belongs
74
- */
75
- constructor(project) {
76
- super(project);
77
- }
78
-
79
- /**
80
- * Loads this object settings from an XML element
81
- * @override
82
- * @param {external:jQuery} $xml - The jQuery XML element to parse
83
- */
84
- setProperties($xml) {
85
- super.setProperties($xml);
86
- this.abc['primary'].avoidAllIdsNull(this.abc['answers'].getNumCells());
87
- }
88
-
89
- /**
90
- * Retrieves the minimum number of actions needed to solve this activity
91
- * @override
92
- * @returns {number}
93
- */
94
- getMinNumActions() {
95
- return this.invAss ?
96
- this.abc['answers'].getNumCells() :
97
- this.abc['primary'].getNumCells() - this.nonAssignedCells;
98
- }
99
-
100
- /**
101
- * This activity uses random values to shuffle its internal components
102
- * @override
103
- * @returns {boolean}
104
- */
105
- hasRandom() {
106
- return true;
107
- }
108
-
109
- /**
110
- * This activity makes use of the keyboard
111
- * @override
112
- * @returns {boolean}
113
- */
114
- needsKeyboard() {
115
- return true;
116
- }
117
-
118
- /**
119
- * This activity can permit the user to display the solution
120
- * @override
121
- * @returns {boolean}
122
- */
123
- helpSolutionAllowed() {
124
- return true;
125
- }
126
- }
127
-
128
- Object.assign(WrittenAnswer.prototype, {
129
- /**
130
- * Number of unassigned cells
131
- * @name module:activities/text/WrittenAnswer.WrittenAnswer#nonAssignedCells
132
- * @type {number} */
133
- nonAssignedCells: 0,
134
- /**
135
- * Whether to use or not the cell's `idAss` field to check if pairings match
136
- * @name module:activities/text/WrittenAnswer.WrittenAnswer#useIdAss
137
- * @type {boolean} */
138
- useIdAss: true,
139
- });
140
-
141
- /**
142
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/text/WrittenAnswer.WrittenAnswer WrittenAnswer} activities are played.
143
- * @extends module:Activity.ActivityPanel
144
- */
145
- class WrittenAnswerPanel extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .ActivityPanel */ .S {
146
- /**
147
- * WrittenAnswerPanel constructor
148
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
149
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
150
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
151
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
152
- */
153
- constructor(act, ps, $div) {
154
- super(act, ps, $div);
155
- }
156
-
157
- /**
158
- * Performs miscellaneous cleaning operations
159
- * @override
160
- */
161
- clear() {
162
- if (this.bgA) {
163
- this.bgA.end();
164
- this.bgA = null;
165
- }
166
- if (this.bgB) {
167
- this.bgB.end();
168
- this.bgB = null;
169
- }
170
- }
171
-
172
- /**
173
- * Prepares the visual components of the activity
174
- * @override
175
- */
176
- buildVisualComponents() {
177
- if (this.firstRun)
178
- super.buildVisualComponents();
179
-
180
- this.clear();
181
-
182
- const
183
- abcA = this.act.abc['primary'],
184
- abcB = this.act.abc['answers'],
185
- solved = this.act.abc['solvedPrimary'];
186
-
187
- if (abcA && abcB) {
188
- if (this.act.invAss)
189
- this.invAssCheck = Array(abcB.getNumCells()).fill(false);
190
-
191
- if (abcA.image) {
192
- abcA.setImgContent(this.act.project.mediaBag, null, false);
193
- if (abcA.animatedGifFile && !abcA.shaper.rectangularShapes && !this.act.shuffleA)
194
- this.$animatedBg = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<span/>').css({
195
- 'background-image': 'url(' + abcA.animatedGifFile + ')',
196
- 'background-position': 'center',
197
- 'background-repeat': 'no-repeat',
198
- position: 'absolute'
199
- }).appendTo(this.$div);
200
- }
201
-
202
- if (solved && solved.image)
203
- solved.setImgContent(this.act.project.mediaBag, null, false);
204
-
205
- if (this.act.acp !== null) {
206
- const contentKit = [abcA, abcB];
207
- if (solved)
208
- contentKit.push(solved);
209
- this.act.acp.generateContent(abcA.nch, abcA.ncw, contentKit, false);
210
- }
211
-
212
- this.bgA = _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__["default"].createEmptyGrid(null, this, this.act.margin, this.act.margin, abcA);
213
-
214
- let w = abcB.w;
215
- if (this.act.boxGridPos === 'AUB' || this.act.boxGridPos === 'BUA')
216
- w = abcA.getTotalWidth();
217
- //
218
- // bgB will be used only as a placeholder for `$textField`
219
- this.bgB = new _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__["default"](null, this, abcB.style, this.act.margin, this.act.margin, w, abcB.h, new _shapers_Rectangular_js__WEBPACK_IMPORTED_MODULE_6__["default"](1, 1));
220
- this.$form = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<form/>', { id: 'form1' /*, action: '#' */ });
221
- // Modified 05/Feb/2020: jQuery not catching submit event when on first activity
222
- this.$form[0].addEventListener('submit', event => {
223
- event.preventDefault();
224
- if (this.playing)
225
- this.setCurrentCell(this.currentCell);
226
- return false;
227
- });
228
-
229
- this.$textField = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<input/>', { type: 'text', size: 200 })
230
- .css(abcB.style.getCSS())
231
- .css({
232
- position: 'absolute', top: 0, left: 0,
233
- border: 0, padding: 0, margin: 0,
234
- 'text-align': 'center'
235
- })
236
- .attr({
237
- autocomplete: 'off',
238
- autocorrect: 'off',
239
- autocapitalize: 'off',
240
- spellcheck: 'false',
241
- });
242
-
243
- this.$div.append(this.$form.append(this.$textField));
244
- this.bgA.setContent(abcA, solved || null);
245
- this.bgA.setDefaultIdAss();
246
- if (this.$animatedBg)
247
- this.bgA.setCellAttr('tmpTrans', true);
248
-
249
- this.act.nonAssignedCells = 0;
250
- for (let i = 0; i < this.bgA.getNumCells(); i++) {
251
- var bx = this.bgA.getActiveBox(i);
252
- if (bx.idAss === -1) {
253
- this.act.nonAssignedCells++;
254
- bx.switchToAlt(this.ps);
255
- }
256
- }
257
- this.bgA.setVisible(true);
258
- this.bgB.setVisible(false);
259
- }
260
- }
261
-
262
- /**
263
- * Basic initialization procedure
264
- * @override
265
- */
266
- initActivity() {
267
- super.initActivity();
268
- if (!this.firstRun)
269
- this.buildVisualComponents();
270
- else
271
- this.firstRun = false;
272
-
273
- if (this.bgA && this.bgB) {
274
- // Scramble cells
275
- if (this.act.shuffleA)
276
- this.shuffle([this.bgA], true, true);
277
-
278
- if (this.useOrder)
279
- this.currentItem = this.bgA.getNextItem(-1);
280
-
281
- this.setAndPlayMsg('initial', 'start');
282
- this.invalidate().update();
283
- this.playing = true;
284
- }
285
- }
286
-
287
- /**
288
- * Called by [JClicPlayer](JClicPlayer.html) when this activity panel is fully visible, just
289
- * after the initialization process.
290
- * @override
291
- */
292
- activityReady() {
293
- super.activityReady();
294
- this.setCurrentCell(0);
295
- }
296
-
297
- /**
298
- * Updates the graphic content of this panel.
299
- * This method will be called from {@link module:AWT.Container#update} when needed.
300
- * @override
301
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
302
- * it's the whole panel.
303
- */
304
- updateContent(dirtyRegion) {
305
- super.updateContent(dirtyRegion);
306
- if (this.bgA && this.$canvas) {
307
- const
308
- canvas = this.$canvas.get(-1),
309
- ctx = canvas.getContext('2d');
310
- if (!dirtyRegion)
311
- dirtyRegion = new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Rectangle */ .M_(0, 0, canvas.width, canvas.height);
312
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
313
- this.bgA.update(ctx, dirtyRegion);
314
- }
315
- return this;
316
- }
317
-
318
- /**
319
- * Sets the real dimension of this panel.
320
- * @override
321
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
322
- * @returns {module:AWT.Dimension}
323
- */
324
- setDimension(preferredMaxSize) {
325
- return (!this.bgA || !this.bgB || this.getBounds().equals(preferredMaxSize)) ?
326
- preferredMaxSize :
327
- _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__["default"].layoutDouble(preferredMaxSize, this.bgA, this.bgB, this.act.boxGridPos, this.act.margin);
328
- }
329
-
330
- /**
331
- * Sets the size and position of this activity panel
332
- * @override
333
- * @param {module:AWT.Rectangle} rect
334
- */
335
- setBounds(rect) {
336
- if (this.$canvas)
337
- this.$canvas.remove();
338
-
339
- super.setBounds(rect);
340
- if (this.bgA || this.bgB) {
341
- const r = rect.clone();
342
- if (this.act.boxGridPos === 'AUB')
343
- r.height -= this.bgB.pos.y + this.act.margin / 2;
344
- else if (this.act.boxGridPos === 'AB')
345
- r.width -= this.bgB.pos.x + this.act.margin / 2;
346
-
347
- // Create the main canvas
348
- this.$canvas = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<canvas width="' + r.dim.width + '" height="' + r.dim.height + '"/>').css({
349
- position: 'absolute',
350
- top: 0,
351
- left: 0
352
- });
353
-
354
- // Resize animated gif background
355
- if (this.bgA && this.$animatedBg) {
356
- var bgRect = this.bgA.getBounds();
357
- this.$animatedBg.css({
358
- left: bgRect.pos.x,
359
- top: bgRect.pos.y,
360
- width: bgRect.dim.width + 'px',
361
- height: bgRect.dim.height + 'px',
362
- 'background-size': bgRect.dim.width + 'px ' + bgRect.dim.height + 'px'
363
- });
364
- this.$canvas.insertAfter(this.$animatedBg);
365
- } else
366
- this.$div.prepend(this.$canvas);
367
-
368
- if (this.$textField) {
369
- this.$textField.css({
370
- top: this.bgB.pos.y,
371
- left: this.bgB.pos.x,
372
- width: this.bgB.dim.width,
373
- height: this.bgB.dim.height,
374
- zIndex: 9
375
- });
376
- }
377
- // Repaint all
378
- this.invalidate().update();
379
- }
380
- }
381
-
382
- /**
383
- * Builds the accessible components needed for this ActivityPanel
384
- * This method is called when all main elements are placed and visible, when the activity is ready
385
- * to start or when resized.
386
- * @override
387
- */
388
- buildAccessibleComponents() {
389
- if (this.$canvas && this.accessibleCanvas) {
390
- super.buildAccessibleComponents();
391
- if (this.bgA)
392
- this.bgA.buildAccessibleElements(this.$canvas, this.$div, 'click');
393
- // bgB has a regular input element, so it's already accessible
394
- }
395
- }
396
-
397
- /**
398
- * Checks if all inverse associations are done
399
- * @returns {boolean}
400
- */
401
- checkInvAss() {
402
- return this.act.invAss && this.invAssCheck && this.invAssCheck.every(chk => chk);
403
- }
404
-
405
- /**
406
- * Updates the currently selected cell, evaluating the answer written by the user on the text field.
407
- * @param {number} i - Index into the {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} of the cell to make active
408
- * @param {function[]} delayedActions - If set, store the the action in this array for future execution
409
- */
410
- setCurrentCell(i, delayedActions = null) {
411
- if (!this.playing)
412
- return;
413
-
414
- let
415
- bx = null,
416
- m = false;
417
-
418
- if (this.currentCell !== -1) {
419
- let ok = false;
420
- bx = this.bgA ? this.bgA.getActiveBoxWithIdLoc(this.currentCell) : null;
421
- if (bx) {
422
- bx.setMarked(false);
423
- const
424
- src = bx.getDescription(),
425
- id = bx.idAss,
426
- txCheck = id >= 0 ? this.act.abc['answers'].getActiveBoxContent(id).text : '',
427
- txAnswer = this.$textField.val().trim();
428
- if ((0,_Utils_js__WEBPACK_IMPORTED_MODULE_5__/* .compareMultipleOptions */ .UM)(txAnswer, txCheck, false, this.act.numericContent)) {
429
- ok = true;
430
- bx.idAss = -1;
431
- // When in multiple-answer, fill-in textField with the first valid option:
432
- const p = txCheck.indexOf('|');
433
- if (p >= 0)
434
- this.$textField.val(txCheck.substring(0, p));
435
-
436
- if (this.act.abc['solvedPrimary']) {
437
- bx.switchToAlt(this.ps);
438
- m = bx.playMedia(this.ps, delayedActions);
439
- } else
440
- bx.clear();
441
- if (this.act.invAss && id >= 0 && id < this.invAssCheck.length) {
442
- this.invAssCheck[id] = true;
443
- }
444
- if (this.act.useOrder)
445
- this.currentItem = this.bgA.getNextItem(this.currentItem);
446
- }
447
-
448
- const cellsPlaced = this.bgA.countCellsWithIdAss(-1);
449
- if (txAnswer.length > 0) {
450
- this.ps.reportNewAction(this.act, 'WRITE', src, txAnswer, ok, cellsPlaced);
451
- }
452
- if (ok && (this.checkInvAss() || cellsPlaced === this.bgA.getNumCells())) {
453
- this.finishActivity(true);
454
- this.$textField.prop('disabled', true);
455
- this.invalidate().update();
456
- return;
457
- } else if (!m && txAnswer.length > 0)
458
- this.playEvent(ok ? 'actionOk' : 'actionError');
459
- }
460
- }
461
-
462
- bx = this.bgA ?
463
- this.act.useOrder ?
464
- this.bgA.getBox(this.currentItem) :
465
- this.bgA.getActiveBoxWithIdLoc(i) :
466
- null;
467
-
468
- if (this.bgA && (!bx || bx.idAss === -1)) {
469
- for (var j = 0; j < this.bgA.getNumCells(); j++) {
470
- bx = this.bgA.getActiveBoxWithIdLoc(j);
471
- if (bx.idAss !== -1)
472
- break;
473
- }
474
- if (bx && bx.idAss === -1) {
475
- this.finishActivity(false);
476
- this.$textField.prop('disabled', true);
477
- this.invalidate().update();
478
- return;
479
- }
480
- }
481
- // Draw border only if it has more than one cell
482
- if (bx && this.bgA && this.bgA.getNumCells() > 1)
483
- bx.setMarked(true);
484
- if (bx)
485
- this.currentCell = bx.idLoc;
486
- this.$textField.val('');
487
- this.$textField.focus();
488
- this.invalidate().update();
489
- if (bx)
490
- bx.playMedia(this.ps, delayedActions);
491
- }
492
-
493
- /**
494
- * Main handler used to process mouse, touch, keyboard and edit events
495
- * @override
496
- * @param {external:Event} event - The HTML event to be processed
497
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
498
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
499
- */
500
- processEvent(event) {
501
- if (this.playing) {
502
- // Array to be filled with actions to be executed at the end of event processing
503
- const delayedActions = [];
504
- switch (event.type) {
505
- case 'click':
506
- event.preventDefault();
507
- this.ps.stopMedia(1);
508
- const p = new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Point */ .bR(
509
- event.pageX - this.$div.offset().left,
510
- event.pageY - this.$div.offset().top);
511
-
512
- // Avoid clicks on the text field
513
- if (this.bgB.contains(p)) {
514
- this.$textField.focus();
515
- break;
516
- }
517
-
518
- const bx = this.bgA ? this.bgA.findActiveBox(p) : null;
519
- if (bx && !bx.isInactive()) {
520
- if (bx.getContent() && bx.getContent().mediaContent === null)
521
- this.playEvent('CLICK');
522
- this.setCurrentCell(bx.idLoc, delayedActions);
523
- }
524
- break;
525
-
526
- case 'change':
527
- event.preventDefault();
528
- this.setCurrentCell(this.currentCell, delayedActions);
529
- break;
530
- }
531
- delayedActions.forEach(action => action());
532
- return false;
533
- }
534
- }
535
- }
536
-
537
- Object.assign(WrittenAnswerPanel.prototype, {
538
- /**
539
- * The input text field where users write the answers
540
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#$textField
541
- * @type {external:jQuery} */
542
- $textField: null,
543
- /**
544
- * Array for storing checked associations
545
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#invAssCheck
546
- * @type {boolean[]} */
547
- invAssCheck: null,
548
- /**
549
- * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} object containing the questions
550
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#bgA
551
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
552
- bgA: null,
553
- /**
554
- * An optional {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with content displayed as cells are solved.
555
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#bgB
556
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
557
- bgB: null,
558
- /**
559
- * The currently selected cell
560
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#currentCell
561
- * @type {number} */
562
- currentCell: -1,
563
- /**
564
- * Mouse events intercepted by this panel
565
- * @override
566
- * @name module:activities/text/WrittenAnswer.WrittenAnswerPanel#events
567
- * @type {string[]} */
568
- events: ['click', 'change'],
569
- });
570
-
571
- /**
572
- * Panel class associated to this type of activity: {@link module:activities/text/WrittenAnswer.WrittenAnswerPanel WrittenAnswerPanel}
573
- * @type {class} */
574
- WrittenAnswer.Panel = WrittenAnswerPanel;
575
-
576
- // Register activity class
577
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I.registerClass('@text.WrittenAnswer', WrittenAnswer));
578
-
579
-
580
- /***/ }),
581
-
582
- /***/ 7781:
583
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
584
-
585
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
586
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
587
- /* harmony export */ });
588
- /* unused harmony export ActiveBoxGrid */
589
- /* harmony import */ var _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(427);
590
- /* harmony import */ var _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1725);
591
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
592
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1253);
593
- /**
594
- * File : boxes/ActiveBoxGrid.js
595
- * Created : 19/05/2015
596
- * By : Francesc Busquets <francesc@gmail.com>
597
- *
598
- * JClic.js
599
- * An HTML5 player of JClic activities
600
- * https://projectestac.github.io/jclic.js
601
- *
602
- * @source https://github.com/projectestac/jclic.js
603
- *
604
- * @license EUPL-1.2
605
- * @licstart
606
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
607
- *
608
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
609
- * the European Commission- subsequent versions of the EUPL (the "Licence");
610
- * You may not use this work except in compliance with the Licence.
611
- *
612
- * You may obtain a copy of the Licence at:
613
- * https://joinup.ec.europa.eu/software/page/eupl
614
- *
615
- * Unless required by applicable law or agreed to in writing, software
616
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
617
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
618
- * Licence for the specific language governing permissions and limitations
619
- * under the Licence.
620
- * @licend
621
- * @module
622
- */
623
-
624
-
625
-
626
-
627
-
628
-
629
- /**
630
- * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type
631
- * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information
632
- * about the number of "rows" and "columns", useful to compute valid (integer) values when
633
- * resizing or moving its components.
634
- * @extends module:boxes/ActiveBoxBag.ActiveBoxBag
635
- */
636
- class ActiveBoxGrid extends _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
637
- /**
638
- * ActiveBxGrid constructor
639
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
640
- * @param {module:AWT.Container} container - The container where this box grid is placed.
641
- * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
642
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
643
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
644
- * @param {number} setWidth - Total width of the box grid
645
- * @param {number} setHeight - Total height of the box grid
646
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
647
- */
648
- constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {
649
- // ActiveBoxGrid derives from ActiveBoxBag
650
- super(parent, container, boxBase);
651
-
652
- this.nCols = sh.nCols;
653
- this.nRows = sh.nRows;
654
-
655
- // This will be the enclosing rectangle of this ActiveBox bag
656
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(
657
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py),
658
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
659
- Math.round(setWidth / this.nCols) * this.nCols,
660
- Math.round(setHeight / this.nRows) * this.nRows));
661
-
662
- // Create all the [ActiveBox](ActiveBox.html) objects based on the
663
- // shapes provided by the [Shaper](Shaper.html)
664
- for (let i = 0; i < sh.nCells; i++) {
665
- const
666
- tmpSh = sh.getShape(i, r),
667
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, i, tmpSh.getBounds());
668
- if (!sh.rectangularShapes)
669
- bx.setShape(tmpSh);
670
- this.addActiveBox(bx);
671
- }
672
-
673
- // If the Shaper has `remainder` (extra space), set the background box of this
674
- // [BoxBag](BoxBag.html)
675
- if (sh.hasRemainder) {
676
- const
677
- tmpSh = sh.getRemainderShape(r),
678
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, 0, tmpSh.getBounds());
679
- bx.setShape(tmpSh);
680
- this.setBackgroundBox(bx);
681
- }
682
- }
683
-
684
- /**
685
- * This factory constructor creates a new empty grid with the number of cells indicated by the
686
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.
687
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
688
- * @param {module:AWT.Container} container - The container where this box grid is placed.
689
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
690
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
691
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)
692
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
693
- * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
694
- * of this box grid are defined.
695
- * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}
696
- */
697
- static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {
698
- const result = abc ? new ActiveBoxGrid(parent, container,
699
- boxBase || abc.style,
700
- px, py,
701
- abc.getTotalWidth(), abc.getTotalHeight(),
702
- sh || abc.getShaper()) : null;
703
-
704
- if (result)
705
- result.setBorder(abc.border);
706
-
707
- return result;
708
- }
709
-
710
- /**
711
- * Gets the minimum size of this grid
712
- * @returns {module:AWT.Dimension}
713
- */
714
- getMinimumSize() {
715
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
716
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nCols,
717
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nRows);
718
- }
719
-
720
- /**
721
- * Gets a scaled size of this grid, rounded to the nearest integer values
722
- * @param {number} scale - The scale factor
723
- * @returns {module:AWT.Dimension}
724
- */
725
- getScaledSize(scale) {
726
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
727
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.width, this.nCols),
728
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.height, this.nRows));
729
- }
730
-
731
- /**
732
- * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
733
- * The units of the result are not pixels, but ordinal numbers (relative positions) of columns
734
- * and rows in the grid.
735
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process
736
- * @returns {module:AWT.Point}
737
- */
738
- getCoord(bx) {
739
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));
740
- }
741
-
742
- /**
743
- * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
744
- * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows
745
- * in the grid.
746
- * @param {module:boxes/ActiveBox.ActiveBox} src - First box
747
- * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box
748
- * @returns {module:AWT.Point}
749
- */
750
- getCoordDist(src, dest) {
751
- const
752
- ptSrc = this.getCoord(src),
753
- ptDest = this.getCoord(dest);
754
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);
755
- }
756
- }
757
-
758
- Object.assign(ActiveBoxGrid.prototype, {
759
- /**
760
- * Number of columns of this box grid
761
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols
762
- * @type {number} */
763
- nCols: 1,
764
- /**
765
- * Number of rows of this box grid
766
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows
767
- * @type {number} */
768
- nRows: 1,
769
- });
770
-
771
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveBoxGrid);
772
-
773
-
774
- /***/ }),
775
-
776
- /***/ 4921:
777
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
778
-
779
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
780
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
781
- /* harmony export */ });
782
- /* unused harmony export Rectangular */
783
- /* harmony import */ var _Shaper_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8276);
784
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7912);
785
- /**
786
- * File : shapers/Rectangular.js
787
- * Created : 19/05/2015
788
- * By : Francesc Busquets <francesc@gmail.com>
789
- *
790
- * JClic.js
791
- * An HTML5 player of JClic activities
792
- * https://projectestac.github.io/jclic.js
793
- *
794
- * @source https://github.com/projectestac/jclic.js
795
- *
796
- * @license EUPL-1.2
797
- * @licstart
798
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
799
- *
800
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
801
- * the European Commission- subsequent versions of the EUPL (the "Licence");
802
- * You may not use this work except in compliance with the Licence.
803
- *
804
- * You may obtain a copy of the Licence at:
805
- * https://joinup.ec.europa.eu/software/page/eupl
806
- *
807
- * Unless required by applicable law or agreed to in writing, software
808
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
809
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
810
- * Licence for the specific language governing permissions and limitations
811
- * under the Licence.
812
- * @licend
813
- * @module
814
- */
815
-
816
-
817
-
818
-
819
- /**
820
- *
821
- * This is the simplest {@link module:shapers/Shaper.Shaper Shaper}. It divides the graphic object in a set of rectangular
822
- * shapes distributed in the specified number of rows and columns.
823
- * @extends module:shapers/Shaper.Shaper
824
- */
825
- class Rectangular extends _Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
826
- /**
827
- * Rectangular constructor
828
- * @param {number} nx - Number of columns
829
- * @param {number} ny - Number of rows
830
- */
831
- constructor(nx, ny) {
832
- super(nx, ny);
833
- }
834
-
835
- /**
836
- * Builds the rectangular shapes based on the number of rows and columns
837
- * @override
838
- */
839
- buildShapes() {
840
- const
841
- w = 1 / this.nCols,
842
- h = 1 / this.nRows;
843
- for (let y = 0; y < this.nRows; y++) {
844
- for (let x = 0; x < this.nCols; x++) {
845
- this.shapeData[y * this.nCols + x] = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(x * w, y * h), new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(w, h));
846
- }
847
- }
848
- this.initiated = true;
849
- }
850
- }
851
-
852
- Object.assign(Rectangular.prototype, {
853
- /**
854
- * Overrides same flag in {@link module:/shapers/Shaper.Shaper#rectangularShapes Shaper#rectangularShapes}
855
- * @name module:shapers/Rectangular.Rectangular#rectangularShapes
856
- * @override
857
- * @type {boolean} */
858
- rectangularShapes: true,
859
- });
860
-
861
- // Register this class in the list of known shapers
862
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"].registerClass('@Rectangular', Rectangular));
863
-
864
-
865
- /***/ })
866
-
867
- };
868
- ;
869
- //# sourceMappingURL=2531.jclic-node.js.map