@micromag/screen-quiz 0.3.644 → 0.3.649
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 +27 -29
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -1262,10 +1262,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1262
1262
|
_ref5$customAnswerLab = _ref5.customAnswerLabel,
|
|
1263
1263
|
customAnswerLabel = _ref5$customAnswerLab === undefined ? null : _ref5$customAnswerLab;
|
|
1264
1264
|
var firstCustomAnswerLabel = (answers || []).find(function () {
|
|
1265
|
-
var
|
|
1266
|
-
|
|
1267
|
-
cal = _ref6$customAnswerLab === undefined ? null : _ref6$customAnswerLab;
|
|
1268
|
-
return cal !== null;
|
|
1265
|
+
var it = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1266
|
+
return (it === null || it === undefined ? undefined : it.customAnswerLabel) !== null;
|
|
1269
1267
|
}) || null;
|
|
1270
1268
|
var hasResult = questionResult !== null || questionResultImage !== null || customAnswerLabel !== null || firstCustomAnswerLabel !== null;
|
|
1271
1269
|
var onNextSlide = useCallback(function () {
|
|
@@ -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.649",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@micromag/element-header": "^0.3.637",
|
|
73
73
|
"@micromag/element-heading": "^0.3.637",
|
|
74
74
|
"@micromag/element-layout": "^0.3.637",
|
|
75
|
-
"@micromag/element-scroll": "^0.3.
|
|
75
|
+
"@micromag/element-scroll": "^0.3.646",
|
|
76
76
|
"@micromag/element-text": "^0.3.637",
|
|
77
77
|
"@micromag/element-visual": "^0.3.637",
|
|
78
78
|
"@micromag/transforms": "^0.3.637",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"access": "public",
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "9f5087a75a0503179391a38dd7dcc03009198ac2"
|
|
93
93
|
}
|