@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,184 +1,125 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React, { useEffect } from 'react';
|
|
4
|
-
import { config, getOrgMaterialQuizGet,
|
|
2
|
+
import { config, postOrgMaterialQuizOptionsSetSelect, getOrgMaterialQuizGet, getOrgCourseGet, getOrgLectureGet } from '@elice/api-client';
|
|
5
3
|
import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
|
|
6
4
|
import { enums } from '@elice/types';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const StateContext = React.createContext(undefined);
|
|
7
|
+
const DispatchContext = React.createContext(undefined);
|
|
10
8
|
StateContext.displayName = 'MaterialQuizStateContext';
|
|
11
9
|
DispatchContext.displayName = 'MaterialQuizDispatchContext';
|
|
12
|
-
function MaterialQuizProvider(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
lecture = _React$useState4[0],
|
|
29
|
-
setLecture = _React$useState4[1];
|
|
30
|
-
var _React$useState5 = React.useState('idle'),
|
|
31
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
32
|
-
initStatus = _React$useState6[0],
|
|
33
|
-
setInitStatus = _React$useState6[1];
|
|
34
|
-
var _React$useState7 = React.useState(false),
|
|
35
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
36
|
-
vertical = _React$useState8[0],
|
|
37
|
-
setVertical = _React$useState8[1];
|
|
38
|
-
var _React$useState9 = React.useState(false),
|
|
39
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
40
|
-
isLongPassage = _React$useState10[0],
|
|
41
|
-
setIsLongPassage = _React$useState10[1];
|
|
42
|
-
var _React$useState11 = React.useState(true),
|
|
43
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
44
|
-
isInitialLoading = _React$useState12[0],
|
|
45
|
-
setIsInitialLoading = _React$useState12[1];
|
|
46
|
-
var canInit = useMaterialConfigApiClientUpdate(config.init);
|
|
47
|
-
var resetLayout = function resetLayout() {
|
|
10
|
+
function MaterialQuizProvider({
|
|
11
|
+
materialQuizId,
|
|
12
|
+
userId,
|
|
13
|
+
onSubmit = () => void 0,
|
|
14
|
+
onDirty,
|
|
15
|
+
onNext,
|
|
16
|
+
children
|
|
17
|
+
}) {
|
|
18
|
+
const [course, setCourse] = React.useState();
|
|
19
|
+
const [lecture, setLecture] = React.useState();
|
|
20
|
+
const [initStatus, setInitStatus] = React.useState('idle');
|
|
21
|
+
const [vertical, setVertical] = React.useState(false);
|
|
22
|
+
const [isLongPassage, setIsLongPassage] = React.useState(false);
|
|
23
|
+
const [isInitialLoading, setIsInitialLoading] = React.useState(true);
|
|
24
|
+
const canInit = useMaterialConfigApiClientUpdate(config.init);
|
|
25
|
+
const resetLayout = () => {
|
|
48
26
|
setIsInitialLoading(true);
|
|
49
27
|
setIsLongPassage(false);
|
|
50
28
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}));
|
|
78
|
-
return function (_x) {
|
|
79
|
-
return _ref2.apply(this, arguments);
|
|
80
|
-
};
|
|
81
|
-
}(), [materialQuizId, userId]), canInit),
|
|
82
|
-
materialQuiz = _useMaterialFetchRaw.materialQuiz,
|
|
83
|
-
materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
|
|
84
|
-
refreshOrgMaterialQuiz = _useMaterialFetchRaw.refetch;
|
|
85
|
-
var init = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
86
|
-
var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
|
|
87
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
88
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
89
|
-
case 0:
|
|
90
|
-
controller = new AbortController();
|
|
91
|
-
signal = controller.signal;
|
|
92
|
-
_context2.prev = 2;
|
|
93
|
-
setInitStatus('pending');
|
|
94
|
-
if (materialLecturePage) {
|
|
95
|
-
_context2.next = 6;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
throw new Error('materialSurvey is not ready');
|
|
99
|
-
case 6:
|
|
100
|
-
_context2.next = 8;
|
|
101
|
-
return getOrgCourseGet({
|
|
102
|
-
courseId: materialLecturePage.courseId
|
|
103
|
-
}, {
|
|
104
|
-
signal: signal
|
|
105
|
-
});
|
|
106
|
-
case 8:
|
|
107
|
-
_yield$getOrgCourseGe = _context2.sent;
|
|
108
|
-
_course = _yield$getOrgCourseGe.course;
|
|
109
|
-
_context2.next = 12;
|
|
110
|
-
return getOrgLectureGet({
|
|
111
|
-
lectureId: materialLecturePage.lectureId
|
|
112
|
-
}, {
|
|
113
|
-
signal: signal
|
|
114
|
-
});
|
|
115
|
-
case 12:
|
|
116
|
-
_yield$getOrgLectureG = _context2.sent;
|
|
117
|
-
_lecture = _yield$getOrgLectureG.lecture;
|
|
118
|
-
setCourse(_course);
|
|
119
|
-
setLecture(_lecture);
|
|
120
|
-
setInitStatus('resolved');
|
|
121
|
-
_context2.next = 23;
|
|
122
|
-
break;
|
|
123
|
-
case 19:
|
|
124
|
-
_context2.prev = 19;
|
|
125
|
-
_context2.t0 = _context2["catch"](2);
|
|
126
|
-
console.error(_context2.t0);
|
|
127
|
-
setInitStatus('rejected');
|
|
128
|
-
case 23:
|
|
129
|
-
return _context2.abrupt("return", function () {
|
|
130
|
-
return controller.abort();
|
|
131
|
-
});
|
|
132
|
-
case 24:
|
|
133
|
-
case "end":
|
|
134
|
-
return _context2.stop();
|
|
29
|
+
const {
|
|
30
|
+
materialQuiz,
|
|
31
|
+
materialLecturePage,
|
|
32
|
+
refetch: refreshOrgMaterialQuiz
|
|
33
|
+
} = useMaterialFetchRaw(enums.LectureMaterialType.Quiz, React.useCallback(async signal => {
|
|
34
|
+
await postOrgMaterialQuizOptionsSetSelect({
|
|
35
|
+
materialQuizId
|
|
36
|
+
}, {
|
|
37
|
+
signal
|
|
38
|
+
});
|
|
39
|
+
return await getOrgMaterialQuizGet({
|
|
40
|
+
materialQuizId,
|
|
41
|
+
userId
|
|
42
|
+
}, {
|
|
43
|
+
signal
|
|
44
|
+
});
|
|
45
|
+
}, [materialQuizId, userId]), canInit);
|
|
46
|
+
const init = React.useCallback(async () => {
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
const {
|
|
49
|
+
signal
|
|
50
|
+
} = controller;
|
|
51
|
+
try {
|
|
52
|
+
setInitStatus('pending');
|
|
53
|
+
if (!materialLecturePage) {
|
|
54
|
+
throw new Error('materialSurvey is not ready');
|
|
135
55
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
56
|
+
// fetch course
|
|
57
|
+
const {
|
|
58
|
+
course
|
|
59
|
+
} = await getOrgCourseGet({
|
|
60
|
+
courseId: materialLecturePage.courseId
|
|
61
|
+
}, {
|
|
62
|
+
signal
|
|
63
|
+
});
|
|
64
|
+
// fetch lecture
|
|
65
|
+
const {
|
|
66
|
+
lecture
|
|
67
|
+
} = await getOrgLectureGet({
|
|
68
|
+
lectureId: materialLecturePage.lectureId
|
|
69
|
+
}, {
|
|
70
|
+
signal
|
|
71
|
+
});
|
|
72
|
+
setCourse(course);
|
|
73
|
+
setLecture(lecture);
|
|
74
|
+
setInitStatus('resolved');
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(error);
|
|
77
|
+
setInitStatus('rejected');
|
|
78
|
+
}
|
|
79
|
+
return () => controller.abort();
|
|
80
|
+
}, [materialLecturePage]);
|
|
81
|
+
useEffect(() => {
|
|
139
82
|
if (materialQuizId) {
|
|
140
83
|
resetLayout();
|
|
141
84
|
}
|
|
142
85
|
}, [materialQuizId]);
|
|
143
|
-
React.useEffect(
|
|
86
|
+
React.useEffect(() => {
|
|
144
87
|
if (canInit && materialLecturePage) {
|
|
145
88
|
void init();
|
|
146
89
|
}
|
|
147
90
|
}, [canInit, materialLecturePage, init]);
|
|
148
|
-
return
|
|
91
|
+
return React.createElement(StateContext.Provider, {
|
|
149
92
|
value: {
|
|
150
|
-
course
|
|
151
|
-
lecture
|
|
93
|
+
course,
|
|
94
|
+
lecture,
|
|
152
95
|
materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
|
|
153
|
-
userId
|
|
154
|
-
vertical
|
|
155
|
-
initStatus
|
|
156
|
-
isLongPassage
|
|
157
|
-
isInitialLoading
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})
|
|
171
|
-
});
|
|
96
|
+
userId,
|
|
97
|
+
vertical,
|
|
98
|
+
initStatus,
|
|
99
|
+
isLongPassage,
|
|
100
|
+
isInitialLoading
|
|
101
|
+
}
|
|
102
|
+
}, React.createElement(DispatchContext.Provider, {
|
|
103
|
+
value: {
|
|
104
|
+
onSubmit,
|
|
105
|
+
onDirty,
|
|
106
|
+
onNext,
|
|
107
|
+
refreshOrgMaterialQuiz,
|
|
108
|
+
setVertical,
|
|
109
|
+
setIsLongPassage,
|
|
110
|
+
setIsInitialLoading
|
|
111
|
+
}
|
|
112
|
+
}, children));
|
|
172
113
|
}
|
|
173
114
|
function useMaterialQuizState() {
|
|
174
|
-
|
|
115
|
+
const context = React.useContext(StateContext);
|
|
175
116
|
if (context === undefined) {
|
|
176
117
|
throw new Error('useMaterialQuizState must be used within a MaterialQuizProvider');
|
|
177
118
|
}
|
|
178
119
|
return context;
|
|
179
120
|
}
|
|
180
121
|
function useMaterialQuizDispatch() {
|
|
181
|
-
|
|
122
|
+
const context = React.useContext(DispatchContext);
|
|
182
123
|
if (context === undefined) {
|
|
183
124
|
throw new Error('useMaterialQuizDispatch must be used within a MaterialQuizProvider');
|
|
184
125
|
}
|