@micromag/screen-quiz 0.3.670 → 0.3.673
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 +34 -31
- package/package.json +15 -15
package/es/index.js
CHANGED
|
@@ -1291,10 +1291,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1291
1291
|
_ref4$resultImage = _ref4.resultImage,
|
|
1292
1292
|
questionResultImage = _ref4$resultImage === void 0 ? null : _ref4$resultImage;
|
|
1293
1293
|
var currentAnsweredIndex = userAnswers !== null && typeof userAnswers[questionIndex] !== 'undefined' ? userAnswers[questionIndex] : null;
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1294
|
+
|
|
1295
|
+
// const answer =
|
|
1296
|
+
// currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined'
|
|
1297
|
+
// ? answers[currentAnsweredIndex]
|
|
1298
|
+
// : null;
|
|
1299
|
+
// const { result: answerResult = null } = answer || {};
|
|
1300
|
+
|
|
1298
1301
|
var hasTrueFalse = answers !== null ? (answers || []).find(function (ans) {
|
|
1299
1302
|
return (ans === null || ans === void 0 ? void 0 : ans.good) === true || (ans === null || ans === void 0 ? void 0 : ans.good) === false;
|
|
1300
1303
|
}) !== undefined : false;
|
|
@@ -1304,8 +1307,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1304
1307
|
var withoutGoodAnswer = goodAnswerIndex === null || goodAnswerIndex === -1;
|
|
1305
1308
|
var questionResultHasText = isTextFilled(questionResult);
|
|
1306
1309
|
var questionResultHasImage = isImageFilled(questionResultImage);
|
|
1307
|
-
|
|
1308
|
-
var hasResult = questionResultHasText || questionResultHasImage
|
|
1310
|
+
// const answerResultHasText = isTextFilled(answerResult);
|
|
1311
|
+
var hasResult = questionResultHasText || questionResultHasImage;
|
|
1309
1312
|
var onNextSlide = useCallback(function () {
|
|
1310
1313
|
if (isEdit || isPreview) {
|
|
1311
1314
|
return;
|
|
@@ -1320,13 +1323,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1320
1323
|
}, [questions, questionIndex, setQuestionIndex, isEdit, isPreview]);
|
|
1321
1324
|
var currentPoints = useMemo(function () {
|
|
1322
1325
|
return userAnswers !== null ? Object.keys(userAnswers).reduce(function (totalPoints, answerQuestionIndex) {
|
|
1323
|
-
var
|
|
1324
|
-
|
|
1325
|
-
questionAnswers =
|
|
1326
|
+
var _ref5 = questions !== null ? questions[answerQuestionIndex] || {} : {},
|
|
1327
|
+
_ref5$answers = _ref5.answers,
|
|
1328
|
+
questionAnswers = _ref5$answers === void 0 ? [] : _ref5$answers;
|
|
1326
1329
|
var answerIndex = userAnswers[answerQuestionIndex];
|
|
1327
|
-
var
|
|
1328
|
-
|
|
1329
|
-
points =
|
|
1330
|
+
var _ref6 = questionAnswers[answerIndex] || {},
|
|
1331
|
+
_ref6$points = _ref6.points,
|
|
1332
|
+
points = _ref6$points === void 0 ? 0 : _ref6$points;
|
|
1330
1333
|
return points + totalPoints;
|
|
1331
1334
|
}, 0) : 0;
|
|
1332
1335
|
}, [userAnswers, questions]);
|
|
@@ -1340,30 +1343,30 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1340
1343
|
if (stateId === 'results') {
|
|
1341
1344
|
return (results || [])[parseInt(stateIndex, 10)] || null;
|
|
1342
1345
|
}
|
|
1343
|
-
return (results || []).sort(function (
|
|
1346
|
+
return (results || []).sort(function (_ref7, _ref8) {
|
|
1347
|
+
var _ref7$points = _ref7.points,
|
|
1348
|
+
pointsA = _ref7$points === void 0 ? 0 : _ref7$points;
|
|
1344
1349
|
var _ref8$points = _ref8.points,
|
|
1345
|
-
|
|
1346
|
-
var _ref9$points = _ref9.points,
|
|
1347
|
-
pointsB = _ref9$points === void 0 ? 0 : _ref9$points;
|
|
1350
|
+
pointsB = _ref8$points === void 0 ? 0 : _ref8$points;
|
|
1348
1351
|
if (pointsA === pointsB) {
|
|
1349
1352
|
return 0;
|
|
1350
1353
|
}
|
|
1351
1354
|
return pointsA > pointsB ? 1 : -1;
|
|
1352
1355
|
}).reduce(function (lastResult, result) {
|
|
1353
|
-
var
|
|
1356
|
+
var _ref9 = lastResult || {},
|
|
1357
|
+
_ref9$points = _ref9.points,
|
|
1358
|
+
lastPoints = _ref9$points === void 0 ? 0 : _ref9$points;
|
|
1359
|
+
var _ref10 = result || {},
|
|
1354
1360
|
_ref10$points = _ref10.points,
|
|
1355
|
-
|
|
1356
|
-
var _ref11 = result || {},
|
|
1357
|
-
_ref11$points = _ref11.points,
|
|
1358
|
-
points = _ref11$points === void 0 ? 0 : _ref11$points;
|
|
1361
|
+
points = _ref10$points === void 0 ? 0 : _ref10$points;
|
|
1359
1362
|
return currentPoints >= (lastPoints || 0) && currentPoints >= points ? result : lastResult;
|
|
1360
1363
|
}, null);
|
|
1361
1364
|
}, [isResults, results, currentPoints, stateId, stateIndex]);
|
|
1362
|
-
var
|
|
1363
|
-
|
|
1364
|
-
resultBackground =
|
|
1365
|
-
|
|
1366
|
-
resultLayout =
|
|
1365
|
+
var _ref11 = currentResult || {},
|
|
1366
|
+
_ref11$background = _ref11.background,
|
|
1367
|
+
resultBackground = _ref11$background === void 0 ? null : _ref11$background,
|
|
1368
|
+
_ref11$layout = _ref11.layout,
|
|
1369
|
+
resultLayout = _ref11$layout === void 0 ? null : _ref11$layout;
|
|
1367
1370
|
var _useQuizCreate = useQuizCreate({
|
|
1368
1371
|
screenId: screenId
|
|
1369
1372
|
}),
|
|
@@ -1423,8 +1426,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1423
1426
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1424
1427
|
scrolledBottom = _useState6[0],
|
|
1425
1428
|
setScrolledBottom = _useState6[1];
|
|
1426
|
-
var onScrolledBottom = useCallback(function (
|
|
1427
|
-
var initial =
|
|
1429
|
+
var onScrolledBottom = useCallback(function (_ref12) {
|
|
1430
|
+
var initial = _ref12.initial;
|
|
1428
1431
|
if (initial) {
|
|
1429
1432
|
trackScreenEvent('scroll', 'Screen');
|
|
1430
1433
|
}
|
|
@@ -1437,9 +1440,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1437
1440
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1438
1441
|
hasScroll = _useState8[0],
|
|
1439
1442
|
setHasScroll = _useState8[1];
|
|
1440
|
-
var onScrollHeightChange = useCallback(function (
|
|
1441
|
-
var
|
|
1442
|
-
canScroll =
|
|
1443
|
+
var onScrollHeightChange = useCallback(function (_ref13) {
|
|
1444
|
+
var _ref13$canScroll = _ref13.canScroll,
|
|
1445
|
+
canScroll = _ref13$canScroll === void 0 ? false : _ref13$canScroll;
|
|
1443
1446
|
setHasScroll(canScroll);
|
|
1444
1447
|
}, [setHasScroll]);
|
|
1445
1448
|
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.673",
|
|
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.673",
|
|
67
|
+
"@micromag/data": "^0.3.673",
|
|
68
|
+
"@micromag/element-background": "^0.3.673",
|
|
69
|
+
"@micromag/element-button": "^0.3.673",
|
|
70
|
+
"@micromag/element-container": "^0.3.673",
|
|
71
|
+
"@micromag/element-footer": "^0.3.673",
|
|
72
|
+
"@micromag/element-header": "^0.3.673",
|
|
73
|
+
"@micromag/element-heading": "^0.3.673",
|
|
74
|
+
"@micromag/element-layout": "^0.3.673",
|
|
75
|
+
"@micromag/element-scroll": "^0.3.673",
|
|
76
|
+
"@micromag/element-text": "^0.3.673",
|
|
77
|
+
"@micromag/element-visual": "^0.3.673",
|
|
78
|
+
"@micromag/transforms": "^0.3.673",
|
|
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": "6bcd614e97a55a542e28528433b2815be9c487fc"
|
|
93
93
|
}
|