@micromag/screen-quiz 0.3.646 → 0.3.651
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/es/index.js +35 -37
- package/package.json +15 -15
package/es/index.js
CHANGED
|
@@ -450,14 +450,14 @@ var Question = function Question(_ref) {
|
|
|
450
450
|
var answered = answeredIndex !== null;
|
|
451
451
|
var answer = answeredIndex !== null && answers[answeredIndex] ? answers[answeredIndex] : null;
|
|
452
452
|
var _ref3 = answer || {},
|
|
453
|
-
_ref3$
|
|
454
|
-
|
|
453
|
+
_ref3$result = _ref3.result,
|
|
454
|
+
answerResult = _ref3$result === undefined ? null : _ref3$result,
|
|
455
455
|
_ref3$answerImage = _ref3.answerImage,
|
|
456
456
|
answerImage = _ref3$answerImage === undefined ? null : _ref3$answerImage;
|
|
457
|
-
var hasResult = isTextFilled(
|
|
457
|
+
var hasResult = isTextFilled(answerResult) || isTextFilled(result);
|
|
458
458
|
var hasResultVisual = isImageFilled(answerImage) || isImageFilled(resultImage);
|
|
459
459
|
var defaultResult = isTextFilled(result) ? result : null;
|
|
460
|
-
var customResult = isTextFilled(
|
|
460
|
+
var customResult = isTextFilled(answerResult) ? answerResult : null;
|
|
461
461
|
var finalResult = customResult || defaultResult;
|
|
462
462
|
var _ref4 = finalResult || {},
|
|
463
463
|
_ref4$textStyle = _ref4.textStyle,
|
|
@@ -1259,15 +1259,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1259
1259
|
var currentAnsweredIndex = userAnswers !== null && typeof userAnswers[questionIndex] !== 'undefined' ? userAnswers[questionIndex] : null;
|
|
1260
1260
|
var answer = currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined' ? answers[currentAnsweredIndex] : null;
|
|
1261
1261
|
var _ref5 = answer || {},
|
|
1262
|
-
_ref5$
|
|
1263
|
-
|
|
1264
|
-
var
|
|
1265
|
-
var
|
|
1266
|
-
|
|
1267
|
-
cal = _ref6$customAnswerLab === undefined ? null : _ref6$customAnswerLab;
|
|
1268
|
-
return cal !== null;
|
|
1262
|
+
_ref5$result = _ref5.result,
|
|
1263
|
+
answerResult = _ref5$result === undefined ? null : _ref5$result;
|
|
1264
|
+
var firstCustomResult = (answers || []).find(function () {
|
|
1265
|
+
var it = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1266
|
+
return (it === null || it === undefined ? undefined : it.result) !== null;
|
|
1269
1267
|
}) || null;
|
|
1270
|
-
var hasResult = questionResult !== null || questionResultImage !== null ||
|
|
1268
|
+
var hasResult = questionResult !== null || questionResultImage !== null || answerResult !== null || firstCustomResult !== null;
|
|
1271
1269
|
var onNextSlide = useCallback(function () {
|
|
1272
1270
|
if (isEdit) {
|
|
1273
1271
|
return;
|
|
@@ -1282,13 +1280,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1282
1280
|
}, [questions, questionIndex, setQuestionIndex, isEdit]);
|
|
1283
1281
|
var currentPoints = useMemo(function () {
|
|
1284
1282
|
return userAnswers !== null ? Object.keys(userAnswers).reduce(function (totalPoints, answerQuestionIndex) {
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1287
|
-
questionAnswers =
|
|
1283
|
+
var _ref6 = questions !== null ? questions[answerQuestionIndex] || {} : {},
|
|
1284
|
+
_ref6$answers = _ref6.answers,
|
|
1285
|
+
questionAnswers = _ref6$answers === undefined ? [] : _ref6$answers;
|
|
1288
1286
|
var answerIndex = userAnswers[answerQuestionIndex];
|
|
1289
|
-
var
|
|
1290
|
-
|
|
1291
|
-
points =
|
|
1287
|
+
var _ref7 = questionAnswers[answerIndex] || {},
|
|
1288
|
+
_ref7$points = _ref7.points,
|
|
1289
|
+
points = _ref7$points === undefined ? 0 : _ref7$points;
|
|
1292
1290
|
return points + totalPoints;
|
|
1293
1291
|
}, 0) : 0;
|
|
1294
1292
|
}, [userAnswers, questions]);
|
|
@@ -1302,30 +1300,30 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1302
1300
|
if (stateId === 'results') {
|
|
1303
1301
|
return (results || [])[parseInt(stateIndex, 10)] || null;
|
|
1304
1302
|
}
|
|
1305
|
-
return (results || []).sort(function (
|
|
1303
|
+
return (results || []).sort(function (_ref8, _ref9) {
|
|
1304
|
+
var _ref8$points = _ref8.points,
|
|
1305
|
+
pointsA = _ref8$points === undefined ? 0 : _ref8$points;
|
|
1306
1306
|
var _ref9$points = _ref9.points,
|
|
1307
|
-
|
|
1308
|
-
var _ref10$points = _ref10.points,
|
|
1309
|
-
pointsB = _ref10$points === undefined ? 0 : _ref10$points;
|
|
1307
|
+
pointsB = _ref9$points === undefined ? 0 : _ref9$points;
|
|
1310
1308
|
if (pointsA === pointsB) {
|
|
1311
1309
|
return 0;
|
|
1312
1310
|
}
|
|
1313
1311
|
return pointsA > pointsB ? 1 : -1;
|
|
1314
1312
|
}).reduce(function (lastResult, result) {
|
|
1315
|
-
var
|
|
1313
|
+
var _ref10 = lastResult || {},
|
|
1314
|
+
_ref10$points = _ref10.points,
|
|
1315
|
+
lastPoints = _ref10$points === undefined ? 0 : _ref10$points;
|
|
1316
|
+
var _ref11 = result || {},
|
|
1316
1317
|
_ref11$points = _ref11.points,
|
|
1317
|
-
|
|
1318
|
-
var _ref12 = result || {},
|
|
1319
|
-
_ref12$points = _ref12.points,
|
|
1320
|
-
points = _ref12$points === undefined ? 0 : _ref12$points;
|
|
1318
|
+
points = _ref11$points === undefined ? 0 : _ref11$points;
|
|
1321
1319
|
return currentPoints >= (lastPoints || 0) && currentPoints >= points ? result : lastResult;
|
|
1322
1320
|
}, null);
|
|
1323
1321
|
}, [isResults, results, currentPoints, stateId, stateIndex]);
|
|
1324
|
-
var
|
|
1325
|
-
|
|
1326
|
-
resultBackground =
|
|
1327
|
-
|
|
1328
|
-
resultLayout =
|
|
1322
|
+
var _ref12 = currentResult || {},
|
|
1323
|
+
_ref12$background = _ref12.background,
|
|
1324
|
+
resultBackground = _ref12$background === undefined ? null : _ref12$background,
|
|
1325
|
+
_ref12$layout = _ref12.layout,
|
|
1326
|
+
resultLayout = _ref12$layout === undefined ? null : _ref12$layout;
|
|
1329
1327
|
var _useQuizCreate = useQuizCreate({
|
|
1330
1328
|
screenId: screenId
|
|
1331
1329
|
}),
|
|
@@ -1385,8 +1383,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1385
1383
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1386
1384
|
scrolledBottom = _useState6[0],
|
|
1387
1385
|
setScrolledBottom = _useState6[1];
|
|
1388
|
-
var onScrolledBottom = useCallback(function (
|
|
1389
|
-
var initial =
|
|
1386
|
+
var onScrolledBottom = useCallback(function (_ref13) {
|
|
1387
|
+
var initial = _ref13.initial;
|
|
1390
1388
|
if (initial) {
|
|
1391
1389
|
trackScreenEvent('scroll', 'Screen');
|
|
1392
1390
|
}
|
|
@@ -1399,9 +1397,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1399
1397
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1400
1398
|
hasScroll = _useState8[0],
|
|
1401
1399
|
setHasScroll = _useState8[1];
|
|
1402
|
-
var onScrollHeightChange = useCallback(function (
|
|
1403
|
-
var
|
|
1404
|
-
canScroll =
|
|
1400
|
+
var onScrollHeightChange = useCallback(function (_ref14) {
|
|
1401
|
+
var _ref14$canScroll = _ref14.canScroll,
|
|
1402
|
+
canScroll = _ref14$canScroll === undefined ? false : _ref14$canScroll;
|
|
1405
1403
|
setHasScroll(canScroll);
|
|
1406
1404
|
}, [setHasScroll]);
|
|
1407
1405
|
var onQuizReset = useCallback(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.651",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"@fortawesome/fontawesome-svg-core": "^6.5.2",
|
|
64
64
|
"@fortawesome/free-solid-svg-icons": "^6.5.2",
|
|
65
65
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
66
|
-
"@micromag/core": "^0.3.
|
|
67
|
-
"@micromag/data": "^0.3.
|
|
68
|
-
"@micromag/element-background": "^0.3.
|
|
69
|
-
"@micromag/element-button": "^0.3.
|
|
70
|
-
"@micromag/element-container": "^0.3.
|
|
71
|
-
"@micromag/element-footer": "^0.3.
|
|
72
|
-
"@micromag/element-header": "^0.3.
|
|
73
|
-
"@micromag/element-heading": "^0.3.
|
|
74
|
-
"@micromag/element-layout": "^0.3.
|
|
75
|
-
"@micromag/element-scroll": "^0.3.
|
|
76
|
-
"@micromag/element-text": "^0.3.
|
|
77
|
-
"@micromag/element-visual": "^0.3.
|
|
78
|
-
"@micromag/transforms": "^0.3.
|
|
66
|
+
"@micromag/core": "^0.3.651",
|
|
67
|
+
"@micromag/data": "^0.3.651",
|
|
68
|
+
"@micromag/element-background": "^0.3.651",
|
|
69
|
+
"@micromag/element-button": "^0.3.651",
|
|
70
|
+
"@micromag/element-container": "^0.3.651",
|
|
71
|
+
"@micromag/element-footer": "^0.3.651",
|
|
72
|
+
"@micromag/element-header": "^0.3.651",
|
|
73
|
+
"@micromag/element-heading": "^0.3.651",
|
|
74
|
+
"@micromag/element-layout": "^0.3.651",
|
|
75
|
+
"@micromag/element-scroll": "^0.3.651",
|
|
76
|
+
"@micromag/element-text": "^0.3.651",
|
|
77
|
+
"@micromag/element-visual": "^0.3.651",
|
|
78
|
+
"@micromag/transforms": "^0.3.651",
|
|
79
79
|
"@react-spring/core": "^9.6.1",
|
|
80
80
|
"@react-spring/web": "^9.6.1",
|
|
81
81
|
"classnames": "^2.2.6",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"access": "public",
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "9639dccc046f7adfe9673f53ede77360b8b75d51"
|
|
93
93
|
}
|