@elice/material-survey 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.
- package/README.md +3 -0
- package/cjs/components/material-survey/MaterialSurvey.d.ts +4 -0
- package/cjs/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
- package/cjs/components/material-survey/MaterialSurvey.i18n.js +37 -0
- package/cjs/components/material-survey/MaterialSurvey.js +109 -0
- package/cjs/components/material-survey/MaterialSurveyError.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyInfo.js +73 -0
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +184 -0
- package/cjs/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +164 -0
- package/cjs/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +61 -0
- package/cjs/components/material-survey/MaterialSurveyText.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyText.js +159 -0
- package/cjs/components/material-survey/SurveyResultBadge.d.ts +7 -0
- package/cjs/components/material-survey/SurveyResultBadge.js +32 -0
- package/cjs/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
- package/cjs/components/material-survey/SurveySubmitStatusText.js +38 -0
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +134 -0
- package/cjs/components/material-survey/index.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +91 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +235 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +132 -0
- package/cjs/components/material-survey-edit/context.d.ts +6 -0
- package/cjs/components/material-survey-edit/context.js +15 -0
- package/cjs/components/material-survey-edit/index.d.ts +2 -0
- package/cjs/components/material-survey-edit/locales.d.ts +20 -0
- package/cjs/components/material-survey-edit/locales.js +45 -0
- package/cjs/components/material-survey-edit/utils/editValue.d.ts +19 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +46 -0
- package/cjs/components/material-survey-edit/utils/randomId.d.ts +4 -0
- package/cjs/components/material-survey-edit/utils/randomId.js +12 -0
- package/cjs/components/shared/StyledMarkdown.d.ts +3 -0
- package/cjs/components/shared/StyledMarkdown.js +14 -0
- package/cjs/components/shared/SurveyContentBox.d.ts +15 -0
- package/cjs/components/shared/SurveyContentBox.js +108 -0
- package/cjs/components/shared/index.d.ts +4 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +26 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +42 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +226 -0
- package/cjs/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/cjs/components/shared/question-radio/QuestionRadio.js +26 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +42 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +187 -0
- package/cjs/helpers/index.d.ts +22 -0
- package/cjs/helpers/index.js +26 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +21 -0
- package/es/components/material-survey/MaterialSurvey.d.ts +4 -0
- package/es/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
- package/es/components/material-survey/MaterialSurvey.i18n.js +32 -0
- package/es/components/material-survey/MaterialSurvey.js +101 -0
- package/es/components/material-survey/MaterialSurveyError.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyInfo.js +67 -0
- package/es/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +178 -0
- package/es/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveySelectOne.js +158 -0
- package/es/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyShimmer.js +54 -0
- package/es/components/material-survey/MaterialSurveyText.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyText.js +152 -0
- package/es/components/material-survey/SurveyResultBadge.d.ts +7 -0
- package/es/components/material-survey/SurveyResultBadge.js +26 -0
- package/es/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
- package/es/components/material-survey/SurveySubmitStatusText.js +32 -0
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
- package/es/components/material-survey/context/MaterialSurveyContext.js +124 -0
- package/es/components/material-survey/index.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +86 -0
- package/es/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +228 -0
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +125 -0
- package/es/components/material-survey-edit/context.d.ts +6 -0
- package/es/components/material-survey-edit/context.js +6 -0
- package/es/components/material-survey-edit/index.d.ts +2 -0
- package/es/components/material-survey-edit/locales.d.ts +20 -0
- package/es/components/material-survey-edit/locales.js +40 -0
- package/es/components/material-survey-edit/utils/editValue.d.ts +19 -0
- package/es/components/material-survey-edit/utils/editValue.js +41 -0
- package/es/components/material-survey-edit/utils/randomId.d.ts +4 -0
- package/es/components/material-survey-edit/utils/randomId.js +8 -0
- package/es/components/shared/StyledMarkdown.d.ts +3 -0
- package/es/components/shared/StyledMarkdown.js +8 -0
- package/es/components/shared/SurveyContentBox.d.ts +15 -0
- package/es/components/shared/SurveyContentBox.js +98 -0
- package/es/components/shared/index.d.ts +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +19 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +33 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +219 -0
- package/es/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/es/components/shared/question-radio/QuestionRadio.js +19 -0
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioContext.js +33 -0
- package/es/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioOption.js +180 -0
- package/es/helpers/index.d.ts +22 -0
- package/es/helpers/index.js +21 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +7 -0
- package/package.json +71 -0
|
@@ -0,0 +1,187 @@
|
|
|
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-zgbv8k-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
|
+
if (checked) {
|
|
20
|
+
return designTokens.base.color.primary1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
switch (status) {
|
|
24
|
+
case 'correct':
|
|
25
|
+
return designTokens.base.color.green1;
|
|
26
|
+
|
|
27
|
+
case 'wrong':
|
|
28
|
+
return designTokens.base.color.red1;
|
|
29
|
+
|
|
30
|
+
default:
|
|
31
|
+
return designTokens.base.color.navy5;
|
|
32
|
+
}
|
|
33
|
+
}, ({
|
|
34
|
+
disabled
|
|
35
|
+
}) => disabled ? 'not-allowed' : 'pointer', ({
|
|
36
|
+
isAnswer
|
|
37
|
+
}) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
|
|
38
|
+
const StyledQuestionRadioInput = styled__default["default"].input.withConfig({
|
|
39
|
+
componentId: "sc-zgbv8k-1"
|
|
40
|
+
})(["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 ", ";", ""], ({
|
|
41
|
+
checked,
|
|
42
|
+
status
|
|
43
|
+
}) => {
|
|
44
|
+
if (checked) {
|
|
45
|
+
return designTokens.base.color.primary6;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
switch (status) {
|
|
49
|
+
case 'correct':
|
|
50
|
+
return designTokens.base.color.green9;
|
|
51
|
+
|
|
52
|
+
case 'wrong':
|
|
53
|
+
return designTokens.base.color.red9;
|
|
54
|
+
|
|
55
|
+
default:
|
|
56
|
+
return designTokens.base.color.gray3;
|
|
57
|
+
}
|
|
58
|
+
}, ({
|
|
59
|
+
status,
|
|
60
|
+
checked
|
|
61
|
+
}) => {
|
|
62
|
+
if (checked) {
|
|
63
|
+
return `
|
|
64
|
+
&:after {
|
|
65
|
+
content: '';
|
|
66
|
+
position: absolute;
|
|
67
|
+
top: 50%;
|
|
68
|
+
left: 50%;
|
|
69
|
+
transform: translate(-50%, -50%);
|
|
70
|
+
width: 70%;
|
|
71
|
+
height: 70%;
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
background-color: ${designTokens.base.color.primary6};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (status) {
|
|
79
|
+
let bgColor;
|
|
80
|
+
|
|
81
|
+
switch (status) {
|
|
82
|
+
case 'correct':
|
|
83
|
+
bgColor = designTokens.base.color.green9;
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 'wrong':
|
|
87
|
+
bgColor = designTokens.base.color.red9;
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
bgColor = designTokens.base.color.gray3;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return `
|
|
96
|
+
&:after {
|
|
97
|
+
content: '';
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 50%;
|
|
100
|
+
left: 50%;
|
|
101
|
+
transform: translate(-50%, -50%);
|
|
102
|
+
width: 70%;
|
|
103
|
+
height: 70%;
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
background-color: ${bgColor};
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const StyledLabel = styled__default["default"].label.withConfig({
|
|
111
|
+
componentId: "sc-zgbv8k-2"
|
|
112
|
+
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3, ({
|
|
113
|
+
checked,
|
|
114
|
+
status
|
|
115
|
+
}) => {
|
|
116
|
+
if (checked) {
|
|
117
|
+
return designTokens.base.color.primary6;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
switch (status) {
|
|
121
|
+
case 'correct':
|
|
122
|
+
return designTokens.base.color.green9;
|
|
123
|
+
|
|
124
|
+
case 'wrong':
|
|
125
|
+
return designTokens.base.color.red9;
|
|
126
|
+
|
|
127
|
+
default:
|
|
128
|
+
return designTokens.base.color.navy0;
|
|
129
|
+
}
|
|
130
|
+
}, ({
|
|
131
|
+
checked,
|
|
132
|
+
status
|
|
133
|
+
}) => {
|
|
134
|
+
if (checked) {
|
|
135
|
+
return designTokens.base.color.primary6;
|
|
136
|
+
}
|
|
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 designTokens.base.color.navy0;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const QuestionRadioOption = React__default["default"].memo(({
|
|
150
|
+
value,
|
|
151
|
+
status,
|
|
152
|
+
isAnswer,
|
|
153
|
+
children
|
|
154
|
+
}) => {
|
|
155
|
+
const {
|
|
156
|
+
selectedValue,
|
|
157
|
+
disabled,
|
|
158
|
+
onSelect
|
|
159
|
+
} = QuestionRadioContext.useQuestionRadioContext();
|
|
160
|
+
return React__default["default"].createElement(StyledQuestionRadioOption, {
|
|
161
|
+
isAnswer: isAnswer,
|
|
162
|
+
disabled: disabled,
|
|
163
|
+
checked: selectedValue === value,
|
|
164
|
+
onClick: e => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
|
|
167
|
+
if (disabled) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onSelect(value);
|
|
172
|
+
},
|
|
173
|
+
status: status
|
|
174
|
+
}, React__default["default"].createElement(StyledQuestionRadioInput, {
|
|
175
|
+
id: value,
|
|
176
|
+
type: "radio",
|
|
177
|
+
readOnly: true,
|
|
178
|
+
checked: selectedValue === value,
|
|
179
|
+
status: status
|
|
180
|
+
}), React__default["default"].createElement(StyledLabel, {
|
|
181
|
+
htmlFor: value,
|
|
182
|
+
checked: selectedValue === value,
|
|
183
|
+
status: status
|
|
184
|
+
}, children));
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
module.exports = QuestionRadioOption;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GetOrgLectureGetResponses, GetOrgMaterialSurveyResponseGetResponses } from '@elice/types';
|
|
2
|
+
import type { SurveyOptionType } from '@elice/types/es/enums';
|
|
3
|
+
interface OptionInfo {
|
|
4
|
+
content: string;
|
|
5
|
+
optionType: SurveyOptionType;
|
|
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 enum SurveyResultStatus {
|
|
17
|
+
Submitted = 0,
|
|
18
|
+
NotSubmitted = 1
|
|
19
|
+
}
|
|
20
|
+
export declare function getSurveyResultStatus(materialSurveyResponse?: GetOrgMaterialSurveyResponseGetResponses['surveyResponse']): SurveyResultStatus;
|
|
21
|
+
export declare function checkUserLectureTestEnded(lecture?: GetOrgLectureGetResponses['lecture']): boolean;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var types = require('@elice/types');
|
|
6
|
+
|
|
7
|
+
exports.SurveyResultStatus = void 0;
|
|
8
|
+
|
|
9
|
+
(function (SurveyResultStatus) {
|
|
10
|
+
SurveyResultStatus[SurveyResultStatus["Submitted"] = 0] = "Submitted";
|
|
11
|
+
SurveyResultStatus[SurveyResultStatus["NotSubmitted"] = 1] = "NotSubmitted";
|
|
12
|
+
})(exports.SurveyResultStatus || (exports.SurveyResultStatus = {}));
|
|
13
|
+
|
|
14
|
+
function getSurveyResultStatus(materialSurveyResponse) {
|
|
15
|
+
if (materialSurveyResponse) {
|
|
16
|
+
return exports.SurveyResultStatus.Submitted;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return exports.SurveyResultStatus.NotSubmitted;
|
|
20
|
+
}
|
|
21
|
+
function checkUserLectureTestEnded(lecture) {
|
|
22
|
+
return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === types.enums.TestAdmissionStatus.Completed;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.checkUserLectureTestEnded = checkUserLectureTestEnded;
|
|
26
|
+
exports.getSurveyResultStatus = getSurveyResultStatus;
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var MaterialSurvey = require('./components/material-survey/MaterialSurvey.js');
|
|
6
|
+
var MaterialSurveyInfo = require('./components/material-survey/MaterialSurveyInfo.js');
|
|
7
|
+
var MaterialSurveyEdit = require('./components/material-survey-edit/MaterialSurveyEdit.js');
|
|
8
|
+
var QuestionRadio = require('./components/shared/question-radio/QuestionRadio.js');
|
|
9
|
+
var QuestionRadioOption = require('./components/shared/question-radio/QuestionRadioOption.js');
|
|
10
|
+
var QuestionCheckbox = require('./components/shared/question-checkbox/QuestionCheckbox.js');
|
|
11
|
+
var QuestionCheckboxOption = require('./components/shared/question-checkbox/QuestionCheckboxOption.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.MaterialSurvey = MaterialSurvey;
|
|
16
|
+
exports.MaterialSurveyInfo = MaterialSurveyInfo;
|
|
17
|
+
exports.MaterialSurveyEdit = MaterialSurveyEdit;
|
|
18
|
+
exports.QuestionRadio = QuestionRadio;
|
|
19
|
+
exports.QuestionRadioOption = QuestionRadioOption;
|
|
20
|
+
exports.QuestionCheckbox = QuestionCheckbox;
|
|
21
|
+
exports.QuestionCheckboxOption = QuestionCheckboxOption;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
'materialSurvey.error': string;
|
|
3
|
+
'materialSurvey.submit': string;
|
|
4
|
+
'materialSurvey.submittedAnswer': string;
|
|
5
|
+
'materialSurvey.next': string;
|
|
6
|
+
'materialSurvey.myAnswer': string;
|
|
7
|
+
'materialSurvey.empty.title': string;
|
|
8
|
+
'materialSurvey.empty.description': string;
|
|
9
|
+
'materialSurvey.survey.empty.title': string;
|
|
10
|
+
'materialSurvey.survey.empty.description': string;
|
|
11
|
+
'materialSurvey.submitStatus.success': string;
|
|
12
|
+
'materialSurvey.submitStatus.failure': string;
|
|
13
|
+
'materialSurvey.resultStatus.submitted': string;
|
|
14
|
+
'materialSurvey.text.placeholder': string;
|
|
15
|
+
};
|
|
16
|
+
export declare const ko: typeof en;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
'materialSurvey.error': 'Failed to fetch survey',
|
|
3
|
+
'materialSurvey.submit': 'Submit',
|
|
4
|
+
'materialSurvey.submittedAnswer': 'Submitted Answer',
|
|
5
|
+
'materialSurvey.next': 'Next question >',
|
|
6
|
+
'materialSurvey.myAnswer': 'My answer',
|
|
7
|
+
'materialSurvey.empty.title': 'Survey is now preparing.',
|
|
8
|
+
'materialSurvey.empty.description': 'Please check again after survey posting!',
|
|
9
|
+
'materialSurvey.survey.empty.title': 'Survey is now preparing.',
|
|
10
|
+
'materialSurvey.survey.empty.description': 'Please check again after survey posting!',
|
|
11
|
+
'materialSurvey.submitStatus.success': 'Submitted',
|
|
12
|
+
'materialSurvey.submitStatus.failure': 'Failed to submit',
|
|
13
|
+
'materialSurvey.resultStatus.submitted': 'Submitted',
|
|
14
|
+
'materialSurvey.text.placeholder': 'please fill the answer'
|
|
15
|
+
};
|
|
16
|
+
const ko = {
|
|
17
|
+
'materialSurvey.error': '설문조사를 불러오는데 실패했습니다.\n잠시 후 다시 시도해주세요.',
|
|
18
|
+
'materialSurvey.submit': '제출',
|
|
19
|
+
'materialSurvey.submittedAnswer': '제출한 답',
|
|
20
|
+
'materialSurvey.next': '다음으로 이동 >',
|
|
21
|
+
'materialSurvey.myAnswer': '내 답변',
|
|
22
|
+
'materialSurvey.empty.title': '설문조사가 준비 중 입니다.',
|
|
23
|
+
'materialSurvey.empty.description': '설문조사 게시 후 다시 확인해주세요!',
|
|
24
|
+
'materialSurvey.survey.empty.title': '설문조사가 준비 중 입니다.',
|
|
25
|
+
'materialSurvey.survey.empty.description': '설문지 게시 후 다시 확인해주세요!',
|
|
26
|
+
'materialSurvey.submitStatus.success': '제출되었습니다.',
|
|
27
|
+
'materialSurvey.submitStatus.failure': '제출에 실패하였습니다.',
|
|
28
|
+
'materialSurvey.resultStatus.submitted': '제출완료',
|
|
29
|
+
'materialSurvey.text.placeholder': '답변을 입력하세요.'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { en, ko };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IntlProvider } from 'react-intl';
|
|
3
|
+
import { useMeasure } from 'react-use';
|
|
4
|
+
import { base } from '@elice/design-tokens';
|
|
5
|
+
import { enums } from '@elice/types';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { MaterialSurveyProvider, useMaterialSurveyState, useMaterialSurveyDispatch } from './context/MaterialSurveyContext.js';
|
|
8
|
+
import MaterialSurveyShimmer from './MaterialSurveyShimmer.js';
|
|
9
|
+
import MaterialSurveyInfo from './MaterialSurveyInfo.js';
|
|
10
|
+
import * as MaterialSurvey_i18n from './MaterialSurvey.i18n.js';
|
|
11
|
+
import { en } from './MaterialSurvey.i18n.js';
|
|
12
|
+
|
|
13
|
+
const AsyncMaterialSurveySelectMultiple = React.lazy(() => import('./MaterialSurveySelectMultiple.js'));
|
|
14
|
+
const AsyncMaterialSurveyText = React.lazy(() => import('./MaterialSurveyText.js'));
|
|
15
|
+
const AsyncMaterialSurveySelectOne = React.lazy(() => import('./MaterialSurveySelectOne.js'));
|
|
16
|
+
const StyledMaterialSurveyInfo = styled.div.withConfig({
|
|
17
|
+
componentId: "sc-1fyzkvm-0"
|
|
18
|
+
})([""]);
|
|
19
|
+
const StyledMaterialSurveyContent = styled.div.withConfig({
|
|
20
|
+
componentId: "sc-1fyzkvm-1"
|
|
21
|
+
})([""]);
|
|
22
|
+
const StyledMaterialSurveyWrapper = styled.div.withConfig({
|
|
23
|
+
componentId: "sc-1fyzkvm-2"
|
|
24
|
+
})(["display:flex;height:100%;flex-direction:", ";& > *{flex:", ";}& > *:first-child{margin-right:", ";margin-bottom:", ";}", "{height:", ";overflow-y:", ";}"], ({
|
|
25
|
+
vertical
|
|
26
|
+
}) => vertical ? 'column' : 'row', ({
|
|
27
|
+
vertical
|
|
28
|
+
}) => vertical ? 'auto' : '1 0 calc(50% - 1rem);', ({
|
|
29
|
+
vertical
|
|
30
|
+
}) => vertical ? '0' : '1rem', ({
|
|
31
|
+
vertical
|
|
32
|
+
}) => vertical ? '1rem' : '0', StyledMaterialSurveyInfo, ({
|
|
33
|
+
vertical
|
|
34
|
+
}) => vertical ? 'auto' : '100%', ({
|
|
35
|
+
vertical
|
|
36
|
+
}) => vertical ? 'intial' : 'auto');
|
|
37
|
+
|
|
38
|
+
const MaterialSurvey = () => {
|
|
39
|
+
const {
|
|
40
|
+
materialSurvey,
|
|
41
|
+
vertical
|
|
42
|
+
} = useMaterialSurveyState();
|
|
43
|
+
const {
|
|
44
|
+
setVertical
|
|
45
|
+
} = useMaterialSurveyDispatch();
|
|
46
|
+
const [ref, {
|
|
47
|
+
width
|
|
48
|
+
}] = useMeasure();
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (width > 0) {
|
|
51
|
+
setVertical(width <= base.screen.medium);
|
|
52
|
+
}
|
|
53
|
+
}, [width, setVertical]);
|
|
54
|
+
let Component = null;
|
|
55
|
+
|
|
56
|
+
switch (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0].optionType) {
|
|
57
|
+
case enums.SurveyOptionType.SelectOne:
|
|
58
|
+
Component = React.createElement(AsyncMaterialSurveySelectOne, null);
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case enums.SurveyOptionType.SelectMultiple:
|
|
62
|
+
Component = React.createElement(AsyncMaterialSurveySelectMultiple, null);
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case enums.SurveyOptionType.Text:
|
|
66
|
+
Component = React.createElement(AsyncMaterialSurveyText, null);
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
default:
|
|
70
|
+
Component = React.createElement(MaterialSurveyShimmer, null);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return React.createElement(React.Suspense, {
|
|
75
|
+
fallback: null
|
|
76
|
+
}, React.createElement(StyledMaterialSurveyWrapper, {
|
|
77
|
+
ref: ref,
|
|
78
|
+
vertical: vertical
|
|
79
|
+
}, React.createElement(StyledMaterialSurveyInfo, null, React.createElement(MaterialSurveyInfo, null)), React.createElement(StyledMaterialSurveyContent, null, Component)));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const MaterialSurveyContainer = ({
|
|
83
|
+
materialSurveyId,
|
|
84
|
+
userId,
|
|
85
|
+
locale = 'en',
|
|
86
|
+
onSubmit,
|
|
87
|
+
onNext
|
|
88
|
+
}) => {
|
|
89
|
+
return React.createElement(IntlProvider, {
|
|
90
|
+
locale: locale,
|
|
91
|
+
defaultLocale: "en",
|
|
92
|
+
messages: locale in MaterialSurvey_i18n ? MaterialSurvey_i18n[locale] : en
|
|
93
|
+
}, React.createElement(MaterialSurveyProvider, {
|
|
94
|
+
materialSurveyId: materialSurveyId,
|
|
95
|
+
userId: userId,
|
|
96
|
+
onSubmit: onSubmit,
|
|
97
|
+
onNext: onNext
|
|
98
|
+
}, React.createElement(MaterialSurvey, null)));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { MaterialSurveyContainer as default };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Flex, Text, Shimmer, Vspace } from '@elice/blocks';
|
|
3
|
+
import { base } from '@elice/design-tokens';
|
|
4
|
+
import { MarkdownSSR } from '@elice/markdown';
|
|
5
|
+
import SurveyContentBox from '../shared/SurveyContentBox.js';
|
|
6
|
+
import { useMaterialSurveyState } from './context/MaterialSurveyContext.js';
|
|
7
|
+
|
|
8
|
+
const MaterialSurveyInfo = () => {
|
|
9
|
+
const {
|
|
10
|
+
materialSurvey
|
|
11
|
+
} = useMaterialSurveyState();
|
|
12
|
+
return React.createElement(SurveyContentBox, {
|
|
13
|
+
title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title
|
|
14
|
+
}, materialSurvey ? React.createElement(Flex, null, React.createElement(Text, {
|
|
15
|
+
bold: true,
|
|
16
|
+
size: "large",
|
|
17
|
+
customStyles: {
|
|
18
|
+
color: base.color.primary3,
|
|
19
|
+
marginRight: '0.5rem'
|
|
20
|
+
}
|
|
21
|
+
}, 'Q.'), React.createElement(Text, {
|
|
22
|
+
bold: true,
|
|
23
|
+
role: "white",
|
|
24
|
+
size: "large",
|
|
25
|
+
wordBreak: "break-word"
|
|
26
|
+
}, materialSurvey.questionInfoList[0].questionTitle)) : React.createElement(Shimmer, {
|
|
27
|
+
dark: true,
|
|
28
|
+
borderRadius: '4px',
|
|
29
|
+
width: "80%",
|
|
30
|
+
height: '40px'
|
|
31
|
+
}), React.createElement(Vspace, {
|
|
32
|
+
height: 1
|
|
33
|
+
}), materialSurvey ? React.createElement(MarkdownSSR, {
|
|
34
|
+
children: materialSurvey.questionInfoList[0].questionDescription,
|
|
35
|
+
dark: true,
|
|
36
|
+
paddingx: 0,
|
|
37
|
+
paddingy: 0
|
|
38
|
+
}) : React.createElement(React.Fragment, null, React.createElement(Shimmer, {
|
|
39
|
+
dark: true,
|
|
40
|
+
borderRadius: '4px',
|
|
41
|
+
width: "80%",
|
|
42
|
+
height: '40px'
|
|
43
|
+
}), React.createElement(Vspace, {
|
|
44
|
+
height: 1
|
|
45
|
+
}), React.createElement(Shimmer, {
|
|
46
|
+
dark: true,
|
|
47
|
+
borderRadius: '4px',
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: '40px'
|
|
50
|
+
}), React.createElement(Vspace, {
|
|
51
|
+
height: 1
|
|
52
|
+
}), React.createElement(Shimmer, {
|
|
53
|
+
dark: true,
|
|
54
|
+
borderRadius: '4px',
|
|
55
|
+
width: "100%",
|
|
56
|
+
height: '40px'
|
|
57
|
+
}), React.createElement(Vspace, {
|
|
58
|
+
height: 1
|
|
59
|
+
}), React.createElement(Shimmer, {
|
|
60
|
+
dark: true,
|
|
61
|
+
borderRadius: '4px',
|
|
62
|
+
width: "100%",
|
|
63
|
+
height: '40px'
|
|
64
|
+
})));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { MaterialSurveyInfo as default };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
|
|
4
|
+
import { checkUserLectureTestEnded } from '../../helpers/index.js';
|
|
5
|
+
import '../shared/question-radio/QuestionRadio.js';
|
|
6
|
+
import '../shared/question-radio/QuestionRadioOption.js';
|
|
7
|
+
import QuestionCheckbox from '../shared/question-checkbox/QuestionCheckbox.js';
|
|
8
|
+
import QuestionCheckboxOption from '../shared/question-checkbox/QuestionCheckboxOption.js';
|
|
9
|
+
import StyledMarkdown from '../shared/StyledMarkdown.js';
|
|
10
|
+
import SurveyContentBox from '../shared/SurveyContentBox.js';
|
|
11
|
+
import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/MaterialSurveyContext.js';
|
|
12
|
+
import SurveyResultBadge from './SurveyResultBadge.js';
|
|
13
|
+
import SurveySubmitStatusText from './SurveySubmitStatusText.js';
|
|
14
|
+
|
|
15
|
+
const MaterialSurveySelectMultiple = () => {
|
|
16
|
+
var _a; // context
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
course,
|
|
21
|
+
lecture,
|
|
22
|
+
materialSurvey,
|
|
23
|
+
userId
|
|
24
|
+
} = useMaterialSurveyState();
|
|
25
|
+
const {
|
|
26
|
+
onSubmit,
|
|
27
|
+
onNext,
|
|
28
|
+
refreshOrgMaterialSurvey
|
|
29
|
+
} = useMaterialSurveyDispatch(); // state
|
|
30
|
+
|
|
31
|
+
const intl = useIntl();
|
|
32
|
+
const [selectedAnswer, setSelectedAnswer] = React.useState([]);
|
|
33
|
+
const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
|
|
34
|
+
const [submitStatus, setSubmitStatus] = React.useState('idle'); // survey response fetcher
|
|
35
|
+
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const {
|
|
40
|
+
signal
|
|
41
|
+
} = controller;
|
|
42
|
+
getOrgMaterialSurveyResponseGet({
|
|
43
|
+
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
44
|
+
}, {
|
|
45
|
+
signal
|
|
46
|
+
}).then(response => {
|
|
47
|
+
setMaterialSurveyResponse(response.surveyResponse);
|
|
48
|
+
setSelectedAnswer(response.surveyResponse.answers[0]);
|
|
49
|
+
}).catch(error => {
|
|
50
|
+
console.error(error);
|
|
51
|
+
});
|
|
52
|
+
return () => controller.abort();
|
|
53
|
+
}
|
|
54
|
+
}, [materialSurvey, userId]); // survey response fetcher
|
|
55
|
+
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (userId && materialSurvey) {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
const {
|
|
60
|
+
signal
|
|
61
|
+
} = controller;
|
|
62
|
+
getOrgMaterialSurveyResponseList({
|
|
63
|
+
materialSurveyId: materialSurvey.id,
|
|
64
|
+
filterUserIds: [userId],
|
|
65
|
+
isContainOnlyLast: true,
|
|
66
|
+
isIncludeAnswer: true,
|
|
67
|
+
offset: 0,
|
|
68
|
+
count: 1
|
|
69
|
+
}, {
|
|
70
|
+
signal
|
|
71
|
+
}).then(response => {
|
|
72
|
+
const surveyResponse = response.surveyResponses[0];
|
|
73
|
+
|
|
74
|
+
const getAnswer = () => {
|
|
75
|
+
if (!surveyResponse) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!Array.isArray(surveyResponse.answers)) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof surveyResponse.answers[0] === 'string') {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return surveyResponse.answers[0];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
91
|
+
setSelectedAnswer(getAnswer());
|
|
92
|
+
}).catch(error => {
|
|
93
|
+
console.error(error);
|
|
94
|
+
});
|
|
95
|
+
return () => controller.abort();
|
|
96
|
+
}
|
|
97
|
+
}, [materialSurvey, userId]); // submit handler
|
|
98
|
+
|
|
99
|
+
const handleSubmit = async () => {
|
|
100
|
+
if (!materialSurvey) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setSubmitStatus('pending');
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const {
|
|
108
|
+
surveyResponseId
|
|
109
|
+
} = await postOrgMaterialSurveyResponseAdd({
|
|
110
|
+
materialSurveyId: materialSurvey.id,
|
|
111
|
+
answers: [selectedAnswer]
|
|
112
|
+
});
|
|
113
|
+
const {
|
|
114
|
+
surveyResponse
|
|
115
|
+
} = await getOrgMaterialSurveyResponseGet({
|
|
116
|
+
surveyResponseId
|
|
117
|
+
});
|
|
118
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
119
|
+
void refreshOrgMaterialSurvey();
|
|
120
|
+
onSubmit(true);
|
|
121
|
+
setSubmitStatus('resolved');
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error(error);
|
|
124
|
+
onSubmit(false);
|
|
125
|
+
setSubmitStatus('rejected');
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
return React.createElement(SurveyContentBox, {
|
|
130
|
+
title: intl.formatMessage({
|
|
131
|
+
id: 'materialSurvey.myAnswer'
|
|
132
|
+
}),
|
|
133
|
+
onNext: onNext,
|
|
134
|
+
submitResult: React.createElement(SurveyResultBadge, {
|
|
135
|
+
materialSurveyResponse: materialSurveyResponse
|
|
136
|
+
}),
|
|
137
|
+
submitStatus: React.createElement(SurveySubmitStatusText, {
|
|
138
|
+
status: submitStatus
|
|
139
|
+
}),
|
|
140
|
+
footerActions: [{
|
|
141
|
+
border: true,
|
|
142
|
+
disabled: selectedAnswer.length === 0 || checkUserLectureTestEnded(lecture) || !!userId,
|
|
143
|
+
loading: submitStatus === 'pending',
|
|
144
|
+
tabIndex: 0,
|
|
145
|
+
transparent: false,
|
|
146
|
+
role: 'primary',
|
|
147
|
+
onClick: handleSubmit,
|
|
148
|
+
children: intl.formatMessage({
|
|
149
|
+
id: 'materialSurvey.submit'
|
|
150
|
+
})
|
|
151
|
+
}]
|
|
152
|
+
}, React.createElement(QuestionCheckbox, {
|
|
153
|
+
onSelect: index => {
|
|
154
|
+
if (checkUserLectureTestEnded(lecture) || !!userId) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
setSelectedAnswer(prevState => {
|
|
159
|
+
const newState = prevState.includes(index) ? prevState.filter(ident => ident !== index) : [...prevState, index];
|
|
160
|
+
return newState;
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
selectedOptions: selectedAnswer,
|
|
164
|
+
disabled: submitStatus === 'pending' || checkUserLectureTestEnded(lecture) || !!userId
|
|
165
|
+
}, (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0]) ? (_a = materialSurvey.questionInfoList[0].optionInfo) === null || _a === void 0 ? void 0 : _a.map((option, index) => {
|
|
166
|
+
return React.createElement(QuestionCheckboxOption, {
|
|
167
|
+
key: index,
|
|
168
|
+
value: index
|
|
169
|
+
}, (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? React.createElement(StyledMarkdown, {
|
|
170
|
+
dark: false,
|
|
171
|
+
children: option,
|
|
172
|
+
paddingx: 0,
|
|
173
|
+
paddingy: 0
|
|
174
|
+
}) : option);
|
|
175
|
+
}) : null));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export { MaterialSurveySelectMultiple as default };
|