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