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.
- 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 -672
- package/TRANSLATIONS.md +0 -11
- package/build-locales.mjs +0 -82
- package/dist/jclic-node.js +0 -31680
- 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 -660
- 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,318 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : bags/ActivitySequence.js
|
|
3
|
-
* Created : 05/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 $ from 'jquery';
|
|
33
|
-
import JumpInfo from './JumpInfo.js';
|
|
34
|
-
import ActivitySequenceElement from './ActivitySequenceElement.js';
|
|
35
|
-
import ActivitySequenceJump from './ActivitySequenceJump.js';
|
|
36
|
-
import { nSlash } from '../Utils.js';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* This class stores the definition of the sequence to follow to show the activities of a
|
|
40
|
-
* {@link module:project/JClicProject.JClicProject JClicProject}. The sequence are formed by an ordered list of objects of type
|
|
41
|
-
* {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement}.
|
|
42
|
-
* It stores also a transient pointer to the current sequence element.
|
|
43
|
-
*/
|
|
44
|
-
export class ActivitySequence {
|
|
45
|
-
/**
|
|
46
|
-
* ActivitySequence constructor
|
|
47
|
-
* @param {module:project/JClicProject.JClicProject} project - The JClic project to which this ActivitySequence belongs
|
|
48
|
-
*/
|
|
49
|
-
constructor(project) {
|
|
50
|
-
this.project = project;
|
|
51
|
-
this.elements = [];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Loads the object settings from a specific JQuery XML element
|
|
56
|
-
* @param {external:jQuery} $xml - The XML element to parse
|
|
57
|
-
*/
|
|
58
|
-
setProperties($xml) {
|
|
59
|
-
$xml.children('item').each((_i, data) => this.elements.push(new ActivitySequenceElement().setProperties($(data))));
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
65
|
-
* parent references, constants and also attributes retaining the default value.
|
|
66
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
67
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
68
|
-
*/
|
|
69
|
-
getAttributes() {
|
|
70
|
-
return this.elements.map(el => el.getAttributes());
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Loads the object settings from a data object
|
|
75
|
-
* @param {object} data - The data object to parse
|
|
76
|
-
*/
|
|
77
|
-
setAttributes(data) {
|
|
78
|
-
data.forEach(el => this.elements.push(new ActivitySequenceElement().setAttributes(el)));
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Returns the index of the specified element in the sequence.
|
|
84
|
-
* @param {module:bags/ActivitySequenceElement.ActivitySequenceElement} ase - The element to search.
|
|
85
|
-
* @returns {number} - The requested index, or `null` if not found.
|
|
86
|
-
*/
|
|
87
|
-
getElementIndex(ase) {
|
|
88
|
-
return ase === null ? -1 : this.elements.indexOf(ase);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Returns the nth element of the sequence.
|
|
93
|
-
* @param {number} n - Index of the requested element
|
|
94
|
-
* @param {boolean} updateCurrentAct - when `true`, the `currentAct` index will be updated.
|
|
95
|
-
* @returns {module:bags/ActivitySequenceElement.ActivitySequenceElement} - The requested element, or `null` if out of range.
|
|
96
|
-
*/
|
|
97
|
-
getElement(n, updateCurrentAct) {
|
|
98
|
-
let result = null;
|
|
99
|
-
if (n >= 0 && n < this.elements.length) {
|
|
100
|
-
result = this.elements[n];
|
|
101
|
-
if (updateCurrentAct)
|
|
102
|
-
this.currentAct = n;
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Search into the sequence for a element with the provided tag
|
|
109
|
-
* @param {string} tag - The tag to search
|
|
110
|
-
* @param {boolean} updateCurrentAct - when `true`, the `currentAct` index will be updated.
|
|
111
|
-
* @returns {module:bags/ActivitySequenceElement.ActivitySequenceElement} - The requested element, or `null` if not found.
|
|
112
|
-
*/
|
|
113
|
-
getElementByTag(tag, updateCurrentAct) {
|
|
114
|
-
let
|
|
115
|
-
result = null,
|
|
116
|
-
resultIndex = -1;
|
|
117
|
-
if (tag) {
|
|
118
|
-
tag = nSlash(tag);
|
|
119
|
-
this.elements.some((el, index) => {
|
|
120
|
-
if (el.tag === tag) {
|
|
121
|
-
result = el;
|
|
122
|
-
resultIndex = index;
|
|
123
|
-
}
|
|
124
|
-
return resultIndex !== -1;
|
|
125
|
-
});
|
|
126
|
-
if (resultIndex !== -1 && updateCurrentAct)
|
|
127
|
-
this.currentAct = resultIndex;
|
|
128
|
-
}
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Gets the sequence element pointed by the `currentAct` member.
|
|
134
|
-
* @returns {module:bags/ActivitySequenceElement.ActivitySequenceElement} - The current sequence element, or `null` if not set.
|
|
135
|
-
*/
|
|
136
|
-
getCurrentAct() {
|
|
137
|
-
return this.getElement(this.currentAct, false);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Checks if it's possible to go forward from the current position in the sequence.
|
|
142
|
-
* @param {boolean} hasReturn - Indicates whether the history of jumps done since the beginning
|
|
143
|
-
* of the JClic session is empty or not. When not empty, a `RETURN` action is still possible.
|
|
144
|
-
* @returns {boolean} - `true` when the user is allowed to go ahead to a next activity,
|
|
145
|
-
* `false` otherwise. */
|
|
146
|
-
hasNextAct(hasReturn) {
|
|
147
|
-
let result = false;
|
|
148
|
-
const ase = this.getCurrentAct();
|
|
149
|
-
if (ase) {
|
|
150
|
-
if (ase.fwdJump === null)
|
|
151
|
-
result = true;
|
|
152
|
-
else
|
|
153
|
-
switch (ase.fwdJump.action) {
|
|
154
|
-
case 'STOP':
|
|
155
|
-
break;
|
|
156
|
-
case 'RETURN':
|
|
157
|
-
result = hasReturn;
|
|
158
|
-
break;
|
|
159
|
-
default:
|
|
160
|
-
result = true;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Checks if it's possible to go back from the current position in the sequence.
|
|
168
|
-
* @param {boolean} hasReturn - Indicates whether the history of jumps done since the beginning
|
|
169
|
-
* of the JClic session is empty or not. When not empty, a `RETURN` action is still possible.
|
|
170
|
-
* @returns {boolean} - `true` when the user is allowed to go back to a previous activity,
|
|
171
|
-
* `false` otherwise. */
|
|
172
|
-
hasPrevAct(hasReturn) {
|
|
173
|
-
let result = false;
|
|
174
|
-
const ase = this.getCurrentAct();
|
|
175
|
-
if (ase) {
|
|
176
|
-
if (ase.backJump === null)
|
|
177
|
-
result = true;
|
|
178
|
-
else
|
|
179
|
-
switch (ase.backJump.action) {
|
|
180
|
-
case 'STOP':
|
|
181
|
-
break;
|
|
182
|
-
case 'RETURN':
|
|
183
|
-
result = hasReturn;
|
|
184
|
-
break;
|
|
185
|
-
default:
|
|
186
|
-
result = true;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Gets the current state for the 'next' and 'prev' buttons.
|
|
194
|
-
* @returns {string} - One of the possible values of {@link module:bags/ActivitySequenceElement.ActivitySequenceElement#navButtons navButtons},
|
|
195
|
-
* thus: `none`, `fwd`, `back` or `both`
|
|
196
|
-
*/
|
|
197
|
-
getNavButtonsFlag() {
|
|
198
|
-
let flag = 'none';
|
|
199
|
-
const ase = this.getCurrentAct();
|
|
200
|
-
if (ase)
|
|
201
|
-
flag = ase.navButtons;
|
|
202
|
-
return flag;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Computes the jump to perform from the current position on the sequence
|
|
207
|
-
* @param {boolean} back - When `true`, the request is for the 'go back' button. Otherwise, is
|
|
208
|
-
* for the 'next' one.
|
|
209
|
-
* @param {module:report/Reporter.Reporter} reporter - The reporting engine that will provide values about score average
|
|
210
|
-
* and time spend on the activities, used only to compute conditional jumps.
|
|
211
|
-
* @returns {module:bags/JumpInfo.JumpInfo} - The jump info if a valid jump is possible, `null` otherwise.
|
|
212
|
-
*/
|
|
213
|
-
getJump(back, reporter) {
|
|
214
|
-
const ase = this.getCurrentAct();
|
|
215
|
-
let result = null;
|
|
216
|
-
if (ase) {
|
|
217
|
-
const asj = back ? ase.backJump : ase.fwdJump;
|
|
218
|
-
if (asj === null) {
|
|
219
|
-
let i = this.currentAct + (back ? -1 : 1);
|
|
220
|
-
if (i >= this.elements.length || i < 0)
|
|
221
|
-
i = 0;
|
|
222
|
-
result = new JumpInfo('JUMP', i);
|
|
223
|
-
} else {
|
|
224
|
-
let
|
|
225
|
-
rating = -1,
|
|
226
|
-
time = -1;
|
|
227
|
-
if (reporter !== null) {
|
|
228
|
-
const seqRegInfo = reporter.getCurrentSequenceInfo();
|
|
229
|
-
if (seqRegInfo !== null) {
|
|
230
|
-
rating = Math.round(seqRegInfo.tScore);
|
|
231
|
-
time = Math.round(seqRegInfo.tTime / 1000);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
result = asj.resolveJump(rating, time);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return result;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Finds the nearest sequence element with a valid 'tag', looking back in the `elements` list.
|
|
242
|
-
* @param {number} num - The point of the sequence from which to start looking back.
|
|
243
|
-
* @returns {string} - The nearest 'tag', or `null` if not found.
|
|
244
|
-
*/
|
|
245
|
-
getSequenceForElement(num) {
|
|
246
|
-
let tag = null;
|
|
247
|
-
if (num >= 0 && num < this.elements.length)
|
|
248
|
-
for (let i = num; tag === null && i >= 0; i--) {
|
|
249
|
-
tag = this.getElement(i, false).tag;
|
|
250
|
-
}
|
|
251
|
-
return tag;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Gets the first {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement} in the `elements` list pointing to the
|
|
256
|
-
* specified activity name.
|
|
257
|
-
* The search is always case-insensitive.
|
|
258
|
-
* @param {string} activity - The name of the activity to search for.
|
|
259
|
-
* @returns {module:bags/ActivitySequenceElement.ActivitySequenceElement} The requested element or `null` if not found.
|
|
260
|
-
*/
|
|
261
|
-
getElementByActivityName(activity) {
|
|
262
|
-
let result = null;
|
|
263
|
-
if (activity !== null) {
|
|
264
|
-
for (let i = 0; result === null && i < this.elements.length; i++) {
|
|
265
|
-
const ase = this.getElement(i, false);
|
|
266
|
-
if (ase.activity.toLowerCase() === activity.toLowerCase())
|
|
267
|
-
result = ase;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return result;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Utility function to check if the current sequence element corresponds to the specified
|
|
275
|
-
* activity. If negative, the `currentAct` will be accordingly set.
|
|
276
|
-
* @param {string} activity - The name of the activity to check
|
|
277
|
-
*/
|
|
278
|
-
checkCurrentActivity(activity) {
|
|
279
|
-
let ase = this.getCurrentAct();
|
|
280
|
-
if (ase === null || ase.activity.toUpperCase() !== activity.toUpperCase()) {
|
|
281
|
-
for (let i = 0; i < this.elements.length; i++) {
|
|
282
|
-
if (this.getElement(i, false).activity.toUpperCase() === activity.toUpperCase()) {
|
|
283
|
-
this.currentAct = i;
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
ase = new ActivitySequenceElement();
|
|
288
|
-
ase.activity = activity;
|
|
289
|
-
ase.fwdJump = new ActivitySequenceJump('STOP');
|
|
290
|
-
ase.backJump = new ActivitySequenceJump('STOP');
|
|
291
|
-
this.elements.push(ase);
|
|
292
|
-
this.currentAct = this.elements.length - 1;
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
return true;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
Object.assign(ActivitySequence.prototype, {
|
|
300
|
-
/**
|
|
301
|
-
* The ordered list of {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement} objects
|
|
302
|
-
* @name module:bags/ActivitySequence.ActivitySequence#elements
|
|
303
|
-
* @type {module:bags/ActivitySequenceElement.ActivitySequenceElement[]} */
|
|
304
|
-
elements: null,
|
|
305
|
-
/**
|
|
306
|
-
* The JClic project to which this ActivitySequence belongs.
|
|
307
|
-
* @name module:bags/ActivitySequence.ActivitySequence#project
|
|
308
|
-
* @type {module:project/JClicProject.JClicProject} */
|
|
309
|
-
project: null,
|
|
310
|
-
/**
|
|
311
|
-
* Pointer to the {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement} currently running (points inside
|
|
312
|
-
* the `elements` array).
|
|
313
|
-
* @name module:bags/ActivitySequence.ActivitySequence#currentAct
|
|
314
|
-
* @type {number} */
|
|
315
|
-
currentAct: -1,
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
export default ActivitySequence;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : bags/ActivitySequenceElement.js
|
|
3
|
-
* Created : 05/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 $ from 'jquery';
|
|
33
|
-
import ActivitySequenceJump from './ActivitySequenceJump.js';
|
|
34
|
-
import { attrForEach, nSlash, getAttr, isEmpty } from '../Utils.js';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* This class is the basic component of {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence} objects. It represents a specific
|
|
39
|
-
* point in the project's sequence of JClic activities.
|
|
40
|
-
*
|
|
41
|
-
* For each point of the sequence, some options can be set:
|
|
42
|
-
* - What activity must run at this point
|
|
43
|
-
* - What to do or where to jump when the activity finishes
|
|
44
|
-
* - The behavior of the "next" button
|
|
45
|
-
* - The behavior of the "prev" button
|
|
46
|
-
*
|
|
47
|
-
* Sequence points can also have a "tag", used to refer to them with a unique name.
|
|
48
|
-
*/
|
|
49
|
-
export class ActivitySequenceElement {
|
|
50
|
-
constructor() {
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Loads the object settings from a specific JQuery XML element
|
|
55
|
-
* @param {external:jQuery} $xml
|
|
56
|
-
*/
|
|
57
|
-
setProperties($xml) {
|
|
58
|
-
|
|
59
|
-
// Iterate on all provided attributes
|
|
60
|
-
attrForEach($xml.get(0).attributes, (name, val) => {
|
|
61
|
-
switch (name) {
|
|
62
|
-
case 'id':
|
|
63
|
-
this['tag'] = nSlash(val);
|
|
64
|
-
break;
|
|
65
|
-
case 'name':
|
|
66
|
-
this['activity'] = val;
|
|
67
|
-
break;
|
|
68
|
-
case 'description':
|
|
69
|
-
// possible navButtons values are: `none`, `fwd`, `back` or `both`
|
|
70
|
-
case 'navButtons':
|
|
71
|
-
this[name] = val;
|
|
72
|
-
break;
|
|
73
|
-
case 'delay':
|
|
74
|
-
this[name] = Number(val);
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Iterate on 'jump' elements to load fwdJump and/or backJump
|
|
80
|
-
$xml.children('jump').each((_n, data) => {
|
|
81
|
-
const jmp = new ActivitySequenceJump().setProperties($(data));
|
|
82
|
-
if (jmp.id === 'forward')
|
|
83
|
-
this.fwdJump = jmp;
|
|
84
|
-
else if (jmp.id === 'back')
|
|
85
|
-
this.backJump = jmp;
|
|
86
|
-
});
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
92
|
-
* parent references, constants and also attributes retaining the default value.
|
|
93
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
94
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
95
|
-
*/
|
|
96
|
-
getAttributes() {
|
|
97
|
-
return getAttr(this, ['tag', 'description', 'activity', 'fwdJump', 'backJump', 'navButtons', 'delay']);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Loads sequence element settings from a data object
|
|
102
|
-
* @param {object} data
|
|
103
|
-
*/
|
|
104
|
-
setAttributes(data) {
|
|
105
|
-
['tag', 'description', 'activity', 'navButtons', 'delay'].forEach(t => {
|
|
106
|
-
if (!isEmpty(data[t]))
|
|
107
|
-
this[t] = data[t];
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
['fwdJump', 'backJump'].forEach(jmp => {
|
|
111
|
-
if (data[jmp]) {
|
|
112
|
-
this[jmp] = new ActivitySequenceJump().setAttributes(data[jmp]);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
Object.assign(ActivitySequenceElement.prototype, {
|
|
120
|
-
/**
|
|
121
|
-
* Optional unique identifier of this element in the {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence}.
|
|
122
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#tag
|
|
123
|
-
* @type {string} */
|
|
124
|
-
tag: null,
|
|
125
|
-
/**
|
|
126
|
-
* Optional description of this sequence element.
|
|
127
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#description
|
|
128
|
-
* @type {string} */
|
|
129
|
-
description: null,
|
|
130
|
-
/**
|
|
131
|
-
* Name of the {@link module:Activity.Activity Activity} pointed by this element.
|
|
132
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#activity
|
|
133
|
-
* @type {string} */
|
|
134
|
-
activity: '',
|
|
135
|
-
/**
|
|
136
|
-
* Jump to be processed by the 'next' button action
|
|
137
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#fwdJump
|
|
138
|
-
* @type {module:bags/ActivitySequenceJump.ActivitySequenceJump} */
|
|
139
|
-
fwdJump: null,
|
|
140
|
-
/**
|
|
141
|
-
* Jump to be processed by the 'prev' button action.
|
|
142
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#backJump
|
|
143
|
-
* @type {module:bags/ActivitySequenceJump.ActivitySequenceJump} */
|
|
144
|
-
backJump: null,
|
|
145
|
-
/**
|
|
146
|
-
* What buttons should be active at this point of the sequence. Valid values are:
|
|
147
|
-
* - 'none'
|
|
148
|
-
* - 'fwd'
|
|
149
|
-
* - 'back'
|
|
150
|
-
* - 'both'
|
|
151
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#navButtons
|
|
152
|
-
* @type {string} */
|
|
153
|
-
navButtons: 'both',
|
|
154
|
-
/**
|
|
155
|
-
* Time delay (in seconds) before passing to the next/prev activity
|
|
156
|
-
* @name module:bags/ActivitySequenceElement.ActivitySequenceElement#delay
|
|
157
|
-
* @type {number} */
|
|
158
|
-
delay: 0,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
export default ActivitySequenceElement;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : bags/ActivitySequenceJump.js
|
|
3
|
-
* Created : 05/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 Catalan Educational Telematic Network (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 JumpInfo from './JumpInfo.js';
|
|
34
|
-
import ConditionalJumpInfo from './ConditionalJumpInfo.js';
|
|
35
|
-
import { getAttr } from '../Utils.js';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* This is a special case of {@link module:bags/JumpInfo.JumpInfo JumpInfo}, used only in {@link module:bags/ActivitySequenceElement.ActivitySequenceElement ActivitySequenceElement} objects.
|
|
39
|
-
* Sequence elements can contain up to two ActivitySequenceJump objects: one to be processed
|
|
40
|
-
* when the user clicks on the "next" button (or when the activity finishes, if in automatic mode),
|
|
41
|
-
* and the other used with the "prev" button. ActivitySequenceJump objects define a default jump
|
|
42
|
-
* or action to be performed, but can also have up to two {@link module:bags/ConditionalJumpInfo.ConditionalJumpInfo ConditionalJumpInfo} objects. These
|
|
43
|
-
* define alternative jumps that are performed only when score or time are below or over a specific
|
|
44
|
-
* threshold.
|
|
45
|
-
* @extends module:bags/JumpInfo.JumpInfo
|
|
46
|
-
*/
|
|
47
|
-
export class ActivitySequenceJump extends JumpInfo {
|
|
48
|
-
/**
|
|
49
|
-
* ActivitySequenceJump constructor
|
|
50
|
-
* @param {string} action - Must be one of the described actions.
|
|
51
|
-
* @param {number|string} [sq] - Can be the tag of the sequence element to jump to, or its
|
|
52
|
-
* cardinal number in the list.
|
|
53
|
-
*/
|
|
54
|
-
constructor(action, sq) {
|
|
55
|
-
super(action, sq);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Loads the object settings from a specific JQuery XML element.
|
|
60
|
-
* @param {external:jQuery} $xml - The XML element to parse
|
|
61
|
-
*/
|
|
62
|
-
setProperties($xml) {
|
|
63
|
-
super.setProperties($xml);
|
|
64
|
-
|
|
65
|
-
// Read conditional jumps
|
|
66
|
-
$xml.children('jump').each((_n, child) => {
|
|
67
|
-
const condJmp = new ConditionalJumpInfo().setProperties($(child));
|
|
68
|
-
if (condJmp.id === 'upper')
|
|
69
|
-
this.upperJump = condJmp;
|
|
70
|
-
else if (condJmp.id === 'lower')
|
|
71
|
-
this.lowerJump = condJmp;
|
|
72
|
-
});
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
78
|
-
* parent references, constants and also attributes retaining the default value.
|
|
79
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
80
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
81
|
-
*/
|
|
82
|
-
getAttributes() {
|
|
83
|
-
return Object.assign(super.getAttributes(), getAttr(this, ['upperJump', 'lowerJump']));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Loads the jump settings from a data object
|
|
88
|
-
* @param {object} data - The data object to parse
|
|
89
|
-
*/
|
|
90
|
-
setAttributes(data) {
|
|
91
|
-
super.setAttributes(data);
|
|
92
|
-
|
|
93
|
-
['upperJump', 'lowerJump'].forEach(cj => {
|
|
94
|
-
if (data[cj])
|
|
95
|
-
this[cj] = new ConditionalJumpInfo().setAttributes(data[cj]);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Resolves what {@link module:bags/JumpInfo.JumpInfo JumpInfo} must be taken, based on a done time and average rating obtained
|
|
104
|
-
* in activities.
|
|
105
|
-
* @param {number} rating - Average rating obtained by the user in the activities done during the
|
|
106
|
-
* last sequence stretch.
|
|
107
|
-
* @param {number} time - Total time spend doing the activities.
|
|
108
|
-
* @returns {module:bags/JumpInfo.JumpInfo}
|
|
109
|
-
*/
|
|
110
|
-
resolveJump(rating, time) {
|
|
111
|
-
let result = this;
|
|
112
|
-
if (rating >= 0 && time >= 0) {
|
|
113
|
-
if (this.upperJump !== null &&
|
|
114
|
-
rating > this.upperJump.threshold &&
|
|
115
|
-
(this.upperJump.time <= 0 || time < this.upperJump.time)) {
|
|
116
|
-
result = this.upperJump;
|
|
117
|
-
} else if (this.lowerJump !== null &&
|
|
118
|
-
(rating < this.lowerJump.threshold ||
|
|
119
|
-
this.lowerJump.time > 0 && time > this.lowerJump.time)) {
|
|
120
|
-
result = this.lowerJump;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Object.assign(ActivitySequenceJump.prototype, {
|
|
128
|
-
/**
|
|
129
|
-
* Optional jump to be performed when the results (score and time) are above a specific threshold.
|
|
130
|
-
* @name module:bags/ActivitySequenceJump.ActivitySequenceJump#upperJump
|
|
131
|
-
* @type {module:bags/ConditionalJumpInfo.ConditionalJumpInfo} */
|
|
132
|
-
upperJump: null,
|
|
133
|
-
/**
|
|
134
|
-
* Optional jump to be performed when the results (score or time) are below a specific threshold.
|
|
135
|
-
* @name module:bags/ActivitySequenceJump.ActivitySequenceJump#lowerJump
|
|
136
|
-
* @type {module:bags/ConditionalJumpInfo.ConditionalJumpInfo} */
|
|
137
|
-
lowerJump: null,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export default ActivitySequenceJump;
|