@gamelearn/arcade-components 0.22.8 → 0.22.9
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/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +41 -9
- package/dist/components/chained-image-click-puzzle-component/mocks/mockForStory.js +263 -3
- package/dist/components/conversational-pro-component/components/Message.js +1 -3
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +46 -11
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +13 -2
- package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +265 -6
- package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +1 -1
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +118 -83
- package/dist/components/konva-components/Area/index.js +1 -1
- package/dist/components/konva-components/KonvaMapper.js +1 -1
- package/package.json +1 -1
package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js
CHANGED
|
@@ -58,6 +58,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
58
58
|
selected = _ref.selected,
|
|
59
59
|
setShowPoints = _ref.setShowPoints;
|
|
60
60
|
var accRewards = (0, _react.useRef)([]);
|
|
61
|
+
var correctClicked = (0, _react.useRef)(0);
|
|
61
62
|
|
|
62
63
|
var _useState = (0, _react.useState)(0),
|
|
63
64
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -89,7 +90,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
89
90
|
setShowPoints([].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rewards)));
|
|
90
91
|
}, [playSound, emitEvent, setShowPoints]);
|
|
91
92
|
var currentImageProps = list[index];
|
|
92
|
-
var info = currentImageProps.info
|
|
93
|
+
var info = currentImageProps.info,
|
|
94
|
+
specificFeedbacks = currentImageProps.specificFeedbacks;
|
|
93
95
|
info.description = description;
|
|
94
96
|
var handleResolve = (0, _react.useCallback)(function () {
|
|
95
97
|
emitEvent({
|
|
@@ -101,18 +103,47 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
}, [emitEvent, puzzleId, info.resolve.rewards]);
|
|
106
|
+
(0, _react.useEffect)(function () {
|
|
107
|
+
correctClicked.current = 0;
|
|
108
|
+
}, [index]);
|
|
104
109
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
111
|
+
|
|
112
|
+
if (correct) {
|
|
113
|
+
var _specificFeedbacks$co;
|
|
114
|
+
|
|
115
|
+
if ((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length) {
|
|
116
|
+
correctClicked.current += 1;
|
|
117
|
+
setSelected(selected + 1);
|
|
118
|
+
} else {
|
|
119
|
+
correctClicked.current += currentImageProps.areas.length;
|
|
120
|
+
setSelected(selected + currentImageProps.areas.length);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (correctClicked.current === currentImageProps.areas.length) {
|
|
124
|
+
if (index + 1 >= list.length) {
|
|
125
|
+
handleFinish(rw);
|
|
126
|
+
} else {
|
|
127
|
+
setIndex(index + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
108
131
|
setRewards(rw);
|
|
109
|
-
|
|
132
|
+
} else {
|
|
133
|
+
emitEvent({
|
|
134
|
+
type: 'addPoints',
|
|
135
|
+
payload: rw,
|
|
136
|
+
finish: false
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (currentImageProps.hasClickOrder) {
|
|
140
|
+
setSelected(selected - correctClicked.current);
|
|
141
|
+
correctClicked.current = 0;
|
|
142
|
+
}
|
|
110
143
|
}
|
|
144
|
+
}, [index, list.length, currentImageProps.hasClickOrder, currentImageProps.areas.length, handleFinish, specificFeedbacks, setSelected, selected, emitEvent]);
|
|
111
145
|
|
|
112
|
-
|
|
113
|
-
}, [index, list.length, selected, currentImageProps.areas.length, handleFinish, setSelected]);
|
|
114
|
-
|
|
115
|
-
var onResolve = function onResolve(resolve) {
|
|
146
|
+
var onResolve = function onResolve() {
|
|
116
147
|
playSound('score');
|
|
117
148
|
setTimeout(function () {
|
|
118
149
|
handleResolve();
|
|
@@ -146,6 +177,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
146
177
|
name: puzzleId,
|
|
147
178
|
component: 'chained-image-click-puzzle'
|
|
148
179
|
},
|
|
180
|
+
specificFeedbacks: specificFeedbacks,
|
|
149
181
|
emitFinish: onComplete,
|
|
150
182
|
emitError: setRewards,
|
|
151
183
|
emitResolve: onResolve,
|
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.mockProps = void 0;
|
|
6
|
+
exports.mockProps2 = exports.mockProps = void 0;
|
|
7
7
|
|
|
8
|
-
var emitEvent = function emitEvent(
|
|
8
|
+
var emitEvent = function emitEvent(_ref) {
|
|
9
|
+
var type = _ref.type,
|
|
10
|
+
payload = _ref.payload;
|
|
9
11
|
console.log('Emit event called', type);
|
|
12
|
+
|
|
13
|
+
if (type === 'translate') {
|
|
14
|
+
return payload;
|
|
15
|
+
}
|
|
10
16
|
};
|
|
11
17
|
|
|
12
18
|
var soundActions = [function (sound) {
|
|
@@ -63,6 +69,7 @@ var mockProps = {
|
|
|
63
69
|
height: 1097
|
|
64
70
|
},
|
|
65
71
|
areas: [{
|
|
72
|
+
id: 'Uno',
|
|
66
73
|
name: 'Uno',
|
|
67
74
|
x: 0,
|
|
68
75
|
y: 0,
|
|
@@ -127,6 +134,7 @@ var mockProps = {
|
|
|
127
134
|
height: 1099
|
|
128
135
|
},
|
|
129
136
|
areas: [{
|
|
137
|
+
id: 'Dos',
|
|
130
138
|
name: 'Uno',
|
|
131
139
|
x: 0,
|
|
132
140
|
y: 0,
|
|
@@ -136,6 +144,7 @@ var mockProps = {
|
|
|
136
144
|
stroke: 'rgb(101,154,93)',
|
|
137
145
|
closed: true
|
|
138
146
|
}, {
|
|
147
|
+
id: 'Tres',
|
|
139
148
|
name: 'Dos',
|
|
140
149
|
x: 0,
|
|
141
150
|
y: 0,
|
|
@@ -161,4 +170,255 @@ var mockProps = {
|
|
|
161
170
|
hasHighlights: true
|
|
162
171
|
}]
|
|
163
172
|
};
|
|
164
|
-
exports.mockProps = mockProps;
|
|
173
|
+
exports.mockProps = mockProps;
|
|
174
|
+
var mockProps2 = {
|
|
175
|
+
nodeId: 'xxas',
|
|
176
|
+
description: 'Dale al arma',
|
|
177
|
+
showFrames: true,
|
|
178
|
+
setInfo: function setInfo() {},
|
|
179
|
+
emitEvent: emitEvent,
|
|
180
|
+
soundActions: soundActions,
|
|
181
|
+
disableExit: function disableExit() {},
|
|
182
|
+
setResolveAction: function setResolveAction() {},
|
|
183
|
+
setShowPoints: function setShowPoints() {},
|
|
184
|
+
list: [{
|
|
185
|
+
info: {
|
|
186
|
+
hint: {
|
|
187
|
+
active: true,
|
|
188
|
+
desc: 'hint',
|
|
189
|
+
rewards: []
|
|
190
|
+
},
|
|
191
|
+
resolve: {
|
|
192
|
+
rewards: []
|
|
193
|
+
},
|
|
194
|
+
solution: {
|
|
195
|
+
right: {
|
|
196
|
+
desc: 'Estupendo',
|
|
197
|
+
desc_labelId: 'alfalfa01',
|
|
198
|
+
rewards: []
|
|
199
|
+
},
|
|
200
|
+
wrong: {
|
|
201
|
+
desc: 'BUUUU',
|
|
202
|
+
desc_labelId: 'fabada01',
|
|
203
|
+
rewards: [{
|
|
204
|
+
id: 'grade',
|
|
205
|
+
name: 'grade',
|
|
206
|
+
points: -17,
|
|
207
|
+
type: 'grade'
|
|
208
|
+
}]
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
instructions: 'instructions'
|
|
212
|
+
},
|
|
213
|
+
itemOrder: 1,
|
|
214
|
+
image: {
|
|
215
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
216
|
+
img: {
|
|
217
|
+
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/image/609a9b30901f3e001247c031/Paz-Vizla-Concept.png',
|
|
218
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
219
|
+
resourceId: '609a9b30901f3e001247c031'
|
|
220
|
+
},
|
|
221
|
+
width: 1920,
|
|
222
|
+
height: 1097
|
|
223
|
+
},
|
|
224
|
+
areas: [{
|
|
225
|
+
id: 'Uno',
|
|
226
|
+
name: 'Uno',
|
|
227
|
+
x: 0,
|
|
228
|
+
y: 0,
|
|
229
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
230
|
+
draggable: true,
|
|
231
|
+
points: [1150.0742574257429, 217.48228650990103, 1570.95297029703, 65.42288056930694, 1704.0049504950498, 195.7595142326733, 1576.383663366337, 421.13327660891093, 1247.8267326732675, 510.73971225247533],
|
|
232
|
+
stroke: 'rgb(101,154,93)',
|
|
233
|
+
closed: true
|
|
234
|
+
}],
|
|
235
|
+
badAreas: [{
|
|
236
|
+
id: 'AllArea',
|
|
237
|
+
name: 'BadArea',
|
|
238
|
+
x: 0,
|
|
239
|
+
y: 0,
|
|
240
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
241
|
+
draggable: true,
|
|
242
|
+
points: [0, 0, 1920, 0, 1920, 1097, 0, 1097, 0, 0],
|
|
243
|
+
stroke: '#ff634d',
|
|
244
|
+
strokeWidth: 2,
|
|
245
|
+
closed: true
|
|
246
|
+
}],
|
|
247
|
+
hasClickOrder: false,
|
|
248
|
+
hasHighlights: true,
|
|
249
|
+
specificFeedbacks: {
|
|
250
|
+
correctFeedbacks: [{
|
|
251
|
+
id: 'Uno',
|
|
252
|
+
desc: 'specificFeedbacks 1 correcto',
|
|
253
|
+
rewards: [{
|
|
254
|
+
id: 'k2koxnkq',
|
|
255
|
+
name: 'Power',
|
|
256
|
+
points: 10,
|
|
257
|
+
type: 'score'
|
|
258
|
+
}]
|
|
259
|
+
}, {
|
|
260
|
+
id: 'Dos',
|
|
261
|
+
desc: 'specificFeedbacks 2 correcto',
|
|
262
|
+
rewards: [{
|
|
263
|
+
id: 'k2koxnkq',
|
|
264
|
+
name: 'Power',
|
|
265
|
+
points: 10,
|
|
266
|
+
type: 'score'
|
|
267
|
+
}]
|
|
268
|
+
}, {
|
|
269
|
+
id: 'Tres',
|
|
270
|
+
desc: 'specificFeedbacks 3 correcto',
|
|
271
|
+
rewards: [{
|
|
272
|
+
id: 'k2koxnkq',
|
|
273
|
+
name: 'Power',
|
|
274
|
+
points: 10,
|
|
275
|
+
type: 'score'
|
|
276
|
+
}]
|
|
277
|
+
}],
|
|
278
|
+
wrongFeedbacks: [{
|
|
279
|
+
id: 'Uno_bad',
|
|
280
|
+
desc: 'specificFeedbacks 1 incorrecto',
|
|
281
|
+
rewards: [{
|
|
282
|
+
id: 'k2koxnkq',
|
|
283
|
+
name: 'Power',
|
|
284
|
+
points: -10,
|
|
285
|
+
type: 'score'
|
|
286
|
+
}]
|
|
287
|
+
}, {
|
|
288
|
+
id: 'Dos_bad',
|
|
289
|
+
desc: 'specificFeedbacks 2 incorrecto',
|
|
290
|
+
rewards: [{
|
|
291
|
+
id: 'k2koxnkq',
|
|
292
|
+
name: 'Power',
|
|
293
|
+
points: -10,
|
|
294
|
+
type: 'score'
|
|
295
|
+
}]
|
|
296
|
+
}]
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
info: {
|
|
300
|
+
hint: {
|
|
301
|
+
active: true,
|
|
302
|
+
desc: 'hint',
|
|
303
|
+
rewards: []
|
|
304
|
+
},
|
|
305
|
+
resolve: {
|
|
306
|
+
rewards: []
|
|
307
|
+
},
|
|
308
|
+
solution: {
|
|
309
|
+
right: {
|
|
310
|
+
desc: 'Estupendo',
|
|
311
|
+
desc_labelId: 'alfalfa01',
|
|
312
|
+
rewards: []
|
|
313
|
+
},
|
|
314
|
+
wrong: {
|
|
315
|
+
desc: 'BUUUU',
|
|
316
|
+
desc_labelId: 'fabada01',
|
|
317
|
+
rewards: [{
|
|
318
|
+
id: 'grade',
|
|
319
|
+
name: 'grade',
|
|
320
|
+
points: -17,
|
|
321
|
+
type: 'grade'
|
|
322
|
+
}]
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
instructions: 'instructions'
|
|
326
|
+
},
|
|
327
|
+
itemOrder: 2,
|
|
328
|
+
image: {
|
|
329
|
+
imgName: 'pablo-carpio-slave2.jpeg',
|
|
330
|
+
img: {
|
|
331
|
+
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/image/609e3d358782ea00116a7eee/pablo-carpio-slave2.jpeg',
|
|
332
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
333
|
+
resourceId: '609e3d358782ea00116a7eee'
|
|
334
|
+
},
|
|
335
|
+
width: 1920,
|
|
336
|
+
height: 1099
|
|
337
|
+
},
|
|
338
|
+
areas: [{
|
|
339
|
+
id: 'Dos',
|
|
340
|
+
name: 'Uno',
|
|
341
|
+
x: 0,
|
|
342
|
+
y: 0,
|
|
343
|
+
fill: 'rgba(68, 215, 171, 0.56)',
|
|
344
|
+
draggable: true,
|
|
345
|
+
points: [1305.4777227722775, 606.8812654702971, 1455.094059405941, 593.2797803217823, 1463.2549504950498, 941.4778001237626, 1346.282178217822, 1012.2055228960397, 1275.5544554455448, 906.1139387376239],
|
|
346
|
+
stroke: 'rgb(101,154,93)',
|
|
347
|
+
closed: true
|
|
348
|
+
}, {
|
|
349
|
+
id: 'Tres',
|
|
350
|
+
name: 'Dos',
|
|
351
|
+
x: 0,
|
|
352
|
+
y: 0,
|
|
353
|
+
fill: 'rgba(68, 215, 171, 0.56)',
|
|
354
|
+
draggable: true,
|
|
355
|
+
points: [171.1138613861387, 506.23027537128723, 312.5693069306932, 519.8317605198021, 304.4084158415843, 593.2797803217823, 157.51237623762387, 585.1188892326734],
|
|
356
|
+
stroke: 'rgb(101,154,93)',
|
|
357
|
+
closed: true
|
|
358
|
+
}],
|
|
359
|
+
badAreas: [{
|
|
360
|
+
id: 'AllArea',
|
|
361
|
+
name: 'BadArea',
|
|
362
|
+
x: 0,
|
|
363
|
+
y: 0,
|
|
364
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
365
|
+
draggable: true,
|
|
366
|
+
points: [0, 0, 1920, 0, 1920, 1099, 0, 1099, 0, 0],
|
|
367
|
+
stroke: '#ff634d',
|
|
368
|
+
strokeWidth: 2,
|
|
369
|
+
closed: true
|
|
370
|
+
}],
|
|
371
|
+
hasClickOrder: true,
|
|
372
|
+
hasHighlights: true,
|
|
373
|
+
specificFeedbacks: {
|
|
374
|
+
correctFeedbacks: [{
|
|
375
|
+
id: 'Uno',
|
|
376
|
+
desc: 'specificFeedbacks 1 correcto',
|
|
377
|
+
rewards: [{
|
|
378
|
+
id: 'k2koxnkq',
|
|
379
|
+
name: 'Power',
|
|
380
|
+
points: 10,
|
|
381
|
+
type: 'score'
|
|
382
|
+
}]
|
|
383
|
+
}, {
|
|
384
|
+
id: 'Dos',
|
|
385
|
+
desc: 'specificFeedbacks 2 correcto',
|
|
386
|
+
rewards: [{
|
|
387
|
+
id: 'k2koxnkq',
|
|
388
|
+
name: 'Power',
|
|
389
|
+
points: 10,
|
|
390
|
+
type: 'score'
|
|
391
|
+
}]
|
|
392
|
+
}, {
|
|
393
|
+
id: 'Tres',
|
|
394
|
+
desc: 'specificFeedbacks 3 correcto',
|
|
395
|
+
rewards: [{
|
|
396
|
+
id: 'k2koxnkq',
|
|
397
|
+
name: 'Power',
|
|
398
|
+
points: 10,
|
|
399
|
+
type: 'score'
|
|
400
|
+
}]
|
|
401
|
+
}],
|
|
402
|
+
wrongFeedbacks: [{
|
|
403
|
+
id: 'Uno_bad',
|
|
404
|
+
desc: 'specificFeedbacks 1 incorrecto',
|
|
405
|
+
rewards: [{
|
|
406
|
+
id: 'k2koxnkq',
|
|
407
|
+
name: 'Power',
|
|
408
|
+
points: -10,
|
|
409
|
+
type: 'score'
|
|
410
|
+
}]
|
|
411
|
+
}, {
|
|
412
|
+
id: 'Dos_bad',
|
|
413
|
+
desc: 'specificFeedbacks 2 incorrecto',
|
|
414
|
+
rewards: [{
|
|
415
|
+
id: 'k2koxnkq',
|
|
416
|
+
name: 'Power',
|
|
417
|
+
points: -10,
|
|
418
|
+
type: 'score'
|
|
419
|
+
}]
|
|
420
|
+
}]
|
|
421
|
+
}
|
|
422
|
+
}]
|
|
423
|
+
};
|
|
424
|
+
exports.mockProps2 = mockProps2;
|
|
@@ -19,9 +19,7 @@ var Message = function Message(_ref) {
|
|
|
19
19
|
className: "conversation--message ".concat(voiceOver ? 'voice--over' : '')
|
|
20
20
|
}, voiceOver ? /*#__PURE__*/_react.default.createElement("div", {
|
|
21
21
|
className: "conversation--voice__over"
|
|
22
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
23
|
-
className: "icon-voice-over"
|
|
24
|
-
}), /*#__PURE__*/_react.default.createElement("span", null, current.name ? current.name : 'Voice-Over')) : /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("span", {
|
|
22
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, current.name ? current.name : 'Voice-Over')) : /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("span", {
|
|
25
23
|
className: "conversation--main__text"
|
|
26
24
|
}, currentText));
|
|
27
25
|
};
|
|
@@ -44,7 +44,6 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
44
44
|
framesCompleted = _ref.framesCompleted,
|
|
45
45
|
handleFinish = _ref.handleFinish,
|
|
46
46
|
setRewards = _ref.setRewards,
|
|
47
|
-
accRewards = _ref.accRewards,
|
|
48
47
|
setIndex = _ref.setIndex,
|
|
49
48
|
setFramesCompleted = _ref.setFramesCompleted,
|
|
50
49
|
loadPuzzleStatus = _ref.loadPuzzleStatus,
|
|
@@ -55,14 +54,18 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
55
54
|
translateFromParent = _ref.translateFromParent,
|
|
56
55
|
setInfo = _ref.setInfo,
|
|
57
56
|
emitEvent = _ref.emitEvent,
|
|
58
|
-
nodeId = _ref.nodeId
|
|
57
|
+
nodeId = _ref.nodeId,
|
|
58
|
+
setSelected = _ref.setSelected,
|
|
59
|
+
selected = _ref.selected;
|
|
59
60
|
|
|
60
61
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
61
62
|
playSound = _soundActions[0];
|
|
62
63
|
|
|
63
64
|
var props = list[index];
|
|
64
|
-
var info = props.info
|
|
65
|
+
var info = props.info,
|
|
66
|
+
specificFeedbacks = props.specificFeedbacks;
|
|
65
67
|
info.description = description;
|
|
68
|
+
var correctClicked = (0, _react.useRef)(0);
|
|
66
69
|
var puzzleId = "frame-image-click-puzzle_".concat(index, "_").concat(nodeId);
|
|
67
70
|
(0, _react.useEffect)(function () {
|
|
68
71
|
puzzlesCompiledRef.current += 1;
|
|
@@ -72,18 +75,49 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
72
75
|
hintId: puzzleId
|
|
73
76
|
}));
|
|
74
77
|
}, [setInfo, info, puzzleId]);
|
|
78
|
+
(0, _react.useEffect)(function () {
|
|
79
|
+
correctClicked.current = 0;
|
|
80
|
+
}, [index]);
|
|
75
81
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
76
|
-
var
|
|
82
|
+
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
83
|
+
|
|
84
|
+
var updatedCompleted = _objectSpread({}, framesCompleted);
|
|
85
|
+
|
|
86
|
+
if (correct) {
|
|
87
|
+
var _specificFeedbacks$co;
|
|
88
|
+
|
|
89
|
+
if ((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length) {
|
|
90
|
+
correctClicked.current += 1;
|
|
91
|
+
setSelected(selected + 1);
|
|
92
|
+
} else {
|
|
93
|
+
correctClicked.current += props.areas.length;
|
|
94
|
+
setSelected(selected + props.areas.length);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (correctClicked.current === props.areas.length) {
|
|
98
|
+
if (index + 1 >= list.length) {
|
|
99
|
+
handleFinish(rw);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
updatedCompleted = _objectSpread(_objectSpread({}, updatedCompleted), {}, _defineProperty({}, index, true));
|
|
103
|
+
setFramesCompleted(updatedCompleted);
|
|
104
|
+
setIndex(index + 1 > list.length - 1 ? 0 : index + 1);
|
|
105
|
+
}
|
|
77
106
|
|
|
78
|
-
if (Object.keys(updatedCompleted).length === list.length) {
|
|
79
|
-
handleFinish(rw);
|
|
80
|
-
} else {
|
|
81
107
|
setRewards(rw);
|
|
82
|
-
|
|
108
|
+
} else {
|
|
109
|
+
emitEvent({
|
|
110
|
+
type: 'addPoints',
|
|
111
|
+
payload: rw,
|
|
112
|
+
finish: false
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (props.hasClickOrder) {
|
|
116
|
+
setSelected(selected - correctClicked.current);
|
|
117
|
+
correctClicked.current = 0;
|
|
118
|
+
}
|
|
83
119
|
}
|
|
84
|
-
|
|
85
|
-
setFramesCompleted(updatedCompleted);
|
|
86
|
-
}, [framesCompleted, handleFinish, index, list.length, setFramesCompleted, setIndex, setRewards]);
|
|
120
|
+
}, [emitEvent, specificFeedbacks, framesCompleted, props.hasClickOrder, props.areas.length, list.length, selected, setSelected, setRewards, index, setFramesCompleted, setIndex, handleFinish]);
|
|
87
121
|
var handleResolve = (0, _react.useCallback)(function () {
|
|
88
122
|
playSound('score');
|
|
89
123
|
emitEvent({
|
|
@@ -114,6 +148,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
114
148
|
name: "",
|
|
115
149
|
component: 'frame-click-puzzle'
|
|
116
150
|
},
|
|
151
|
+
specificFeedbacks: specificFeedbacks,
|
|
117
152
|
emitFinish: onComplete,
|
|
118
153
|
emitResolve: handleResolve,
|
|
119
154
|
hideContinue: true,
|
package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js
CHANGED
|
@@ -63,12 +63,21 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
|
|
|
63
63
|
framesCompleted = _useState4[0],
|
|
64
64
|
setFramesCompleted = _useState4[1];
|
|
65
65
|
|
|
66
|
+
var _useState5 = (0, _react.useState)(0),
|
|
67
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
68
|
+
selected = _useState6[0],
|
|
69
|
+
setSelected = _useState6[1];
|
|
70
|
+
|
|
66
71
|
var puzzlesCompiledRef = (0, _react.useRef)(0);
|
|
67
72
|
var hideTooltipRef = (0, _react.useRef)(false);
|
|
68
73
|
|
|
69
74
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
70
75
|
playSound = _soundActions[0];
|
|
71
76
|
|
|
77
|
+
var totalCorrects = list.reduce(function (acc, current) {
|
|
78
|
+
return acc + current.areas.length;
|
|
79
|
+
}, 0);
|
|
80
|
+
|
|
72
81
|
var setRewards = function setRewards(rw) {
|
|
73
82
|
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rw));
|
|
74
83
|
};
|
|
@@ -121,6 +130,8 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
|
|
|
121
130
|
handleFinish: handleFinish,
|
|
122
131
|
setRewards: setRewards,
|
|
123
132
|
accRewards: accRewards,
|
|
133
|
+
setSelected: setSelected,
|
|
134
|
+
selected: selected,
|
|
124
135
|
setIndex: setIndex,
|
|
125
136
|
setFramesCompleted: setFramesCompleted,
|
|
126
137
|
loadPuzzleStatus: loadPuzzleStatus,
|
|
@@ -161,8 +172,8 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
|
|
|
161
172
|
}))), showFrames ? /*#__PURE__*/_react.default.createElement("div", {
|
|
162
173
|
className: "puzzle-frame__info"
|
|
163
174
|
}, /*#__PURE__*/_react.default.createElement(_Counter.default, {
|
|
164
|
-
current:
|
|
165
|
-
total:
|
|
175
|
+
current: selected,
|
|
176
|
+
total: totalCorrects,
|
|
166
177
|
tooltip: !hideTooltipRef.current,
|
|
167
178
|
emitEvent: emitEvent
|
|
168
179
|
})) : null));
|
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.mockPropsOnce = exports.mockProps = void 0;
|
|
6
|
+
exports.mockProps2 = exports.mockPropsOnce = exports.mockProps = void 0;
|
|
7
|
+
|
|
8
|
+
var emitEvent = function emitEvent(_ref) {
|
|
9
|
+
var type = _ref.type,
|
|
10
|
+
payload = _ref.payload;
|
|
11
|
+
|
|
12
|
+
if (type === 'translate') {
|
|
13
|
+
return payload;
|
|
14
|
+
}
|
|
7
15
|
|
|
8
|
-
var emitEvent = function emitEvent(type) {
|
|
9
16
|
console.log('Emit event called', type);
|
|
10
17
|
};
|
|
11
18
|
|
|
12
|
-
var soundActions = [function (
|
|
13
|
-
console.log('PlaySound called :', sound);
|
|
14
|
-
}, function () {}];
|
|
19
|
+
var soundActions = [function () {}, function () {}];
|
|
15
20
|
var mockProps = {
|
|
16
21
|
nodeId: 'xxas',
|
|
17
22
|
description: 'Dale al arma',
|
|
@@ -63,6 +68,7 @@ var mockProps = {
|
|
|
63
68
|
height: 1097
|
|
64
69
|
},
|
|
65
70
|
areas: [{
|
|
71
|
+
id: 'Uno',
|
|
66
72
|
name: 'Uno',
|
|
67
73
|
x: 0,
|
|
68
74
|
y: 0,
|
|
@@ -127,6 +133,7 @@ var mockProps = {
|
|
|
127
133
|
height: 1099
|
|
128
134
|
},
|
|
129
135
|
areas: [{
|
|
136
|
+
id: 'Dos',
|
|
130
137
|
name: 'Uno',
|
|
131
138
|
x: 0,
|
|
132
139
|
y: 0,
|
|
@@ -136,6 +143,7 @@ var mockProps = {
|
|
|
136
143
|
stroke: 'rgb(101,154,93)',
|
|
137
144
|
closed: true
|
|
138
145
|
}, {
|
|
146
|
+
id: 'Tres',
|
|
139
147
|
name: 'Dos',
|
|
140
148
|
x: 0,
|
|
141
149
|
y: 0,
|
|
@@ -313,4 +321,255 @@ var mockPropsOnce = {
|
|
|
313
321
|
hasClickOnce: true
|
|
314
322
|
}]
|
|
315
323
|
};
|
|
316
|
-
exports.mockPropsOnce = mockPropsOnce;
|
|
324
|
+
exports.mockPropsOnce = mockPropsOnce;
|
|
325
|
+
var mockProps2 = {
|
|
326
|
+
nodeId: 'xxas',
|
|
327
|
+
description: 'Dale al arma',
|
|
328
|
+
isFrame: true,
|
|
329
|
+
showFrames: true,
|
|
330
|
+
setInfo: function setInfo() {},
|
|
331
|
+
emitEvent: emitEvent,
|
|
332
|
+
soundActions: soundActions,
|
|
333
|
+
disableExit: function disableExit() {},
|
|
334
|
+
setResolveAction: function setResolveAction() {},
|
|
335
|
+
list: [{
|
|
336
|
+
info: {
|
|
337
|
+
hint: {
|
|
338
|
+
active: true,
|
|
339
|
+
desc: 'hint',
|
|
340
|
+
rewards: []
|
|
341
|
+
},
|
|
342
|
+
resolve: {
|
|
343
|
+
rewards: []
|
|
344
|
+
},
|
|
345
|
+
solution: {
|
|
346
|
+
right: {
|
|
347
|
+
desc: 'Estupendo',
|
|
348
|
+
desc_labelId: 'alfalfa01',
|
|
349
|
+
rewards: []
|
|
350
|
+
},
|
|
351
|
+
wrong: {
|
|
352
|
+
desc: 'BUUUU',
|
|
353
|
+
desc_labelId: 'fabada01',
|
|
354
|
+
rewards: [{
|
|
355
|
+
id: 'grade',
|
|
356
|
+
name: 'grade',
|
|
357
|
+
points: -17,
|
|
358
|
+
type: 'grade'
|
|
359
|
+
}]
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
instructions: 'instructions'
|
|
363
|
+
},
|
|
364
|
+
itemOrder: 1,
|
|
365
|
+
image: {
|
|
366
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
367
|
+
img: {
|
|
368
|
+
url: 'https://gl-lms-storage.s3-eu-west-1.amazonaws.com/development/clients/58dccfba26561500117caf53/image/609a9b30901f3e001247c031/Paz-Vizla-Concept.png',
|
|
369
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
370
|
+
resourceId: '609a9b30901f3e001247c031'
|
|
371
|
+
},
|
|
372
|
+
width: 1920,
|
|
373
|
+
height: 1097
|
|
374
|
+
},
|
|
375
|
+
areas: [{
|
|
376
|
+
id: 'Uno',
|
|
377
|
+
name: 'Uno',
|
|
378
|
+
x: 0,
|
|
379
|
+
y: 0,
|
|
380
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
381
|
+
draggable: true,
|
|
382
|
+
points: [1150.0742574257429, 217.48228650990103, 1570.95297029703, 65.42288056930694, 1704.0049504950498, 195.7595142326733, 1576.383663366337, 421.13327660891093, 1247.8267326732675, 510.73971225247533],
|
|
383
|
+
stroke: 'rgb(101,154,93)',
|
|
384
|
+
closed: true
|
|
385
|
+
}],
|
|
386
|
+
badAreas: [{
|
|
387
|
+
id: 'AllArea',
|
|
388
|
+
name: 'BadArea',
|
|
389
|
+
x: 0,
|
|
390
|
+
y: 0,
|
|
391
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
392
|
+
draggable: true,
|
|
393
|
+
points: [0, 0, 1920, 0, 1920, 1097, 0, 1097, 0, 0],
|
|
394
|
+
stroke: '#ff634d',
|
|
395
|
+
strokeWidth: 2,
|
|
396
|
+
closed: true
|
|
397
|
+
}],
|
|
398
|
+
hasClickOrder: false,
|
|
399
|
+
hasHighlights: true,
|
|
400
|
+
specificFeedbacks: {
|
|
401
|
+
correctFeedbacks: [{
|
|
402
|
+
id: 'Uno',
|
|
403
|
+
desc: 'specificFeedbacks 1 correcto',
|
|
404
|
+
rewards: [{
|
|
405
|
+
id: 'k2koxnkq',
|
|
406
|
+
name: 'Power',
|
|
407
|
+
points: 10,
|
|
408
|
+
type: 'score'
|
|
409
|
+
}]
|
|
410
|
+
}, {
|
|
411
|
+
id: 'Dos',
|
|
412
|
+
desc: 'specificFeedbacks 2 correcto',
|
|
413
|
+
rewards: [{
|
|
414
|
+
id: 'k2koxnkq',
|
|
415
|
+
name: 'Power',
|
|
416
|
+
points: 10,
|
|
417
|
+
type: 'score'
|
|
418
|
+
}]
|
|
419
|
+
}, {
|
|
420
|
+
id: 'Tres',
|
|
421
|
+
desc: 'specificFeedbacks 3 correcto',
|
|
422
|
+
rewards: [{
|
|
423
|
+
id: 'k2koxnkq',
|
|
424
|
+
name: 'Power',
|
|
425
|
+
points: 10,
|
|
426
|
+
type: 'score'
|
|
427
|
+
}]
|
|
428
|
+
}],
|
|
429
|
+
wrongFeedbacks: [{
|
|
430
|
+
id: 'Uno_bad',
|
|
431
|
+
desc: 'specificFeedbacks 1 incorrecto',
|
|
432
|
+
rewards: [{
|
|
433
|
+
id: 'k2koxnkq',
|
|
434
|
+
name: 'Power',
|
|
435
|
+
points: -10,
|
|
436
|
+
type: 'score'
|
|
437
|
+
}]
|
|
438
|
+
}, {
|
|
439
|
+
id: 'Dos_bad',
|
|
440
|
+
desc: 'specificFeedbacks 2 incorrecto',
|
|
441
|
+
rewards: [{
|
|
442
|
+
id: 'k2koxnkq',
|
|
443
|
+
name: 'Power',
|
|
444
|
+
points: -10,
|
|
445
|
+
type: 'score'
|
|
446
|
+
}]
|
|
447
|
+
}]
|
|
448
|
+
}
|
|
449
|
+
}, {
|
|
450
|
+
info: {
|
|
451
|
+
hint: {
|
|
452
|
+
active: true,
|
|
453
|
+
desc: 'hint',
|
|
454
|
+
rewards: []
|
|
455
|
+
},
|
|
456
|
+
resolve: {
|
|
457
|
+
rewards: []
|
|
458
|
+
},
|
|
459
|
+
solution: {
|
|
460
|
+
right: {
|
|
461
|
+
desc: 'Estupendo',
|
|
462
|
+
desc_labelId: 'alfalfa01',
|
|
463
|
+
rewards: []
|
|
464
|
+
},
|
|
465
|
+
wrong: {
|
|
466
|
+
desc: 'BUUUU',
|
|
467
|
+
desc_labelId: 'fabada01',
|
|
468
|
+
rewards: [{
|
|
469
|
+
id: 'grade',
|
|
470
|
+
name: 'grade',
|
|
471
|
+
points: -17,
|
|
472
|
+
type: 'grade'
|
|
473
|
+
}]
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
instructions: 'instructions'
|
|
477
|
+
},
|
|
478
|
+
itemOrder: 2,
|
|
479
|
+
image: {
|
|
480
|
+
imgName: 'pablo-carpio-slave2.jpeg',
|
|
481
|
+
img: {
|
|
482
|
+
url: 'https://gl-lms-storage.s3-eu-west-1.amazonaws.com/development/clients/58dccfba26561500117caf53/image/609e3d358782ea00116a7eee/pablo-carpio-slave2.jpeg',
|
|
483
|
+
imgName: 'Paz-Vizla-Concept.png',
|
|
484
|
+
resourceId: '609e3d358782ea00116a7eee'
|
|
485
|
+
},
|
|
486
|
+
width: 1920,
|
|
487
|
+
height: 1099
|
|
488
|
+
},
|
|
489
|
+
areas: [{
|
|
490
|
+
id: 'Dos',
|
|
491
|
+
name: 'Uno',
|
|
492
|
+
x: 0,
|
|
493
|
+
y: 0,
|
|
494
|
+
fill: 'rgba(68, 215, 171, 0.56)',
|
|
495
|
+
draggable: true,
|
|
496
|
+
points: [1305.4777227722775, 606.8812654702971, 1455.094059405941, 593.2797803217823, 1463.2549504950498, 941.4778001237626, 1346.282178217822, 1012.2055228960397, 1275.5544554455448, 906.1139387376239],
|
|
497
|
+
stroke: 'rgb(101,154,93)',
|
|
498
|
+
closed: true
|
|
499
|
+
}, {
|
|
500
|
+
id: 'Tres',
|
|
501
|
+
name: 'Dos',
|
|
502
|
+
x: 0,
|
|
503
|
+
y: 0,
|
|
504
|
+
fill: 'rgba(68, 215, 171, 0.56)',
|
|
505
|
+
draggable: true,
|
|
506
|
+
points: [171.1138613861387, 506.23027537128723, 312.5693069306932, 519.8317605198021, 304.4084158415843, 593.2797803217823, 157.51237623762387, 585.1188892326734],
|
|
507
|
+
stroke: 'rgb(101,154,93)',
|
|
508
|
+
closed: true
|
|
509
|
+
}],
|
|
510
|
+
badAreas: [{
|
|
511
|
+
id: 'AllArea',
|
|
512
|
+
name: 'BadArea',
|
|
513
|
+
x: 0,
|
|
514
|
+
y: 0,
|
|
515
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
516
|
+
draggable: true,
|
|
517
|
+
points: [0, 0, 1920, 0, 1920, 1099, 0, 1099, 0, 0],
|
|
518
|
+
stroke: '#ff634d',
|
|
519
|
+
strokeWidth: 2,
|
|
520
|
+
closed: true
|
|
521
|
+
}],
|
|
522
|
+
hasClickOrder: true,
|
|
523
|
+
hasHighlights: true,
|
|
524
|
+
specificFeedbacks: {
|
|
525
|
+
correctFeedbacks: [{
|
|
526
|
+
id: 'Uno',
|
|
527
|
+
desc: 'specificFeedbacks 1 correcto',
|
|
528
|
+
rewards: [{
|
|
529
|
+
id: 'k2koxnkq',
|
|
530
|
+
name: 'Power',
|
|
531
|
+
points: 10,
|
|
532
|
+
type: 'score'
|
|
533
|
+
}]
|
|
534
|
+
}, {
|
|
535
|
+
id: 'Dos',
|
|
536
|
+
desc: 'specificFeedbacks 2 correcto',
|
|
537
|
+
rewards: [{
|
|
538
|
+
id: 'k2koxnkq',
|
|
539
|
+
name: 'Power',
|
|
540
|
+
points: 10,
|
|
541
|
+
type: 'score'
|
|
542
|
+
}]
|
|
543
|
+
}, {
|
|
544
|
+
id: 'Tres',
|
|
545
|
+
desc: 'specificFeedbacks 3 correcto',
|
|
546
|
+
rewards: [{
|
|
547
|
+
id: 'k2koxnkq',
|
|
548
|
+
name: 'Power',
|
|
549
|
+
points: 10,
|
|
550
|
+
type: 'score'
|
|
551
|
+
}]
|
|
552
|
+
}],
|
|
553
|
+
wrongFeedbacks: [{
|
|
554
|
+
id: 'Uno_bad',
|
|
555
|
+
desc: 'specificFeedbacks 1 incorrecto',
|
|
556
|
+
rewards: [{
|
|
557
|
+
id: 'k2koxnkq',
|
|
558
|
+
name: 'Power',
|
|
559
|
+
points: -10,
|
|
560
|
+
type: 'score'
|
|
561
|
+
}]
|
|
562
|
+
}, {
|
|
563
|
+
id: 'Dos_bad',
|
|
564
|
+
desc: 'specificFeedbacks 2 incorrecto',
|
|
565
|
+
rewards: [{
|
|
566
|
+
id: 'k2koxnkq',
|
|
567
|
+
name: 'Power',
|
|
568
|
+
points: -10,
|
|
569
|
+
type: 'score'
|
|
570
|
+
}]
|
|
571
|
+
}]
|
|
572
|
+
}
|
|
573
|
+
}]
|
|
574
|
+
};
|
|
575
|
+
exports.mockProps2 = mockProps2;
|
|
@@ -8,7 +8,7 @@ exports.mockProps4 = exports.mockProps3 = exports.mockProps2 = exports.mockProps
|
|
|
8
8
|
var emitEvent = function emitEvent(_ref) {
|
|
9
9
|
var type = _ref.type,
|
|
10
10
|
payload = _ref.payload;
|
|
11
|
-
console.log('Emit event called');
|
|
11
|
+
console.log('Emit event called', type);
|
|
12
12
|
|
|
13
13
|
if (type === 'translate') {
|
|
14
14
|
return payload;
|
package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js
CHANGED
|
@@ -57,32 +57,7 @@ var ImageReview = function ImageReview() {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
60
|
-
|
|
61
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
-
clickedZones = _useState2[0],
|
|
63
|
-
setClickedZones = _useState2[1];
|
|
64
|
-
|
|
65
|
-
var _useState3 = (0, _react.useState)(false),
|
|
66
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
67
|
-
completed = _useState4[0],
|
|
68
|
-
setCompleted = _useState4[1];
|
|
69
|
-
|
|
70
|
-
var _useState5 = (0, _react.useState)(false),
|
|
71
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
72
|
-
finished = _useState6[0],
|
|
73
|
-
setFinished = _useState6[1];
|
|
74
|
-
|
|
75
|
-
var _useState7 = (0, _react.useState)(false),
|
|
76
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
77
|
-
showWrongFeedback = _useState8[0],
|
|
78
|
-
setShowWrongFeedback = _useState8[1];
|
|
79
|
-
|
|
80
|
-
var _useState9 = (0, _react.useState)(false),
|
|
81
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
82
|
-
disableClick = _useState10[0],
|
|
83
|
-
setDisableClick = _useState10[1]; // Common config
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
// Common config
|
|
86
61
|
var soundActions = props.soundActions,
|
|
87
62
|
emitEvent = props.emitEvent,
|
|
88
63
|
disableExit = props.disableExit,
|
|
@@ -99,7 +74,33 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
99
74
|
className = props.className,
|
|
100
75
|
emitFinish = props.emitFinish,
|
|
101
76
|
emitResolve = props.emitResolve,
|
|
102
|
-
translateFromParent = props.translateFromParent
|
|
77
|
+
translateFromParent = props.translateFromParent,
|
|
78
|
+
specificFeedbacks = props.specificFeedbacks;
|
|
79
|
+
|
|
80
|
+
var _useState = (0, _react.useState)([]),
|
|
81
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
82
|
+
clickedZones = _useState2[0],
|
|
83
|
+
setClickedZones = _useState2[1];
|
|
84
|
+
|
|
85
|
+
var _useState3 = (0, _react.useState)(false),
|
|
86
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
87
|
+
completed = _useState4[0],
|
|
88
|
+
setCompleted = _useState4[1];
|
|
89
|
+
|
|
90
|
+
var _useState5 = (0, _react.useState)(false),
|
|
91
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
92
|
+
finished = _useState6[0],
|
|
93
|
+
setFinished = _useState6[1];
|
|
94
|
+
|
|
95
|
+
var _useState7 = (0, _react.useState)({
|
|
96
|
+
show: false,
|
|
97
|
+
success: false,
|
|
98
|
+
text: '',
|
|
99
|
+
rewards: []
|
|
100
|
+
}),
|
|
101
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
102
|
+
feedbackData = _useState8[0],
|
|
103
|
+
setFeedbackData = _useState8[1];
|
|
103
104
|
|
|
104
105
|
var translate = function translate(id) {
|
|
105
106
|
if (translateFromParent) return translateFromParent(id); // when there is no emitEvent pass the Translate
|
|
@@ -110,11 +111,6 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
110
111
|
});
|
|
111
112
|
};
|
|
112
113
|
|
|
113
|
-
var _useState11 = (0, _react.useState)(''),
|
|
114
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
115
|
-
resolvedClass = _useState12[0],
|
|
116
|
-
setResolveClass = _useState12[1];
|
|
117
|
-
|
|
118
114
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
119
115
|
playSound = _soundActions[0];
|
|
120
116
|
|
|
@@ -132,18 +128,16 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
132
128
|
shape: 'poly'
|
|
133
129
|
}, area);
|
|
134
130
|
});
|
|
135
|
-
var handleFinish = (0, _react.useCallback)(function () {
|
|
136
|
-
var rewards = solution.right.rewards;
|
|
137
|
-
|
|
131
|
+
var handleFinish = (0, _react.useCallback)(function (rewards) {
|
|
138
132
|
if (emitFinish) {
|
|
139
|
-
emitFinish(rewards);
|
|
133
|
+
emitFinish(rewards, feedbackData.success);
|
|
140
134
|
} else {
|
|
141
135
|
emitEvent({
|
|
142
136
|
type: 'addPoints',
|
|
143
137
|
payload: rewards
|
|
144
138
|
});
|
|
145
139
|
}
|
|
146
|
-
}, [emitEvent, emitFinish,
|
|
140
|
+
}, [emitEvent, emitFinish, feedbackData.success]);
|
|
147
141
|
(0, _react.useEffect)(function () {
|
|
148
142
|
if (completed) {
|
|
149
143
|
disableExit(true);
|
|
@@ -154,15 +148,25 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
154
148
|
}, [defaultCompleted]);
|
|
155
149
|
(0, _react.useEffect)(function () {
|
|
156
150
|
if (areas.length === clickedZones.length && !completed || hasClickOnce && clickedZones.length > 0) {
|
|
151
|
+
var _specificFeedbacks$co;
|
|
152
|
+
|
|
157
153
|
setCompleted(true);
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
|
|
155
|
+
if (!((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length)) {
|
|
156
|
+
setFeedbackData(function (oldState) {
|
|
157
|
+
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
158
|
+
show: true,
|
|
159
|
+
success: true,
|
|
160
|
+
text: info.solution.right.desc,
|
|
161
|
+
rewards: info.solution.right.rewards
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
|
-
}, [clickedZones, areas.length, completed, info.solution.right
|
|
166
|
+
}, [clickedZones, areas.length, specificFeedbacks, hasClickOnce, completed, info.solution.right]);
|
|
162
167
|
(0, _react.useEffect)(function () {
|
|
163
168
|
setResolveAction(function (resolve) {
|
|
164
169
|
setCompleted(true);
|
|
165
|
-
setDisableClick(true);
|
|
166
170
|
setFinished(true);
|
|
167
171
|
setTimeout(function () {
|
|
168
172
|
emitResolve ? emitResolve(resolve) : resolve();
|
|
@@ -175,78 +179,109 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
175
179
|
}
|
|
176
180
|
}, [finished, disableExit]);
|
|
177
181
|
|
|
178
|
-
var
|
|
179
|
-
if (!
|
|
180
|
-
var
|
|
182
|
+
var handleIncorrectAreaClick = function handleIncorrectAreaClick(area) {
|
|
183
|
+
if (!completed) {
|
|
184
|
+
var _specificFeedbacks$wr;
|
|
185
|
+
|
|
186
|
+
var _solution$wrong = solution.wrong,
|
|
187
|
+
wrongRewards = _solution$wrong.rewards,
|
|
188
|
+
desc = _solution$wrong.desc;
|
|
189
|
+
var feedback = desc;
|
|
190
|
+
var rewards = wrongRewards;
|
|
181
191
|
emitEvent({
|
|
182
192
|
type: 'hidePuzzleButtons',
|
|
183
193
|
payload: true
|
|
184
194
|
});
|
|
195
|
+
var specific = (_specificFeedbacks$wr = specificFeedbacks.wrongFeedbacks) === null || _specificFeedbacks$wr === void 0 ? void 0 : _specificFeedbacks$wr.find(function (feed) {
|
|
196
|
+
return feed.id === area.id;
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
if (specific) {
|
|
200
|
+
feedback = specific.desc;
|
|
201
|
+
rewards = specific.rewards;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (emitFinish) {
|
|
205
|
+
emitFinish(wrongRewards, false);
|
|
206
|
+
}
|
|
185
207
|
|
|
186
208
|
if (hasClickOrder) {
|
|
187
209
|
setClickedZones([]);
|
|
188
210
|
}
|
|
189
211
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
emitEvent({
|
|
197
|
-
type: 'addPoints',
|
|
198
|
-
payload: wrongRewards,
|
|
199
|
-
finish: false
|
|
212
|
+
setFeedbackData(function (oldState) {
|
|
213
|
+
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
214
|
+
show: true,
|
|
215
|
+
success: false,
|
|
216
|
+
text: feedback,
|
|
217
|
+
rewards: rewards
|
|
200
218
|
});
|
|
201
|
-
}
|
|
219
|
+
});
|
|
220
|
+
playSound('fail');
|
|
202
221
|
}
|
|
203
222
|
};
|
|
204
223
|
|
|
205
224
|
var handleOnClose = function handleOnClose() {
|
|
206
|
-
handleFinish();
|
|
225
|
+
handleFinish(feedbackData.rewards);
|
|
207
226
|
playSound('click-ui');
|
|
208
|
-
|
|
209
|
-
|
|
227
|
+
setFeedbackData(function (oldState) {
|
|
228
|
+
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
229
|
+
show: false,
|
|
230
|
+
success: false,
|
|
231
|
+
text: '',
|
|
232
|
+
rewards: []
|
|
233
|
+
});
|
|
234
|
+
});
|
|
210
235
|
};
|
|
211
236
|
|
|
212
|
-
var
|
|
237
|
+
var handleCorrectAreaClick = function handleCorrectAreaClick(area) {
|
|
213
238
|
if (!clickedZones.some(function (zone) {
|
|
214
239
|
return zone.index === area.index;
|
|
215
|
-
}) && !
|
|
216
|
-
var updatedClickedZones = [].concat(_toConsumableArray(clickedZones), [area]);
|
|
240
|
+
}) && !feedbackData.show && !completed) {
|
|
217
241
|
playSound('click-ui');
|
|
242
|
+
var feedback = solution.right.desc;
|
|
243
|
+
var rewards = solution.right.rewards;
|
|
218
244
|
|
|
219
245
|
if (hasClickOrder && area.index === clickedZones.length || !hasClickOrder) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
246
|
+
var _specificFeedbacks$co2;
|
|
247
|
+
|
|
248
|
+
if ((_specificFeedbacks$co2 = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co2 !== void 0 && _specificFeedbacks$co2.length) {
|
|
249
|
+
var _specificFeedbacks$co3;
|
|
250
|
+
|
|
251
|
+
var specific = (_specificFeedbacks$co3 = specificFeedbacks.correctFeedbacks) === null || _specificFeedbacks$co3 === void 0 ? void 0 : _specificFeedbacks$co3.find(function (feed) {
|
|
252
|
+
return feed.id === area.id;
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
if (specific) {
|
|
256
|
+
feedback = specific.desc;
|
|
257
|
+
rewards = specific.rewards;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
setFeedbackData(function (oldState) {
|
|
261
|
+
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
262
|
+
show: true,
|
|
263
|
+
success: true,
|
|
264
|
+
text: feedback,
|
|
265
|
+
rewards: rewards
|
|
266
|
+
});
|
|
236
267
|
});
|
|
237
268
|
}
|
|
269
|
+
|
|
270
|
+
setClickedZones([].concat(_toConsumableArray(clickedZones), [area]));
|
|
271
|
+
} else {
|
|
272
|
+
handleIncorrectAreaClick(area);
|
|
238
273
|
}
|
|
239
274
|
}
|
|
240
275
|
};
|
|
241
276
|
|
|
242
277
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
243
278
|
className: className
|
|
244
|
-
},
|
|
279
|
+
}, feedbackData.show ? /*#__PURE__*/_react.default.createElement(_FeedbackComponent.default, {
|
|
245
280
|
playSound: playSound,
|
|
246
|
-
text:
|
|
247
|
-
success:
|
|
281
|
+
text: feedbackData.text,
|
|
282
|
+
success: feedbackData.success,
|
|
248
283
|
translate: translate,
|
|
249
|
-
hasTimeout: !
|
|
284
|
+
hasTimeout: !feedbackData.text,
|
|
250
285
|
delay: 2000,
|
|
251
286
|
functionOnClose: handleOnClose
|
|
252
287
|
}) : null, /*#__PURE__*/_react.default.createElement(_KonvaMapper.default, {
|
|
@@ -255,8 +290,8 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
255
290
|
areas: areasList,
|
|
256
291
|
badAreas: badAreasList,
|
|
257
292
|
clickedZones: clickedZones,
|
|
258
|
-
onClick:
|
|
259
|
-
onClickOutside:
|
|
293
|
+
onClick: handleCorrectAreaClick,
|
|
294
|
+
onClickOutside: handleIncorrectAreaClick,
|
|
260
295
|
hasHighlights: hasHighlights,
|
|
261
296
|
emitEvent: emitEvent
|
|
262
297
|
}), hasImageReview ? /*#__PURE__*/_react.default.createElement(ImageReview, null) : null);
|