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