jclic 2.2.1 → 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 -672
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31680
  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 -660
  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,360 +0,0 @@
1
- /**
2
- * File : activities/puzzles/HolePuzzle.js
3
- * Created : 01/06/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 { Rectangle, Point } from '../../AWT.js';
37
- import Rectangular from '../../shapers/Rectangular.js';
38
-
39
- /**
40
- * This class of {@link module:Activity.Activity Activity} shows only one panel with shuffled {@link module:boxes/ActiveBox.ActiveBox ActiveBox} cells.
41
- *
42
- * One of the cells is out of the main panel, thus allowing its neighbors occupy their space.
43
- * Only immediate neighbors of the "hole" can move into it.
44
- *
45
- * When all cells are on place, the initially "expulsed" cell comes back home and the activity is done.
46
- * @extends module:Activity.Activity
47
- */
48
- export class HolePuzzle extends Activity {
49
- /**
50
- * HolePuzzle constructor
51
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
52
- */
53
- constructor(project) {
54
- super(project);
55
- }
56
-
57
- /**
58
- * Retrieves the minimum number of actions needed to solve this activity.
59
- * @override
60
- * @returns {number}
61
- */
62
- getMinNumActions() {
63
- return this.abc.primary.getNumCells();
64
- }
65
-
66
- /**
67
- * Whether or not the activity uses random to shuffle internal components
68
- * @override
69
- * @returns {boolean}
70
- */
71
- hasRandom() {
72
- return true;
73
- }
74
-
75
- /**
76
- * When `true`, the activity must always be shuffled
77
- * @override
78
- * @returns {boolean}
79
- */
80
- shuffleAlways() {
81
- return true;
82
- }
83
-
84
- /**
85
- * Whether the activity allows the user to request help
86
- * @override
87
- * @returns {boolean}
88
- */
89
- helpSolutionAllowed() {
90
- return true;
91
- }
92
- }
93
-
94
- /**
95
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/puzzles/HolePuzzle.HolePuzzle HolePuzzle} activities are played
96
- * @extends module:Activity.ActivityPanel
97
- */
98
- export class HolePuzzlePanel extends ActivityPanel {
99
- /**
100
- * HolePuzzlePanel constructor
101
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
102
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
103
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
104
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
105
- */
106
- constructor(act, ps, $div) {
107
- super(act, ps, $div);
108
- }
109
-
110
- /**
111
- * Miscellaneous cleaning operations
112
- * @override
113
- */
114
- clear() {
115
- if (this.bg) {
116
- this.bg.end();
117
- this.bg = null;
118
- }
119
- if (this.parkBg) {
120
- this.parkBg.end();
121
- this.parkBg = null;
122
- }
123
- }
124
-
125
- /**
126
- * Prepares the visual components of the activity
127
- * @override
128
- */
129
- buildVisualComponents() {
130
- if (this.firstRun)
131
- super.buildVisualComponents();
132
- this.clear();
133
-
134
- const abc = this.act.abc['primary'];
135
- if (abc) {
136
- if (abc.image)
137
- abc.setImgContent(this.act.project.mediaBag, null, false);
138
-
139
- if (this.act.acp !== null)
140
- this.act.acp.generateContent(abc.nch, abc.ncw, [abc], false);
141
-
142
- this.bg = ActiveBoxGrid.createEmptyGrid(null, this, this.act.margin, this.act.margin, abc);
143
- this.bg.setContent(abc);
144
- this.bg.setVisible(true);
145
-
146
- this.hiddenBoxIndex = Math.floor(Math.random() * this.bg.getNumCells());
147
- this.hiddenBox = this.bg.getActiveBox(this.hiddenBoxIndex);
148
- this.hiddenBox.setVisible(false);
149
- this.parkBg = new ActiveBoxGrid(null, this, abc.style, this.act.margin, this.act.margin,
150
- this.hiddenBox.dim.width, this.hiddenBox.dim.height, new Rectangular(1, 1));
151
- this.parkBg.setContent(abc, null, this.hiddenBoxIndex, 0, 1);
152
- this.parkBg.setBorder(this.bg.hasBorder());
153
- this.parkBg.setVisible(true);
154
- }
155
- }
156
-
157
- /**
158
- * Basic initialization procedure
159
- * @override
160
- */
161
- initActivity() {
162
- super.initActivity();
163
- if (!this.firstRun)
164
- this.buildVisualComponents();
165
- else
166
- this.firstRun = false;
167
-
168
- if (this.bg) {
169
- //
170
- // This activity has an special shuffle method. Cells can move only to places near the 'hole'
171
- if (this.act.shuffles % 2 !== 1)
172
- this.act.shuffles++;
173
- for (var i = 0; i < this.act.shuffles; i++) {
174
- const pth = this.bg.getCoord(this.hiddenBox);
175
- const v = Math.floor(Math.random() * 2) === 0 ? 1 : -1;
176
-
177
- if (Math.floor(Math.random() * 2) === 0) {
178
- pth.x += v;
179
- if (pth.x < 0 || pth.x >= this.bg.nCols)
180
- pth.x -= 2 * v;
181
- } else {
182
- pth.y += v;
183
- if (pth.y < 0 || pth.y >= this.bg.nRows)
184
- pth.y -= 2 * v;
185
- }
186
- var dstBx = this.bg.getActiveBoxWithIdLoc(pth.y * this.bg.nCols + pth.x);
187
- if (dstBx !== null)
188
- this.hiddenBox.exchangeLocation(dstBx);
189
- }
190
- this.setAndPlayMsg('initial', 'start');
191
- this.invalidate().update();
192
- this.playing = true;
193
- }
194
- }
195
-
196
- /**
197
- * Updates the graphic content of this panel.
198
- * This method will be called from {@link module:AWT.Container#update} when needed.
199
- * @override
200
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
201
- * it's the whole panel.
202
- */
203
- updateContent(dirtyRegion) {
204
- super.updateContent(dirtyRegion);
205
- if (this.bg && this.parkBg && this.$canvas) {
206
- const
207
- canvas = this.$canvas.get(-1),
208
- ctx = canvas.getContext('2d');
209
- if (!dirtyRegion)
210
- dirtyRegion = new Rectangle(0, 0, canvas.width, canvas.height);
211
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
212
- this.bg.update(ctx, dirtyRegion);
213
- this.parkBg.update(ctx, dirtyRegion);
214
- }
215
- return this;
216
- }
217
-
218
- /**
219
- * Sets the real dimension of this panel.
220
- * @override
221
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
222
- * @returns {module:AWT.Dimension}
223
- */
224
- setDimension(preferredMaxSize) {
225
- return !this.bg || !this.parkBg || this.getBounds().equals(preferredMaxSize) ?
226
- preferredMaxSize :
227
- BoxBag.layoutDouble(preferredMaxSize, this.bg, this.parkBg, this.act.boxGridPos, this.act.margin);
228
- }
229
-
230
- /**
231
- * Sets the size and position of this activity panel
232
- * @override
233
- * @param {module:AWT.Rectangle} rect
234
- */
235
- setBounds(rect) {
236
- if (this.$canvas)
237
- this.$canvas.remove();
238
-
239
- super.setBounds(rect);
240
- if (this.bg && this.parkBg) {
241
- // Create the main canvas
242
- this.$canvas = $(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
243
- position: 'absolute',
244
- top: 0,
245
- left: 0
246
- });
247
- this.$div.append(this.$canvas);
248
-
249
- // Repaint all
250
- this.invalidate().update();
251
- }
252
- }
253
-
254
- /**
255
- * Builds the accessible components needed for this ActivityPanel
256
- * This method is called when all main elements are placed and visible, when the activity is ready
257
- * to start or when resized.
258
- * @override
259
- */
260
- buildAccessibleComponents() {
261
- if (this.$canvas && this.accessibleCanvas && this.bg) {
262
- super.buildAccessibleComponents();
263
- this.bg.buildAccessibleElements(this.$canvas, this.$div);
264
- }
265
- }
266
-
267
- /**
268
- * Main handler used to process mouse, touch, keyboard and edit events
269
- * @override
270
- * @param {external:Event} event - The HTML event to be processed
271
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
272
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
273
- */
274
- processEvent(event) {
275
- if (this.playing) {
276
- const p = new Point(
277
- event.pageX - this.$div.offset().left,
278
- event.pageY - this.$div.offset().top);
279
- // Array to be filled with actions to be executed at the end of event processing
280
- const delayedActions = [];
281
-
282
- switch (event.type) {
283
- case 'click':
284
- this.ps.stopMedia(1);
285
- // Find the box behind the clicked point
286
- const bx = this.bg.findActiveBox(p);
287
- if (bx) {
288
- if (bx.isVisible()) {
289
- // Check if it's a valid move
290
- const pt = this.bg.getCoordDist(bx, this.hiddenBox);
291
- if (Math.abs(pt.x) + Math.abs(pt.y) === 1) {
292
- // Ok, the cell is adjacent to the hole. Complete the move.
293
- let m = bx.playMedia(this.ps, delayedActions);
294
- const
295
- src = `${bx.getDescription()} (${bx.idOrder})`,
296
- dest = `(${this.hiddenBox.idLoc})`;
297
- bx.exchangeLocation(this.hiddenBox);
298
- const ok = bx.idOrder === bx.idLoc;
299
- // Check results and notify action
300
- const cellsAtPlace = this.bg.countCellsAtEquivalentPlace(true);
301
- this.ps.reportNewAction(this.act, 'SELECT', src, dest, ok, cellsAtPlace);
302
- if (ok && cellsAtPlace === this.bg.getNumCells()) {
303
- // Activity completed!
304
- this.hiddenBox.setVisible(true);
305
- this.parkBg.setVisible(false);
306
- this.finishActivity(true);
307
- } else
308
- if (!m)
309
- this.playEvent('click');
310
- }
311
- this.update();
312
- } else {
313
- this.playEvent('actionError');
314
- }
315
- }
316
- break;
317
- }
318
- delayedActions.forEach(action => action());
319
- event.preventDefault();
320
- }
321
- }
322
- }
323
-
324
- Object.assign(HolePuzzlePanel.prototype, {
325
- /**
326
- * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} object containing the information to be displayed in the panel.
327
- * @name module:activities/puzzles/HolePuzzle.HolePuzzlePanel#bg
328
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
329
- bg: null,
330
- /**
331
- * An auxiliary box bag with only one box, used to store the "missing piece" of
332
- * the puzzle.
333
- * @name module:activities/puzzles/HolePuzzle.HolePuzzlePanel#parkBg
334
- * @type {module:boxes/ActiveBoxGrid.ActiveBoxGrid} */
335
- parkBg: null,
336
- /**
337
- * The hidden cell
338
- * @name module:activities/puzzles/HolePuzzle.HolePuzzlePanel#hiddenBox
339
- * @type {module:boxes/ActiveBox.ActiveBox} */
340
- hiddenBox: null,
341
- /**
342
- * Index of the hidden cell on the ActiveBagContent
343
- * @name module:activities/puzzles/HolePuzzle.HolePuzzlePanel#hiddenBoxIndex
344
- * @type {number} */
345
- hiddenBoxIndex: -1,
346
- /**
347
- * List of mouse, touch and keyboard events intercepted by this panel
348
- * @override
349
- * @name module:activities/puzzles/HolePuzzle.HolePuzzlePanel#events
350
- * @type {string[]} */
351
- events: ['click'],
352
- });
353
-
354
- /**
355
- * Panel class associated to this type of activity: {@link module:activities/puzzles/HolePuzzle.HolePuzzlePanel HolePuzzlePanel}
356
- * @type {class} */
357
- HolePuzzle.Panel = HolePuzzlePanel;
358
-
359
- // Register activity class
360
- export default Activity.registerClass('@puzzles.HolePuzzle', HolePuzzle);
@@ -1,127 +0,0 @@
1
- /**
2
- * File : activities/text/Complete.js
3
- * Created : 20/06/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 Activity from '../../Activity.js';
33
- import { TextActivityBase, TextActivityBasePanel } from './TextActivityBase.js';
34
-
35
- /**
36
- * This type of text activity suggests users to complete a given text, without any help on where to
37
- * write the missing words or phrases.
38
- * @extends module:activities/text/TextActivityBase.TextActivityBase
39
- */
40
- export class Complete extends TextActivityBase {
41
- /**
42
- * Complete constructor
43
- * @param {module:project/JClicProject.JClicProject} project - The project to which this activity belongs
44
- */
45
- constructor(project) {
46
- super(project);
47
- }
48
- }
49
-
50
- /**
51
- * The {@link module:activities/text/TextActivityBase.TextActivityBasePanel TextActivityBasePanel} where {@link module:activities/text/Complete.Complete Complete} activities are played.
52
- * @extends module:activities/text/TextActivityBasePanel.TextActivityBasePanel
53
- */
54
- export class CompletePanel extends TextActivityBasePanel {
55
- /**
56
- * CompletePanel constructor
57
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
58
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
59
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
60
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
61
- */
62
- constructor(act, ps, $div) {
63
- super(act, ps, $div);
64
- }
65
-
66
- /**
67
- * Creates a target DOM element for the provided target.
68
- * @override
69
- * @param {module:activities/text/TextActivityDocument.TextTarget} _target - The target related to the DOM object to be created
70
- * @param {external:jQuery} _$span - - An initial DOM object (usually a `span`) that can be used
71
- * to store the target, or replaced by another type of object.
72
- * @returns {external:jQuery} - The jQuery DOM element loaded with the target data.
73
- */
74
- $createTargetElement(_target, _$span) {
75
- // Targets are always hidden in this type of activities
76
- return null;
77
- }
78
-
79
- /**
80
- * Called when the activity starts playing
81
- * @override
82
- */
83
- startActivity() {
84
- super.startActivity();
85
- this.$div.find('.JClicTextDocument').attr('contenteditable', 'true').attr('spellcheck', 'false');
86
- }
87
-
88
- /**
89
- * Evaluates all the targets in this panel. This method is usually called from the `Check` button.
90
- * @override
91
- * @returns {boolean} - `true` when all targets are OK, `false` otherwise.
92
- */
93
- evaluatePanel() {
94
- // TODO: Mark errors!
95
- const
96
- currentText = this.$div.find('.JClicTextDocument').text().trim(),
97
- originalText = this.act.document.getRawText(),
98
- ok = this.act.ev.checkText(currentText, originalText);
99
-
100
- this.ps.reportNewAction(this.act, 'WRITE', currentText, originalText, ok, this.targets.length);
101
-
102
- if (ok) {
103
- this.finishActivity(true);
104
- return true;
105
- } else {
106
- this.playEvent('finishedError');
107
- }
108
- return false;
109
- }
110
-
111
- /**
112
- * Ordinary ending of the activity, usually called form `processEvent`
113
- * @param {boolean} result - `true` if the activity was successfully completed, `false` otherwise
114
- */
115
- finishActivity(result) {
116
- this.$div.find('.JClicTextDocument').attr('contenteditable', 'false');
117
- return super.finishActivity(result);
118
- }
119
- }
120
-
121
- /**
122
- * Panel class associated to this type of activity: {@link module:activities/text/Complete.CompletePanel CompletePanel}
123
- * @type {class} */
124
- Complete.Panel = CompletePanel;
125
-
126
- // Register activity class
127
- export default Activity.registerClass('@text.Complete', Complete);