@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.1
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/components/eb-sortable/EbDraggable.js +33 -42
- package/cjs/components/eb-sortable/EbDroppable.js +20 -27
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
- package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
- package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
- package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
- 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 +93 -156
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
- package/cjs/components/material-quiz-edit/context.js +2 -8
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
- package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
- package/cjs/components/shared/QuestionBox.js +165 -198
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
- package/cjs/components/shared/QuizDraggbleOption.js +59 -65
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/cjs/components/shared/utils/mergeRefs.js +6 -15
- package/cjs/constant/element.js +3 -3
- package/cjs/helpers/index.js +10 -8
- package/cjs/hooks/useCaculatePassage.js +20 -21
- package/es/components/eb-sortable/EbDraggable.js +33 -37
- package/es/components/eb-sortable/EbDroppable.js +20 -22
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-quiz/MaterialQuiz.js +83 -109
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
- package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
- package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
- package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
- package/es/components/material-quiz/MaterialQuizText.js +115 -158
- package/es/components/material-quiz/QuizResultBadge.js +22 -27
- package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
- 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 +94 -153
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
- package/es/components/material-quiz-edit/context.js +2 -4
- package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
- package/es/components/material-quiz-edit/options/OptionText.js +82 -86
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/es/components/material-quiz-edit/utils/editValue.js +12 -17
- package/es/components/shared/QuestionBox.js +165 -192
- package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
- package/es/components/shared/QuizDraggbleOption.js +59 -61
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
- package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/es/components/shared/utils/mergeRefs.js +6 -15
- package/es/constant/element.js +3 -3
- package/es/helpers/index.js +10 -8
- package/es/hooks/useCaculatePassage.js +20 -21
- package/package.json +15 -12
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
- package/cjs/components/material-quiz/index.js +0 -9
- package/cjs/components/material-quiz/locales/index.js +0 -13
- package/cjs/components/material-quiz-edit/index.js +0 -7
- package/cjs/components/material-quiz-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -19
- package/cjs/constant/index.js +0 -9
- package/cjs/hooks/index.js +0 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
- package/es/components/material-quiz/index.js +0 -2
- package/es/components/material-quiz/locales/index.js +0 -4
- package/es/components/material-quiz-edit/index.js +0 -1
- package/es/components/material-quiz-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -7
- package/es/constant/index.js +0 -1
- package/es/hooks/index.js +0 -1
|
@@ -1,5 +1,3 @@
|
|
|
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';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { getOrgMaterialQuizResponseGet, getOrgMaterialQuizResponseList, postOrgMaterialQuizResponseAdd } from '@elice/api-client';
|
|
5
3
|
import { Flex } from '@elice/blocks';
|
|
@@ -24,70 +22,48 @@ import MaterialQuizGroupMobile from './MaterialQuizGroupMobile.js';
|
|
|
24
22
|
//
|
|
25
23
|
//
|
|
26
24
|
//
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const MaterialQuizGroup = () => {
|
|
26
|
+
const intl = useRawEliceIntl();
|
|
29
27
|
// context
|
|
30
|
-
|
|
31
|
-
materialQuiz
|
|
32
|
-
userId
|
|
33
|
-
vertical
|
|
34
|
-
isLongPassage
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
|
28
|
+
const {
|
|
29
|
+
materialQuiz,
|
|
30
|
+
userId,
|
|
31
|
+
vertical,
|
|
32
|
+
isLongPassage
|
|
33
|
+
} = useMaterialQuizState();
|
|
34
|
+
const {
|
|
35
|
+
onSubmit,
|
|
36
|
+
onNext,
|
|
37
|
+
refreshOrgMaterialQuiz,
|
|
38
|
+
onDirty
|
|
39
|
+
} = useMaterialQuizDispatch();
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
const [groupList, setGroupList] = React.useState([]);
|
|
42
|
+
const [optionList, setOptionList] = React.useState([]);
|
|
43
|
+
const [currentAnswerList, setCurrentAnswerList] = React.useState([]);
|
|
44
|
+
const [currentOptionList, setCurrentOptionList] = React.useState([]);
|
|
45
|
+
const [materialQuizResponse, setMaterialQuizResponse] = React.useState();
|
|
46
|
+
const [submitStatus, setSubmitStatus] = React.useState('idle');
|
|
47
|
+
const [hasSubmitted, setHasSubmitted] = React.useState(false);
|
|
48
|
+
const isNextActive = hasSubmitted && typeof onNext === 'function';
|
|
49
|
+
const isDisabled = !flattenDeep(currentAnswerList).length || !!userId;
|
|
50
|
+
const {
|
|
51
|
+
questionRef,
|
|
52
|
+
containerRef
|
|
53
|
+
} = useCaculatePassage();
|
|
54
|
+
const isVisibleSideBySide = !vertical && isLongPassage;
|
|
75
55
|
/**
|
|
76
56
|
*
|
|
77
57
|
*/
|
|
78
|
-
|
|
58
|
+
const getCurrentAnswer = (answerInfo, materialOptionList, materialGroupList) => {
|
|
79
59
|
if (answerInfo.length) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
options: materialOptionList[answer]
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
});
|
|
60
|
+
const userAnswerList = answerInfo.map(answers => answers.map(answer => ({
|
|
61
|
+
order: answer,
|
|
62
|
+
options: materialOptionList[answer]
|
|
63
|
+
})));
|
|
88
64
|
if (answerInfo.length !== materialGroupList.length) {
|
|
89
|
-
|
|
90
|
-
return [
|
|
65
|
+
const deficientAnswerList = new Array(materialGroupList.length - answerInfo.length).fill([]);
|
|
66
|
+
return [...userAnswerList, ...deficientAnswerList];
|
|
91
67
|
}
|
|
92
68
|
return userAnswerList;
|
|
93
69
|
} else {
|
|
@@ -97,34 +73,26 @@ var MaterialQuizGroup = function MaterialQuizGroup() {
|
|
|
97
73
|
/**
|
|
98
74
|
*
|
|
99
75
|
*/
|
|
100
|
-
|
|
76
|
+
const initQuizGroupInfo = React.useCallback(answerInfo => {
|
|
101
77
|
var _a, _b;
|
|
102
78
|
if (!materialQuiz) {
|
|
103
79
|
return;
|
|
104
80
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}).map(function (option) {
|
|
112
|
-
var order = materialOptionList.findIndex(function (optionInfo) {
|
|
113
|
-
return optionInfo === option;
|
|
114
|
-
});
|
|
81
|
+
const materialOptionList = (_a = materialQuiz.options) !== null && _a !== void 0 ? _a : []; // options
|
|
82
|
+
const materialGroupList = (_b = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.groups) !== null && _b !== void 0 ? _b : []; // groups
|
|
83
|
+
const flattenAnswerList = flattenDeep(answerInfo);
|
|
84
|
+
const userAnswerList = getCurrentAnswer(answerInfo, materialOptionList, materialGroupList);
|
|
85
|
+
const userOptionList = materialOptionList.filter((_, index) => !flattenAnswerList.includes(index)).map(option => {
|
|
86
|
+
const order = materialOptionList.findIndex(optionInfo => optionInfo === option);
|
|
115
87
|
return {
|
|
116
|
-
order
|
|
88
|
+
order,
|
|
117
89
|
options: materialOptionList[order]
|
|
118
90
|
};
|
|
119
91
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}),
|
|
125
|
-
options: materialOptionList[index]
|
|
126
|
-
};
|
|
127
|
-
});
|
|
92
|
+
const optionList = materialOptionList.map((option, index) => ({
|
|
93
|
+
order: materialOptionList.findIndex(optionInfo => optionInfo === option),
|
|
94
|
+
options: materialOptionList[index]
|
|
95
|
+
}));
|
|
128
96
|
setGroupList(materialGroupList);
|
|
129
97
|
setOptionList(optionList);
|
|
130
98
|
setCurrentAnswerList(userAnswerList);
|
|
@@ -133,102 +101,60 @@ var MaterialQuizGroup = function MaterialQuizGroup() {
|
|
|
133
101
|
/**
|
|
134
102
|
* submit handler
|
|
135
103
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
}();
|
|
104
|
+
const handleSubmit = async () => {
|
|
105
|
+
if (!materialQuiz) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setSubmitStatus('pending');
|
|
109
|
+
try {
|
|
110
|
+
const {
|
|
111
|
+
quizResponseId
|
|
112
|
+
} = await postOrgMaterialQuizResponseAdd({
|
|
113
|
+
materialQuizId: materialQuiz.id,
|
|
114
|
+
answer: currentAnswerList.map(answers => answers.map(answer => answer.order))
|
|
115
|
+
});
|
|
116
|
+
const {
|
|
117
|
+
quizResponse
|
|
118
|
+
} = await getOrgMaterialQuizResponseGet({
|
|
119
|
+
quizResponseId
|
|
120
|
+
});
|
|
121
|
+
setMaterialQuizResponse(quizResponse);
|
|
122
|
+
void refreshOrgMaterialQuiz();
|
|
123
|
+
setHasSubmitted(true);
|
|
124
|
+
onSubmit(true, getQuizResult(quizResponse));
|
|
125
|
+
setSubmitStatus('resolved');
|
|
126
|
+
onDirty(false);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(error);
|
|
129
|
+
onSubmit(false);
|
|
130
|
+
setSubmitStatus('rejected');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
193
133
|
/**
|
|
194
134
|
*
|
|
195
135
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return [];
|
|
200
|
-
});
|
|
136
|
+
const handleAnswerReset = () => {
|
|
137
|
+
const cloneAnswerList = cloneDeep(currentAnswerList);
|
|
138
|
+
const emptyAnswerList = cloneAnswerList.map(() => []);
|
|
201
139
|
setCurrentAnswerList(emptyAnswerList);
|
|
202
140
|
setCurrentOptionList(optionList);
|
|
203
141
|
};
|
|
204
142
|
/**
|
|
205
143
|
*
|
|
206
144
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
});
|
|
211
|
-
var selectedAnswerOption = optionList.find(function (option) {
|
|
212
|
-
return option.order === targetId;
|
|
213
|
-
});
|
|
145
|
+
const updateCurrentAnswer = (targetId, dropzoneIndex) => {
|
|
146
|
+
const selectedUserOption = currentOptionList.find(option => option.order === targetId);
|
|
147
|
+
const selectedAnswerOption = optionList.find(option => option.order === targetId);
|
|
214
148
|
if (selectedUserOption) {
|
|
215
|
-
setCurrentOptionList(
|
|
216
|
-
return prevOptionList.filter(function (option) {
|
|
217
|
-
return option.order !== selectedUserOption.order;
|
|
218
|
-
});
|
|
219
|
-
});
|
|
149
|
+
setCurrentOptionList(prevOptionList => prevOptionList.filter(option => option.order !== selectedUserOption.order));
|
|
220
150
|
}
|
|
221
151
|
if (!selectedAnswerOption) {
|
|
222
152
|
return;
|
|
223
153
|
}
|
|
224
|
-
setCurrentAnswerList(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return answer.order !== targetId;
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
answerList[dropzoneIndex] = [].concat(_toConsumableArray(answerList[dropzoneIndex]), [selectedAnswerOption]);
|
|
154
|
+
setCurrentAnswerList(prevAnswerList => {
|
|
155
|
+
const cloneAnswerList = cloneDeep(prevAnswerList);
|
|
156
|
+
const answerList = cloneAnswerList.map(answers => answers.filter(answer => answer.order !== targetId));
|
|
157
|
+
answerList[dropzoneIndex] = [...answerList[dropzoneIndex], selectedAnswerOption];
|
|
232
158
|
return answerList;
|
|
233
159
|
});
|
|
234
160
|
onDirty(true);
|
|
@@ -237,62 +163,54 @@ var MaterialQuizGroup = function MaterialQuizGroup() {
|
|
|
237
163
|
/**
|
|
238
164
|
*
|
|
239
165
|
*/
|
|
240
|
-
|
|
166
|
+
const updateCurrentOption = targetId => {
|
|
241
167
|
var _a;
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
});
|
|
168
|
+
const pastTargetZoneIndex = currentAnswerList.findIndex(answer => answer === null || answer === void 0 ? void 0 : answer.find(item => item.order === targetId));
|
|
169
|
+
const selectedOption = (_a = currentAnswerList[pastTargetZoneIndex]) === null || _a === void 0 ? void 0 : _a.find(answer => answer.order === targetId);
|
|
250
170
|
if (!selectedOption) {
|
|
251
171
|
return;
|
|
252
172
|
}
|
|
253
|
-
setCurrentAnswerList(
|
|
254
|
-
|
|
255
|
-
return answer.order !== selectedOption.order;
|
|
256
|
-
});
|
|
173
|
+
setCurrentAnswerList(prevAnswerList => {
|
|
174
|
+
const filteredAnswerList = prevAnswerList[pastTargetZoneIndex].filter(answer => answer.order !== selectedOption.order);
|
|
257
175
|
prevAnswerList[pastTargetZoneIndex] = filteredAnswerList;
|
|
258
|
-
return
|
|
259
|
-
});
|
|
260
|
-
setCurrentOptionList(function (prevOptionList) {
|
|
261
|
-
return [].concat(_toConsumableArray(prevOptionList), [selectedOption]);
|
|
176
|
+
return [...prevAnswerList];
|
|
262
177
|
});
|
|
178
|
+
setCurrentOptionList(prevOptionList => [...prevOptionList, ...[selectedOption]]);
|
|
263
179
|
onDirty(true);
|
|
264
180
|
};
|
|
265
181
|
//
|
|
266
182
|
//
|
|
267
183
|
// quiz response fetcher
|
|
268
|
-
React.useEffect(
|
|
184
|
+
React.useEffect(() => {
|
|
269
185
|
if (!userId && (materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.lastQuizResponseId)) {
|
|
270
|
-
|
|
271
|
-
|
|
186
|
+
const controller = new AbortController();
|
|
187
|
+
const {
|
|
188
|
+
signal
|
|
189
|
+
} = controller;
|
|
272
190
|
getOrgMaterialQuizResponseGet({
|
|
273
191
|
quizResponseId: materialQuiz.lastQuizResponseId
|
|
274
192
|
}, {
|
|
275
|
-
signal
|
|
276
|
-
}).then(
|
|
277
|
-
|
|
193
|
+
signal
|
|
194
|
+
}).then(response => {
|
|
195
|
+
const answerInfo = response.quizResponse.answer;
|
|
278
196
|
initQuizGroupInfo(answerInfo);
|
|
279
197
|
setMaterialQuizResponse(response.quizResponse);
|
|
280
|
-
}).catch(
|
|
198
|
+
}).catch(error => {
|
|
281
199
|
console.error(error);
|
|
282
200
|
});
|
|
283
|
-
return
|
|
284
|
-
return controller.abort();
|
|
285
|
-
};
|
|
201
|
+
return () => controller.abort();
|
|
286
202
|
} else {
|
|
287
|
-
|
|
203
|
+
const answerInfo = [];
|
|
288
204
|
initQuizGroupInfo(answerInfo);
|
|
289
205
|
}
|
|
290
206
|
}, [initQuizGroupInfo, materialQuiz, userId]);
|
|
291
207
|
// Tutoring
|
|
292
|
-
React.useEffect(
|
|
208
|
+
React.useEffect(() => {
|
|
293
209
|
if (userId && materialQuiz) {
|
|
294
|
-
|
|
295
|
-
|
|
210
|
+
const controller = new AbortController();
|
|
211
|
+
const {
|
|
212
|
+
signal
|
|
213
|
+
} = controller;
|
|
296
214
|
getOrgMaterialQuizResponseList({
|
|
297
215
|
materialQuizId: materialQuiz.id,
|
|
298
216
|
filterUserIds: [userId],
|
|
@@ -301,88 +219,78 @@ var MaterialQuizGroup = function MaterialQuizGroup() {
|
|
|
301
219
|
offset: 0,
|
|
302
220
|
count: 1
|
|
303
221
|
}, {
|
|
304
|
-
signal
|
|
305
|
-
}).then(
|
|
306
|
-
|
|
307
|
-
|
|
222
|
+
signal
|
|
223
|
+
}).then(response => {
|
|
224
|
+
const quizResponse = response.quizResponses[0];
|
|
225
|
+
const answerInfo = quizResponse === null || quizResponse === void 0 ? void 0 : quizResponse.answer;
|
|
308
226
|
initQuizGroupInfo(answerInfo !== null && answerInfo !== void 0 ? answerInfo : []);
|
|
309
227
|
setMaterialQuizResponse(quizResponse);
|
|
310
|
-
}).catch(
|
|
311
|
-
|
|
312
|
-
});
|
|
313
|
-
return function () {
|
|
314
|
-
return controller.abort();
|
|
315
|
-
};
|
|
228
|
+
}).catch(error => console.error(error));
|
|
229
|
+
return () => controller.abort();
|
|
316
230
|
}
|
|
317
231
|
}, [initQuizGroupInfo, materialQuiz, userId]);
|
|
318
232
|
/**
|
|
319
233
|
*
|
|
320
234
|
*/
|
|
321
|
-
|
|
235
|
+
const renderQuizInfo = () => {
|
|
322
236
|
if (!materialQuiz || isVisibleSideBySide) {
|
|
323
237
|
return null;
|
|
324
238
|
}
|
|
325
|
-
return
|
|
239
|
+
return React.createElement(Flex, {
|
|
326
240
|
marginbottom: "1.5rem",
|
|
327
241
|
id: MATERIAL_QUIZ_PASSIVE_ID,
|
|
328
242
|
column: true,
|
|
329
|
-
ref: questionRef
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
});
|
|
243
|
+
ref: questionRef
|
|
244
|
+
}, React.createElement(MaterialQuizInfo, {
|
|
245
|
+
renderWithBox: false
|
|
246
|
+
}));
|
|
334
247
|
};
|
|
335
248
|
//
|
|
336
249
|
//
|
|
337
250
|
//
|
|
338
|
-
return
|
|
251
|
+
return React.createElement(QuizGroupContext.Provider, {
|
|
339
252
|
value: {
|
|
340
|
-
groupList
|
|
341
|
-
optionList
|
|
342
|
-
currentOptionList
|
|
343
|
-
currentAnswerList
|
|
253
|
+
groupList,
|
|
254
|
+
optionList,
|
|
255
|
+
currentOptionList,
|
|
256
|
+
currentAnswerList,
|
|
344
257
|
onUpdateAnswer: setCurrentAnswerList,
|
|
345
258
|
onUpdateOption: setCurrentOptionList,
|
|
346
259
|
onUpdateHasSubmitted: setHasSubmitted,
|
|
347
|
-
onDirty
|
|
348
|
-
updateCurrentAnswer
|
|
349
|
-
updateCurrentOption
|
|
350
|
-
handleAnswerReset
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
260
|
+
onDirty,
|
|
261
|
+
updateCurrentAnswer,
|
|
262
|
+
updateCurrentOption,
|
|
263
|
+
handleAnswerReset
|
|
264
|
+
}
|
|
265
|
+
}, React.createElement(QuestionBox, {
|
|
266
|
+
title: materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.title,
|
|
267
|
+
onNext: onNext,
|
|
268
|
+
isNextActive: isNextActive,
|
|
269
|
+
submitStatus: React.createElement(QuizSubmitStatusText, {
|
|
270
|
+
status: submitStatus
|
|
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'
|
|
361
285
|
}),
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
});
|
|
286
|
+
customStyles: {
|
|
287
|
+
backgroundColor: isNextActive ? theme.palette.secondary.main : isDisabled ? base.color.gray6 : theme.palette.primary.main,
|
|
288
|
+
color: isNextActive ? theme.palette.secondary.contrastText : isDisabled ? base.color.gray3 : theme.palette.primary.contrastText
|
|
289
|
+
}
|
|
290
|
+
}]
|
|
291
|
+
}, renderQuizInfo(), vertical || isVisibleSideBySide ? React.createElement("div", {
|
|
292
|
+
id: MATERIAL_QUIZ_ANSWER_ID
|
|
293
|
+
}, React.createElement(MaterialQuizGroupMobile, null)) : React.createElement(React.Fragment, null, React.createElement(MaterialQuizGroupDesktop, null)), React.createElement(MaterialQuizAnswerExplanation, null)));
|
|
386
294
|
};
|
|
387
295
|
var MaterialQuizGroup$1 = MaterialQuizGroup;
|
|
388
296
|
|