jclic 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +5 -7
  2. package/dist-node/jclic-node.js +14157 -0
  3. package/dist-node/jclic-node.umd.cjs +530 -0
  4. package/package.json +38 -26
  5. package/.vscode/launch.json +0 -33
  6. package/.vscode/settings.json +0 -13
  7. package/CHANGELOG.md +0 -664
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31678
  11. package/dist/jclic-node.js.map +0 -1
  12. package/dist/jclic.components.LICENSE +0 -2254
  13. package/dist/jclic.min.js +0 -27
  14. package/dist/jclic.min.js.map +0 -1
  15. package/eslint.config.mjs +0 -31
  16. package/jsdoc.config.js +0 -71
  17. package/locales/ar.po +0 -244
  18. package/locales/ast.po +0 -246
  19. package/locales/bs.po +0 -247
  20. package/locales/ca.po +0 -248
  21. package/locales/ca_ES@valencia.po +0 -248
  22. package/locales/cs.po +0 -244
  23. package/locales/da.po +0 -244
  24. package/locales/de.po +0 -246
  25. package/locales/el.po +0 -244
  26. package/locales/es.po +0 -248
  27. package/locales/eu.po +0 -244
  28. package/locales/fr.po +0 -244
  29. package/locales/gl.po +0 -244
  30. package/locales/he.po +0 -244
  31. package/locales/hr.po +0 -245
  32. package/locales/it.po +0 -246
  33. package/locales/ja.po +0 -242
  34. package/locales/jclic.js.pot +0 -241
  35. package/locales/nb_NO.po +0 -244
  36. package/locales/nl.po +0 -244
  37. package/locales/pl.po +0 -244
  38. package/locales/pt.po +0 -244
  39. package/locales/pt_BR.po +0 -248
  40. package/locales/ro.po +0 -248
  41. package/locales/ru.po +0 -245
  42. package/locales/ta.po +0 -244
  43. package/locales/tr.po +0 -246
  44. package/locales/uk.po +0 -247
  45. package/locales/vec.po +0 -244
  46. package/locales/zh_TW.po +0 -246
  47. package/patches/po2json+1.0.0-beta-3.patch +0 -12
  48. package/src/AWT.js +0 -2067
  49. package/src/Activity.js +0 -1311
  50. package/src/Deps.js +0 -232
  51. package/src/GlobalData.js +0 -5
  52. package/src/JClic.js +0 -196
  53. package/src/JClicPlayer.js +0 -1308
  54. package/src/PlayerHistory.js +0 -305
  55. package/src/Utils.js +0 -1355
  56. package/src/activities/associations/ComplexAssociation.js +0 -321
  57. package/src/activities/associations/SimpleAssociation.js +0 -519
  58. package/src/activities/memory/MemoryGame.js +0 -423
  59. package/src/activities/panels/Explore.js +0 -349
  60. package/src/activities/panels/Identify.js +0 -356
  61. package/src/activities/panels/InformationScreen.js +0 -262
  62. package/src/activities/panels/Menu.js +0 -209
  63. package/src/activities/panels/icons/ico00.png +0 -0
  64. package/src/activities/panels/icons/ico01.png +0 -0
  65. package/src/activities/panels/icons/ico02.png +0 -0
  66. package/src/activities/panels/icons/ico03.png +0 -0
  67. package/src/activities/panels/icons/icofolder.png +0 -0
  68. package/src/activities/puzzles/DoublePuzzle.js +0 -424
  69. package/src/activities/puzzles/ExchangePuzzle.js +0 -374
  70. package/src/activities/puzzles/HolePuzzle.js +0 -360
  71. package/src/activities/text/Complete.js +0 -127
  72. package/src/activities/text/Evaluator.js +0 -534
  73. package/src/activities/text/FillInBlanks.js +0 -426
  74. package/src/activities/text/IdentifyText.js +0 -253
  75. package/src/activities/text/OrderText.js +0 -421
  76. package/src/activities/text/TextActivityBase.js +0 -557
  77. package/src/activities/text/TextActivityDocument.js +0 -658
  78. package/src/activities/text/WrittenAnswer.js +0 -557
  79. package/src/activities/textGrid/CrossWord.js +0 -565
  80. package/src/activities/textGrid/WordSearch.js +0 -458
  81. package/src/activities/textGrid/icons/hIcon.svg +0 -3
  82. package/src/activities/textGrid/icons/vIcon.svg +0 -3
  83. package/src/automation/AutoContentProvider.js +0 -182
  84. package/src/automation/arith/Arith.js +0 -864
  85. package/src/bags/ActivitySequence.js +0 -318
  86. package/src/bags/ActivitySequenceElement.js +0 -161
  87. package/src/bags/ActivitySequenceJump.js +0 -140
  88. package/src/bags/ConditionalJumpInfo.js +0 -113
  89. package/src/bags/JumpInfo.js +0 -136
  90. package/src/bags/MediaBag.js +0 -215
  91. package/src/bags/MediaBagElement.js +0 -516
  92. package/src/boxes/AbstractBox.js +0 -699
  93. package/src/boxes/ActiveBagContent.js +0 -494
  94. package/src/boxes/ActiveBox.js +0 -810
  95. package/src/boxes/ActiveBoxBag.js +0 -357
  96. package/src/boxes/ActiveBoxContent.js +0 -484
  97. package/src/boxes/ActiveBoxGrid.js +0 -179
  98. package/src/boxes/BoxBag.js +0 -500
  99. package/src/boxes/BoxBase.js +0 -398
  100. package/src/boxes/BoxConnector.js +0 -325
  101. package/src/boxes/TextGrid.js +0 -887
  102. package/src/boxes/TextGridContent.js +0 -215
  103. package/src/init-jsdom.js +0 -65
  104. package/src/jclic-node.js +0 -219
  105. package/src/media/ActiveMediaBag.js +0 -145
  106. package/src/media/ActiveMediaPlayer.js +0 -297
  107. package/src/media/AudioBuffer.js +0 -219
  108. package/src/media/EventSounds.js +0 -169
  109. package/src/media/EventSoundsElement.js +0 -155
  110. package/src/media/MediaContent.js +0 -328
  111. package/src/media/MidiAudioPlayer.js +0 -254
  112. package/src/media/icons/audio.svg +0 -3
  113. package/src/media/icons/generic.svg +0 -3
  114. package/src/media/icons/mic.svg +0 -3
  115. package/src/media/icons/movie.svg +0 -3
  116. package/src/media/icons/music.svg +0 -3
  117. package/src/media/icons/url.svg +0 -3
  118. package/src/media/sounds/actionError.mp3 +0 -0
  119. package/src/media/sounds/actionOk.mp3 +0 -0
  120. package/src/media/sounds/click.mp3 +0 -0
  121. package/src/media/sounds/finishedError.mp3 +0 -0
  122. package/src/media/sounds/finishedOk.mp3 +0 -0
  123. package/src/media/sounds/start.mp3 +0 -0
  124. package/src/project/JClicProject.js +0 -282
  125. package/src/project/ProjectSettings.js +0 -273
  126. package/src/report/ActionReg.js +0 -123
  127. package/src/report/ActivityReg.js +0 -271
  128. package/src/report/EncryptMin.js +0 -210
  129. package/src/report/Reporter.js +0 -727
  130. package/src/report/SCORM.js +0 -272
  131. package/src/report/SequenceReg.js +0 -275
  132. package/src/report/SessionReg.js +0 -340
  133. package/src/report/SessionStorageReporter.js +0 -131
  134. package/src/report/TCPReporter.js +0 -628
  135. package/src/shapers/ClassicJigSaw.js +0 -138
  136. package/src/shapers/Holes.js +0 -77
  137. package/src/shapers/JigSaw.js +0 -161
  138. package/src/shapers/Rectangular.js +0 -78
  139. package/src/shapers/Shaper.js +0 -386
  140. package/src/shapers/TriangularJigSaw.js +0 -121
  141. package/src/skins/BlueSkin.js +0 -80
  142. package/src/skins/Counter.js +0 -152
  143. package/src/skins/CustomSkin.js +0 -412
  144. package/src/skins/DefaultSkin.js +0 -376
  145. package/src/skins/EmptySkin.js +0 -82
  146. package/src/skins/GreenSkin.js +0 -94
  147. package/src/skins/MiniSkin.js +0 -130
  148. package/src/skins/OrangeSkin.js +0 -78
  149. package/src/skins/SimpleSkin.js +0 -92
  150. package/src/skins/Skin.js +0 -1021
  151. package/src/skins/assets/actionsIcon.svg +0 -3
  152. package/src/skins/assets/appLogo.svg +0 -8
  153. package/src/skins/assets/basic.css +0 -41
  154. package/src/skins/assets/closeDialogIcon.svg +0 -3
  155. package/src/skins/assets/closeIcon.svg +0 -3
  156. package/src/skins/assets/copyIcon.svg +0 -3
  157. package/src/skins/assets/fullScreenExitIcon.svg +0 -3
  158. package/src/skins/assets/fullScreenIcon.svg +0 -3
  159. package/src/skins/assets/infoIcon.svg +0 -3
  160. package/src/skins/assets/main.css +0 -43
  161. package/src/skins/assets/mainHalf.css +0 -23
  162. package/src/skins/assets/mainTwoThirds.css +0 -23
  163. package/src/skins/assets/mini.css +0 -15
  164. package/src/skins/assets/nextIcon.svg +0 -3
  165. package/src/skins/assets/okDialogIcon.svg +0 -3
  166. package/src/skins/assets/prevIcon.svg +0 -3
  167. package/src/skins/assets/reports.css +0 -156
  168. package/src/skins/assets/reportsIcon.svg +0 -3
  169. package/src/skins/assets/scoreIcon.svg +0 -3
  170. package/src/skins/assets/simple.css +0 -16
  171. package/src/skins/assets/simpleHalf.css +0 -11
  172. package/src/skins/assets/simpleTwoThirds.css +0 -11
  173. package/src/skins/assets/timeIcon.svg +0 -4
  174. package/src/skins/assets/waitAnim.css +0 -54
  175. package/src/skins/assets/waitImgBig.svg +0 -3
  176. package/src/skins/assets/waitImgSmall.svg +0 -3
  177. package/webpack.config.mjs +0 -169
@@ -1,374 +0,0 @@
1
- /**
2
- * File : activities/puzzles/ExchangePuzzle.js
3
- * Created : 30/05/2015
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- import $ from 'jquery';
33
- import { Activity, ActivityPanel } from '../../Activity.js';
34
- import ActiveBoxGrid from '../../boxes/ActiveBoxGrid.js';
35
- import BoxBag from '../../boxes/BoxBag.js';
36
- import BoxConnector from '../../boxes/BoxConnector.js';
37
- import { Rectangle, Point } from '../../AWT.js';
38
-
39
- /**
40
- * This class of {@link module:Activity.Activity Activity} shows only one panel with shuffled {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
41
- * To solve the activity, each cell must exchange its location with another one. When all cells are
42
- * on place, the activity is done.
43
- * @extends module:Activity.Activity
44
- */
45
- export class ExchangePuzzle extends Activity {
46
- /**
47
- * ExchangePuzzle constructor
48
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
49
- */
50
- constructor(project) {
51
- super(project);
52
- }
53
-
54
- /**
55
- * Retrieves the minimum number of actions needed to solve this activity.
56
- * @override
57
- * @returns {number}
58
- */
59
- getMinNumActions() {
60
- return this.abc.primary.getNumCells();
61
- }
62
-
63
- /**
64
- * Whether or not the activity uses random to shuffle internal components
65
- * @override
66
- * @returns {boolean}
67
- */
68
- hasRandom() {
69
- return true;
70
- }
71
-
72
- /**
73
- * When `true`, the activity must always be shuffled
74
- * @override
75
- * @returns {boolean}
76
- */
77
- shuffleAlways() {
78
- return true;
79
- }
80
-
81
- /**
82
- * Whether the activity allows the user to request help.
83
- * @override
84
- * @returns {boolean}
85
- */
86
- helpSolutionAllowed() {
87
- return true;
88
- }
89
- }
90
-
91
- /**
92
- * The {@link module:Activity.ActivityPanel ActivityPanel} where activities of type {@link module:activities/puzzles/ExchangePuzzle.ExchangePuzzle ExchangePuzzle} are played.
93
- * @extends module:Activity.ActivityPanel
94
- */
95
- class ExchangePuzzlePanel extends ActivityPanel {
96
- /**
97
- * ExchangePuzzlePanel constructor
98
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
99
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
100
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
101
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
102
- */
103
- constructor(act, ps, $div) {
104
- super(act, ps, $div);
105
- }
106
-
107
- /**
108
- * Miscellaneous cleaning operations
109
- * @override
110
- */
111
- clear() {
112
- if (this.bg) {
113
- this.bg.end();
114
- this.bg = null;
115
- }
116
- }
117
-
118
- /**
119
- * Prepares the visual components of the activity
120
- * @override
121
- */
122
- buildVisualComponents() {
123
- if (this.firstRun)
124
- super.buildVisualComponents();
125
- this.clear();
126
-
127
- const abc = this.act.abc['primary'];
128
- if (abc) {
129
- if (abc.image)
130
- abc.setImgContent(this.act.project.mediaBag, null, false);
131
-
132
- if (this.act.acp !== null)
133
- this.act.acp.generateContent(abc.nch, abc.ncw, [abc], false);
134
-
135
- this.bg = ActiveBoxGrid.createEmptyGrid(null, this, this.act.margin, this.act.margin, abc);
136
- this.bg.setContent(abc);
137
- this.bg.setVisible(true);
138
- }
139
- }
140
-
141
- /**
142
- * Basic initialization procedure
143
- * @override
144
- */
145
- initActivity() {
146
- super.initActivity();
147
- if (!this.firstRun)
148
- this.buildVisualComponents();
149
- else
150
- this.firstRun = false;
151
-
152
- if (this.bg) {
153
- this.shuffle([this.bg], true, true);
154
- if (this.useOrder)
155
- this.currentItem = this.bg.getNextItem(-1);
156
- this.setAndPlayMsg('initial', 'start');
157
- this.invalidate().update();
158
- this.playing = true;
159
- }
160
- }
161
-
162
- /**
163
- * Updates the graphic content of this panel.
164
- * This method will be called from {@link module:AWT.Container#update} when needed.
165
- * @override
166
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
167
- * it's the whole panel.
168
- */
169
- updateContent(dirtyRegion) {
170
- super.updateContent(dirtyRegion);
171
- if (this.bg && this.$canvas) {
172
- const
173
- canvas = this.$canvas.get(-1),
174
- ctx = canvas.getContext('2d');
175
- if (!dirtyRegion)
176
- dirtyRegion = new Rectangle(0, 0, canvas.width, canvas.height);
177
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
178
- this.bg.update(ctx, dirtyRegion);
179
- }
180
- return this;
181
- }
182
-
183
- /**
184
- * Sets the real dimension of this panel.
185
- * @override
186
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
187
- * @returns {module:AWT.Dimension}
188
- */
189
- setDimension(preferredMaxSize) {
190
- return !this.bg || this.getBounds().equals(preferredMaxSize) ?
191
- preferredMaxSize :
192
- BoxBag.layoutSingle(preferredMaxSize, this.bg, this.act.margin);
193
- }
194
-
195
- /**
196
- * Sets the size and position of this activity panel
197
- * @override
198
- * @param {module:AWT.Rectangle} rect
199
- */
200
- setBounds(rect) {
201
- if (this.$canvas)
202
- this.$canvas.remove();
203
-
204
- super.setBounds(rect);
205
- if (this.bg) {
206
- // Create the main canvas
207
- this.$canvas = $(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
208
- position: 'absolute',
209
- top: 0,
210
- left: 0
211
- });
212
- this.$div.append(this.$canvas);
213
-
214
- // Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
215
- this.bc = new BoxConnector(this, this.$canvas);
216
-
217
- // Repaint all
218
- this.invalidate().update();
219
- }
220
- }
221
-
222
- /**
223
- * Builds the accessible components needed for this ActivityPanel
224
- * This method is called when all main elements are placed and visible, when the activity is ready
225
- * to start or when resized.
226
- * @override
227
- */
228
- buildAccessibleComponents() {
229
- if (this.$canvas && this.accessibleCanvas && this.bg) {
230
- super.buildAccessibleComponents();
231
- this.bg.buildAccessibleElements(this.$canvas, this.$div, 'mousedown');
232
- }
233
- }
234
-
235
- /**
236
- * Main handler used to process mouse, touch, keyboard and edit events
237
- * @override
238
- * @param {external:Event} event - The HTML event to be processed
239
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
240
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
241
- */
242
- processEvent(event) {
243
- if (this.bc && this.playing) {
244
-
245
- //
246
- // The [AWT.Point](AWT.html#Point) where the mouse or touch event has been originated
247
- let p = null;
248
- //
249
- // Two [ActiveBox](ActiveBox.html) pointers used for the [BoxConnector](BoxConnector.html)
250
- // `origin` and `dest` points.
251
- let bx1, bx2;
252
- // Array to be filled with actions to be executed at the end of event processing
253
- const delayedActions = [];
254
- //
255
- // _touchend_ event don't provide pageX nor pageY information
256
- if (event.type === 'touchend')
257
- p = this.bc.active ? this.bc.dest.clone() : new Point();
258
- else {
259
- // Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
260
- const
261
- x = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
262
- y = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
263
- p = new Point(x - this.$div.offset().left, y - this.$div.offset().top);
264
- }
265
-
266
- // Flag for tracking `mouseup` events
267
- let up = false;
268
-
269
- switch (event.type) {
270
- case 'touchcancel':
271
- // Canvel movement
272
- if (this.bc.active)
273
- this.bc.end();
274
- break;
275
-
276
- case 'mouseup':
277
- // Don't consider drag moves below 3 pixels. Can be a "trembling click"
278
- if (this.bc.active && p.distanceTo(this.bc.origin) <= 3)
279
- break;
280
-
281
- up = true;
282
- /* falls through */
283
- case 'touchend':
284
- case 'touchstart':
285
- case 'mousedown':
286
- if (!this.bc.active) {
287
- // New pairing starts
288
- //
289
- // Pairings never can start with a `mouseup` event
290
- if (up)
291
- break;
292
-
293
- this.ps.stopMedia(1);
294
- // Find the ActiveBox behind the clicked point
295
- bx1 = this.bg.findActiveBox(p);
296
- if (bx1) {
297
- // Start the [BoxConnector](BoxConnector.html)
298
- if (this.act.dragCells)
299
- this.bc.begin(p, bx1);
300
- else
301
- this.bc.begin(p);
302
- // Play cell media or event sound
303
- if (!bx1.playMedia(this.ps, delayedActions))
304
- this.playEvent('click');
305
- }
306
- } else {
307
- this.ps.stopMedia(1);
308
- // Pairing completed
309
- //
310
- // Find the active boxes behind `bc.origin` and `p`
311
- if (this.act.dragCells)
312
- bx1 = this.bc.bx;
313
- else
314
- bx1 = this.bg.findActiveBox(this.bc.origin);
315
- this.bc.end();
316
- bx2 = this.bg.findActiveBox(p);
317
- //
318
- // Check if the pairing was OK
319
- if (bx1 && bx2) {
320
- const
321
- src = `${bx1.getDescription()} (${bx1.idOrder})`,
322
- dest = `(${bx2.idLoc})`;
323
- let ok = (bx1.idOrder === bx2.idLoc);
324
- this.bg.swapCellPositions(bx1, bx2, true);
325
- // Check results and notify action
326
- const cellsAtPlace = this.bg.countCellsAtEquivalentPlace(true);
327
- this.ps.reportNewAction(this.act, 'PLACE', src, dest, ok, cellsAtPlace);
328
- // End activity or play event sound
329
- if (ok && cellsAtPlace === this.bg.getNumCells())
330
- this.finishActivity(true);
331
- else
332
- this.playEvent(ok ? 'actionOk' : 'actionError');
333
- }
334
- this.update();
335
- }
336
- break;
337
-
338
- case 'mousemove':
339
- case 'touchmove':
340
- this.bc.moveTo(p);
341
- break;
342
- }
343
- delayedActions.forEach(action => action());
344
- event.preventDefault();
345
- }
346
- }
347
- }
348
-
349
- Object.assign(ExchangePuzzlePanel.prototype, {
350
- /**
351
- * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} object containing the information to be displayed in the panel.
352
- * @name module:activities/puzzles/ExchangePuzzle.ExchangePuzzlePanel#bg
353
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
354
- bg: null,
355
- /**
356
- * The box connector
357
- * @name module:activities/puzzles/ExchangePuzzle.ExchangePuzzlePanel#bc
358
- * @type {module:boxes/BoxConnector.BoxConnector} */
359
- bc: null,
360
- /**
361
- * List of mouse, touch and keyboard events intercepted by this panel
362
- * @override
363
- * @name module:activities/puzzles/ExchangePuzzle.ExchangePuzzlePanel#events
364
- * @type {string[]} */
365
- events: ['mousedown', 'mouseup', 'mousemove', 'touchstart', 'touchend', 'touchmove', 'touchcancel'],
366
- });
367
-
368
- /**
369
- * Panel class associated to this type of activity: {@link module:activities/puzzles/ExchangePuzzle.ExchangePuzzlePanel ExchangePuzzlePanel}
370
- * @type {class} */
371
- ExchangePuzzle.Panel = ExchangePuzzlePanel;
372
-
373
- // Register activity class
374
- export default Activity.registerClass('@puzzles.ExchangePuzzle', ExchangePuzzle);