@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,181 @@
1
+ import React from 'react';
2
+ import { base } from '@elice/design-tokens';
3
+ import styled from 'styled-components';
4
+ import { useQuestionCheckboxContext } from './QuestionCheckboxContext.js';
5
+
6
+ const StyledQuestionCheckboxOption = styled.div.withConfig({
7
+ componentId: "sc-1erloup-0"
8
+ })(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
9
+ checked,
10
+ status
11
+ }) => {
12
+ switch (status) {
13
+ case 'correct':
14
+ return base.color.green1;
15
+
16
+ case 'wrong':
17
+ return base.color.red1;
18
+
19
+ default:
20
+ return checked ? base.color.primary1 : base.color.navy5;
21
+ }
22
+ }, ({
23
+ disabled
24
+ }) => disabled ? 'not-allowed' : 'pointer', ({
25
+ isAnswer
26
+ }) => isAnswer ? `border: 3px solid ${base.color.green5}` : '');
27
+ const StyledCustomCheckboxButton = styled.span.withConfig({
28
+ componentId: "sc-1erloup-1"
29
+ })([""]);
30
+ const StyledQuestionCheckboxInput = styled.input.withConfig({
31
+ componentId: "sc-1erloup-2"
32
+ })(["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:", ";", ""], ({
33
+ checked,
34
+ status
35
+ }) => {
36
+ switch (status) {
37
+ case 'correct':
38
+ return base.color.green9;
39
+
40
+ case 'wrong':
41
+ return base.color.red9;
42
+
43
+ default:
44
+ return checked ? base.color.primary6 : 'transparent';
45
+ }
46
+ }, ({
47
+ checked,
48
+ status
49
+ }) => {
50
+ switch (status) {
51
+ case 'correct':
52
+ return base.color.green9;
53
+
54
+ case 'wrong':
55
+ return base.color.red9;
56
+
57
+ default:
58
+ return checked ? base.color.primary6 : `1px solid ${base.color.gray3}`;
59
+ }
60
+ }, ({
61
+ status,
62
+ checked
63
+ }) => {
64
+ let bgColor;
65
+
66
+ switch (status) {
67
+ case 'correct':
68
+ bgColor = base.color.green9;
69
+ break;
70
+
71
+ case 'wrong':
72
+ bgColor = base.color.red9;
73
+ break;
74
+
75
+ default:
76
+ bgColor = 'transparent';
77
+ break;
78
+ }
79
+
80
+ let borderColor;
81
+
82
+ switch (status) {
83
+ case 'correct':
84
+ borderColor = base.color.green1;
85
+ break;
86
+
87
+ case 'wrong':
88
+ borderColor = base.color.red1;
89
+ break;
90
+
91
+ default:
92
+ borderColor = checked ? base.color.primary1 : status ? base.color.navy5 : 'transparent';
93
+ break;
94
+ }
95
+
96
+ return `
97
+ &:after {
98
+ content: '';
99
+ position: absolute;
100
+ top: 50%;
101
+ left: 50%;
102
+ width: 5px;
103
+ height: 10px;
104
+ border: solid ${borderColor};
105
+ transform: translate(-50%, -50%) rotate(45deg);
106
+ border-width: 0 3px 3px 0;
107
+ background-color: ${bgColor};
108
+ }
109
+ `;
110
+ });
111
+ const StyledLabel = styled.label.withConfig({
112
+ componentId: "sc-1erloup-3"
113
+ })(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], base.size.body3, ({
114
+ checked,
115
+ status
116
+ }) => {
117
+ switch (status) {
118
+ case 'correct':
119
+ return base.color.green9;
120
+
121
+ case 'wrong':
122
+ return base.color.red9;
123
+
124
+ default:
125
+ return checked ? base.color.primary6 : base.color.navy0;
126
+ }
127
+ }, ({
128
+ checked,
129
+ status
130
+ }) => {
131
+ switch (status) {
132
+ case 'correct':
133
+ return base.color.green9;
134
+
135
+ case 'wrong':
136
+ return base.color.red9;
137
+
138
+ default:
139
+ return checked ? base.color.primary6 : base.color.navy0;
140
+ }
141
+ });
142
+ const QuestionCheckboxOption = React.memo(({
143
+ value,
144
+ status,
145
+ isAnswer,
146
+ children
147
+ }) => {
148
+ const {
149
+ selectedOptions,
150
+ disabled,
151
+ onSelect
152
+ } = useQuestionCheckboxContext();
153
+ const checked = selectedOptions.includes(value);
154
+ return React.createElement(StyledQuestionCheckboxOption, {
155
+ isAnswer: isAnswer,
156
+ disabled: disabled,
157
+ checked: checked,
158
+ onClick: e => {
159
+ e.preventDefault();
160
+
161
+ if (disabled) {
162
+ return;
163
+ }
164
+
165
+ onSelect(value);
166
+ },
167
+ status: status
168
+ }, React.createElement(StyledCustomCheckboxButton, null), React.createElement(StyledQuestionCheckboxInput, {
169
+ id: value,
170
+ readOnly: true,
171
+ type: "checkbox",
172
+ checked: checked,
173
+ status: status
174
+ }), React.createElement(StyledLabel, {
175
+ htmlFor: value,
176
+ checked: checked,
177
+ status: status
178
+ }, children));
179
+ });
180
+
181
+ export { QuestionCheckboxOption as default };
@@ -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,19 @@
1
+ import { __rest } from 'tslib';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { QuestionRadioContextProvider } from './QuestionRadioContext.js';
5
+
6
+ const StyledQuestionRadio = styled.div.withConfig({
7
+ componentId: "sc-s7wqiy-0"
8
+ })(["display:flex;flex-direction:column;"]);
9
+
10
+ const QuestionRadio = _a => {
11
+ var {
12
+ children
13
+ } = _a,
14
+ props = __rest(_a, ["children"]);
15
+
16
+ return React.createElement(QuestionRadioContextProvider, Object.assign({}, props), React.createElement(StyledQuestionRadio, null, children));
17
+ };
18
+
19
+ export { QuestionRadio as default };
@@ -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,33 @@
1
+ import React from 'react';
2
+
3
+ const QuestionRadioContext = React.createContext(undefined);
4
+ QuestionRadioContext.displayName = 'QuestionRadioContext';
5
+
6
+ function QuestionRadioContextProvider({
7
+ selectedValue,
8
+ onSelect,
9
+ disabled,
10
+ children
11
+ }) {
12
+ const onSelectValue = React.useCallback(onSelect, []);
13
+ const value = React.useMemo(() => ({
14
+ selectedValue,
15
+ disabled,
16
+ onSelect: onSelectValue
17
+ }), [selectedValue, disabled, onSelectValue]);
18
+ return React.createElement(QuestionRadioContext.Provider, {
19
+ value: value
20
+ }, children);
21
+ }
22
+
23
+ function useQuestionRadioContext() {
24
+ const context = React.useContext(QuestionRadioContext);
25
+
26
+ if (context === undefined) {
27
+ throw new Error('useQuestionRadioContext must be used within a QuestionRadioContextProvider');
28
+ }
29
+
30
+ return context;
31
+ }
32
+
33
+ export { QuestionRadioContextProvider, 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,149 @@
1
+ import React from 'react';
2
+ import { base } from '@elice/design-tokens';
3
+ import styled from 'styled-components';
4
+ import { useQuestionRadioContext } from './QuestionRadioContext.js';
5
+
6
+ const StyledQuestionRadioOption = styled.div.withConfig({
7
+ componentId: "sc-cy66me-0"
8
+ })(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
9
+ checked,
10
+ status
11
+ }) => {
12
+ switch (status) {
13
+ case 'correct':
14
+ return base.color.green1;
15
+
16
+ case 'wrong':
17
+ return base.color.red1;
18
+
19
+ case 'answer':
20
+ return base.color.black;
21
+
22
+ default:
23
+ return checked ? base.color.primary1 : base.color.navy5;
24
+ }
25
+ }, ({
26
+ disabled
27
+ }) => disabled ? 'not-allowed' : 'pointer', ({
28
+ isAnswer
29
+ }) => isAnswer ? `border: 3px solid ${base.color.green5}` : '');
30
+ const StyledQuestionRadioInput = styled.input.withConfig({
31
+ componentId: "sc-cy66me-1"
32
+ })(["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 ", ";", ""], ({
33
+ checked,
34
+ status
35
+ }) => {
36
+ switch (status) {
37
+ case 'correct':
38
+ return base.color.green9;
39
+
40
+ case 'wrong':
41
+ return base.color.red9;
42
+
43
+ default:
44
+ return checked ? base.color.primary6 : base.color.gray3;
45
+ }
46
+ }, ({
47
+ status,
48
+ checked
49
+ }) => {
50
+ let bgColor;
51
+
52
+ switch (status) {
53
+ case 'correct':
54
+ bgColor = base.color.green9;
55
+ break;
56
+
57
+ case 'wrong':
58
+ bgColor = base.color.red9;
59
+ break;
60
+
61
+ default:
62
+ bgColor = checked ? base.color.primary6 : status ? base.color.gray3 : 'transparent';
63
+ break;
64
+ }
65
+
66
+ return `
67
+ &:after {
68
+ content: '';
69
+ position: absolute;
70
+ top: 50%;
71
+ left: 50%;
72
+ transform: translate(-50%, -50%);
73
+ width: 70%;
74
+ height: 70%;
75
+ border-radius: 50%;
76
+ background-color: ${bgColor};
77
+ }
78
+ `;
79
+ });
80
+ const StyledLabel = styled.label.withConfig({
81
+ componentId: "sc-cy66me-2"
82
+ })(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], base.size.body3, ({
83
+ checked,
84
+ status
85
+ }) => {
86
+ switch (status) {
87
+ case 'correct':
88
+ return base.color.green9;
89
+
90
+ case 'wrong':
91
+ return base.color.red9;
92
+
93
+ default:
94
+ return checked ? base.color.primary6 : base.color.navy0;
95
+ }
96
+ }, ({
97
+ checked,
98
+ status
99
+ }) => {
100
+ switch (status) {
101
+ case 'correct':
102
+ return base.color.green9;
103
+
104
+ case 'wrong':
105
+ return base.color.red9;
106
+
107
+ default:
108
+ return checked ? base.color.primary6 : base.color.navy0;
109
+ }
110
+ });
111
+ const QuestionRadioOption = React.memo(({
112
+ value,
113
+ status,
114
+ isAnswer,
115
+ children
116
+ }) => {
117
+ const {
118
+ selectedValue,
119
+ disabled,
120
+ onSelect
121
+ } = useQuestionRadioContext();
122
+ return React.createElement(StyledQuestionRadioOption, {
123
+ isAnswer: isAnswer,
124
+ disabled: disabled,
125
+ checked: selectedValue === value,
126
+ onClick: e => {
127
+ e.preventDefault();
128
+
129
+ if (disabled) {
130
+ return;
131
+ }
132
+
133
+ onSelect(value);
134
+ },
135
+ status: status
136
+ }, React.createElement(StyledQuestionRadioInput, {
137
+ id: value,
138
+ type: "radio",
139
+ readOnly: true,
140
+ checked: selectedValue === value,
141
+ status: status
142
+ }), React.createElement(StyledLabel, {
143
+ htmlFor: value,
144
+ checked: selectedValue === value,
145
+ status: status
146
+ }, children));
147
+ });
148
+
149
+ export { QuestionRadioOption as default };
@@ -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,78 @@
1
+ import { enums } from '@elice/types';
2
+
3
+ var QuizResultStatus;
4
+
5
+ (function (QuizResultStatus) {
6
+ QuizResultStatus[QuizResultStatus["Correct"] = 0] = "Correct";
7
+ QuizResultStatus[QuizResultStatus["Wrong"] = 1] = "Wrong";
8
+ QuizResultStatus[QuizResultStatus["Submitted"] = 2] = "Submitted";
9
+ QuizResultStatus[QuizResultStatus["WrongNotSubmitted"] = 3] = "WrongNotSubmitted";
10
+ QuizResultStatus[QuizResultStatus["NotSubmitted"] = 4] = "NotSubmitted";
11
+ })(QuizResultStatus || (QuizResultStatus = {}));
12
+
13
+ function getQuizResultStatus(materialQuizResponse) {
14
+ if (materialQuizResponse && materialQuizResponse.isCompleted === true) {
15
+ return QuizResultStatus.Correct;
16
+ }
17
+
18
+ if (materialQuizResponse && materialQuizResponse.isCompleted === false) {
19
+ return QuizResultStatus.Wrong;
20
+ }
21
+
22
+ if (materialQuizResponse) {
23
+ return QuizResultStatus.Submitted;
24
+ }
25
+
26
+ return QuizResultStatus.NotSubmitted;
27
+ }
28
+ const getOptionStatus = ({
29
+ isSelected,
30
+ isActive,
31
+ materialQuizResponse
32
+ }) => {
33
+ const status = getQuizResultStatus(materialQuizResponse);
34
+
35
+ if (isActive) {
36
+ return;
37
+ }
38
+
39
+ if (isSelected) {
40
+ if (status === QuizResultStatus.Correct) {
41
+ return 'correct';
42
+ }
43
+
44
+ if (status === QuizResultStatus.Wrong) {
45
+ return 'wrong';
46
+ }
47
+ }
48
+
49
+ return;
50
+ };
51
+ function checkUserLectureTestEnded(lecture) {
52
+ return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === enums.TestAdmissionStatus.Completed;
53
+ }
54
+ function shouldResetOptions({
55
+ materialQuizResponse
56
+ }) {
57
+ // when score is given(correct, wrong), reset selected option in order to select options from scratch
58
+ // score condition
59
+ // normal quiz - score is always given(not a null) as long as a user submits the answer
60
+ // test quiz - score is given if a user finishes test and "lecture.isTestScoreOpened(성적공개)" is valid
61
+ return [(materialQuizResponse === null || materialQuizResponse === void 0 ? void 0 : materialQuizResponse.score) !== null].every(Boolean);
62
+ }
63
+ function getQuizResult(materialQuizResponse) {
64
+ const status = getQuizResultStatus(materialQuizResponse);
65
+
66
+ switch (status) {
67
+ case QuizResultStatus.Correct:
68
+ return true;
69
+
70
+ case QuizResultStatus.Wrong:
71
+ return false;
72
+
73
+ default:
74
+ return;
75
+ }
76
+ }
77
+
78
+ export { QuizResultStatus, checkUserLectureTestEnded, getOptionStatus, getQuizResult, getQuizResultStatus, shouldResetOptions };
package/es/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/es/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { default as MaterialQuiz } from './components/material-quiz/MaterialQuiz.js';
2
+ export { default as MaterialQuizInfo } from './components/material-quiz/MaterialQuizInfo.js';
3
+ export { default as MaterialQuizEdit } from './components/material-quiz-edit/MaterialQuizEdit.js';
4
+ export { default as QuizDraggbleDroppedOption } from './components/shared/QuizDraggbleDroppedOption.js';
5
+ export { default as QuizDraggbleDummyOption } from './components/shared/QuizDraggbleDummyOption.js';
6
+ export { default as QuizDraggbleOption } from './components/shared/QuizDraggbleOption.js';
7
+ export { default as QuestionRadio } from './components/shared/question-radio/QuestionRadio.js';
8
+ export { default as QuestionRadioOption } from './components/shared/question-radio/QuestionRadioOption.js';
9
+ export { default as QuestionCheckbox } from './components/shared/question-checkbox/QuestionCheckbox.js';
10
+ export { default as QuestionCheckboxOption } from './components/shared/question-checkbox/QuestionCheckboxOption.js';
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@elice/material-quiz",
3
+ "version": "1.220803.0",
4
+ "description": "User view and editing components of Elice material quiz",
5
+ "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
+ "license": "UNLICENSED",
7
+ "main": "./cjs/index.js",
8
+ "module": "./es/index.js",
9
+ "types": "./es/index.d.ts",
10
+ "files": [
11
+ "es",
12
+ "cjs",
13
+ "package.json",
14
+ "README.md"
15
+ ],
16
+ "sideEffects": false,
17
+ "engines": {
18
+ "node": "~16.14",
19
+ "yarn": ">=1.20 <2"
20
+ },
21
+ "scripts": {
22
+ "start": "run-s watch",
23
+ "prebuild": "run-s clean",
24
+ "build": "run-p build:es build:cjs",
25
+ "build:es": "rollup -c ../../rollup.config.ts -f es",
26
+ "build:cjs": "rollup -c ../../rollup.config.ts -f cjs",
27
+ "watch": "rollup -c ../../rollup.config.ts -f es -w",
28
+ "lint": "eslint --ext .ts,.tsx ./src --max-warnings=0",
29
+ "clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
30
+ },
31
+ "peerDependencies": {
32
+ "@elice/api-client": "^1.220802.1",
33
+ "@elice/blocks": "^1.220803.0",
34
+ "@elice/design-tokens": "^1.220803.0",
35
+ "@elice/icons": "^1.220803.0",
36
+ "@elice/markdown": "^1.220803.0",
37
+ "@elice/material-shared-types": "22.7.2-1",
38
+ "@elice/material-shared-utils": "22.7.2-1",
39
+ "@elice/types": "^1.220802.1",
40
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
41
+ "react-intl": "^5.0.0",
42
+ "react-use": "^17.0.0",
43
+ "styled-components": "^5.2.0"
44
+ },
45
+ "dependencies": {
46
+ "classnames": "^2.2.0",
47
+ "jquery": "^3.6.0",
48
+ "jquery-ui": "^1.13.1",
49
+ "react-hook-form": "~7.12.0",
50
+ "react-transition-group": "^4.4.0",
51
+ "tslib": "^2.3.1"
52
+ },
53
+ "devDependencies": {
54
+ "@elice/api-client": "^1.220802.1",
55
+ "@elice/blocks": "^1.220803.0",
56
+ "@elice/design-tokens": "^1.220803.0",
57
+ "@elice/icons": "^1.220803.0",
58
+ "@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
59
+ "@elice/markdown": "^1.220803.0",
60
+ "@elice/material-shared-types": "1.220803.0",
61
+ "@elice/material-shared-utils": "1.220803.0",
62
+ "@elice/types": "^1.220802.1",
63
+ "@types/classnames": "^2.3.1",
64
+ "@types/jquery": "^3.5.13",
65
+ "@types/jqueryui": "^1.12.16",
66
+ "@types/react": "~17.0.9",
67
+ "@types/react-transition-group": "^4.4.4",
68
+ "@types/styled-components": "^5.1.21",
69
+ "react": "^17.0.2",
70
+ "react-intl": "^5.20.10",
71
+ "react-use": "^17.2.4",
72
+ "styled-components": "^5.3.0"
73
+ },
74
+ "gitHead": "21c6b42ae6550e7899c57bf39fa78cea0f47e64c"
75
+ }