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.
- package/README.md +5 -7
- package/dist-node/jclic-node.js +14157 -0
- package/dist-node/jclic-node.umd.cjs +530 -0
- package/package.json +38 -26
- package/.vscode/launch.json +0 -33
- package/.vscode/settings.json +0 -13
- package/CHANGELOG.md +0 -664
- package/TRANSLATIONS.md +0 -11
- package/build-locales.mjs +0 -82
- package/dist/jclic-node.js +0 -31678
- package/dist/jclic-node.js.map +0 -1
- package/dist/jclic.components.LICENSE +0 -2254
- package/dist/jclic.min.js +0 -27
- package/dist/jclic.min.js.map +0 -1
- package/eslint.config.mjs +0 -31
- package/jsdoc.config.js +0 -71
- package/locales/ar.po +0 -244
- package/locales/ast.po +0 -246
- package/locales/bs.po +0 -247
- package/locales/ca.po +0 -248
- package/locales/ca_ES@valencia.po +0 -248
- package/locales/cs.po +0 -244
- package/locales/da.po +0 -244
- package/locales/de.po +0 -246
- package/locales/el.po +0 -244
- package/locales/es.po +0 -248
- package/locales/eu.po +0 -244
- package/locales/fr.po +0 -244
- package/locales/gl.po +0 -244
- package/locales/he.po +0 -244
- package/locales/hr.po +0 -245
- package/locales/it.po +0 -246
- package/locales/ja.po +0 -242
- package/locales/jclic.js.pot +0 -241
- package/locales/nb_NO.po +0 -244
- package/locales/nl.po +0 -244
- package/locales/pl.po +0 -244
- package/locales/pt.po +0 -244
- package/locales/pt_BR.po +0 -248
- package/locales/ro.po +0 -248
- package/locales/ru.po +0 -245
- package/locales/ta.po +0 -244
- package/locales/tr.po +0 -246
- package/locales/uk.po +0 -247
- package/locales/vec.po +0 -244
- package/locales/zh_TW.po +0 -246
- package/patches/po2json+1.0.0-beta-3.patch +0 -12
- package/src/AWT.js +0 -2067
- package/src/Activity.js +0 -1311
- package/src/Deps.js +0 -232
- package/src/GlobalData.js +0 -5
- package/src/JClic.js +0 -196
- package/src/JClicPlayer.js +0 -1308
- package/src/PlayerHistory.js +0 -305
- package/src/Utils.js +0 -1355
- package/src/activities/associations/ComplexAssociation.js +0 -321
- package/src/activities/associations/SimpleAssociation.js +0 -519
- package/src/activities/memory/MemoryGame.js +0 -423
- package/src/activities/panels/Explore.js +0 -349
- package/src/activities/panels/Identify.js +0 -356
- package/src/activities/panels/InformationScreen.js +0 -262
- package/src/activities/panels/Menu.js +0 -209
- package/src/activities/panels/icons/ico00.png +0 -0
- package/src/activities/panels/icons/ico01.png +0 -0
- package/src/activities/panels/icons/ico02.png +0 -0
- package/src/activities/panels/icons/ico03.png +0 -0
- package/src/activities/panels/icons/icofolder.png +0 -0
- package/src/activities/puzzles/DoublePuzzle.js +0 -424
- package/src/activities/puzzles/ExchangePuzzle.js +0 -374
- package/src/activities/puzzles/HolePuzzle.js +0 -360
- package/src/activities/text/Complete.js +0 -127
- package/src/activities/text/Evaluator.js +0 -534
- package/src/activities/text/FillInBlanks.js +0 -426
- package/src/activities/text/IdentifyText.js +0 -253
- package/src/activities/text/OrderText.js +0 -421
- package/src/activities/text/TextActivityBase.js +0 -557
- package/src/activities/text/TextActivityDocument.js +0 -658
- package/src/activities/text/WrittenAnswer.js +0 -557
- package/src/activities/textGrid/CrossWord.js +0 -565
- package/src/activities/textGrid/WordSearch.js +0 -458
- package/src/activities/textGrid/icons/hIcon.svg +0 -3
- package/src/activities/textGrid/icons/vIcon.svg +0 -3
- package/src/automation/AutoContentProvider.js +0 -182
- package/src/automation/arith/Arith.js +0 -864
- package/src/bags/ActivitySequence.js +0 -318
- package/src/bags/ActivitySequenceElement.js +0 -161
- package/src/bags/ActivitySequenceJump.js +0 -140
- package/src/bags/ConditionalJumpInfo.js +0 -113
- package/src/bags/JumpInfo.js +0 -136
- package/src/bags/MediaBag.js +0 -215
- package/src/bags/MediaBagElement.js +0 -516
- package/src/boxes/AbstractBox.js +0 -699
- package/src/boxes/ActiveBagContent.js +0 -494
- package/src/boxes/ActiveBox.js +0 -810
- package/src/boxes/ActiveBoxBag.js +0 -357
- package/src/boxes/ActiveBoxContent.js +0 -484
- package/src/boxes/ActiveBoxGrid.js +0 -179
- package/src/boxes/BoxBag.js +0 -500
- package/src/boxes/BoxBase.js +0 -398
- package/src/boxes/BoxConnector.js +0 -325
- package/src/boxes/TextGrid.js +0 -887
- package/src/boxes/TextGridContent.js +0 -215
- package/src/init-jsdom.js +0 -65
- package/src/jclic-node.js +0 -219
- package/src/media/ActiveMediaBag.js +0 -145
- package/src/media/ActiveMediaPlayer.js +0 -297
- package/src/media/AudioBuffer.js +0 -219
- package/src/media/EventSounds.js +0 -169
- package/src/media/EventSoundsElement.js +0 -155
- package/src/media/MediaContent.js +0 -328
- package/src/media/MidiAudioPlayer.js +0 -254
- package/src/media/icons/audio.svg +0 -3
- package/src/media/icons/generic.svg +0 -3
- package/src/media/icons/mic.svg +0 -3
- package/src/media/icons/movie.svg +0 -3
- package/src/media/icons/music.svg +0 -3
- package/src/media/icons/url.svg +0 -3
- package/src/media/sounds/actionError.mp3 +0 -0
- package/src/media/sounds/actionOk.mp3 +0 -0
- package/src/media/sounds/click.mp3 +0 -0
- package/src/media/sounds/finishedError.mp3 +0 -0
- package/src/media/sounds/finishedOk.mp3 +0 -0
- package/src/media/sounds/start.mp3 +0 -0
- package/src/project/JClicProject.js +0 -282
- package/src/project/ProjectSettings.js +0 -273
- package/src/report/ActionReg.js +0 -123
- package/src/report/ActivityReg.js +0 -271
- package/src/report/EncryptMin.js +0 -210
- package/src/report/Reporter.js +0 -727
- package/src/report/SCORM.js +0 -272
- package/src/report/SequenceReg.js +0 -275
- package/src/report/SessionReg.js +0 -340
- package/src/report/SessionStorageReporter.js +0 -131
- package/src/report/TCPReporter.js +0 -628
- package/src/shapers/ClassicJigSaw.js +0 -138
- package/src/shapers/Holes.js +0 -77
- package/src/shapers/JigSaw.js +0 -161
- package/src/shapers/Rectangular.js +0 -78
- package/src/shapers/Shaper.js +0 -386
- package/src/shapers/TriangularJigSaw.js +0 -121
- package/src/skins/BlueSkin.js +0 -80
- package/src/skins/Counter.js +0 -152
- package/src/skins/CustomSkin.js +0 -412
- package/src/skins/DefaultSkin.js +0 -376
- package/src/skins/EmptySkin.js +0 -82
- package/src/skins/GreenSkin.js +0 -94
- package/src/skins/MiniSkin.js +0 -130
- package/src/skins/OrangeSkin.js +0 -78
- package/src/skins/SimpleSkin.js +0 -92
- package/src/skins/Skin.js +0 -1021
- package/src/skins/assets/actionsIcon.svg +0 -3
- package/src/skins/assets/appLogo.svg +0 -8
- package/src/skins/assets/basic.css +0 -41
- package/src/skins/assets/closeDialogIcon.svg +0 -3
- package/src/skins/assets/closeIcon.svg +0 -3
- package/src/skins/assets/copyIcon.svg +0 -3
- package/src/skins/assets/fullScreenExitIcon.svg +0 -3
- package/src/skins/assets/fullScreenIcon.svg +0 -3
- package/src/skins/assets/infoIcon.svg +0 -3
- package/src/skins/assets/main.css +0 -43
- package/src/skins/assets/mainHalf.css +0 -23
- package/src/skins/assets/mainTwoThirds.css +0 -23
- package/src/skins/assets/mini.css +0 -15
- package/src/skins/assets/nextIcon.svg +0 -3
- package/src/skins/assets/okDialogIcon.svg +0 -3
- package/src/skins/assets/prevIcon.svg +0 -3
- package/src/skins/assets/reports.css +0 -156
- package/src/skins/assets/reportsIcon.svg +0 -3
- package/src/skins/assets/scoreIcon.svg +0 -3
- package/src/skins/assets/simple.css +0 -16
- package/src/skins/assets/simpleHalf.css +0 -11
- package/src/skins/assets/simpleTwoThirds.css +0 -11
- package/src/skins/assets/timeIcon.svg +0 -4
- package/src/skins/assets/waitAnim.css +0 -54
- package/src/skins/assets/waitImgBig.svg +0 -3
- package/src/skins/assets/waitImgSmall.svg +0 -3
- package/webpack.config.mjs +0 -169
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : activities/textGrid/WordSearch.js
|
|
3
|
-
* Created : 15/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 BoxConnector from '../../boxes/BoxConnector.js';
|
|
37
|
-
import { Rectangle, Point } from '../../AWT.js';
|
|
38
|
-
import TextGrid from '../../boxes/TextGrid.js';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* This class of {@link module:Activity.Activity Activity} shows a {@link module:boxes/TextGrid.TextGrid TextGrid} with some words placed in horizontal,
|
|
42
|
-
* vertical or diagonal direction, written right or upside down. The remaining grid cells will be
|
|
43
|
-
* filled with randomly selected characters.
|
|
44
|
-
*
|
|
45
|
-
* The aim of the activity is to find all the words hidden on the text grid.
|
|
46
|
-
* The content of an optional {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} can be revealed on an auxiliary panel as
|
|
47
|
-
* words are found.
|
|
48
|
-
* @extends module:Activity.Activity
|
|
49
|
-
*/
|
|
50
|
-
export class WordSearch extends Activity {
|
|
51
|
-
/**
|
|
52
|
-
* WordSearch constructor
|
|
53
|
-
* @param {module:project/JClicProject.JClicProject} project - The JClic project to which this activity belongs
|
|
54
|
-
*/
|
|
55
|
-
constructor(project) {
|
|
56
|
-
super(project);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves the minimum number of actions needed to solve this activity
|
|
61
|
-
* @override
|
|
62
|
-
* @returns {number}
|
|
63
|
-
*/
|
|
64
|
-
getMinNumActions() {
|
|
65
|
-
return this.clues.length;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* This type of activity permits the user to display the solution
|
|
70
|
-
* @override
|
|
71
|
-
* @returns {boolean}
|
|
72
|
-
*/
|
|
73
|
-
helpSolutionAllowed() {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* This kind of activity uses random numbers to generate the filling characters
|
|
79
|
-
* @override
|
|
80
|
-
* @returns {boolean}
|
|
81
|
-
*/
|
|
82
|
-
hasRandom() {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
Object.assign(WordSearch.prototype, {
|
|
88
|
-
/**
|
|
89
|
-
* String array containing all the valid clues.
|
|
90
|
-
* @name module:activities/textGrid/WordSearch.WordSearch#clues
|
|
91
|
-
* @type {string[]} */
|
|
92
|
-
clues: null,
|
|
93
|
-
/**
|
|
94
|
-
* Array of integers containing __for each clue__ the index
|
|
95
|
-
* of an associated {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} located on the secondary {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag}.
|
|
96
|
-
* This associated element is optional.
|
|
97
|
-
* @name module:activities/textGrid/WordSearch.WordSearch#clueItems
|
|
98
|
-
* @type {number[]} */
|
|
99
|
-
clueItems: null,
|
|
100
|
-
/**
|
|
101
|
-
* Objects that indicate if box grids A and B must be shuffled.
|
|
102
|
-
* (defaults to _false_ in WordSearch activities)
|
|
103
|
-
* @name module:activities/textGrid/WordSearch.WordSearch#shuffleA
|
|
104
|
-
* @type {boolean} */
|
|
105
|
-
shuffleA: false,
|
|
106
|
-
/**
|
|
107
|
-
* Objects that indicate if box grids A and B must be shuffled.
|
|
108
|
-
* (defaults to _false_ in WordSearch activities)
|
|
109
|
-
* @name module:activities/textGrid/WordSearch.WordSearch#shuffleB
|
|
110
|
-
* @type {boolean} */
|
|
111
|
-
shuffleB: false,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/textGrid/WordSearch.WordSearch WordSearch} activities are played.
|
|
116
|
-
* @extends module:Activity.ActivityPanel
|
|
117
|
-
*/
|
|
118
|
-
export class WordSearchPanel extends ActivityPanel {
|
|
119
|
-
/**
|
|
120
|
-
* WordSearchPanel constructor
|
|
121
|
-
* @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
|
|
122
|
-
* @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
|
|
123
|
-
* [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
|
|
124
|
-
* @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
|
|
125
|
-
*/
|
|
126
|
-
constructor(act, ps, $div) {
|
|
127
|
-
super(act, ps, $div);
|
|
128
|
-
this.resolvedClues = [];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Performs miscellaneous cleaning operations
|
|
133
|
-
* @override
|
|
134
|
-
*/
|
|
135
|
-
clear() {
|
|
136
|
-
if (this.grid) {
|
|
137
|
-
this.grid.end();
|
|
138
|
-
this.grid = null;
|
|
139
|
-
}
|
|
140
|
-
if (this.bgAlt) {
|
|
141
|
-
this.bgAlt.end();
|
|
142
|
-
this.bgAlt = null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Prepares the visual components of the activity
|
|
148
|
-
* @override
|
|
149
|
-
*/
|
|
150
|
-
buildVisualComponents() {
|
|
151
|
-
if (this.firstRun)
|
|
152
|
-
super.buildVisualComponents();
|
|
153
|
-
this.clear();
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
tgc = this.act.tgc,
|
|
157
|
-
abcAlt = this.act.abc['secondary'];
|
|
158
|
-
if (abcAlt) {
|
|
159
|
-
if (abcAlt.image) {
|
|
160
|
-
abcAlt.setImgContent(this.act.project.mediaBag, null, false);
|
|
161
|
-
if (abcAlt.animatedGifFile && !abcAlt.shaper.rectangularShapes && !this.act.shuffleB)
|
|
162
|
-
this.$animatedBg = $('<span/>').css({
|
|
163
|
-
'background-image': `url(${abcAlt.animatedGifFile})`,
|
|
164
|
-
'background-position': 'center',
|
|
165
|
-
'background-repeat': 'no-repeat',
|
|
166
|
-
position: 'absolute'
|
|
167
|
-
}).appendTo(this.$div);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (this.act.acp !== null)
|
|
171
|
-
this.act.acp.generateContent(0, 0, [abcAlt], false);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (tgc) {
|
|
175
|
-
this.grid = TextGrid.createEmptyGrid(null, this, this.act.margin, this.act.margin, tgc, false);
|
|
176
|
-
if (abcAlt) {
|
|
177
|
-
this.bgAlt = ActiveBoxGrid.createEmptyGrid(null, this, this.act.margin, this.act.margin, abcAlt);
|
|
178
|
-
if (this.$animatedBg && this.bgAlt.backgroundBox)
|
|
179
|
-
this.bgAlt.backgroundBox['tmpTrans'] = true;
|
|
180
|
-
}
|
|
181
|
-
this.grid.setVisible(true);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Basic initialization procedure
|
|
187
|
-
* @override
|
|
188
|
-
*/
|
|
189
|
-
initActivity() {
|
|
190
|
-
super.initActivity();
|
|
191
|
-
if (!this.firstRun)
|
|
192
|
-
this.buildVisualComponents();
|
|
193
|
-
else
|
|
194
|
-
this.firstRun = false;
|
|
195
|
-
|
|
196
|
-
if (this.grid) {
|
|
197
|
-
this.grid.setChars(this.act.tgc.text);
|
|
198
|
-
this.grid.randomize();
|
|
199
|
-
this.grid.setAllCellsAttribute(TextGrid.flags.INVERTED, false);
|
|
200
|
-
|
|
201
|
-
this.resolvedClues = Array(this.act.clueItems.length).fill(false);
|
|
202
|
-
|
|
203
|
-
if (this.bgAlt) {
|
|
204
|
-
this.bgAlt.setContent(this.act.abc['secondary']);
|
|
205
|
-
if (this.$animatedBg)
|
|
206
|
-
this.bgAlt.clearAllBoxes();
|
|
207
|
-
if (this.act.shuffleB)
|
|
208
|
-
this.shuffle([this.bgAlt], true, true);
|
|
209
|
-
this.bgAlt.setVisible(this.$animatedBg !== null || this.act.invAss);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
this.setAndPlayMsg('initial', 'start');
|
|
213
|
-
this.invalidate().update();
|
|
214
|
-
this.playing = true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Updates the graphic content of this panel.
|
|
220
|
-
* This method will be called from {@link module:AWT.Container#update} when needed.
|
|
221
|
-
* @override
|
|
222
|
-
* @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
|
|
223
|
-
* it's the whole panel.
|
|
224
|
-
*/
|
|
225
|
-
updateContent(dirtyRegion) {
|
|
226
|
-
super.updateContent(dirtyRegion);
|
|
227
|
-
if (this.grid && this.$canvas) {
|
|
228
|
-
const
|
|
229
|
-
canvas = this.$canvas.get(-1),
|
|
230
|
-
ctx = canvas.getContext('2d');
|
|
231
|
-
if (!dirtyRegion)
|
|
232
|
-
dirtyRegion = new Rectangle(0, 0, canvas.width, canvas.height);
|
|
233
|
-
ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
|
|
234
|
-
this.grid.update(ctx, dirtyRegion);
|
|
235
|
-
if (this.bgAlt)
|
|
236
|
-
this.bgAlt.update(ctx, dirtyRegion);
|
|
237
|
-
}
|
|
238
|
-
return this;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Sets the real dimension of this panel.
|
|
243
|
-
* @override
|
|
244
|
-
* @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
|
|
245
|
-
* @returns {module:AWT.Dimension}
|
|
246
|
-
*/
|
|
247
|
-
setDimension(preferredMaxSize) {
|
|
248
|
-
if (!this.grid || this.getBounds().equals(preferredMaxSize))
|
|
249
|
-
return preferredMaxSize;
|
|
250
|
-
if (this.bgAlt)
|
|
251
|
-
return BoxBag.layoutDouble(preferredMaxSize, this.grid, this.bgAlt, this.act.boxGridPos, this.act.margin);
|
|
252
|
-
else
|
|
253
|
-
return BoxBag.layoutSingle(preferredMaxSize, this.grid, this.act.margin);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Sets the size and position of this activity panel
|
|
258
|
-
* @override
|
|
259
|
-
* @param {module:AWT.Rectangle} rect
|
|
260
|
-
*/
|
|
261
|
-
setBounds(rect) {
|
|
262
|
-
if (this.$canvas)
|
|
263
|
-
this.$canvas.remove();
|
|
264
|
-
super.setBounds(rect);
|
|
265
|
-
if (this.grid) {
|
|
266
|
-
// Create the main canvas
|
|
267
|
-
this.$canvas = $(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
|
|
268
|
-
position: 'absolute',
|
|
269
|
-
top: 0,
|
|
270
|
-
left: 0
|
|
271
|
-
});
|
|
272
|
-
// Resize animated gif background
|
|
273
|
-
if (this.$animatedBg && this.bgAlt) {
|
|
274
|
-
const bgRect = this.bgAlt.getBounds();
|
|
275
|
-
this.$animatedBg.css({
|
|
276
|
-
left: bgRect.pos.x,
|
|
277
|
-
top: bgRect.pos.y,
|
|
278
|
-
width: `${bgRect.dim.width}px`,
|
|
279
|
-
height: `${bgRect.dim.height}px`,
|
|
280
|
-
'background-size': `${bgRect.dim.width}px ${bgRect.dim.height}px`
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
this.$div.append(this.$canvas);
|
|
284
|
-
|
|
285
|
-
// Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
|
|
286
|
-
this.bc = new BoxConnector(this, this.$canvas);
|
|
287
|
-
|
|
288
|
-
// Repaint all
|
|
289
|
-
this.invalidate().update();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Calculates the current score
|
|
295
|
-
* @returns {number}
|
|
296
|
-
*/
|
|
297
|
-
getCurrentScore() {
|
|
298
|
-
return this.resolvedClues.reduce((n, resolved) => resolved ? ++n : n, 0);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Main handler used to process mouse, touch, keyboard and edit events
|
|
303
|
-
* @override
|
|
304
|
-
* @param {external:Event} event - The HTML event to be processed
|
|
305
|
-
* @returns {boolean} - When this event handler returns `false`, jQuery will stop its
|
|
306
|
-
* propagation through the DOM tree. See: {@link http://api.jquery.com/on}
|
|
307
|
-
*/
|
|
308
|
-
processEvent(event) {
|
|
309
|
-
if (this.bc && this.playing) {
|
|
310
|
-
//
|
|
311
|
-
// The [AWT.Point](AWT.html#Point) where the mouse or touch event has been originated
|
|
312
|
-
let p = null;
|
|
313
|
-
//
|
|
314
|
-
// _touchend_ event don't provide pageX nor pageY information
|
|
315
|
-
if (event.type === 'touchend')
|
|
316
|
-
p = this.bc.active ? this.bc.dest.clone() : new Point();
|
|
317
|
-
else {
|
|
318
|
-
// Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
|
|
319
|
-
const
|
|
320
|
-
x = event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
|
|
321
|
-
y = event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
|
|
322
|
-
p = new Point(x - this.$div.offset().left, y - this.$div.offset().top);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Flag for tracking `mouseup` events
|
|
326
|
-
let up = false;
|
|
327
|
-
// Flag for assuring that only one media plays per event (avoid event sounds overlapping
|
|
328
|
-
// cell's media sounds)
|
|
329
|
-
let m = false;
|
|
330
|
-
// Array to be filled with actions to be executed at the end of event processing
|
|
331
|
-
const delayedActions = [];
|
|
332
|
-
|
|
333
|
-
switch (event.type) {
|
|
334
|
-
case 'touchcancel':
|
|
335
|
-
// Canvel movement
|
|
336
|
-
if (this.bc.active)
|
|
337
|
-
this.bc.end();
|
|
338
|
-
break;
|
|
339
|
-
|
|
340
|
-
case 'mouseup':
|
|
341
|
-
// Don't consider drag moves below 3 pixels. Can be a "trembling click"
|
|
342
|
-
if (this.bc.active && p.distanceTo(this.bc.origin) <= 3)
|
|
343
|
-
break;
|
|
344
|
-
|
|
345
|
-
up = true;
|
|
346
|
-
/* falls through */
|
|
347
|
-
case 'touchend':
|
|
348
|
-
case 'touchstart':
|
|
349
|
-
case 'mousedown':
|
|
350
|
-
if (!this.bc.active) {
|
|
351
|
-
// A new word selection starts
|
|
352
|
-
//
|
|
353
|
-
// Selection of words can never start with a `mouseup` event
|
|
354
|
-
if (up)
|
|
355
|
-
break;
|
|
356
|
-
|
|
357
|
-
this.ps.stopMedia(1);
|
|
358
|
-
if (this.grid.contains(p)) {
|
|
359
|
-
this.playEvent('click');
|
|
360
|
-
this.bc.begin(p);
|
|
361
|
-
}
|
|
362
|
-
} else {
|
|
363
|
-
this.ps.stopMedia(1);
|
|
364
|
-
// Word selection completed
|
|
365
|
-
//
|
|
366
|
-
// Find the active boxes behind `bc.origin` and `p`
|
|
367
|
-
const
|
|
368
|
-
pt1 = this.grid.getLogicalCoords(this.bc.origin),
|
|
369
|
-
pt2 = this.grid.getLogicalCoords(this.bc.dest);
|
|
370
|
-
this.bc.end();
|
|
371
|
-
const s = this.grid.getStringBetween(pt1.x, pt1.y, pt2.x, pt2.y);
|
|
372
|
-
if (s !== null && s.length > 0) {
|
|
373
|
-
let ok = false, c = 0;
|
|
374
|
-
for (; c < this.act.clues.length; c++) {
|
|
375
|
-
if (s === this.act.clues[c]) {
|
|
376
|
-
ok = true;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
const repeated = this.resolvedClues[c];
|
|
381
|
-
if (ok && !repeated) {
|
|
382
|
-
this.resolvedClues[c] = true;
|
|
383
|
-
this.grid.setAttributeBetween(pt1.x, pt1.y, pt2.x, pt2.y, TextGrid.flags.INVERTED, true);
|
|
384
|
-
if (this.bgAlt !== null) {
|
|
385
|
-
const k = this.act.clueItems[c];
|
|
386
|
-
if (k >= 0 && k < this.bgAlt.getNumCells()) {
|
|
387
|
-
const bx = this.bgAlt.getActiveBox(this.act.clueItems[c]);
|
|
388
|
-
if (bx) {
|
|
389
|
-
bx.setVisible(this.$animatedBg === null && !this.act.invAss);
|
|
390
|
-
m = bx.playMedia(this.ps, delayedActions);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
if (!repeated) {
|
|
396
|
-
const r = this.getCurrentScore();
|
|
397
|
-
this.ps.reportNewAction(this.act, 'ACTION_SELECT', s, null, ok, r);
|
|
398
|
-
if (r === this.act.clues.length)
|
|
399
|
-
this.finishActivity(true);
|
|
400
|
-
else if (!m)
|
|
401
|
-
this.playEvent(ok ? 'actionOK' : 'actionError');
|
|
402
|
-
this.invalidate();
|
|
403
|
-
} else if (!ok && !m)
|
|
404
|
-
this.playEvent('actionError');
|
|
405
|
-
} else
|
|
406
|
-
this.playEvent('actionError');
|
|
407
|
-
|
|
408
|
-
this.update();
|
|
409
|
-
}
|
|
410
|
-
break;
|
|
411
|
-
|
|
412
|
-
case 'mousemove':
|
|
413
|
-
case 'touchmove':
|
|
414
|
-
this.bc.moveTo(p);
|
|
415
|
-
break;
|
|
416
|
-
}
|
|
417
|
-
delayedActions.forEach(action => action());
|
|
418
|
-
event.preventDefault();
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
Object.assign(WordSearchPanel.prototype, {
|
|
424
|
-
/**
|
|
425
|
-
* The {@link module:boxes/TextGrid.TextGrid TextGrid} object of this ActivityPanel
|
|
426
|
-
* @name module:activities/textGrid/WordSearch.WordSearchPanel#grid
|
|
427
|
-
* @type {module:boxes/TextGrid.TextGrid} */
|
|
428
|
-
grid: null,
|
|
429
|
-
/**
|
|
430
|
-
* An optional {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} used to display information associated with the hidden words.
|
|
431
|
-
* @name module:activities/textGrid/WordSearch.WordSearchPanel#bgAlt
|
|
432
|
-
* @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
|
|
433
|
-
bgAlt: null,
|
|
434
|
-
/**
|
|
435
|
-
* An array of boolean values indicating which clues have been found
|
|
436
|
-
* @name module:activities/textGrid/WordSearch.WordSearchPanel#resolvedClues
|
|
437
|
-
* @type {boolean[]} */
|
|
438
|
-
resolvedClues: null,
|
|
439
|
-
/**
|
|
440
|
-
* The box connector object
|
|
441
|
-
* @name module:activities/textGrid/WordSearch.WordSearchPanel#bc
|
|
442
|
-
* @type {module:boxes/BoxConnector.BoxConnector} */
|
|
443
|
-
bc: null,
|
|
444
|
-
/**
|
|
445
|
-
* Mouse and touch events intercepted by this panel
|
|
446
|
-
* @override
|
|
447
|
-
* @name module:activities/textGrid/WordSearch.WordSearchPanel#events
|
|
448
|
-
* @type {string[]} */
|
|
449
|
-
events: ['mousedown', 'mouseup', 'mousemove', 'touchstart', 'touchend', 'touchmove', 'touchcancel'],
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Panel class associated to this type of activity: {@link module:activities/textGrid/WordSearch.WordSearchPanel WordSearchPanel}
|
|
454
|
-
* @type {class} */
|
|
455
|
-
WordSearch.Panel = WordSearchPanel;
|
|
456
|
-
|
|
457
|
-
// Register activity class
|
|
458
|
-
export default Activity.registerClass('@textGrid.WordSearch', WordSearch);
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : automation/AutoContentProvider.js
|
|
3
|
-
* Created : 13/04/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 {log, getAttr} from '../Utils.js';
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* This abstract class is the base for classes that create on-time automatic content for JClic
|
|
36
|
-
* activities, usually using random parameters to assure different content in each session.
|
|
37
|
-
*
|
|
38
|
-
* Activities with `AutoContentProvider` objects rely on them to build new content on every start.
|
|
39
|
-
*/
|
|
40
|
-
export class AutoContentProvider {
|
|
41
|
-
/**
|
|
42
|
-
* AutoContentProvider constructor
|
|
43
|
-
*/
|
|
44
|
-
constructor() {
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Dynamic constructor that returns a specific type of AutoContentProvider based on the `class`
|
|
49
|
-
* attribute declared on an $xml element.
|
|
50
|
-
* It should be called only from {@link module:Activity.Activity#setProperties Activity.setProperties}
|
|
51
|
-
* @param {external.jQuery} $xml - The XML element to parse
|
|
52
|
-
* @returns {module:automation/AutoContentProvider.AutoContentProvider}
|
|
53
|
-
*/
|
|
54
|
-
static getProvider($xml) {
|
|
55
|
-
let automation = null;
|
|
56
|
-
if ($xml) {
|
|
57
|
-
const
|
|
58
|
-
className = ($xml.attr('class') || '').replace(/^edu\.xtec\.jclic\.automation\./, '@'),
|
|
59
|
-
cl = AutoContentProvider.CLASSES[className];
|
|
60
|
-
if (cl) {
|
|
61
|
-
automation = new cl();
|
|
62
|
-
automation.setProperties($xml);
|
|
63
|
-
} else
|
|
64
|
-
log('error', `Unknown AutoContentProvider class: ${className}`);
|
|
65
|
-
}
|
|
66
|
-
return automation;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Loads the object settings from a specific jQuery XML element
|
|
71
|
-
* @param {external:jQuery} $xml - The XML element to parse
|
|
72
|
-
*/
|
|
73
|
-
setProperties($xml) {
|
|
74
|
-
this.className = ($xml.attr('class') || '').replace(/^edu\.xtec\.jclic\.automation\./, '@');
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
80
|
-
* parent references, constants and also attributes retaining the default value.
|
|
81
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
82
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
83
|
-
*/
|
|
84
|
-
getAttributes() {
|
|
85
|
-
// To be overrided!
|
|
86
|
-
return getAttr(this, ['className']);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Builds a new AutoContentProvider, based on the properties specified in a data object
|
|
91
|
-
* @param {object} data - The data object to be parsed
|
|
92
|
-
* @param {object[]} params - Optional parameters to be passed to `setAttributes`
|
|
93
|
-
* @returns {module:shapers/Shaper.Shaper}
|
|
94
|
-
*/
|
|
95
|
-
static factory(data, params = []) {
|
|
96
|
-
const cl = AutoContentProvider.CLASSES[data.className];
|
|
97
|
-
return (new cl()).setAttributes(data, ...params);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Initializes the content provider
|
|
102
|
-
*/
|
|
103
|
-
init() {
|
|
104
|
-
// To be implemented in real content providers
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Builds an {@link module:automation/AutoContentProvider/ActiveBagContentKit ActiveBagContentKit} and generates the automatized content.
|
|
109
|
-
* @param {number} nRows - Number of rows to be processed
|
|
110
|
-
* @param {number} nCols - Number of columns to be processed
|
|
111
|
-
* @param {module:boxes/ActiveBagContent.ActiveBagContent[]} content - Array with one or more containers of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent}
|
|
112
|
-
* objects to be filled with new content.
|
|
113
|
-
* @param {boolean} useIds - When `true`, the `id` field of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects is significant
|
|
114
|
-
* @returns {boolean} - `true` if the process was OK. `false` otherwise.
|
|
115
|
-
*/
|
|
116
|
-
generateContent(nRows, nCols, content, useIds) {
|
|
117
|
-
return this.process(new AutoContentProvider.ActiveBagContentKit(nRows, nCols, content, useIds));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Generates the automatized content
|
|
122
|
-
* @param {module:automation/AutoContentProvider.ActiveBagContentKit} _kit - The objects to be filled with content
|
|
123
|
-
* @returns {boolean} - `true` if the process was OK. `false` otherwise.
|
|
124
|
-
*/
|
|
125
|
-
process(_kit) {
|
|
126
|
-
// To be implemented in subclasses
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Registers a new type of AutoContentProvider
|
|
132
|
-
* @param {string} providerName - The name used to identify this AutoContentProvider
|
|
133
|
-
* @param {function} providerClass - The activity class, usually extending AutoContentProvider
|
|
134
|
-
* @returns {module:automation/AutoContentProvider.AutoContentProvider} - The provider class
|
|
135
|
-
*/
|
|
136
|
-
static registerClass(providerName, providerClass) {
|
|
137
|
-
AutoContentProvider.CLASSES[providerName] = providerClass;
|
|
138
|
-
return providerClass;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
Object.assign(AutoContentProvider.prototype, {
|
|
143
|
-
/**
|
|
144
|
-
* This AutoContentProvider manages numeric expressions, so text literals should be
|
|
145
|
-
* converted to numbers for comparisions, taking in account the
|
|
146
|
-
* number format of the current locale (dot or comma as decimal separator)
|
|
147
|
-
* @name module:automation/AutoContentProvider.AutoContentProvider#numericContent
|
|
148
|
-
* @type {boolean} */
|
|
149
|
-
numericContent: false,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Utility class used to encapsulate multiple sets of box contents
|
|
154
|
-
* @param {number} nRows - Number of rows to be processed
|
|
155
|
-
* @param {number} nCols - Number of columns to be processed
|
|
156
|
-
* @param {module:boxes/ActiveBagContent.ActiveBagContent[]} content - Array with one or more containers of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent}
|
|
157
|
-
* objects to be filled with new content.
|
|
158
|
-
* @param {boolean} useIds - `true` when the `id` field of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects is significant.
|
|
159
|
-
*/
|
|
160
|
-
AutoContentProvider.ActiveBagContentKit = class {
|
|
161
|
-
constructor(nRows, nCols, content, useIds) {
|
|
162
|
-
this.nRows = nRows;
|
|
163
|
-
this.nCols = nCols;
|
|
164
|
-
this.content = content;
|
|
165
|
-
this.useIds = useIds;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Contains the current list of classes derived from AutoContentProvider.
|
|
171
|
-
* This object should be updated by real automation classes at declaration time.
|
|
172
|
-
* Currently, only two types of "AutoContentProvider" are defined: {@link module:automation/arith/Arith.Arith Arith} and TagReplace.
|
|
173
|
-
* @type {object} */
|
|
174
|
-
AutoContentProvider.CLASSES = {
|
|
175
|
-
// TODO: Implement TagReplace
|
|
176
|
-
'@tagreplace.TagReplace': AutoContentProvider
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// TODO: Implement TagReplace
|
|
180
|
-
AutoContentProvider.registerClass('@tagreplace.TagReplace', AutoContentProvider);
|
|
181
|
-
|
|
182
|
-
export default AutoContentProvider;
|