@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.
Files changed (127) hide show
  1. package/cjs/components/eb-sortable/EbDraggable.js +33 -42
  2. package/cjs/components/eb-sortable/EbDroppable.js +20 -27
  3. package/cjs/components/markdown-editor/index.d.ts +2 -1
  4. package/cjs/components/markdown-editor/index.js +10 -19
  5. package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
  6. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
  7. package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
  8. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
  10. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
  11. package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
  12. package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
  13. package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
  14. package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
  15. package/cjs/components/material-quiz/constants/color.js +5 -5
  16. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
  18. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
  19. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
  20. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
  22. package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
  23. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
  24. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
  25. package/cjs/components/material-quiz-edit/context.js +2 -8
  26. package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
  27. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
  28. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
  29. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
  30. package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
  31. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  32. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
  33. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
  34. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
  35. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
  36. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  37. package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
  38. package/cjs/components/shared/QuestionBox.js +165 -198
  39. package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
  40. package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
  41. package/cjs/components/shared/QuizDraggbleOption.js +59 -65
  42. package/cjs/components/shared/StyledMarkdown.js +1 -5
  43. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
  44. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  45. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
  46. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
  47. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
  48. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  49. package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
  50. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
  51. package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
  52. package/cjs/components/shared/utils/mergeRefs.js +6 -15
  53. package/cjs/constant/element.js +3 -3
  54. package/cjs/helpers/index.js +10 -8
  55. package/cjs/hooks/useCaculatePassage.js +20 -21
  56. package/es/components/eb-sortable/EbDraggable.js +33 -37
  57. package/es/components/eb-sortable/EbDroppable.js +20 -22
  58. package/es/components/markdown-editor/index.d.ts +2 -1
  59. package/es/components/markdown-editor/index.js +10 -15
  60. package/es/components/material-quiz/MaterialQuiz.js +83 -109
  61. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
  62. package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
  63. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
  64. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
  65. package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
  66. package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
  67. package/es/components/material-quiz/MaterialQuizText.js +115 -158
  68. package/es/components/material-quiz/QuizResultBadge.js +22 -27
  69. package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
  70. package/es/components/material-quiz/constants/color.js +5 -5
  71. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  72. package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
  73. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
  74. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
  75. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
  76. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
  77. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  78. package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
  79. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
  80. package/es/components/material-quiz-edit/context.js +2 -4
  81. package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
  82. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
  83. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
  84. package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
  85. package/es/components/material-quiz-edit/options/OptionText.js +82 -86
  86. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  87. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
  88. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
  89. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
  90. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
  91. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  92. package/es/components/material-quiz-edit/utils/editValue.js +12 -17
  93. package/es/components/shared/QuestionBox.js +165 -192
  94. package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
  95. package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
  96. package/es/components/shared/QuizDraggbleOption.js +59 -61
  97. package/es/components/shared/StyledMarkdown.js +1 -1
  98. package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  99. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  100. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
  101. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
  102. package/es/components/shared/question-radio/QuestionRadio.js +7 -9
  103. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  104. package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
  105. package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
  106. package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
  107. package/es/components/shared/utils/mergeRefs.js +6 -15
  108. package/es/constant/element.js +3 -3
  109. package/es/helpers/index.js +10 -8
  110. package/es/hooks/useCaculatePassage.js +20 -21
  111. package/package.json +15 -12
  112. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
  113. package/cjs/components/material-quiz/index.js +0 -9
  114. package/cjs/components/material-quiz/locales/index.js +0 -13
  115. package/cjs/components/material-quiz-edit/index.js +0 -7
  116. package/cjs/components/material-quiz-edit/locales/index.js +0 -13
  117. package/cjs/components/shared/index.js +0 -19
  118. package/cjs/constant/index.js +0 -9
  119. package/cjs/hooks/index.js +0 -7
  120. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
  121. package/es/components/material-quiz/index.js +0 -2
  122. package/es/components/material-quiz/locales/index.js +0 -4
  123. package/es/components/material-quiz-edit/index.js +0 -1
  124. package/es/components/material-quiz-edit/locales/index.js +0 -4
  125. package/es/components/shared/index.js +0 -7
  126. package/es/constant/index.js +0 -1
  127. 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, postOrgMaterialQuizOptionsSetSelect, getOrgLectureGet, getOrgCourseGet } from '@elice/api-client';
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
- var StateContext = React.createContext(undefined);
9
- var DispatchContext = React.createContext(undefined);
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(_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() {
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
- 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();
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
- }, _callee2, null, [[2, 19]]);
137
- })), [materialLecturePage]);
138
- useEffect(function () {
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(function () {
86
+ React.useEffect(() => {
144
87
  if (canInit && materialLecturePage) {
145
88
  void init();
146
89
  }
147
90
  }, [canInit, materialLecturePage, init]);
148
- return jsx(StateContext.Provider, {
91
+ return React.createElement(StateContext.Provider, {
149
92
  value: {
150
- course: course,
151
- lecture: lecture,
93
+ course,
94
+ lecture,
152
95
  materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
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
- });
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
- var context = React.useContext(StateContext);
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
- var context = React.useContext(DispatchContext);
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
  }