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,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : activities/text/OrderText.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 $ from 'jquery';
|
|
33
|
-
import Activity from '../../Activity.js';
|
|
34
|
-
import { TextActivityBase, TextActivityBasePanel } from './TextActivityBase.js';
|
|
35
|
-
import BoxConnector from '../../boxes/BoxConnector.js';
|
|
36
|
-
import { Point } from '../../AWT.js';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* In this type of text activity users must put in order some words or paragraphs that have been
|
|
40
|
-
* initially shuffled.
|
|
41
|
-
* @extends module:activities/text/TextActivityBase.TextActivityBase
|
|
42
|
-
*/
|
|
43
|
-
export class OrderText extends TextActivityBase {
|
|
44
|
-
/**
|
|
45
|
-
* OrderText constructor
|
|
46
|
-
* @param {module:project/JClicProject.JClicProject} project - The project to which this activity belongs
|
|
47
|
-
*/
|
|
48
|
-
constructor(project) {
|
|
49
|
-
super(project);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Whether or not the activity uses random to shuffle internal components
|
|
54
|
-
* @override
|
|
55
|
-
* @returns {boolean}
|
|
56
|
-
*/
|
|
57
|
-
hasRandom() {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* When `true`, the activity must always be shuffled
|
|
63
|
-
* @override
|
|
64
|
-
* @returns {boolean}
|
|
65
|
-
*/
|
|
66
|
-
shuffleAlways() {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Whether the activity allows the user to request help.
|
|
72
|
-
* @override
|
|
73
|
-
* @returns {boolean}
|
|
74
|
-
*/
|
|
75
|
-
helpSolutionAllowed() {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Object.assign(OrderText.prototype, {
|
|
81
|
-
/**
|
|
82
|
-
* Whether to allow or not to shuffle words among different paragraphs.
|
|
83
|
-
* @name module:activities/text/OrderText.OrderText#amongParagraphs
|
|
84
|
-
* @type {boolean} */
|
|
85
|
-
amongParagraphs: false,
|
|
86
|
-
/**
|
|
87
|
-
* The box connector
|
|
88
|
-
* @name module:activities/text/OrderText.OrderText#bc
|
|
89
|
-
* @type {module:boxes/BoxConnector.BoxConnector} */
|
|
90
|
-
bc: null,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* The {@link module:activities/text/TextActivityBase.TextActivityBasePanel TextActivityBasePanel} where {@link module:activities/text/OrderText.OrderText OrderText} activities are played.
|
|
95
|
-
* @extends module:activities/text/TextActivityBase.TextActivityBasePanel
|
|
96
|
-
*/
|
|
97
|
-
export class OrderTextPanel extends TextActivityBasePanel {
|
|
98
|
-
/**
|
|
99
|
-
* OrderTextPanel constructor
|
|
100
|
-
* @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
|
|
101
|
-
* @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
|
|
102
|
-
* [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
|
|
103
|
-
* @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
|
|
104
|
-
*/
|
|
105
|
-
constructor(act, ps, $div) {
|
|
106
|
-
super(act, ps, $div);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Prepares the text panel
|
|
111
|
-
* @override
|
|
112
|
-
*/
|
|
113
|
-
buildVisualComponents() {
|
|
114
|
-
this.act.document.style['target'].css.cursor = 'pointer';
|
|
115
|
-
super.buildVisualComponents();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Sets the size and position of this activity panel
|
|
120
|
-
* @override
|
|
121
|
-
* @param {module:AWT.Rectangle} rect
|
|
122
|
-
*/
|
|
123
|
-
setBounds(rect) {
|
|
124
|
-
if (this.$canvas)
|
|
125
|
-
this.$canvas.remove();
|
|
126
|
-
|
|
127
|
-
super.setBounds(rect);
|
|
128
|
-
if (!this.act.dragCells) {
|
|
129
|
-
// Create the main canvas
|
|
130
|
-
this.$canvas = $(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
|
|
131
|
-
position: 'absolute',
|
|
132
|
-
top: 0,
|
|
133
|
-
left: 0,
|
|
134
|
-
'pointer-events': 'none'
|
|
135
|
-
});
|
|
136
|
-
this.$div.append(this.$canvas);
|
|
137
|
-
|
|
138
|
-
// Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
|
|
139
|
-
this.bc = new BoxConnector(this, this.$canvas);
|
|
140
|
-
this.bc.compositeOp = this.bc.DEFAULT_COMPOSITE_OP;
|
|
141
|
-
|
|
142
|
-
// Repaint all
|
|
143
|
-
this.invalidate().update();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Creates a target DOM element for the provided target.
|
|
149
|
-
* @override
|
|
150
|
-
* @param {module:activities/text/TextActivityDocument.TextTarget} target - The target related to the DOM object to be created
|
|
151
|
-
* @param {external:jQuery} $span - - An initial DOM object (usually a `span`) that can be used
|
|
152
|
-
* to store the target, or replaced by another type of object.
|
|
153
|
-
* @returns {external:jQuery} - The jQuery DOM element loaded with the target data.
|
|
154
|
-
*/
|
|
155
|
-
$createTargetElement(target, $span) {
|
|
156
|
-
super.$createTargetElement(target, $span);
|
|
157
|
-
const idLabel = `target${`000${this.targets.length - 1}`.slice(-3)}`;
|
|
158
|
-
$span.addClass('JClicTextTarget').on('click', event => {
|
|
159
|
-
event.textTarget = target;
|
|
160
|
-
event.idLabel = idLabel;
|
|
161
|
-
this.processEvent(event);
|
|
162
|
-
});
|
|
163
|
-
return $span;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Swaps the position of two targets in the document
|
|
168
|
-
* @param {module:activities/text/TextActivityDocument.TextTarget} t1 - One target
|
|
169
|
-
* @param {module:activities/text/TextActivityDocument.TextTarget} t2 - Another target
|
|
170
|
-
*/
|
|
171
|
-
swapTargets(t1, t2) {
|
|
172
|
-
const
|
|
173
|
-
$span1 = t1.$span,
|
|
174
|
-
$span2 = t2.$span,
|
|
175
|
-
$marker = $('<span/>');
|
|
176
|
-
$marker.insertAfter($span2);
|
|
177
|
-
$span2.detach();
|
|
178
|
-
$span2.insertAfter($span1);
|
|
179
|
-
$span1.detach();
|
|
180
|
-
$span1.insertAfter($marker);
|
|
181
|
-
$marker.remove();
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
pos = t1.pos,
|
|
185
|
-
$p = t1.$p;
|
|
186
|
-
t1.pos = t2.pos;
|
|
187
|
-
t1.$p = t2.$p;
|
|
188
|
-
t2.pos = pos;
|
|
189
|
-
t2.$p = $p;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Basic initialization procedure
|
|
194
|
-
* @override
|
|
195
|
-
*/
|
|
196
|
-
initActivity() {
|
|
197
|
-
super.initActivity();
|
|
198
|
-
if (!this.firstRun)
|
|
199
|
-
this.buildVisualComponents();
|
|
200
|
-
else
|
|
201
|
-
this.firstRun = false;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Called when the activity starts playing
|
|
206
|
-
* @override
|
|
207
|
-
*/
|
|
208
|
-
startActivity() {
|
|
209
|
-
super.startActivity();
|
|
210
|
-
if (!this.showingPrevScreen) {
|
|
211
|
-
if (this.act.type === 'orderWords' && !this.act.amongParagraphs) {
|
|
212
|
-
// Group targets by paragraph
|
|
213
|
-
const groups = [];
|
|
214
|
-
let
|
|
215
|
-
lastTarget = null,
|
|
216
|
-
currentGroup = [];
|
|
217
|
-
this.targets.forEach(t => {
|
|
218
|
-
if (lastTarget !== null && lastTarget.$p !== t.$p) {
|
|
219
|
-
groups.push(currentGroup);
|
|
220
|
-
currentGroup = [];
|
|
221
|
-
}
|
|
222
|
-
currentGroup.push(t);
|
|
223
|
-
lastTarget = t;
|
|
224
|
-
});
|
|
225
|
-
if (currentGroup.length > 0)
|
|
226
|
-
groups.push(currentGroup);
|
|
227
|
-
|
|
228
|
-
// Scramble group by group
|
|
229
|
-
groups.forEach(group => this.shuffleTargets(group, this.act.shuffles));
|
|
230
|
-
} else
|
|
231
|
-
this.shuffleTargets(this.targets, this.act.shuffles);
|
|
232
|
-
|
|
233
|
-
this.playing = true;
|
|
234
|
-
}
|
|
235
|
-
this.setBounds(this);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Randomly shuffles a set of targets
|
|
240
|
-
* @param {module:activities/text/TextActivityDocument.TextTarget[]} targets - The set of targets to shuffle (can be all
|
|
241
|
-
* document targets or just the targets belonging to the same paragraph, depending on the value of
|
|
242
|
-
* `amongParagraphs` in {@link module:Activity.Activity Activity}.
|
|
243
|
-
* @param {number} steps - The number of times to shuffle the elements
|
|
244
|
-
*/
|
|
245
|
-
shuffleTargets(targets, steps) {
|
|
246
|
-
const nt = targets.length;
|
|
247
|
-
if (nt > 1) {
|
|
248
|
-
let repeatCount = 100;
|
|
249
|
-
for (let i = 0; i < steps; i++) {
|
|
250
|
-
const
|
|
251
|
-
r1 = Math.floor(Math.random() * nt),
|
|
252
|
-
r2 = Math.floor(Math.random() * nt);
|
|
253
|
-
if (r1 !== r2) {
|
|
254
|
-
this.swapTargets(targets[r1], targets[r2]);
|
|
255
|
-
} else {
|
|
256
|
-
if (--repeatCount)
|
|
257
|
-
i++;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Sets the current target
|
|
265
|
-
* @param {module:activities/text/TextActivityDocument.TextTarget} target - The currently selected target. Can be `null`.
|
|
266
|
-
*/
|
|
267
|
-
setCurrentTarget(target) {
|
|
268
|
-
const targetCss = this.act.document.getFullStyle('target').css;
|
|
269
|
-
if (this.currentTarget && this.currentTarget.$span)
|
|
270
|
-
this.currentTarget.$span.css(targetCss);
|
|
271
|
-
if (target && target.$span) {
|
|
272
|
-
target.$span.css({
|
|
273
|
-
color: targetCss['background-color'],
|
|
274
|
-
'background-color': targetCss.color
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
this.currentTarget = target;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Counts the number of targets that are at right position
|
|
282
|
-
* @returns {number}
|
|
283
|
-
*/
|
|
284
|
-
countSolvedTargets() {
|
|
285
|
-
return this.targets.filter(({ num, pos }) => num === pos).length;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Evaluates all the targets in this panel. This method is usually called from the `Check` button.
|
|
290
|
-
* @override
|
|
291
|
-
* @returns {boolean} - `true` when all targets are OK, `false` otherwise.
|
|
292
|
-
*/
|
|
293
|
-
evaluatePanel() {
|
|
294
|
-
if (this.bc && this.bc.active)
|
|
295
|
-
this.bc.end();
|
|
296
|
-
this.setCurrentTarget(null);
|
|
297
|
-
|
|
298
|
-
let targetsOk = 0;
|
|
299
|
-
this.targets.forEach(target => {
|
|
300
|
-
const ok = target.num === target.pos;
|
|
301
|
-
target.targetStatus = ok ? 'SOLVED' : 'WITH_ERROR';
|
|
302
|
-
if (ok)
|
|
303
|
-
targetsOk++;
|
|
304
|
-
target.checkColors();
|
|
305
|
-
this.ps.reportNewAction(this.act, 'PLACE', target.text, target.pos, ok, targetsOk);
|
|
306
|
-
});
|
|
307
|
-
if (targetsOk === this.targets.length) {
|
|
308
|
-
this.finishActivity(true);
|
|
309
|
-
return true;
|
|
310
|
-
} else {
|
|
311
|
-
this.playEvent('finishedError');
|
|
312
|
-
}
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Ordinary ending of the activity, usually called form `processEvent`
|
|
318
|
-
* @override
|
|
319
|
-
* @param {boolean} result - `true` if the activity was successfully completed, `false` otherwise
|
|
320
|
-
*/
|
|
321
|
-
finishActivity(result) {
|
|
322
|
-
$('.JClicTextTarget').css('cursor', 'pointer');
|
|
323
|
-
return super.finishActivity(result);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Main handler used to process mouse, touch, keyboard and edit events.
|
|
328
|
-
* @override
|
|
329
|
-
* @param {external:Event} event - The HTML event to be processed
|
|
330
|
-
* @returns {boolean} - When this event handler returns `false`, jQuery will stop its
|
|
331
|
-
* propagation through the DOM tree. See: {@link http://api.jquery.com/on}
|
|
332
|
-
*/
|
|
333
|
-
processEvent(event) {
|
|
334
|
-
if (!super.processEvent(event))
|
|
335
|
-
return false;
|
|
336
|
-
|
|
337
|
-
const target = event.textTarget;
|
|
338
|
-
let p = null;
|
|
339
|
-
if (this.bc && this.playing && !this.showingPrevScreen) {
|
|
340
|
-
//
|
|
341
|
-
// _touchend_ event don't provide pageX nor pageY information
|
|
342
|
-
if (event.type === 'touchend')
|
|
343
|
-
p = this.bc.active ? this.bc.dest.clone() : new Point();
|
|
344
|
-
else {
|
|
345
|
-
// Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
|
|
346
|
-
const
|
|
347
|
-
x = event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
|
|
348
|
-
y = event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
|
|
349
|
-
p = new Point(x - this.$div.offset().left, y - this.$div.offset().top);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
switch (event.type) {
|
|
353
|
-
case 'click':
|
|
354
|
-
if (target && target !== this.currentTarget) {
|
|
355
|
-
if (this.currentTarget) {
|
|
356
|
-
if (this.bc && this.bc.active)
|
|
357
|
-
this.bc.end();
|
|
358
|
-
this.swapTargets(target, this.currentTarget);
|
|
359
|
-
this.setCurrentTarget(null);
|
|
360
|
-
|
|
361
|
-
if (!this.$checkButton) {
|
|
362
|
-
// Check and notify action
|
|
363
|
-
const
|
|
364
|
-
cellsAtPlace = this.countSolvedTargets(),
|
|
365
|
-
ok = target.pos === target.num;
|
|
366
|
-
this.ps.reportNewAction(this.act, 'PLACE', target.text, target.pos, ok, cellsAtPlace);
|
|
367
|
-
|
|
368
|
-
// End activity or play event sound
|
|
369
|
-
if (ok && cellsAtPlace === this.targets.length)
|
|
370
|
-
this.finishActivity(true);
|
|
371
|
-
else
|
|
372
|
-
this.playEvent(ok ? 'actionOk' : 'actionError');
|
|
373
|
-
}
|
|
374
|
-
} else {
|
|
375
|
-
this.setCurrentTarget(target);
|
|
376
|
-
this.bc.begin(p);
|
|
377
|
-
this.playEvent('click');
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
break;
|
|
381
|
-
|
|
382
|
-
case 'mousemove':
|
|
383
|
-
this.bc.moveTo(p);
|
|
384
|
-
break;
|
|
385
|
-
|
|
386
|
-
default:
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
event.preventDefault();
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// Properties and methods specific to OrderTextPanel
|
|
396
|
-
Object.assign(OrderTextPanel.prototype, {
|
|
397
|
-
/**
|
|
398
|
-
* Currently selected text target
|
|
399
|
-
* @name module:activities/text/OrderText.OrderTextPanel#currentTarget
|
|
400
|
-
* @type {module:activities/text/TextActivityDocument.TextActivityDocument.TextTarget} */
|
|
401
|
-
currentTarget: null,
|
|
402
|
-
/**
|
|
403
|
-
* The box connector
|
|
404
|
-
* @name module:activities/text/OrderText.OrderTextPanel#bc
|
|
405
|
-
* @type {module:boxes/BoxConnector.BoxConnector} */
|
|
406
|
-
bc: null,
|
|
407
|
-
/**
|
|
408
|
-
* List of mouse, touch and keyboard events intercepted by this panel
|
|
409
|
-
* @override
|
|
410
|
-
* @name module:activities/text/OrderText.OrderTextPanel#events
|
|
411
|
-
* @type {string[]} */
|
|
412
|
-
events: ['click', 'mousemove'],
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Panel class associated to this type of activity: {@link module:activities/text/OrderText.OrderTextPanel OrderTextPanel}
|
|
417
|
-
* @type {class} */
|
|
418
|
-
OrderText.Panel = OrderTextPanel;
|
|
419
|
-
|
|
420
|
-
// Register activity class
|
|
421
|
-
export default Activity.registerClass('@text.Order', OrderText);
|