@elice/material-quiz 1.240718.0-trasncript.0 → 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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { getOrgMaterialQuizResponseGet, getOrgMaterialQuizResponseList, postOrgMaterialQuizResponseAdd } from '@elice/api-client';
|
|
3
5
|
import { Flex } from '@elice/blocks';
|
|
@@ -22,48 +24,70 @@ import MaterialQuizGroupMobile from './MaterialQuizGroupMobile.js';
|
|
|
22
24
|
//
|
|
23
25
|
//
|
|
24
26
|
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
var MaterialQuizGroup = function MaterialQuizGroup() {
|
|
28
|
+
var intl = useRawEliceIntl();
|
|
27
29
|
// context
|
|
28
|
-
|
|
29
|
-
materialQuiz,
|
|
30
|
-
userId,
|
|
31
|
-
vertical,
|
|
32
|
-
isLongPassage
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
var _useMaterialQuizState = useMaterialQuizState(),
|
|
31
|
+
materialQuiz = _useMaterialQuizState.materialQuiz,
|
|
32
|
+
userId = _useMaterialQuizState.userId,
|
|
33
|
+
vertical = _useMaterialQuizState.vertical,
|
|
34
|
+
isLongPassage = _useMaterialQuizState.isLongPassage;
|
|
35
|
+
var _useMaterialQuizDispa = useMaterialQuizDispatch(),
|
|
36
|
+
onSubmit = _useMaterialQuizDispa.onSubmit,
|
|
37
|
+
onNext = _useMaterialQuizDispa.onNext,
|
|
38
|
+
refreshOrgMaterialQuiz = _useMaterialQuizDispa.refreshOrgMaterialQuiz,
|
|
39
|
+
onDirty = _useMaterialQuizDispa.onDirty;
|
|
40
|
+
var theme = useTheme();
|
|
41
|
+
var _React$useState = React.useState([]),
|
|
42
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
43
|
+
groupList = _React$useState2[0],
|
|
44
|
+
setGroupList = _React$useState2[1];
|
|
45
|
+
var _React$useState3 = React.useState([]),
|
|
46
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
47
|
+
optionList = _React$useState4[0],
|
|
48
|
+
setOptionList = _React$useState4[1];
|
|
49
|
+
var _React$useState5 = React.useState([]),
|
|
50
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
51
|
+
currentAnswerList = _React$useState6[0],
|
|
52
|
+
setCurrentAnswerList = _React$useState6[1];
|
|
53
|
+
var _React$useState7 = React.useState([]),
|
|
54
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
55
|
+
currentOptionList = _React$useState8[0],
|
|
56
|
+
setCurrentOptionList = _React$useState8[1];
|
|
57
|
+
var _React$useState9 = React.useState(),
|
|
58
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
59
|
+
materialQuizResponse = _React$useState10[0],
|
|
60
|
+
setMaterialQuizResponse = _React$useState10[1];
|
|
61
|
+
var _React$useState11 = React.useState('idle'),
|
|
62
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
63
|
+
submitStatus = _React$useState12[0],
|
|
64
|
+
setSubmitStatus = _React$useState12[1];
|
|
65
|
+
var _React$useState13 = React.useState(false),
|
|
66
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
67
|
+
hasSubmitted = _React$useState14[0],
|
|
68
|
+
setHasSubmitted = _React$useState14[1];
|
|
69
|
+
var isNextActive = hasSubmitted && typeof onNext === 'function';
|
|
70
|
+
var isDisabled = !flattenDeep(currentAnswerList).length || !!userId;
|
|
71
|
+
var _useCaculatePassage = useCaculatePassage(),
|
|
72
|
+
questionRef = _useCaculatePassage.questionRef,
|
|
73
|
+
containerRef = _useCaculatePassage.containerRef;
|
|
74
|
+
var isVisibleSideBySide = !vertical && isLongPassage;
|
|
55
75
|
/**
|
|
56
76
|
*
|
|
57
77
|
*/
|
|
58
|
-
|
|
78
|
+
var getCurrentAnswer = function getCurrentAnswer(answerInfo, materialOptionList, materialGroupList) {
|
|
59
79
|
if (answerInfo.length) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
var userAnswerList = answerInfo.map(function (answers) {
|
|
81
|
+
return answers.map(function (answer) {
|
|
82
|
+
return {
|
|
83
|
+
order: answer,
|
|
84
|
+
options: materialOptionList[answer]
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
});
|
|
64
88
|
if (answerInfo.length !== materialGroupList.length) {
|
|
65
|
-
|
|
66
|
-
return [
|
|
89
|
+
var deficientAnswerList = new Array(materialGroupList.length - answerInfo.length).fill([]);
|
|
90
|
+
return [].concat(_toConsumableArray(userAnswerList), _toConsumableArray(deficientAnswerList));
|
|
67
91
|
}
|
|
68
92
|
return userAnswerList;
|
|
69
93
|
} else {
|
|
@@ -73,26 +97,34 @@ const MaterialQuizGroup = () => {
|
|
|
73
97
|
/**
|
|
74
98
|
*
|
|
75
99
|
*/
|
|
76
|
-
|
|
100
|
+
var initQuizGroupInfo = React.useCallback(function (answerInfo) {
|
|
77
101
|
var _a, _b;
|
|
78
102
|
if (!materialQuiz) {
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
105
|
+
var materialOptionList = (_a = materialQuiz.options) !== null && _a !== void 0 ? _a : []; // options
|
|
106
|
+
var materialGroupList = (_b = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.groups) !== null && _b !== void 0 ? _b : []; // groups
|
|
107
|
+
var flattenAnswerList = flattenDeep(answerInfo);
|
|
108
|
+
var userAnswerList = getCurrentAnswer(answerInfo, materialOptionList, materialGroupList);
|
|
109
|
+
var userOptionList = materialOptionList.filter(function (_, index) {
|
|
110
|
+
return !flattenAnswerList.includes(index);
|
|
111
|
+
}).map(function (option) {
|
|
112
|
+
var order = materialOptionList.findIndex(function (optionInfo) {
|
|
113
|
+
return optionInfo === option;
|
|
114
|
+
});
|
|
87
115
|
return {
|
|
88
|
-
order,
|
|
116
|
+
order: order,
|
|
89
117
|
options: materialOptionList[order]
|
|
90
118
|
};
|
|
91
119
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
120
|
+
var optionList = materialOptionList.map(function (option, index) {
|
|
121
|
+
return {
|
|
122
|
+
order: materialOptionList.findIndex(function (optionInfo) {
|
|
123
|
+
return optionInfo === option;
|
|
124
|
+
}),
|
|
125
|
+
options: materialOptionList[index]
|
|
126
|
+
};
|
|
127
|
+
});
|
|
96
128
|
setGroupList(materialGroupList);
|
|
97
129
|
setOptionList(optionList);
|
|
98
130
|
setCurrentAnswerList(userAnswerList);
|
|
@@ -101,60 +133,102 @@ const MaterialQuizGroup = () => {
|
|
|
101
133
|
/**
|
|
102
134
|
* submit handler
|
|
103
135
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
137
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
138
|
+
var _yield$postOrgMateria, quizResponseId, _yield$getOrgMaterial, quizResponse;
|
|
139
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
140
|
+
while (1) switch (_context.prev = _context.next) {
|
|
141
|
+
case 0:
|
|
142
|
+
if (materialQuiz) {
|
|
143
|
+
_context.next = 2;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return _context.abrupt("return");
|
|
147
|
+
case 2:
|
|
148
|
+
setSubmitStatus('pending');
|
|
149
|
+
_context.prev = 3;
|
|
150
|
+
_context.next = 6;
|
|
151
|
+
return postOrgMaterialQuizResponseAdd({
|
|
152
|
+
materialQuizId: materialQuiz.id,
|
|
153
|
+
answer: currentAnswerList.map(function (answers) {
|
|
154
|
+
return answers.map(function (answer) {
|
|
155
|
+
return answer.order;
|
|
156
|
+
});
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
case 6:
|
|
160
|
+
_yield$postOrgMateria = _context.sent;
|
|
161
|
+
quizResponseId = _yield$postOrgMateria.quizResponseId;
|
|
162
|
+
_context.next = 10;
|
|
163
|
+
return getOrgMaterialQuizResponseGet({
|
|
164
|
+
quizResponseId: quizResponseId
|
|
165
|
+
});
|
|
166
|
+
case 10:
|
|
167
|
+
_yield$getOrgMaterial = _context.sent;
|
|
168
|
+
quizResponse = _yield$getOrgMaterial.quizResponse;
|
|
169
|
+
setMaterialQuizResponse(quizResponse);
|
|
170
|
+
void refreshOrgMaterialQuiz();
|
|
171
|
+
setHasSubmitted(true);
|
|
172
|
+
onSubmit(true, getQuizResult(quizResponse));
|
|
173
|
+
setSubmitStatus('resolved');
|
|
174
|
+
onDirty(false);
|
|
175
|
+
_context.next = 25;
|
|
176
|
+
break;
|
|
177
|
+
case 20:
|
|
178
|
+
_context.prev = 20;
|
|
179
|
+
_context.t0 = _context["catch"](3);
|
|
180
|
+
console.error(_context.t0);
|
|
181
|
+
onSubmit(false);
|
|
182
|
+
setSubmitStatus('rejected');
|
|
183
|
+
case 25:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context.stop();
|
|
186
|
+
}
|
|
187
|
+
}, _callee, null, [[3, 20]]);
|
|
188
|
+
}));
|
|
189
|
+
return function handleSubmit() {
|
|
190
|
+
return _ref.apply(this, arguments);
|
|
191
|
+
};
|
|
192
|
+
}();
|
|
133
193
|
/**
|
|
134
194
|
*
|
|
135
195
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
196
|
+
var handleAnswerReset = function handleAnswerReset() {
|
|
197
|
+
var cloneAnswerList = cloneDeep(currentAnswerList);
|
|
198
|
+
var emptyAnswerList = cloneAnswerList.map(function () {
|
|
199
|
+
return [];
|
|
200
|
+
});
|
|
139
201
|
setCurrentAnswerList(emptyAnswerList);
|
|
140
202
|
setCurrentOptionList(optionList);
|
|
141
203
|
};
|
|
142
204
|
/**
|
|
143
205
|
*
|
|
144
206
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
207
|
+
var updateCurrentAnswer = function updateCurrentAnswer(targetId, dropzoneIndex) {
|
|
208
|
+
var selectedUserOption = currentOptionList.find(function (option) {
|
|
209
|
+
return option.order === targetId;
|
|
210
|
+
});
|
|
211
|
+
var selectedAnswerOption = optionList.find(function (option) {
|
|
212
|
+
return option.order === targetId;
|
|
213
|
+
});
|
|
148
214
|
if (selectedUserOption) {
|
|
149
|
-
setCurrentOptionList(
|
|
215
|
+
setCurrentOptionList(function (prevOptionList) {
|
|
216
|
+
return prevOptionList.filter(function (option) {
|
|
217
|
+
return option.order !== selectedUserOption.order;
|
|
218
|
+
});
|
|
219
|
+
});
|
|
150
220
|
}
|
|
151
221
|
if (!selectedAnswerOption) {
|
|
152
222
|
return;
|
|
153
223
|
}
|
|
154
|
-
setCurrentAnswerList(prevAnswerList
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
224
|
+
setCurrentAnswerList(function (prevAnswerList) {
|
|
225
|
+
var cloneAnswerList = cloneDeep(prevAnswerList);
|
|
226
|
+
var answerList = cloneAnswerList.map(function (answers) {
|
|
227
|
+
return answers.filter(function (answer) {
|
|
228
|
+
return answer.order !== targetId;
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
answerList[dropzoneIndex] = [].concat(_toConsumableArray(answerList[dropzoneIndex]), [selectedAnswerOption]);
|
|
158
232
|
return answerList;
|
|
159
233
|
});
|
|
160
234
|
onDirty(true);
|
|
@@ -163,54 +237,62 @@ const MaterialQuizGroup = () => {
|
|
|
163
237
|
/**
|
|
164
238
|
*
|
|
165
239
|
*/
|
|
166
|
-
|
|
240
|
+
var updateCurrentOption = function updateCurrentOption(targetId) {
|
|
167
241
|
var _a;
|
|
168
|
-
|
|
169
|
-
|
|
242
|
+
var pastTargetZoneIndex = currentAnswerList.findIndex(function (answer) {
|
|
243
|
+
return answer === null || answer === void 0 ? void 0 : answer.find(function (item) {
|
|
244
|
+
return item.order === targetId;
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
var selectedOption = (_a = currentAnswerList[pastTargetZoneIndex]) === null || _a === void 0 ? void 0 : _a.find(function (answer) {
|
|
248
|
+
return answer.order === targetId;
|
|
249
|
+
});
|
|
170
250
|
if (!selectedOption) {
|
|
171
251
|
return;
|
|
172
252
|
}
|
|
173
|
-
setCurrentAnswerList(prevAnswerList
|
|
174
|
-
|
|
253
|
+
setCurrentAnswerList(function (prevAnswerList) {
|
|
254
|
+
var filteredAnswerList = prevAnswerList[pastTargetZoneIndex].filter(function (answer) {
|
|
255
|
+
return answer.order !== selectedOption.order;
|
|
256
|
+
});
|
|
175
257
|
prevAnswerList[pastTargetZoneIndex] = filteredAnswerList;
|
|
176
|
-
return
|
|
258
|
+
return _toConsumableArray(prevAnswerList);
|
|
259
|
+
});
|
|
260
|
+
setCurrentOptionList(function (prevOptionList) {
|
|
261
|
+
return [].concat(_toConsumableArray(prevOptionList), [selectedOption]);
|
|
177
262
|
});
|
|
178
|
-
setCurrentOptionList(prevOptionList => [...prevOptionList, ...[selectedOption]]);
|
|
179
263
|
onDirty(true);
|
|
180
264
|
};
|
|
181
265
|
//
|
|
182
266
|
//
|
|
183
267
|
// quiz response fetcher
|
|
184
|
-
React.useEffect(()
|
|
268
|
+
React.useEffect(function () {
|
|
185
269
|
if (!userId && (materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.lastQuizResponseId)) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
signal
|
|
189
|
-
} = controller;
|
|
270
|
+
var controller = new AbortController();
|
|
271
|
+
var signal = controller.signal;
|
|
190
272
|
getOrgMaterialQuizResponseGet({
|
|
191
273
|
quizResponseId: materialQuiz.lastQuizResponseId
|
|
192
274
|
}, {
|
|
193
|
-
signal
|
|
194
|
-
}).then(response
|
|
195
|
-
|
|
275
|
+
signal: signal
|
|
276
|
+
}).then(function (response) {
|
|
277
|
+
var answerInfo = response.quizResponse.answer;
|
|
196
278
|
initQuizGroupInfo(answerInfo);
|
|
197
279
|
setMaterialQuizResponse(response.quizResponse);
|
|
198
|
-
}).catch(error
|
|
280
|
+
}).catch(function (error) {
|
|
199
281
|
console.error(error);
|
|
200
282
|
});
|
|
201
|
-
return ()
|
|
283
|
+
return function () {
|
|
284
|
+
return controller.abort();
|
|
285
|
+
};
|
|
202
286
|
} else {
|
|
203
|
-
|
|
287
|
+
var answerInfo = [];
|
|
204
288
|
initQuizGroupInfo(answerInfo);
|
|
205
289
|
}
|
|
206
290
|
}, [initQuizGroupInfo, materialQuiz, userId]);
|
|
207
291
|
// Tutoring
|
|
208
|
-
React.useEffect(()
|
|
292
|
+
React.useEffect(function () {
|
|
209
293
|
if (userId && materialQuiz) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
signal
|
|
213
|
-
} = controller;
|
|
294
|
+
var controller = new AbortController();
|
|
295
|
+
var signal = controller.signal;
|
|
214
296
|
getOrgMaterialQuizResponseList({
|
|
215
297
|
materialQuizId: materialQuiz.id,
|
|
216
298
|
filterUserIds: [userId],
|
|
@@ -219,78 +301,88 @@ const MaterialQuizGroup = () => {
|
|
|
219
301
|
offset: 0,
|
|
220
302
|
count: 1
|
|
221
303
|
}, {
|
|
222
|
-
signal
|
|
223
|
-
}).then(response
|
|
224
|
-
|
|
225
|
-
|
|
304
|
+
signal: signal
|
|
305
|
+
}).then(function (response) {
|
|
306
|
+
var quizResponse = response.quizResponses[0];
|
|
307
|
+
var answerInfo = quizResponse === null || quizResponse === void 0 ? void 0 : quizResponse.answer;
|
|
226
308
|
initQuizGroupInfo(answerInfo !== null && answerInfo !== void 0 ? answerInfo : []);
|
|
227
309
|
setMaterialQuizResponse(quizResponse);
|
|
228
|
-
}).catch(
|
|
229
|
-
|
|
310
|
+
}).catch(function (error) {
|
|
311
|
+
return console.error(error);
|
|
312
|
+
});
|
|
313
|
+
return function () {
|
|
314
|
+
return controller.abort();
|
|
315
|
+
};
|
|
230
316
|
}
|
|
231
317
|
}, [initQuizGroupInfo, materialQuiz, userId]);
|
|
232
318
|
/**
|
|
233
319
|
*
|
|
234
320
|
*/
|
|
235
|
-
|
|
321
|
+
var renderQuizInfo = function renderQuizInfo() {
|
|
236
322
|
if (!materialQuiz || isVisibleSideBySide) {
|
|
237
323
|
return null;
|
|
238
324
|
}
|
|
239
|
-
return
|
|
325
|
+
return jsx(Flex, {
|
|
240
326
|
marginbottom: "1.5rem",
|
|
241
327
|
id: MATERIAL_QUIZ_PASSIVE_ID,
|
|
242
328
|
column: true,
|
|
243
|
-
ref: questionRef
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
329
|
+
ref: questionRef,
|
|
330
|
+
children: jsx(MaterialQuizInfo, {
|
|
331
|
+
renderWithBox: false
|
|
332
|
+
})
|
|
333
|
+
});
|
|
247
334
|
};
|
|
248
335
|
//
|
|
249
336
|
//
|
|
250
337
|
//
|
|
251
|
-
return
|
|
338
|
+
return jsx(QuizGroupContext.Provider, {
|
|
252
339
|
value: {
|
|
253
|
-
groupList,
|
|
254
|
-
optionList,
|
|
255
|
-
currentOptionList,
|
|
256
|
-
currentAnswerList,
|
|
340
|
+
groupList: groupList,
|
|
341
|
+
optionList: optionList,
|
|
342
|
+
currentOptionList: currentOptionList,
|
|
343
|
+
currentAnswerList: currentAnswerList,
|
|
257
344
|
onUpdateAnswer: setCurrentAnswerList,
|
|
258
345
|
onUpdateOption: setCurrentOptionList,
|
|
259
346
|
onUpdateHasSubmitted: setHasSubmitted,
|
|
260
|
-
onDirty,
|
|
261
|
-
updateCurrentAnswer,
|
|
262
|
-
updateCurrentOption,
|
|
263
|
-
handleAnswerReset
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}),
|
|
272
|
-
submitResult: React.createElement(QuizResultBadge, {
|
|
273
|
-
materialQuizResponse: materialQuizResponse
|
|
274
|
-
}),
|
|
275
|
-
bodyContainerRef: containerRef,
|
|
276
|
-
footerActions: [{
|
|
277
|
-
border: false,
|
|
278
|
-
disabled: isDisabled,
|
|
279
|
-
loading: submitStatus === 'pending',
|
|
280
|
-
tabIndex: 0,
|
|
281
|
-
transparent: false,
|
|
282
|
-
onClick: handleSubmit,
|
|
283
|
-
children: intl.formatMessage({
|
|
284
|
-
id: isNextActive ? 'materialQuiz.resubmit' : 'materialQuiz.submit'
|
|
347
|
+
onDirty: onDirty,
|
|
348
|
+
updateCurrentAnswer: updateCurrentAnswer,
|
|
349
|
+
updateCurrentOption: updateCurrentOption,
|
|
350
|
+
handleAnswerReset: handleAnswerReset
|
|
351
|
+
},
|
|
352
|
+
children: jsxs(QuestionBox, {
|
|
353
|
+
title: materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.questionTitle,
|
|
354
|
+
onNext: onNext,
|
|
355
|
+
isNextActive: isNextActive,
|
|
356
|
+
submitStatus: jsx(QuizSubmitStatusText, {
|
|
357
|
+
status: submitStatus
|
|
285
358
|
}),
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
359
|
+
submitResult: jsx(QuizResultBadge, {
|
|
360
|
+
materialQuizResponse: materialQuizResponse
|
|
361
|
+
}),
|
|
362
|
+
bodyContainerRef: containerRef,
|
|
363
|
+
footerActions: [{
|
|
364
|
+
border: false,
|
|
365
|
+
disabled: isDisabled,
|
|
366
|
+
loading: submitStatus === 'pending',
|
|
367
|
+
tabIndex: 0,
|
|
368
|
+
transparent: false,
|
|
369
|
+
onClick: handleSubmit,
|
|
370
|
+
children: intl.formatMessage({
|
|
371
|
+
id: isNextActive ? 'materialQuiz.resubmit' : 'materialQuiz.submit'
|
|
372
|
+
}),
|
|
373
|
+
customStyles: {
|
|
374
|
+
backgroundColor: isNextActive ? theme.palette.secondary.main : isDisabled ? base.color.gray6 : theme.palette.primary.main,
|
|
375
|
+
color: isNextActive ? theme.palette.secondary.contrastText : isDisabled ? base.color.gray3 : theme.palette.primary.contrastText
|
|
376
|
+
}
|
|
377
|
+
}],
|
|
378
|
+
children: [renderQuizInfo(), vertical || isVisibleSideBySide ? jsx("div", {
|
|
379
|
+
id: MATERIAL_QUIZ_ANSWER_ID,
|
|
380
|
+
children: jsx(MaterialQuizGroupMobile, {})
|
|
381
|
+
}) : jsx(Fragment, {
|
|
382
|
+
children: jsx(MaterialQuizGroupDesktop, {})
|
|
383
|
+
}), jsx(MaterialQuizAnswerExplanation, {})]
|
|
384
|
+
})
|
|
385
|
+
});
|
|
294
386
|
};
|
|
295
387
|
var MaterialQuizGroup$1 = MaterialQuizGroup;
|
|
296
388
|
|