@elice/material-quiz 1.240718.0-trasncript.1 → 1.240718.0-trasncript.2
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/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
- package/cjs/components/eb-sortable/EbDraggable.js +42 -33
- package/cjs/components/eb-sortable/EbDroppable.js +27 -20
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
- package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
- package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
- package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
- package/cjs/components/material-quiz/index.js +9 -0
- package/cjs/components/material-quiz/locales/index.js +13 -0
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
- package/cjs/components/material-quiz-edit/context.js +8 -2
- package/cjs/components/material-quiz-edit/index.js +7 -0
- package/cjs/components/material-quiz-edit/locales/index.js +13 -0
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
- package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
- package/cjs/components/shared/QuestionBox.js +198 -165
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
- package/cjs/components/shared/QuizDraggbleOption.js +65 -59
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/index.js +19 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/cjs/components/shared/utils/mergeRefs.js +15 -6
- package/cjs/constant/element.js +3 -3
- package/cjs/constant/index.js +9 -0
- package/cjs/helpers/index.js +8 -10
- package/cjs/hooks/index.js +7 -0
- package/cjs/hooks/useCaculatePassage.js +21 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
- package/es/components/eb-sortable/EbDraggable.js +37 -33
- package/es/components/eb-sortable/EbDroppable.js +22 -20
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-quiz/MaterialQuiz.js +109 -83
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
- package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
- package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
- package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
- package/es/components/material-quiz/MaterialQuizText.js +158 -115
- package/es/components/material-quiz/QuizResultBadge.js +27 -22
- package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
- package/es/components/material-quiz/index.js +2 -0
- package/es/components/material-quiz/locales/index.js +4 -0
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
- package/es/components/material-quiz-edit/context.js +4 -2
- package/es/components/material-quiz-edit/index.js +1 -0
- package/es/components/material-quiz-edit/locales/index.js +4 -0
- package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
- package/es/components/material-quiz-edit/options/OptionText.js +86 -82
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/es/components/material-quiz-edit/utils/editValue.js +17 -12
- package/es/components/shared/QuestionBox.js +192 -165
- package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
- package/es/components/shared/QuizDraggbleOption.js +61 -59
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/index.js +7 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
- package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/es/components/shared/utils/mergeRefs.js +15 -6
- package/es/constant/element.js +3 -3
- package/es/constant/index.js +1 -0
- package/es/helpers/index.js +8 -10
- package/es/hooks/index.js +1 -0
- package/es/hooks/useCaculatePassage.js +21 -20
- package/package.json +12 -15
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var designTokens = require('@elice/design-tokens');
|
|
7
8
|
var styled = require('styled-components');
|
|
@@ -9,12 +10,16 @@ var color = require('../../material-quiz/constants/color.js');
|
|
|
9
10
|
var getQuestionStatusStyle = require('../utils/getQuestionStatusStyle.js');
|
|
10
11
|
var QuestionRadioContext = require('./QuestionRadioContext.js');
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
16
|
+
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
17
|
+
|
|
18
|
+
var StyledQuestionRadioOption = styled__default.default.div.withConfig({
|
|
13
19
|
componentId: "sc-cy66me-0"
|
|
14
|
-
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
|
|
15
|
-
checked,
|
|
16
|
-
|
|
17
|
-
}) => {
|
|
20
|
+
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], function (_ref) {
|
|
21
|
+
var checked = _ref.checked,
|
|
22
|
+
status = _ref.status;
|
|
18
23
|
switch (status) {
|
|
19
24
|
case 'correct':
|
|
20
25
|
return color.CORRECT_BACKGROUND_COLOR;
|
|
@@ -25,17 +30,18 @@ const StyledQuestionRadioOption = styled.div.withConfig({
|
|
|
25
30
|
default:
|
|
26
31
|
return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy6;
|
|
27
32
|
}
|
|
28
|
-
}, ({
|
|
29
|
-
disabled
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
}, function (_ref2) {
|
|
34
|
+
var disabled = _ref2.disabled;
|
|
35
|
+
return disabled ? 'not-allowed' : 'pointer';
|
|
36
|
+
}, function (_ref3) {
|
|
37
|
+
var isAnswer = _ref3.isAnswer;
|
|
38
|
+
return isAnswer ? "border: 3px solid ".concat(designTokens.base.color.green5) : '';
|
|
39
|
+
});
|
|
40
|
+
var StyledQuestionRadioInput = styled__default.default.input.withConfig({
|
|
34
41
|
componentId: "sc-cy66me-1"
|
|
35
|
-
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""], ({
|
|
36
|
-
checked,
|
|
37
|
-
|
|
38
|
-
}) => {
|
|
42
|
+
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""], function (_ref4) {
|
|
43
|
+
var checked = _ref4.checked,
|
|
44
|
+
status = _ref4.status;
|
|
39
45
|
switch (status) {
|
|
40
46
|
case 'correct':
|
|
41
47
|
return designTokens.base.color.green9;
|
|
@@ -44,11 +50,10 @@ const StyledQuestionRadioInput = styled.input.withConfig({
|
|
|
44
50
|
default:
|
|
45
51
|
return checked ? designTokens.base.color.primary6 : designTokens.base.color.gray3;
|
|
46
52
|
}
|
|
47
|
-
}, ({
|
|
48
|
-
status,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let bgColor;
|
|
53
|
+
}, function (_ref5) {
|
|
54
|
+
var status = _ref5.status,
|
|
55
|
+
checked = _ref5.checked;
|
|
56
|
+
var bgColor;
|
|
52
57
|
switch (status) {
|
|
53
58
|
case 'correct':
|
|
54
59
|
bgColor = designTokens.base.color.green9;
|
|
@@ -60,57 +65,45 @@ const StyledQuestionRadioInput = styled.input.withConfig({
|
|
|
60
65
|
bgColor = checked ? designTokens.base.color.primary6 : status ? designTokens.base.color.gray3 : 'transparent';
|
|
61
66
|
break;
|
|
62
67
|
}
|
|
63
|
-
return
|
|
64
|
-
&:after {
|
|
65
|
-
content: '';
|
|
66
|
-
position: absolute;
|
|
67
|
-
top: 50%;
|
|
68
|
-
left: 50%;
|
|
69
|
-
transform: translate(-50%, -50%);
|
|
70
|
-
width: 70%;
|
|
71
|
-
height: 70%;
|
|
72
|
-
border-radius: 50%;
|
|
73
|
-
background-color: ${bgColor};
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
68
|
+
return "\n &:after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 70%;\n height: 70%;\n border-radius: 50%;\n background-color: ".concat(bgColor, ";\n }\n ");
|
|
76
69
|
});
|
|
77
|
-
|
|
70
|
+
var StyledLabel = styled__default.default.label.withConfig({
|
|
78
71
|
componentId: "sc-cy66me-2"
|
|
79
72
|
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";line-height:24px;", ""], designTokens.base.size.body3, getQuestionStatusStyle.getQuestionStatusStyle());
|
|
80
|
-
|
|
81
|
-
value,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} = QuestionRadioContext.useQuestionRadioContext();
|
|
91
|
-
return React.createElement(StyledQuestionRadioOption, {
|
|
73
|
+
var QuestionRadioOption = React__default.default.memo(function (_ref6) {
|
|
74
|
+
var value = _ref6.value,
|
|
75
|
+
status = _ref6.status,
|
|
76
|
+
isAnswer = _ref6.isAnswer,
|
|
77
|
+
children = _ref6.children;
|
|
78
|
+
var _useQuestionRadioCont = QuestionRadioContext.useQuestionRadioContext(),
|
|
79
|
+
selectedValue = _useQuestionRadioCont.selectedValue,
|
|
80
|
+
disabled = _useQuestionRadioCont.disabled,
|
|
81
|
+
onSelect = _useQuestionRadioCont.onSelect;
|
|
82
|
+
return jsxRuntime.jsxs(StyledQuestionRadioOption, {
|
|
92
83
|
isAnswer: isAnswer,
|
|
93
84
|
disabled: disabled,
|
|
94
85
|
checked: selectedValue === value,
|
|
95
|
-
onClick: e
|
|
86
|
+
onClick: function onClick(e) {
|
|
96
87
|
e.preventDefault();
|
|
97
88
|
if (disabled) {
|
|
98
89
|
return;
|
|
99
90
|
}
|
|
100
91
|
onSelect(value);
|
|
101
92
|
},
|
|
102
|
-
status: status
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
status: status,
|
|
94
|
+
children: [jsxRuntime.jsx(StyledQuestionRadioInput, {
|
|
95
|
+
id: value,
|
|
96
|
+
type: "radio",
|
|
97
|
+
readOnly: true,
|
|
98
|
+
checked: selectedValue === value,
|
|
99
|
+
status: status
|
|
100
|
+
}), jsxRuntime.jsx(StyledLabel, {
|
|
101
|
+
htmlFor: value,
|
|
102
|
+
checked: selectedValue === value,
|
|
103
|
+
status: status,
|
|
104
|
+
children: children
|
|
105
|
+
})]
|
|
106
|
+
});
|
|
114
107
|
});
|
|
115
108
|
|
|
116
109
|
exports.default = QuestionRadioOption;
|
|
@@ -8,10 +8,9 @@ var color = require('../../material-quiz/constants/color.js');
|
|
|
8
8
|
* Get shared question custom style depend on checked, status values.
|
|
9
9
|
*/
|
|
10
10
|
function getQuestionStatusStyle() {
|
|
11
|
-
return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"], ({
|
|
12
|
-
checked,
|
|
13
|
-
|
|
14
|
-
}) => {
|
|
11
|
+
return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"], function (_ref) {
|
|
12
|
+
var checked = _ref.checked,
|
|
13
|
+
status = _ref.status;
|
|
15
14
|
switch (status) {
|
|
16
15
|
case 'correct':
|
|
17
16
|
return color.CORRECT_TEXT_COLOR;
|
|
@@ -20,11 +19,10 @@ function getQuestionStatusStyle() {
|
|
|
20
19
|
default:
|
|
21
20
|
return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
|
|
22
21
|
}
|
|
23
|
-
}, ({
|
|
24
|
-
checked,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return checked || status !== 'answer' ? `rgba(0, 0, 0, 0.08);` : null;
|
|
22
|
+
}, function (_ref2) {
|
|
23
|
+
var checked = _ref2.checked,
|
|
24
|
+
status = _ref2.status;
|
|
25
|
+
return checked || status !== 'answer' ? "rgba(0, 0, 0, 0.08);" : null;
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
4
|
+
|
|
5
|
+
var mergeRefs = function mergeRefs() {
|
|
6
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7
|
+
refs[_key] = arguments[_key];
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
return function (element) {
|
|
10
|
+
return refs.forEach(function (ref) {
|
|
11
|
+
if (typeof ref === 'function') {
|
|
12
|
+
ref(element);
|
|
13
|
+
} else if (ref && _rollupPluginBabelHelpers.typeof(ref) === 'object') {
|
|
14
|
+
ref.current = element;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
10
19
|
|
|
11
20
|
exports.mergeRefs = mergeRefs;
|
package/cjs/constant/element.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var MATERIAL_QUIZ_CONTAINER_ID = 'MATERIAL_QUIZ_CONTAINER_ID';
|
|
4
|
+
var MATERIAL_QUIZ_PASSIVE_ID = 'MATERIAL_QUIZ_PASSIVE_ID';
|
|
5
|
+
var MATERIAL_QUIZ_ANSWER_ID = 'MATERIAL_QUIZ_ANSWER_ID';
|
|
6
6
|
|
|
7
7
|
exports.MATERIAL_QUIZ_ANSWER_ID = MATERIAL_QUIZ_ANSWER_ID;
|
|
8
8
|
exports.MATERIAL_QUIZ_CONTAINER_ID = MATERIAL_QUIZ_CONTAINER_ID;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var element = require('./element.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.MATERIAL_QUIZ_ANSWER_ID = element.MATERIAL_QUIZ_ANSWER_ID;
|
|
8
|
+
exports.MATERIAL_QUIZ_CONTAINER_ID = element.MATERIAL_QUIZ_CONTAINER_ID;
|
|
9
|
+
exports.MATERIAL_QUIZ_PASSIVE_ID = element.MATERIAL_QUIZ_PASSIVE_ID;
|
package/cjs/helpers/index.js
CHANGED
|
@@ -22,12 +22,11 @@ function getQuizResultStatus(materialQuizResponse) {
|
|
|
22
22
|
}
|
|
23
23
|
return exports.QuizResultStatus.NotSubmitted;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
isSelected,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const status = getQuizResultStatus(materialQuizResponse);
|
|
25
|
+
var getOptionStatus = function getOptionStatus(_ref) {
|
|
26
|
+
var isSelected = _ref.isSelected,
|
|
27
|
+
isActive = _ref.isActive,
|
|
28
|
+
materialQuizResponse = _ref.materialQuizResponse;
|
|
29
|
+
var status = getQuizResultStatus(materialQuizResponse);
|
|
31
30
|
if (isActive) {
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
@@ -44,9 +43,8 @@ const getOptionStatus = ({
|
|
|
44
43
|
function checkUserLectureTestEnded(lecture) {
|
|
45
44
|
return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === types.enums.TestAdmissionStatus.Completed;
|
|
46
45
|
}
|
|
47
|
-
function shouldResetOptions({
|
|
48
|
-
materialQuizResponse
|
|
49
|
-
}) {
|
|
46
|
+
function shouldResetOptions(_ref2) {
|
|
47
|
+
var materialQuizResponse = _ref2.materialQuizResponse;
|
|
50
48
|
// when score is given(correct, wrong), reset selected option in order to select options from scratch
|
|
51
49
|
// score condition
|
|
52
50
|
// normal quiz - score is always given(not a null) as long as a user submits the answer
|
|
@@ -54,7 +52,7 @@ function shouldResetOptions({
|
|
|
54
52
|
return [(materialQuizResponse === null || materialQuizResponse === void 0 ? void 0 : materialQuizResponse.score) !== null].every(Boolean);
|
|
55
53
|
}
|
|
56
54
|
function getQuizResult(materialQuizResponse) {
|
|
57
|
-
|
|
55
|
+
var status = getQuizResultStatus(materialQuizResponse);
|
|
58
56
|
switch (status) {
|
|
59
57
|
case exports.QuizResultStatus.Correct:
|
|
60
58
|
return true;
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
3
4
|
var React = require('react');
|
|
4
5
|
var reactUse = require('react-use');
|
|
5
6
|
var MaterialQuizContext = require('../components/material-quiz/context/MaterialQuizContext.js');
|
|
6
7
|
var element = require('../constant/element.js');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
materialQuiz,
|
|
11
|
-
vertical
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
height
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
React.useEffect(()
|
|
9
|
+
var useCaculatePassage = function useCaculatePassage() {
|
|
10
|
+
var _useMaterialQuizState = MaterialQuizContext.useMaterialQuizState(),
|
|
11
|
+
materialQuiz = _useMaterialQuizState.materialQuiz,
|
|
12
|
+
vertical = _useMaterialQuizState.vertical;
|
|
13
|
+
var _useMaterialQuizDispa = MaterialQuizContext.useMaterialQuizDispatch(),
|
|
14
|
+
setIsLongPassage = _useMaterialQuizDispa.setIsLongPassage,
|
|
15
|
+
setIsInitialLoading = _useMaterialQuizDispa.setIsInitialLoading;
|
|
16
|
+
var _useMeasure = reactUse.useMeasure(),
|
|
17
|
+
_useMeasure2 = _rollupPluginBabelHelpers.slicedToArray(_useMeasure, 2),
|
|
18
|
+
questionRef = _useMeasure2[0],
|
|
19
|
+
questionDetailHeight = _useMeasure2[1].height;
|
|
20
|
+
var _useMeasure3 = reactUse.useMeasure(),
|
|
21
|
+
_useMeasure4 = _rollupPluginBabelHelpers.slicedToArray(_useMeasure3, 2),
|
|
22
|
+
containerRef = _useMeasure4[0],
|
|
23
|
+
containerHeight = _useMeasure4[1].height;
|
|
24
|
+
React.useEffect(function () {
|
|
24
25
|
var _a, _b;
|
|
25
|
-
|
|
26
|
+
var currentContainerHeight = vertical ? (_b = (_a = document.getElementById(element.MATERIAL_QUIZ_CONTAINER_ID)) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0 : containerHeight;
|
|
26
27
|
if (currentContainerHeight && questionDetailHeight && materialQuiz) {
|
|
27
28
|
setIsLongPassage(questionDetailHeight > currentContainerHeight);
|
|
28
29
|
// add timeout for forcing caculate layout and render in the parent
|
|
29
30
|
// finish before turning off loading
|
|
30
|
-
setTimeout(()
|
|
31
|
+
setTimeout(function () {
|
|
31
32
|
setIsInitialLoading(false);
|
|
32
33
|
}, 300);
|
|
33
34
|
} else if (materialQuiz && !materialQuiz.questionDescription) {
|
|
@@ -35,8 +36,8 @@ const useCaculatePassage = () => {
|
|
|
35
36
|
}
|
|
36
37
|
}, [containerHeight, questionDetailHeight, materialQuiz, setIsLongPassage, vertical, setIsInitialLoading]);
|
|
37
38
|
return {
|
|
38
|
-
questionRef,
|
|
39
|
-
containerRef
|
|
39
|
+
questionRef: questionRef,
|
|
40
|
+
containerRef: containerRef
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
43
|
|