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