@micromag/screen-quiz 0.3.673 → 0.3.676
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/assets/css/styles.css +1 -1
- package/es/index.js +74 -66
- package/package.json +15 -15
package/assets/css/styles.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.micromag-screen-quiz-answers-emptyAnswer{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-answers-button:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-answers-container,.micromag-screen-quiz-answers-items{position:relative}.micromag-screen-quiz-answers-emptyAnswer{font-size:.75em;height:40px;margin:0 auto;width:100%}.micromag-screen-quiz-answers-item{margin:0;padding:0;position:relative;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out}.micromag-screen-quiz-answers-isPlaceholder .micromag-screen-quiz-answers-item{padding:1px 0}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-userAnswer{opacity:1!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-otherAnswer{opacity:.6!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-withoutOpacity{opacity:1!important}.micromag-screen-quiz-answers-button{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-answers-button:disabled{opacity:1
|
|
1
|
+
.micromag-screen-quiz-answers-emptyAnswer{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-answers-button:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-answers-container,.micromag-screen-quiz-answers-items{position:relative}.micromag-screen-quiz-answers-emptyAnswer{font-size:.75em;height:40px;margin:0 auto;width:100%}.micromag-screen-quiz-answers-item{margin:0;padding:0;position:relative;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out}.micromag-screen-quiz-answers-isPlaceholder .micromag-screen-quiz-answers-item{padding:1px 0}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-userAnswer{opacity:1!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-otherAnswer{opacity:.6!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-withoutOpacity{opacity:1!important}.micromag-screen-quiz-answers-button{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-answers-button:disabled{opacity:1}.micromag-screen-quiz-answers-withIcon .micromag-screen-quiz-answers-button{padding-left:42px;padding-right:42px}.micromag-screen-quiz-answers-resultIcon{display:-ms-flexbox;display:flex;left:5px;position:absolute;top:50%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;height:32px;justify-content:center;margin-top:-16px;opacity:0;padding:5px;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;width:32px}.micromag-screen-quiz-answers-answered .micromag-screen-quiz-answers-resultIcon{opacity:1}.micromag-screen-quiz-answers-rightAnswer .micromag-screen-quiz-answers-resultIcon{background-color:#0ed88f}.micromag-screen-quiz-answers-resultIcon .micromag-screen-quiz-answers-faIcon{display:block}.micromag-screen-quiz-answers-itemContent{padding:5px 0}
|
|
2
2
|
.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-question{margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-index{display:block;margin-bottom:1em;text-align:center;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-resultContent{padding:20px 0}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-result{opacity:0;pointer-events:none;position:absolute;-webkit-transition:opacity .5s ease;transition:opacity .5s ease;-webkit-transition-delay:.3s;transition-delay:.3s}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{margin:0 auto;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion{height:60px;margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{height:100px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultVisible .micromag-screen-quiz-question-result{opacity:1;pointer-events:all;position:relative}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultHidden .micromag-screen-quiz-question-result{opacity:0;pointer-events:none;position:absolute}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultHidden .micromag-screen-quiz-question-result .micromag-screen-quiz-question-resultContent{padding:0}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder{padding:10px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder .micromag-screen-quiz-question-index{color:hsla(0,0%,100%,.6);font-size:8px;mix-blend-mode:difference}
|
|
3
3
|
.micromag-screen-quiz-container .micromag-screen-quiz-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-quiz-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-quiz-disabled.micromag-screen-quiz-container{overflow:hidden;pointer-events:none}.micromag-screen-quiz-hidden.micromag-screen-quiz-container{display:none;visibility:hidden}.micromag-screen-quiz-placeholder.micromag-screen-quiz-container .micromag-screen-quiz-content{padding:6px;position:relative}.micromag-screen-quiz-nextButton:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-container .micromag-screen-quiz-background{z-index:0}.micromag-screen-quiz-container .micromag-screen-quiz-content{z-index:2}.micromag-screen-quiz-container.micromag-screen-quiz-disabled{pointer-events:none}.micromag-screen-quiz-reset{background-color:transparent;border:0;padding:10px;position:absolute;right:0;top:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out,-webkit-transform .15s ease-out;z-index:1000}.micromag-screen-quiz-reset:hover{border:0;opacity:.8}.micromag-screen-quiz-reset:hover:active{-webkit-transform:rotate(30deg);-ms-transform:rotate(30deg);transform:rotate(30deg)}.micromag-screen-quiz-points{color:#fff;left:0;padding:10px;position:absolute;top:0;z-index:1000}.micromag-screen-quiz-layout{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-header.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-footer a{padding:0}.micromag-screen-quiz-footer.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-transition{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-intro,.micromag-screen-quiz-nextButton,.micromag-screen-quiz-question,.micromag-screen-quiz-results{overflow:hidden}.micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enterActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-results.micromag-screen-quiz-enterActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-intro.micromag-screen-quiz-exit,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exit,.micromag-screen-quiz-question.micromag-screen-quiz-exit,.micromag-screen-quiz-results.micromag-screen-quiz-exit{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-results.micromag-screen-quiz-exitActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-exitActive{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-nextButton{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-nextButton:disabled{opacity:1;pointer-events:none}.micromag-screen-quiz-withIcon .micromag-screen-quiz-nextButton{padding-left:42px;padding-right:42px}.micromag-screen-quiz-background.micromag-screen-quiz-enter{opacity:0}.micromag-screen-quiz-background.micromag-screen-quiz-enterActive{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:1}.micromag-screen-quiz-background.micromag-screen-quiz-exit{opacity:1}.micromag-screen-quiz-background.micromag-screen-quiz-exitActive{opacity:0;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:0}
|
|
4
4
|
.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-title{margin-bottom:10px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{margin:0 auto;width:100%}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{height:60px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription{height:100px}.micromag-screen-quiz-results-container.micromag-screen-quiz-results-isPlaceholder{padding:10px}
|
package/es/index.js
CHANGED
|
@@ -117,7 +117,7 @@ var Answers = function Answers(_ref) {
|
|
|
117
117
|
return hasGood || good;
|
|
118
118
|
}, false) : false;
|
|
119
119
|
var finalShowUserAnswer = showUserAnswer || !hasRightAnswer;
|
|
120
|
-
var shouldCollapse =
|
|
120
|
+
var shouldCollapse = !withoutGoodAnswer || finalShowUserAnswer && answeredIndex !== null && !withoutCollapse;
|
|
121
121
|
var _useState3 = useState(answeredIndex !== null),
|
|
122
122
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
123
123
|
answersCollapsed = _useState4[0],
|
|
@@ -134,6 +134,7 @@ var Answers = function Answers(_ref) {
|
|
|
134
134
|
var timeout = null;
|
|
135
135
|
if (answeredIndex !== null && shouldCollapse) {
|
|
136
136
|
timeout = setTimeout(function () {
|
|
137
|
+
// console.log('ok should collapse');
|
|
137
138
|
setAnswersCollapsed(true);
|
|
138
139
|
if (onCollapse !== null) {
|
|
139
140
|
onCollapse();
|
|
@@ -141,6 +142,7 @@ var Answers = function Answers(_ref) {
|
|
|
141
142
|
}, hasAnsweredRight || finalShowUserAnswer ? 500 : answersCollapseDelay);
|
|
142
143
|
} else if (answeredIndex !== null && !shouldCollapse) {
|
|
143
144
|
timeout = setTimeout(function () {
|
|
145
|
+
// console.log('ok no collapse');
|
|
144
146
|
if (onCollapse !== null) {
|
|
145
147
|
onCollapse();
|
|
146
148
|
}
|
|
@@ -162,17 +164,27 @@ var Answers = function Answers(_ref) {
|
|
|
162
164
|
}, [answeredIndex, withoutGoodAnswer, setAnswersCollapsed, onCollapse, onCollapsed, onTransitionEnd, answersCollapseDelay, hasAnsweredRight, finalShowUserAnswer, shouldCollapse]);
|
|
163
165
|
useEffect(function () {
|
|
164
166
|
var timeout = null;
|
|
167
|
+
var endTimeout = null;
|
|
165
168
|
if (answersCollapsed) {
|
|
166
169
|
timeout = setTimeout(function () {
|
|
167
170
|
setAnswersFinalCollapse(true);
|
|
168
171
|
}, 300);
|
|
172
|
+
endTimeout = setTimeout(function () {
|
|
173
|
+
// Failsafe cause collapse transition is not always active
|
|
174
|
+
if (onTransitionEnd !== null) {
|
|
175
|
+
onTransitionEnd();
|
|
176
|
+
}
|
|
177
|
+
}, 625);
|
|
169
178
|
}
|
|
170
179
|
return function () {
|
|
171
180
|
if (timeout !== null) {
|
|
172
181
|
clearTimeout(timeout);
|
|
173
182
|
}
|
|
183
|
+
if (endTimeout !== null) {
|
|
184
|
+
clearTimeout(endTimeout);
|
|
185
|
+
}
|
|
174
186
|
};
|
|
175
|
-
}, [answersCollapsed]);
|
|
187
|
+
}, [answersCollapsed, onTransitionEnd, setAnswersFinalCollapse]);
|
|
176
188
|
var _useState9 = useState(false),
|
|
177
189
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
178
190
|
transitioned = _useState10[0],
|
|
@@ -217,26 +229,28 @@ var Answers = function Answers(_ref) {
|
|
|
217
229
|
if (answeredIndex !== null && showAnimation && answersCollapsed && !rightAnswer) {
|
|
218
230
|
hidden = true;
|
|
219
231
|
}
|
|
232
|
+
var _ref6 = answer || {},
|
|
233
|
+
_ref6$label = _ref6.label,
|
|
234
|
+
label = _ref6$label === void 0 ? null : _ref6$label;
|
|
235
|
+
var key = "key-".concat(answerI, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
|
|
220
236
|
return _objectSpread(_objectSpread({}, answer), {}, {
|
|
221
237
|
hidden: hidden,
|
|
222
238
|
userAnswer: userAnswer,
|
|
223
239
|
index: answerI,
|
|
224
|
-
maxHeight: height
|
|
240
|
+
maxHeight: height,
|
|
241
|
+
key: key
|
|
225
242
|
});
|
|
226
243
|
});
|
|
227
244
|
var transitions = useTransition(filteredListOfItems, {
|
|
228
|
-
key: function key(
|
|
229
|
-
var
|
|
230
|
-
|
|
231
|
-
_ref6$label = _ref6.label,
|
|
232
|
-
label = _ref6$label === void 0 ? null : _ref6$label;
|
|
233
|
-
return "key-".concat(index, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
|
|
245
|
+
key: function key(_ref7) {
|
|
246
|
+
var _key = _ref7.key;
|
|
247
|
+
return _key;
|
|
234
248
|
},
|
|
235
|
-
update: function update(
|
|
236
|
-
var
|
|
237
|
-
hidden =
|
|
238
|
-
|
|
239
|
-
maxHeight =
|
|
249
|
+
update: function update(_ref8) {
|
|
250
|
+
var _ref8$hidden = _ref8.hidden,
|
|
251
|
+
hidden = _ref8$hidden === void 0 ? false : _ref8$hidden,
|
|
252
|
+
_ref8$maxHeight = _ref8.maxHeight,
|
|
253
|
+
maxHeight = _ref8$maxHeight === void 0 ? 0 : _ref8$maxHeight;
|
|
240
254
|
return {
|
|
241
255
|
opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
|
|
242
256
|
// Animate this, not height
|
|
@@ -258,9 +272,9 @@ var Answers = function Answers(_ref) {
|
|
|
258
272
|
}
|
|
259
273
|
}, [transitioned, onTransitionEnd]);
|
|
260
274
|
var hasOpacity = useMemo(function () {
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
backgroundColor =
|
|
275
|
+
var _ref9 = inactiveButtonsStyle || {},
|
|
276
|
+
_ref9$backgroundColor = _ref9.backgroundColor,
|
|
277
|
+
backgroundColor = _ref9$backgroundColor === void 0 ? null : _ref9$backgroundColor;
|
|
264
278
|
return backgroundColor === null;
|
|
265
279
|
}, [inactiveButtonsStyle]);
|
|
266
280
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -269,18 +283,18 @@ var Answers = function Answers(_ref) {
|
|
|
269
283
|
className: styles$4.items
|
|
270
284
|
}, transitions(function (style, answer, t, answerI) {
|
|
271
285
|
var userAnswer = answerI === answeredIndex;
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
rightAnswer =
|
|
275
|
-
|
|
276
|
-
label =
|
|
277
|
-
|
|
278
|
-
answerButtonStyle =
|
|
279
|
-
_ref10$textStyle = _ref10.textStyle,
|
|
280
|
-
answerButtonTextStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
|
|
281
|
-
var _ref11 = label || {},
|
|
286
|
+
var _ref11 = answer || {},
|
|
287
|
+
_ref11$good = _ref11.good,
|
|
288
|
+
rightAnswer = _ref11$good === void 0 ? null : _ref11$good,
|
|
289
|
+
_ref11$label = _ref11.label,
|
|
290
|
+
label = _ref11$label === void 0 ? null : _ref11$label,
|
|
291
|
+
_ref11$buttonStyle = _ref11.buttonStyle,
|
|
292
|
+
answerButtonStyle = _ref11$buttonStyle === void 0 ? null : _ref11$buttonStyle,
|
|
282
293
|
_ref11$textStyle = _ref11.textStyle,
|
|
283
|
-
|
|
294
|
+
answerButtonTextStyle = _ref11$textStyle === void 0 ? null : _ref11$textStyle;
|
|
295
|
+
var _ref12 = label || {},
|
|
296
|
+
_ref12$textStyle = _ref12.textStyle,
|
|
297
|
+
textStyle = _ref12$textStyle === void 0 ? null : _ref12$textStyle;
|
|
284
298
|
var hasAnswer = isTextFilled(label);
|
|
285
299
|
var isUserAnswer = withoutGoodAnswer && userAnswer;
|
|
286
300
|
var isOtherAnswer = withoutGoodAnswer && !userAnswer;
|
|
@@ -316,10 +330,6 @@ var Answers = function Answers(_ref) {
|
|
|
316
330
|
onPointerUp: function onPointerUp(e) {
|
|
317
331
|
if (e.pointerType !== 'mouse' || e.button === 0) {
|
|
318
332
|
onClick(answer, answerI);
|
|
319
|
-
// onTransitionEnd();
|
|
320
|
-
// setTimeout(() => {
|
|
321
|
-
// onTransitionEnd();
|
|
322
|
-
// }, 2000);
|
|
323
333
|
}
|
|
324
334
|
},
|
|
325
335
|
disabled: !visible || isPreview || answered,
|
|
@@ -1291,13 +1301,10 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1291
1301
|
_ref4$resultImage = _ref4.resultImage,
|
|
1292
1302
|
questionResultImage = _ref4$resultImage === void 0 ? null : _ref4$resultImage;
|
|
1293
1303
|
var currentAnsweredIndex = userAnswers !== null && typeof userAnswers[questionIndex] !== 'undefined' ? userAnswers[questionIndex] : null;
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
// : null;
|
|
1299
|
-
// const { result: answerResult = null } = answer || {};
|
|
1300
|
-
|
|
1304
|
+
var answer = currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined' ? answers[currentAnsweredIndex] : null;
|
|
1305
|
+
var _ref5 = answer || {},
|
|
1306
|
+
_ref5$result = _ref5.result,
|
|
1307
|
+
answerResult = _ref5$result === void 0 ? null : _ref5$result;
|
|
1301
1308
|
var hasTrueFalse = answers !== null ? (answers || []).find(function (ans) {
|
|
1302
1309
|
return (ans === null || ans === void 0 ? void 0 : ans.good) === true || (ans === null || ans === void 0 ? void 0 : ans.good) === false;
|
|
1303
1310
|
}) !== undefined : false;
|
|
@@ -1307,9 +1314,10 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1307
1314
|
var withoutGoodAnswer = goodAnswerIndex === null || goodAnswerIndex === -1;
|
|
1308
1315
|
var questionResultHasText = isTextFilled(questionResult);
|
|
1309
1316
|
var questionResultHasImage = isImageFilled(questionResultImage);
|
|
1310
|
-
|
|
1311
|
-
var hasResult = questionResultHasText || questionResultHasImage;
|
|
1317
|
+
var answerResultHasText = isTextFilled(answerResult);
|
|
1318
|
+
var hasResult = questionResultHasText || questionResultHasImage || answerResultHasText;
|
|
1312
1319
|
var onNextSlide = useCallback(function () {
|
|
1320
|
+
// console.log('onNextSlide', isEdit, isPreview);
|
|
1313
1321
|
if (isEdit || isPreview) {
|
|
1314
1322
|
return;
|
|
1315
1323
|
}
|
|
@@ -1323,13 +1331,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1323
1331
|
}, [questions, questionIndex, setQuestionIndex, isEdit, isPreview]);
|
|
1324
1332
|
var currentPoints = useMemo(function () {
|
|
1325
1333
|
return userAnswers !== null ? Object.keys(userAnswers).reduce(function (totalPoints, answerQuestionIndex) {
|
|
1326
|
-
var
|
|
1327
|
-
|
|
1328
|
-
questionAnswers =
|
|
1334
|
+
var _ref6 = questions !== null ? questions[answerQuestionIndex] || {} : {},
|
|
1335
|
+
_ref6$answers = _ref6.answers,
|
|
1336
|
+
questionAnswers = _ref6$answers === void 0 ? [] : _ref6$answers;
|
|
1329
1337
|
var answerIndex = userAnswers[answerQuestionIndex];
|
|
1330
|
-
var
|
|
1331
|
-
|
|
1332
|
-
points =
|
|
1338
|
+
var _ref7 = questionAnswers[answerIndex] || {},
|
|
1339
|
+
_ref7$points = _ref7.points,
|
|
1340
|
+
points = _ref7$points === void 0 ? 0 : _ref7$points;
|
|
1333
1341
|
return points + totalPoints;
|
|
1334
1342
|
}, 0) : 0;
|
|
1335
1343
|
}, [userAnswers, questions]);
|
|
@@ -1343,30 +1351,30 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1343
1351
|
if (stateId === 'results') {
|
|
1344
1352
|
return (results || [])[parseInt(stateIndex, 10)] || null;
|
|
1345
1353
|
}
|
|
1346
|
-
return (results || []).sort(function (
|
|
1347
|
-
var _ref7$points = _ref7.points,
|
|
1348
|
-
pointsA = _ref7$points === void 0 ? 0 : _ref7$points;
|
|
1354
|
+
return (results || []).sort(function (_ref8, _ref9) {
|
|
1349
1355
|
var _ref8$points = _ref8.points,
|
|
1350
|
-
|
|
1356
|
+
pointsA = _ref8$points === void 0 ? 0 : _ref8$points;
|
|
1357
|
+
var _ref9$points = _ref9.points,
|
|
1358
|
+
pointsB = _ref9$points === void 0 ? 0 : _ref9$points;
|
|
1351
1359
|
if (pointsA === pointsB) {
|
|
1352
1360
|
return 0;
|
|
1353
1361
|
}
|
|
1354
1362
|
return pointsA > pointsB ? 1 : -1;
|
|
1355
1363
|
}).reduce(function (lastResult, result) {
|
|
1356
|
-
var
|
|
1357
|
-
_ref9$points = _ref9.points,
|
|
1358
|
-
lastPoints = _ref9$points === void 0 ? 0 : _ref9$points;
|
|
1359
|
-
var _ref10 = result || {},
|
|
1364
|
+
var _ref10 = lastResult || {},
|
|
1360
1365
|
_ref10$points = _ref10.points,
|
|
1361
|
-
|
|
1366
|
+
lastPoints = _ref10$points === void 0 ? 0 : _ref10$points;
|
|
1367
|
+
var _ref11 = result || {},
|
|
1368
|
+
_ref11$points = _ref11.points,
|
|
1369
|
+
points = _ref11$points === void 0 ? 0 : _ref11$points;
|
|
1362
1370
|
return currentPoints >= (lastPoints || 0) && currentPoints >= points ? result : lastResult;
|
|
1363
1371
|
}, null);
|
|
1364
1372
|
}, [isResults, results, currentPoints, stateId, stateIndex]);
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
resultBackground =
|
|
1368
|
-
|
|
1369
|
-
resultLayout =
|
|
1373
|
+
var _ref12 = currentResult || {},
|
|
1374
|
+
_ref12$background = _ref12.background,
|
|
1375
|
+
resultBackground = _ref12$background === void 0 ? null : _ref12$background,
|
|
1376
|
+
_ref12$layout = _ref12.layout,
|
|
1377
|
+
resultLayout = _ref12$layout === void 0 ? null : _ref12$layout;
|
|
1370
1378
|
var _useQuizCreate = useQuizCreate({
|
|
1371
1379
|
screenId: screenId
|
|
1372
1380
|
}),
|
|
@@ -1426,8 +1434,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1426
1434
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1427
1435
|
scrolledBottom = _useState6[0],
|
|
1428
1436
|
setScrolledBottom = _useState6[1];
|
|
1429
|
-
var onScrolledBottom = useCallback(function (
|
|
1430
|
-
var initial =
|
|
1437
|
+
var onScrolledBottom = useCallback(function (_ref13) {
|
|
1438
|
+
var initial = _ref13.initial;
|
|
1431
1439
|
if (initial) {
|
|
1432
1440
|
trackScreenEvent('scroll', 'Screen');
|
|
1433
1441
|
}
|
|
@@ -1440,9 +1448,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1440
1448
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1441
1449
|
hasScroll = _useState8[0],
|
|
1442
1450
|
setHasScroll = _useState8[1];
|
|
1443
|
-
var onScrollHeightChange = useCallback(function (
|
|
1444
|
-
var
|
|
1445
|
-
canScroll =
|
|
1451
|
+
var onScrollHeightChange = useCallback(function (_ref14) {
|
|
1452
|
+
var _ref14$canScroll = _ref14.canScroll,
|
|
1453
|
+
canScroll = _ref14$canScroll === void 0 ? false : _ref14$canScroll;
|
|
1446
1454
|
setHasScroll(canScroll);
|
|
1447
1455
|
}, [setHasScroll]);
|
|
1448
1456
|
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.676",
|
|
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.676",
|
|
67
|
+
"@micromag/data": "^0.3.676",
|
|
68
|
+
"@micromag/element-background": "^0.3.676",
|
|
69
|
+
"@micromag/element-button": "^0.3.676",
|
|
70
|
+
"@micromag/element-container": "^0.3.676",
|
|
71
|
+
"@micromag/element-footer": "^0.3.676",
|
|
72
|
+
"@micromag/element-header": "^0.3.676",
|
|
73
|
+
"@micromag/element-heading": "^0.3.676",
|
|
74
|
+
"@micromag/element-layout": "^0.3.676",
|
|
75
|
+
"@micromag/element-scroll": "^0.3.676",
|
|
76
|
+
"@micromag/element-text": "^0.3.676",
|
|
77
|
+
"@micromag/element-visual": "^0.3.676",
|
|
78
|
+
"@micromag/transforms": "^0.3.676",
|
|
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": "941f3a10c4de917c02ca81f39e6d15a85094e289"
|
|
93
93
|
}
|