@elice/material-quiz 1.220803.0

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 (160) hide show
  1. package/README.md +3 -0
  2. package/cjs/components/eb-sortable/EbDraggable.d.ts +18 -0
  3. package/cjs/components/eb-sortable/EbDraggable.js +112 -0
  4. package/cjs/components/eb-sortable/EbDroppable.d.ts +13 -0
  5. package/cjs/components/eb-sortable/EbDroppable.js +60 -0
  6. package/cjs/components/eb-sortable/EbSortable.d.ts +17 -0
  7. package/cjs/components/material-quiz/MaterialQuiz.d.ts +4 -0
  8. package/cjs/components/material-quiz/MaterialQuiz.i18n.d.ts +25 -0
  9. package/cjs/components/material-quiz/MaterialQuiz.i18n.js +55 -0
  10. package/cjs/components/material-quiz/MaterialQuiz.js +114 -0
  11. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.d.ts +3 -0
  12. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +55 -0
  13. package/cjs/components/material-quiz/MaterialQuizError.d.ts +3 -0
  14. package/cjs/components/material-quiz/MaterialQuizInfo.d.ts +3 -0
  15. package/cjs/components/material-quiz/MaterialQuizInfo.js +74 -0
  16. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.d.ts +3 -0
  17. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +203 -0
  18. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.d.ts +3 -0
  19. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +468 -0
  20. package/cjs/components/material-quiz/MaterialQuizSelectOne.d.ts +3 -0
  21. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +191 -0
  22. package/cjs/components/material-quiz/MaterialQuizShimmer.d.ts +3 -0
  23. package/cjs/components/material-quiz/MaterialQuizShimmer.js +61 -0
  24. package/cjs/components/material-quiz/MaterialQuizText.d.ts +3 -0
  25. package/cjs/components/material-quiz/MaterialQuizText.js +181 -0
  26. package/cjs/components/material-quiz/QuizResultBadge.d.ts +7 -0
  27. package/cjs/components/material-quiz/QuizResultBadge.js +48 -0
  28. package/cjs/components/material-quiz/QuizSubmitStatusText.d.ts +7 -0
  29. package/cjs/components/material-quiz/QuizSubmitStatusText.js +38 -0
  30. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +31 -0
  31. package/cjs/components/material-quiz/context/MaterialQuizContext.js +134 -0
  32. package/cjs/components/material-quiz/index.d.ts +3 -0
  33. package/cjs/components/material-quiz-edit/MaterialQuizEdit.d.ts +25 -0
  34. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +91 -0
  35. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.d.ts +3 -0
  36. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +463 -0
  37. package/cjs/components/material-quiz-edit/context.d.ts +6 -0
  38. package/cjs/components/material-quiz-edit/context.js +15 -0
  39. package/cjs/components/material-quiz-edit/index.d.ts +2 -0
  40. package/cjs/components/material-quiz-edit/locales.d.ts +34 -0
  41. package/cjs/components/material-quiz-edit/locales.js +73 -0
  42. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.d.ts +3 -0
  43. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +204 -0
  44. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.d.ts +3 -0
  45. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +205 -0
  46. package/cjs/components/material-quiz-edit/options/OptionSelectOne.d.ts +3 -0
  47. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +207 -0
  48. package/cjs/components/material-quiz-edit/options/OptionText.d.ts +3 -0
  49. package/cjs/components/material-quiz-edit/options/OptionText.js +99 -0
  50. package/cjs/components/material-quiz-edit/utils/editValue.d.ts +15 -0
  51. package/cjs/components/material-quiz-edit/utils/editValue.js +37 -0
  52. package/cjs/components/material-quiz-edit/utils/randomId.d.ts +4 -0
  53. package/cjs/components/material-quiz-edit/utils/randomId.js +12 -0
  54. package/cjs/components/shared/QuestionBox.d.ts +16 -0
  55. package/cjs/components/shared/QuestionBox.js +111 -0
  56. package/cjs/components/shared/QuizDraggbleDroppedOption.d.ts +12 -0
  57. package/cjs/components/shared/QuizDraggbleDroppedOption.js +31 -0
  58. package/cjs/components/shared/QuizDraggbleDummyOption.d.ts +8 -0
  59. package/cjs/components/shared/QuizDraggbleDummyOption.js +36 -0
  60. package/cjs/components/shared/QuizDraggbleOption.d.ts +14 -0
  61. package/cjs/components/shared/QuizDraggbleOption.js +191 -0
  62. package/cjs/components/shared/StyledMarkdown.d.ts +3 -0
  63. package/cjs/components/shared/StyledMarkdown.js +14 -0
  64. package/cjs/components/shared/index.d.ts +7 -0
  65. package/cjs/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
  66. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +26 -0
  67. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
  68. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +42 -0
  69. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
  70. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +188 -0
  71. package/cjs/components/shared/question-radio/QuestionRadio.d.ts +8 -0
  72. package/cjs/components/shared/question-radio/QuestionRadio.js +26 -0
  73. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
  74. package/cjs/components/shared/question-radio/QuestionRadioContext.js +42 -0
  75. package/cjs/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
  76. package/cjs/components/shared/question-radio/QuestionRadioOption.js +156 -0
  77. package/cjs/helpers/index.d.ts +50 -0
  78. package/cjs/helpers/index.js +86 -0
  79. package/cjs/index.d.ts +3 -0
  80. package/cjs/index.js +27 -0
  81. package/es/components/eb-sortable/EbDraggable.d.ts +18 -0
  82. package/es/components/eb-sortable/EbDraggable.js +105 -0
  83. package/es/components/eb-sortable/EbDroppable.d.ts +13 -0
  84. package/es/components/eb-sortable/EbDroppable.js +53 -0
  85. package/es/components/eb-sortable/EbSortable.d.ts +17 -0
  86. package/es/components/material-quiz/MaterialQuiz.d.ts +4 -0
  87. package/es/components/material-quiz/MaterialQuiz.i18n.d.ts +25 -0
  88. package/es/components/material-quiz/MaterialQuiz.i18n.js +50 -0
  89. package/es/components/material-quiz/MaterialQuiz.js +106 -0
  90. package/es/components/material-quiz/MaterialQuizAnswerExplanation.d.ts +3 -0
  91. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +48 -0
  92. package/es/components/material-quiz/MaterialQuizError.d.ts +3 -0
  93. package/es/components/material-quiz/MaterialQuizInfo.d.ts +3 -0
  94. package/es/components/material-quiz/MaterialQuizInfo.js +68 -0
  95. package/es/components/material-quiz/MaterialQuizSelectMultiple.d.ts +3 -0
  96. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +197 -0
  97. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.d.ts +3 -0
  98. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +461 -0
  99. package/es/components/material-quiz/MaterialQuizSelectOne.d.ts +3 -0
  100. package/es/components/material-quiz/MaterialQuizSelectOne.js +185 -0
  101. package/es/components/material-quiz/MaterialQuizShimmer.d.ts +3 -0
  102. package/es/components/material-quiz/MaterialQuizShimmer.js +54 -0
  103. package/es/components/material-quiz/MaterialQuizText.d.ts +3 -0
  104. package/es/components/material-quiz/MaterialQuizText.js +174 -0
  105. package/es/components/material-quiz/QuizResultBadge.d.ts +7 -0
  106. package/es/components/material-quiz/QuizResultBadge.js +42 -0
  107. package/es/components/material-quiz/QuizSubmitStatusText.d.ts +7 -0
  108. package/es/components/material-quiz/QuizSubmitStatusText.js +32 -0
  109. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +31 -0
  110. package/es/components/material-quiz/context/MaterialQuizContext.js +124 -0
  111. package/es/components/material-quiz/index.d.ts +3 -0
  112. package/es/components/material-quiz-edit/MaterialQuizEdit.d.ts +25 -0
  113. package/es/components/material-quiz-edit/MaterialQuizEdit.js +86 -0
  114. package/es/components/material-quiz-edit/MaterialQuizEditContent.d.ts +3 -0
  115. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +456 -0
  116. package/es/components/material-quiz-edit/context.d.ts +6 -0
  117. package/es/components/material-quiz-edit/context.js +6 -0
  118. package/es/components/material-quiz-edit/index.d.ts +2 -0
  119. package/es/components/material-quiz-edit/locales.d.ts +34 -0
  120. package/es/components/material-quiz-edit/locales.js +68 -0
  121. package/es/components/material-quiz-edit/options/OptionSelectMultiple.d.ts +3 -0
  122. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +197 -0
  123. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.d.ts +3 -0
  124. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +198 -0
  125. package/es/components/material-quiz-edit/options/OptionSelectOne.d.ts +3 -0
  126. package/es/components/material-quiz-edit/options/OptionSelectOne.js +200 -0
  127. package/es/components/material-quiz-edit/options/OptionText.d.ts +3 -0
  128. package/es/components/material-quiz-edit/options/OptionText.js +93 -0
  129. package/es/components/material-quiz-edit/utils/editValue.d.ts +15 -0
  130. package/es/components/material-quiz-edit/utils/editValue.js +32 -0
  131. package/es/components/material-quiz-edit/utils/randomId.d.ts +4 -0
  132. package/es/components/material-quiz-edit/utils/randomId.js +8 -0
  133. package/es/components/shared/QuestionBox.d.ts +16 -0
  134. package/es/components/shared/QuestionBox.js +101 -0
  135. package/es/components/shared/QuizDraggbleDroppedOption.d.ts +12 -0
  136. package/es/components/shared/QuizDraggbleDroppedOption.js +25 -0
  137. package/es/components/shared/QuizDraggbleDummyOption.d.ts +8 -0
  138. package/es/components/shared/QuizDraggbleDummyOption.js +29 -0
  139. package/es/components/shared/QuizDraggbleOption.d.ts +14 -0
  140. package/es/components/shared/QuizDraggbleOption.js +184 -0
  141. package/es/components/shared/StyledMarkdown.d.ts +3 -0
  142. package/es/components/shared/StyledMarkdown.js +8 -0
  143. package/es/components/shared/index.d.ts +7 -0
  144. package/es/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
  145. package/es/components/shared/question-checkbox/QuestionCheckbox.js +19 -0
  146. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
  147. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +33 -0
  148. package/es/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
  149. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +181 -0
  150. package/es/components/shared/question-radio/QuestionRadio.d.ts +8 -0
  151. package/es/components/shared/question-radio/QuestionRadio.js +19 -0
  152. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
  153. package/es/components/shared/question-radio/QuestionRadioContext.js +33 -0
  154. package/es/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
  155. package/es/components/shared/question-radio/QuestionRadioOption.js +149 -0
  156. package/es/helpers/index.d.ts +50 -0
  157. package/es/helpers/index.js +78 -0
  158. package/es/index.d.ts +3 -0
  159. package/es/index.js +10 -0
  160. package/package.json +75 -0
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ const QuestionCheckboxContext = React__default["default"].createContext(undefined);
12
+ QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
13
+
14
+ function QuestionCheckboxContextProvider({
15
+ selectedOptions,
16
+ onSelect,
17
+ disabled,
18
+ children
19
+ }) {
20
+ const onSelectValue = React__default["default"].useCallback(onSelect, []);
21
+ const value = React__default["default"].useMemo(() => ({
22
+ selectedOptions,
23
+ disabled,
24
+ onSelect: onSelectValue
25
+ }), [selectedOptions, disabled, onSelectValue]);
26
+ return React__default["default"].createElement(QuestionCheckboxContext.Provider, {
27
+ value: value
28
+ }, children);
29
+ }
30
+
31
+ function useQuestionCheckboxContext() {
32
+ const context = React__default["default"].useContext(QuestionCheckboxContext);
33
+
34
+ if (context === undefined) {
35
+ throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
36
+ }
37
+
38
+ return context;
39
+ }
40
+
41
+ exports.QuestionCheckboxContextProvider = QuestionCheckboxContextProvider;
42
+ exports.useQuestionCheckboxContext = useQuestionCheckboxContext;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ declare type Status = 'correct' | 'wrong' | 'answer';
3
+ interface QuestionCheckboxOptionProps {
4
+ value: any;
5
+ status?: Status;
6
+ isAnswer?: boolean;
7
+ }
8
+ declare const QuestionCheckboxOption: React.FC<QuestionCheckboxOptionProps>;
9
+ export default QuestionCheckboxOption;
@@ -0,0 +1,188 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var designTokens = require('@elice/design-tokens');
5
+ var styled = require('styled-components');
6
+ var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionCheckboxOption = styled__default["default"].div.withConfig({
14
+ componentId: "sc-1erloup-0"
15
+ })(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
16
+ checked,
17
+ status
18
+ }) => {
19
+ switch (status) {
20
+ case 'correct':
21
+ return designTokens.base.color.green1;
22
+
23
+ case 'wrong':
24
+ return designTokens.base.color.red1;
25
+
26
+ default:
27
+ return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy5;
28
+ }
29
+ }, ({
30
+ disabled
31
+ }) => disabled ? 'not-allowed' : 'pointer', ({
32
+ isAnswer
33
+ }) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
34
+ const StyledCustomCheckboxButton = styled__default["default"].span.withConfig({
35
+ componentId: "sc-1erloup-1"
36
+ })([""]);
37
+ const StyledQuestionCheckboxInput = styled__default["default"].input.withConfig({
38
+ componentId: "sc-1erloup-2"
39
+ })(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;width:1.25rem;height:1.25rem;margin-right:0.875rem;background-color:", ";border:", ";", ""], ({
40
+ checked,
41
+ status
42
+ }) => {
43
+ switch (status) {
44
+ case 'correct':
45
+ return designTokens.base.color.green9;
46
+
47
+ case 'wrong':
48
+ return designTokens.base.color.red9;
49
+
50
+ default:
51
+ return checked ? designTokens.base.color.primary6 : 'transparent';
52
+ }
53
+ }, ({
54
+ checked,
55
+ status
56
+ }) => {
57
+ switch (status) {
58
+ case 'correct':
59
+ return designTokens.base.color.green9;
60
+
61
+ case 'wrong':
62
+ return designTokens.base.color.red9;
63
+
64
+ default:
65
+ return checked ? designTokens.base.color.primary6 : `1px solid ${designTokens.base.color.gray3}`;
66
+ }
67
+ }, ({
68
+ status,
69
+ checked
70
+ }) => {
71
+ let bgColor;
72
+
73
+ switch (status) {
74
+ case 'correct':
75
+ bgColor = designTokens.base.color.green9;
76
+ break;
77
+
78
+ case 'wrong':
79
+ bgColor = designTokens.base.color.red9;
80
+ break;
81
+
82
+ default:
83
+ bgColor = 'transparent';
84
+ break;
85
+ }
86
+
87
+ let borderColor;
88
+
89
+ switch (status) {
90
+ case 'correct':
91
+ borderColor = designTokens.base.color.green1;
92
+ break;
93
+
94
+ case 'wrong':
95
+ borderColor = designTokens.base.color.red1;
96
+ break;
97
+
98
+ default:
99
+ borderColor = checked ? designTokens.base.color.primary1 : status ? designTokens.base.color.navy5 : 'transparent';
100
+ break;
101
+ }
102
+
103
+ return `
104
+ &:after {
105
+ content: '';
106
+ position: absolute;
107
+ top: 50%;
108
+ left: 50%;
109
+ width: 5px;
110
+ height: 10px;
111
+ border: solid ${borderColor};
112
+ transform: translate(-50%, -50%) rotate(45deg);
113
+ border-width: 0 3px 3px 0;
114
+ background-color: ${bgColor};
115
+ }
116
+ `;
117
+ });
118
+ const StyledLabel = styled__default["default"].label.withConfig({
119
+ componentId: "sc-1erloup-3"
120
+ })(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3, ({
121
+ checked,
122
+ status
123
+ }) => {
124
+ switch (status) {
125
+ case 'correct':
126
+ return designTokens.base.color.green9;
127
+
128
+ case 'wrong':
129
+ return designTokens.base.color.red9;
130
+
131
+ default:
132
+ return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
133
+ }
134
+ }, ({
135
+ checked,
136
+ status
137
+ }) => {
138
+ switch (status) {
139
+ case 'correct':
140
+ return designTokens.base.color.green9;
141
+
142
+ case 'wrong':
143
+ return designTokens.base.color.red9;
144
+
145
+ default:
146
+ return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
147
+ }
148
+ });
149
+ const QuestionCheckboxOption = React__default["default"].memo(({
150
+ value,
151
+ status,
152
+ isAnswer,
153
+ children
154
+ }) => {
155
+ const {
156
+ selectedOptions,
157
+ disabled,
158
+ onSelect
159
+ } = QuestionCheckboxContext.useQuestionCheckboxContext();
160
+ const checked = selectedOptions.includes(value);
161
+ return React__default["default"].createElement(StyledQuestionCheckboxOption, {
162
+ isAnswer: isAnswer,
163
+ disabled: disabled,
164
+ checked: checked,
165
+ onClick: e => {
166
+ e.preventDefault();
167
+
168
+ if (disabled) {
169
+ return;
170
+ }
171
+
172
+ onSelect(value);
173
+ },
174
+ status: status
175
+ }, React__default["default"].createElement(StyledCustomCheckboxButton, null), React__default["default"].createElement(StyledQuestionCheckboxInput, {
176
+ id: value,
177
+ readOnly: true,
178
+ type: "checkbox",
179
+ checked: checked,
180
+ status: status
181
+ }), React__default["default"].createElement(StyledLabel, {
182
+ htmlFor: value,
183
+ checked: checked,
184
+ status: status
185
+ }, children));
186
+ });
187
+
188
+ module.exports = QuestionCheckboxOption;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface QuestionRadioProps {
3
+ selectedValue: any;
4
+ onSelect: (index: number) => void;
5
+ disabled: boolean;
6
+ }
7
+ declare const QuestionRadio: React.FC<QuestionRadioProps>;
8
+ export default QuestionRadio;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var React = require('react');
5
+ var styled = require('styled-components');
6
+ var QuestionRadioContext = require('./QuestionRadioContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionRadio = styled__default["default"].div.withConfig({
14
+ componentId: "sc-s7wqiy-0"
15
+ })(["display:flex;flex-direction:column;"]);
16
+
17
+ const QuestionRadio = _a => {
18
+ var {
19
+ children
20
+ } = _a,
21
+ props = tslib.__rest(_a, ["children"]);
22
+
23
+ return React__default["default"].createElement(QuestionRadioContext.QuestionRadioContextProvider, Object.assign({}, props), React__default["default"].createElement(StyledQuestionRadio, null, children));
24
+ };
25
+
26
+ module.exports = QuestionRadio;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { QuestionRadioProps } from './QuestionRadio';
3
+ declare type Value = Pick<QuestionRadioProps, 'selectedValue' | 'disabled' | 'onSelect'>;
4
+ interface QuestionRadioProviderProps extends QuestionRadioProps {
5
+ children: React.ReactNode;
6
+ }
7
+ declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): JSX.Element;
8
+ declare function useQuestionRadioContext(): Value;
9
+ export { QuestionRadioContextProvider, useQuestionRadioContext };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ const QuestionRadioContext = React__default["default"].createContext(undefined);
12
+ QuestionRadioContext.displayName = 'QuestionRadioContext';
13
+
14
+ function QuestionRadioContextProvider({
15
+ selectedValue,
16
+ onSelect,
17
+ disabled,
18
+ children
19
+ }) {
20
+ const onSelectValue = React__default["default"].useCallback(onSelect, []);
21
+ const value = React__default["default"].useMemo(() => ({
22
+ selectedValue,
23
+ disabled,
24
+ onSelect: onSelectValue
25
+ }), [selectedValue, disabled, onSelectValue]);
26
+ return React__default["default"].createElement(QuestionRadioContext.Provider, {
27
+ value: value
28
+ }, children);
29
+ }
30
+
31
+ function useQuestionRadioContext() {
32
+ const context = React__default["default"].useContext(QuestionRadioContext);
33
+
34
+ if (context === undefined) {
35
+ throw new Error('useQuestionRadioContext must be used within a QuestionRadioContextProvider');
36
+ }
37
+
38
+ return context;
39
+ }
40
+
41
+ exports.QuestionRadioContextProvider = QuestionRadioContextProvider;
42
+ exports.useQuestionRadioContext = useQuestionRadioContext;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ declare type Status = 'correct' | 'wrong' | 'answer';
3
+ interface QuestionRadioOptionProps {
4
+ value: any;
5
+ status?: Status;
6
+ isAnswer?: boolean;
7
+ }
8
+ declare const QuestionRadioOption: React.FC<QuestionRadioOptionProps>;
9
+ export default QuestionRadioOption;
@@ -0,0 +1,156 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var designTokens = require('@elice/design-tokens');
5
+ var styled = require('styled-components');
6
+ var QuestionRadioContext = require('./QuestionRadioContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionRadioOption = styled__default["default"].div.withConfig({
14
+ componentId: "sc-cy66me-0"
15
+ })(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
16
+ checked,
17
+ status
18
+ }) => {
19
+ switch (status) {
20
+ case 'correct':
21
+ return designTokens.base.color.green1;
22
+
23
+ case 'wrong':
24
+ return designTokens.base.color.red1;
25
+
26
+ case 'answer':
27
+ return designTokens.base.color.black;
28
+
29
+ default:
30
+ return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy5;
31
+ }
32
+ }, ({
33
+ disabled
34
+ }) => disabled ? 'not-allowed' : 'pointer', ({
35
+ isAnswer
36
+ }) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
37
+ const StyledQuestionRadioInput = styled__default["default"].input.withConfig({
38
+ componentId: "sc-cy66me-1"
39
+ })(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1.25rem;height:1.25rem;margin-right:0.875rem;border:2px solid ", ";", ""], ({
40
+ checked,
41
+ status
42
+ }) => {
43
+ switch (status) {
44
+ case 'correct':
45
+ return designTokens.base.color.green9;
46
+
47
+ case 'wrong':
48
+ return designTokens.base.color.red9;
49
+
50
+ default:
51
+ return checked ? designTokens.base.color.primary6 : designTokens.base.color.gray3;
52
+ }
53
+ }, ({
54
+ status,
55
+ checked
56
+ }) => {
57
+ let bgColor;
58
+
59
+ switch (status) {
60
+ case 'correct':
61
+ bgColor = designTokens.base.color.green9;
62
+ break;
63
+
64
+ case 'wrong':
65
+ bgColor = designTokens.base.color.red9;
66
+ break;
67
+
68
+ default:
69
+ bgColor = checked ? designTokens.base.color.primary6 : status ? designTokens.base.color.gray3 : 'transparent';
70
+ break;
71
+ }
72
+
73
+ return `
74
+ &:after {
75
+ content: '';
76
+ position: absolute;
77
+ top: 50%;
78
+ left: 50%;
79
+ transform: translate(-50%, -50%);
80
+ width: 70%;
81
+ height: 70%;
82
+ border-radius: 50%;
83
+ background-color: ${bgColor};
84
+ }
85
+ `;
86
+ });
87
+ const StyledLabel = styled__default["default"].label.withConfig({
88
+ componentId: "sc-cy66me-2"
89
+ })(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3, ({
90
+ checked,
91
+ status
92
+ }) => {
93
+ switch (status) {
94
+ case 'correct':
95
+ return designTokens.base.color.green9;
96
+
97
+ case 'wrong':
98
+ return designTokens.base.color.red9;
99
+
100
+ default:
101
+ return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
102
+ }
103
+ }, ({
104
+ checked,
105
+ status
106
+ }) => {
107
+ switch (status) {
108
+ case 'correct':
109
+ return designTokens.base.color.green9;
110
+
111
+ case 'wrong':
112
+ return designTokens.base.color.red9;
113
+
114
+ default:
115
+ return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
116
+ }
117
+ });
118
+ const QuestionRadioOption = React__default["default"].memo(({
119
+ value,
120
+ status,
121
+ isAnswer,
122
+ children
123
+ }) => {
124
+ const {
125
+ selectedValue,
126
+ disabled,
127
+ onSelect
128
+ } = QuestionRadioContext.useQuestionRadioContext();
129
+ return React__default["default"].createElement(StyledQuestionRadioOption, {
130
+ isAnswer: isAnswer,
131
+ disabled: disabled,
132
+ checked: selectedValue === value,
133
+ onClick: e => {
134
+ e.preventDefault();
135
+
136
+ if (disabled) {
137
+ return;
138
+ }
139
+
140
+ onSelect(value);
141
+ },
142
+ status: status
143
+ }, React__default["default"].createElement(StyledQuestionRadioInput, {
144
+ id: value,
145
+ type: "radio",
146
+ readOnly: true,
147
+ checked: selectedValue === value,
148
+ status: status
149
+ }), React__default["default"].createElement(StyledLabel, {
150
+ htmlFor: value,
151
+ checked: selectedValue === value,
152
+ status: status
153
+ }, children));
154
+ });
155
+
156
+ module.exports = QuestionRadioOption;
@@ -0,0 +1,50 @@
1
+ import type { GetOrgLectureGetResponses, GetOrgMaterialQuizGetResponses, GetOrgMaterialQuizResponseGetResponses } from '@elice/types';
2
+ import type { QuizOptionType } from '@elice/types/es/enums';
3
+ interface OptionInfo {
4
+ content: string;
5
+ optionType: QuizOptionType;
6
+ answerIsSelected?: boolean;
7
+ }
8
+ interface AnswerInfo {
9
+ optionIdent: string;
10
+ text: string | null;
11
+ order: number | null;
12
+ isSelected: boolean;
13
+ }
14
+ export declare type Option = OptionInfo & Omit<AnswerInfo, 'optionIdent'>;
15
+ export declare type OptionList = Option[];
16
+ export declare function mergeOptionAndAnswerInfoList(materialQuiz: GetOrgMaterialQuizGetResponses['materialQuiz'], materialQuizResponse?: GetOrgMaterialQuizResponseGetResponses['quizResponse']): OptionList;
17
+ export declare enum QuizResultStatus {
18
+ Correct = 0,
19
+ Wrong = 1,
20
+ Submitted = 2,
21
+ WrongNotSubmitted = 3,
22
+ NotSubmitted = 4
23
+ }
24
+ export declare function getQuizResultStatus(materialQuizResponse?: GetOrgMaterialQuizResponseGetResponses['quizResponse']): QuizResultStatus.Correct | QuizResultStatus.Wrong | QuizResultStatus.Submitted | QuizResultStatus.NotSubmitted;
25
+ export declare const getOptionStatus: ({ isSelected, isActive, materialQuizResponse, }: {
26
+ isSelected: boolean;
27
+ isActive: boolean;
28
+ materialQuizResponse?: {
29
+ id: number;
30
+ answer: string | number[];
31
+ score: number | null;
32
+ autoScore: number | null;
33
+ manualScore: number | null;
34
+ isCompleted: boolean | null;
35
+ createdDatetime: number;
36
+ user: {
37
+ firstname: string;
38
+ fullname: string;
39
+ id: number;
40
+ lastname: "";
41
+ profileUrl: string | null;
42
+ };
43
+ } | undefined;
44
+ }) => "correct" | "wrong" | undefined;
45
+ export declare function checkUserLectureTestEnded(lecture?: GetOrgLectureGetResponses['lecture']): boolean;
46
+ export declare function shouldResetOptions({ materialQuizResponse, }: {
47
+ materialQuizResponse?: GetOrgMaterialQuizResponseGetResponses['quizResponse'];
48
+ }): boolean;
49
+ export declare function getQuizResult(materialQuizResponse: GetOrgMaterialQuizResponseGetResponses['quizResponse']): boolean | undefined;
50
+ export {};
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var types = require('@elice/types');
6
+
7
+ exports.QuizResultStatus = void 0;
8
+
9
+ (function (QuizResultStatus) {
10
+ QuizResultStatus[QuizResultStatus["Correct"] = 0] = "Correct";
11
+ QuizResultStatus[QuizResultStatus["Wrong"] = 1] = "Wrong";
12
+ QuizResultStatus[QuizResultStatus["Submitted"] = 2] = "Submitted";
13
+ QuizResultStatus[QuizResultStatus["WrongNotSubmitted"] = 3] = "WrongNotSubmitted";
14
+ QuizResultStatus[QuizResultStatus["NotSubmitted"] = 4] = "NotSubmitted";
15
+ })(exports.QuizResultStatus || (exports.QuizResultStatus = {}));
16
+
17
+ function getQuizResultStatus(materialQuizResponse) {
18
+ if (materialQuizResponse && materialQuizResponse.isCompleted === true) {
19
+ return exports.QuizResultStatus.Correct;
20
+ }
21
+
22
+ if (materialQuizResponse && materialQuizResponse.isCompleted === false) {
23
+ return exports.QuizResultStatus.Wrong;
24
+ }
25
+
26
+ if (materialQuizResponse) {
27
+ return exports.QuizResultStatus.Submitted;
28
+ }
29
+
30
+ return exports.QuizResultStatus.NotSubmitted;
31
+ }
32
+ const getOptionStatus = ({
33
+ isSelected,
34
+ isActive,
35
+ materialQuizResponse
36
+ }) => {
37
+ const status = getQuizResultStatus(materialQuizResponse);
38
+
39
+ if (isActive) {
40
+ return;
41
+ }
42
+
43
+ if (isSelected) {
44
+ if (status === exports.QuizResultStatus.Correct) {
45
+ return 'correct';
46
+ }
47
+
48
+ if (status === exports.QuizResultStatus.Wrong) {
49
+ return 'wrong';
50
+ }
51
+ }
52
+
53
+ return;
54
+ };
55
+ function checkUserLectureTestEnded(lecture) {
56
+ return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === types.enums.TestAdmissionStatus.Completed;
57
+ }
58
+ function shouldResetOptions({
59
+ materialQuizResponse
60
+ }) {
61
+ // when score is given(correct, wrong), reset selected option in order to select options from scratch
62
+ // score condition
63
+ // normal quiz - score is always given(not a null) as long as a user submits the answer
64
+ // test quiz - score is given if a user finishes test and "lecture.isTestScoreOpened(성적공개)" is valid
65
+ return [(materialQuizResponse === null || materialQuizResponse === void 0 ? void 0 : materialQuizResponse.score) !== null].every(Boolean);
66
+ }
67
+ function getQuizResult(materialQuizResponse) {
68
+ const status = getQuizResultStatus(materialQuizResponse);
69
+
70
+ switch (status) {
71
+ case exports.QuizResultStatus.Correct:
72
+ return true;
73
+
74
+ case exports.QuizResultStatus.Wrong:
75
+ return false;
76
+
77
+ default:
78
+ return;
79
+ }
80
+ }
81
+
82
+ exports.checkUserLectureTestEnded = checkUserLectureTestEnded;
83
+ exports.getOptionStatus = getOptionStatus;
84
+ exports.getQuizResult = getQuizResult;
85
+ exports.getQuizResultStatus = getQuizResultStatus;
86
+ exports.shouldResetOptions = shouldResetOptions;
package/cjs/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components/material-quiz';
2
+ export * from './components/material-quiz-edit';
3
+ export * from './components/shared';
package/cjs/index.js ADDED
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var MaterialQuiz = require('./components/material-quiz/MaterialQuiz.js');
6
+ var MaterialQuizInfo = require('./components/material-quiz/MaterialQuizInfo.js');
7
+ var MaterialQuizEdit = require('./components/material-quiz-edit/MaterialQuizEdit.js');
8
+ var QuizDraggbleDroppedOption = require('./components/shared/QuizDraggbleDroppedOption.js');
9
+ var QuizDraggbleDummyOption = require('./components/shared/QuizDraggbleDummyOption.js');
10
+ var QuizDraggbleOption = require('./components/shared/QuizDraggbleOption.js');
11
+ var QuestionRadio = require('./components/shared/question-radio/QuestionRadio.js');
12
+ var QuestionRadioOption = require('./components/shared/question-radio/QuestionRadioOption.js');
13
+ var QuestionCheckbox = require('./components/shared/question-checkbox/QuestionCheckbox.js');
14
+ var QuestionCheckboxOption = require('./components/shared/question-checkbox/QuestionCheckboxOption.js');
15
+
16
+
17
+
18
+ exports.MaterialQuiz = MaterialQuiz;
19
+ exports.MaterialQuizInfo = MaterialQuizInfo;
20
+ exports.MaterialQuizEdit = MaterialQuizEdit;
21
+ exports.QuizDraggbleDroppedOption = QuizDraggbleDroppedOption;
22
+ exports.QuizDraggbleDummyOption = QuizDraggbleDummyOption;
23
+ exports.QuizDraggbleOption = QuizDraggbleOption;
24
+ exports.QuestionRadio = QuestionRadio;
25
+ exports.QuestionRadioOption = QuestionRadioOption;
26
+ exports.QuestionCheckbox = QuestionCheckbox;
27
+ exports.QuestionCheckboxOption = QuestionCheckboxOption;
@@ -0,0 +1,18 @@
1
+ /// <reference types="jquery" />
2
+ /// <reference types="jqueryui" />
3
+ import React from 'react';
4
+ import 'jquery-ui/ui/widgets/draggable';
5
+ interface EbDraggableProps {
6
+ id?: string;
7
+ className?: string;
8
+ connectWith?: JQuery.Selector;
9
+ disabled?: boolean;
10
+ revert?: boolean;
11
+ clone?: boolean;
12
+ onStart?: (event: JQueryEventObject, ui: JQueryUI.DraggableEventUIParams) => void;
13
+ onStop?: (event: JQueryEventObject, ui: JQueryUI.DraggableEventUIParams) => void;
14
+ onDrag?: (event: JQueryEventObject, ui: JQueryUI.DraggableEventUIParams) => void;
15
+ onCreate?: (event: JQueryEventObject, ui: JQueryUI.DraggableEventUIParams) => void;
16
+ }
17
+ declare const EbDraggable: React.FC<EbDraggableProps>;
18
+ export default EbDraggable;