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