@elice/material-survey 1.240718.0-trasncript.2 → 1.240718.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-survey/MaterialSurvey.js +57 -82
- package/cjs/components/material-survey/MaterialSurveyInfo.js +59 -69
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +90 -131
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +86 -125
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +40 -47
- package/cjs/components/material-survey/MaterialSurveyText.js +75 -114
- package/cjs/components/material-survey/SurveyResultBadge.js +10 -17
- package/cjs/components/material-survey/SurveySubmitStatusText.js +16 -21
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +74 -115
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +36 -49
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +91 -113
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -100
- package/cjs/components/material-survey-edit/context.js +2 -8
- package/cjs/components/material-survey-edit/utils/editValue.js +11 -17
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/SurveyContentBox.js +74 -85
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -66
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +80 -59
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-survey/MaterialSurvey.js +57 -77
- package/es/components/material-survey/MaterialSurveyInfo.js +59 -65
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +90 -127
- package/es/components/material-survey/MaterialSurveySelectOne.js +86 -121
- package/es/components/material-survey/MaterialSurveyShimmer.js +40 -43
- package/es/components/material-survey/MaterialSurveyText.js +75 -109
- package/es/components/material-survey/SurveyResultBadge.js +10 -13
- package/es/components/material-survey/SurveySubmitStatusText.js +16 -17
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +75 -112
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +36 -45
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +90 -107
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -96
- package/es/components/material-survey-edit/context.js +2 -4
- package/es/components/material-survey-edit/utils/editValue.js +11 -17
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +74 -81
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -61
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +80 -54
- package/package.json +12 -9
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -399
- package/cjs/components/material-survey/index.js +0 -9
- package/cjs/components/material-survey/locales/index.js +0 -13
- package/cjs/components/material-survey-edit/index.js +0 -7
- package/cjs/components/material-survey-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -13
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -386
- package/es/components/material-survey/index.js +0 -2
- package/es/components/material-survey/locales/index.js +0 -4
- package/es/components/material-survey-edit/index.js +0 -1
- package/es/components/material-survey-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -4
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
|
|
5
3
|
import { useRawEliceIntl } from '@elice/intl';
|
|
@@ -14,57 +12,52 @@ import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/Mat
|
|
|
14
12
|
import SurveyResultBadge from './SurveyResultBadge.js';
|
|
15
13
|
import SurveySubmitStatusText from './SurveySubmitStatusText.js';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
const MaterialSurveySelectMultiple = () => {
|
|
18
16
|
var _a;
|
|
19
17
|
// context
|
|
20
|
-
|
|
21
|
-
course
|
|
22
|
-
lecture
|
|
23
|
-
materialSurvey
|
|
24
|
-
userId
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
const {
|
|
19
|
+
course,
|
|
20
|
+
lecture,
|
|
21
|
+
materialSurvey,
|
|
22
|
+
userId
|
|
23
|
+
} = useMaterialSurveyState();
|
|
24
|
+
const {
|
|
25
|
+
onSubmit,
|
|
26
|
+
onNext,
|
|
27
|
+
refreshOrgMaterialSurvey
|
|
28
|
+
} = useMaterialSurveyDispatch();
|
|
29
29
|
// state
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setSelectedAnswer = _React$useState2[1];
|
|
35
|
-
var _React$useState3 = React.useState(),
|
|
36
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
37
|
-
materialSurveyResponse = _React$useState4[0],
|
|
38
|
-
setMaterialSurveyResponse = _React$useState4[1];
|
|
39
|
-
var _React$useState5 = React.useState('idle'),
|
|
40
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
41
|
-
submitStatus = _React$useState6[0],
|
|
42
|
-
setSubmitStatus = _React$useState6[1];
|
|
30
|
+
const intl = useRawEliceIntl();
|
|
31
|
+
const [selectedAnswer, setSelectedAnswer] = React.useState([]);
|
|
32
|
+
const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
|
|
33
|
+
const [submitStatus, setSubmitStatus] = React.useState('idle');
|
|
43
34
|
// survey response fetcher
|
|
44
|
-
React.useEffect(
|
|
35
|
+
React.useEffect(() => {
|
|
45
36
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
const {
|
|
39
|
+
signal
|
|
40
|
+
} = controller;
|
|
48
41
|
getOrgMaterialSurveyResponseGet({
|
|
49
42
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
50
43
|
}, {
|
|
51
|
-
signal
|
|
52
|
-
}).then(
|
|
44
|
+
signal
|
|
45
|
+
}).then(response => {
|
|
53
46
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
54
47
|
setSelectedAnswer(response.surveyResponse.answers[0]);
|
|
55
|
-
}).catch(
|
|
48
|
+
}).catch(error => {
|
|
56
49
|
console.error(error);
|
|
57
50
|
});
|
|
58
|
-
return
|
|
59
|
-
return controller.abort();
|
|
60
|
-
};
|
|
51
|
+
return () => controller.abort();
|
|
61
52
|
}
|
|
62
53
|
}, [materialSurvey, userId]);
|
|
63
54
|
// survey response fetcher
|
|
64
|
-
React.useEffect(
|
|
55
|
+
React.useEffect(() => {
|
|
65
56
|
if (userId && materialSurvey) {
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const {
|
|
59
|
+
signal
|
|
60
|
+
} = controller;
|
|
68
61
|
getOrgMaterialSurveyResponseList({
|
|
69
62
|
materialSurveyId: materialSurvey.id,
|
|
70
63
|
filterUserIds: [userId],
|
|
@@ -73,10 +66,10 @@ var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
|
|
|
73
66
|
offset: 0,
|
|
74
67
|
count: 1
|
|
75
68
|
}, {
|
|
76
|
-
signal
|
|
77
|
-
}).then(
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
signal
|
|
70
|
+
}).then(response => {
|
|
71
|
+
const surveyResponse = response.surveyResponses[0];
|
|
72
|
+
const getAnswer = () => {
|
|
80
73
|
if (!surveyResponse) {
|
|
81
74
|
return [];
|
|
82
75
|
}
|
|
@@ -90,75 +83,49 @@ var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
|
|
|
90
83
|
};
|
|
91
84
|
setMaterialSurveyResponse(surveyResponse);
|
|
92
85
|
setSelectedAnswer(getAnswer());
|
|
93
|
-
}).catch(
|
|
86
|
+
}).catch(error => {
|
|
94
87
|
console.error(error);
|
|
95
88
|
});
|
|
96
|
-
return
|
|
97
|
-
return controller.abort();
|
|
98
|
-
};
|
|
89
|
+
return () => controller.abort();
|
|
99
90
|
}
|
|
100
91
|
}, [materialSurvey, userId]);
|
|
101
92
|
// submit handler
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
surveyResponse = _yield$getOrgMaterial.surveyResponse;
|
|
131
|
-
setMaterialSurveyResponse(surveyResponse);
|
|
132
|
-
void refreshOrgMaterialSurvey();
|
|
133
|
-
onSubmit(true);
|
|
134
|
-
setSubmitStatus('resolved');
|
|
135
|
-
_context.next = 23;
|
|
136
|
-
break;
|
|
137
|
-
case 18:
|
|
138
|
-
_context.prev = 18;
|
|
139
|
-
_context.t0 = _context["catch"](3);
|
|
140
|
-
console.error(_context.t0);
|
|
141
|
-
onSubmit(false);
|
|
142
|
-
setSubmitStatus('rejected');
|
|
143
|
-
case 23:
|
|
144
|
-
case "end":
|
|
145
|
-
return _context.stop();
|
|
146
|
-
}
|
|
147
|
-
}, _callee, null, [[3, 18]]);
|
|
148
|
-
}));
|
|
149
|
-
return function handleSubmit() {
|
|
150
|
-
return _ref.apply(this, arguments);
|
|
151
|
-
};
|
|
152
|
-
}();
|
|
153
|
-
return jsx(SurveyContentBox, {
|
|
93
|
+
const handleSubmit = async () => {
|
|
94
|
+
if (!materialSurvey) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setSubmitStatus('pending');
|
|
98
|
+
try {
|
|
99
|
+
const {
|
|
100
|
+
surveyResponseId
|
|
101
|
+
} = await postOrgMaterialSurveyResponseAdd({
|
|
102
|
+
materialSurveyId: materialSurvey.id,
|
|
103
|
+
answers: [selectedAnswer]
|
|
104
|
+
});
|
|
105
|
+
const {
|
|
106
|
+
surveyResponse
|
|
107
|
+
} = await getOrgMaterialSurveyResponseGet({
|
|
108
|
+
surveyResponseId
|
|
109
|
+
});
|
|
110
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
111
|
+
void refreshOrgMaterialSurvey();
|
|
112
|
+
onSubmit(true);
|
|
113
|
+
setSubmitStatus('resolved');
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error(error);
|
|
116
|
+
onSubmit(false);
|
|
117
|
+
setSubmitStatus('rejected');
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return React.createElement(SurveyContentBox, {
|
|
154
121
|
title: intl.formatMessage({
|
|
155
122
|
id: 'materialSurvey.myAnswer'
|
|
156
123
|
}),
|
|
157
124
|
onNext: onNext,
|
|
158
|
-
submitResult:
|
|
125
|
+
submitResult: React.createElement(SurveyResultBadge, {
|
|
159
126
|
materialSurveyResponse: materialSurveyResponse
|
|
160
127
|
}),
|
|
161
|
-
submitStatus:
|
|
128
|
+
submitStatus: React.createElement(SurveySubmitStatusText, {
|
|
162
129
|
status: submitStatus
|
|
163
130
|
}),
|
|
164
131
|
footerActions: [{
|
|
@@ -172,34 +139,30 @@ var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
|
|
|
172
139
|
children: intl.formatMessage({
|
|
173
140
|
id: 'materialSurvey.submit'
|
|
174
141
|
})
|
|
175
|
-
}]
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, index);
|
|
200
|
-
}) : null
|
|
201
|
-
})
|
|
202
|
-
});
|
|
142
|
+
}]
|
|
143
|
+
}, React.createElement(QuestionCheckbox, {
|
|
144
|
+
onSelect: index => {
|
|
145
|
+
if (checkUserLectureTestEnded(lecture) || !!userId) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setSelectedAnswer(prevState => {
|
|
149
|
+
const newState = prevState.includes(index) ? prevState.filter(ident => ident !== index) : [...prevState, index];
|
|
150
|
+
return newState;
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
selectedOptions: selectedAnswer,
|
|
154
|
+
disabled: submitStatus === 'pending' || checkUserLectureTestEnded(lecture) || !!userId
|
|
155
|
+
}, (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) => {
|
|
156
|
+
return React.createElement(QuestionCheckboxOption, {
|
|
157
|
+
key: index,
|
|
158
|
+
value: index
|
|
159
|
+
}, (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? React.createElement(StyledMarkdown, {
|
|
160
|
+
dark: false,
|
|
161
|
+
children: option,
|
|
162
|
+
paddingx: 0,
|
|
163
|
+
paddingy: 0
|
|
164
|
+
}) : option);
|
|
165
|
+
}) : null));
|
|
203
166
|
};
|
|
204
167
|
|
|
205
168
|
export { MaterialSurveySelectMultiple as default };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
|
|
5
3
|
import { useRawEliceIntl } from '@elice/intl';
|
|
@@ -14,56 +12,51 @@ import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/Mat
|
|
|
14
12
|
import SurveyResultBadge from './SurveyResultBadge.js';
|
|
15
13
|
import SurveySubmitStatusText from './SurveySubmitStatusText.js';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
const MaterialSurveySelectOne = () => {
|
|
18
16
|
// context
|
|
19
|
-
|
|
20
|
-
course
|
|
21
|
-
lecture
|
|
22
|
-
materialSurvey
|
|
23
|
-
userId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const {
|
|
18
|
+
course,
|
|
19
|
+
lecture,
|
|
20
|
+
materialSurvey,
|
|
21
|
+
userId
|
|
22
|
+
} = useMaterialSurveyState();
|
|
23
|
+
const {
|
|
24
|
+
onSubmit,
|
|
25
|
+
onNext,
|
|
26
|
+
refreshOrgMaterialSurvey
|
|
27
|
+
} = useMaterialSurveyDispatch();
|
|
28
28
|
// state
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
setSelectedAnswer = _React$useState2[1];
|
|
34
|
-
var _React$useState3 = React.useState(),
|
|
35
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
36
|
-
materialSurveyResponse = _React$useState4[0],
|
|
37
|
-
setMaterialSurveyResponse = _React$useState4[1];
|
|
38
|
-
var _React$useState5 = React.useState('idle'),
|
|
39
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
40
|
-
submitStatus = _React$useState6[0],
|
|
41
|
-
setSubmitStatus = _React$useState6[1];
|
|
29
|
+
const intl = useRawEliceIntl();
|
|
30
|
+
const [selectedAnswer, setSelectedAnswer] = React.useState();
|
|
31
|
+
const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
|
|
32
|
+
const [submitStatus, setSubmitStatus] = React.useState('idle');
|
|
42
33
|
// survey response fetcher
|
|
43
|
-
React.useEffect(
|
|
34
|
+
React.useEffect(() => {
|
|
44
35
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
const {
|
|
38
|
+
signal
|
|
39
|
+
} = controller;
|
|
47
40
|
getOrgMaterialSurveyResponseGet({
|
|
48
41
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
49
42
|
}, {
|
|
50
|
-
signal
|
|
51
|
-
}).then(
|
|
43
|
+
signal
|
|
44
|
+
}).then(response => {
|
|
52
45
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
53
46
|
setSelectedAnswer(typeof response.surveyResponse.answers[0] === 'string' ? undefined : response.surveyResponse.answers[0][0]);
|
|
54
|
-
}).catch(
|
|
47
|
+
}).catch(error => {
|
|
55
48
|
console.error(error);
|
|
56
49
|
});
|
|
57
|
-
return
|
|
58
|
-
return controller.abort();
|
|
59
|
-
};
|
|
50
|
+
return () => controller.abort();
|
|
60
51
|
}
|
|
61
52
|
}, [materialSurvey, userId]);
|
|
62
53
|
// survey response fetcher
|
|
63
|
-
React.useEffect(
|
|
54
|
+
React.useEffect(() => {
|
|
64
55
|
if (userId && materialSurvey) {
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
const {
|
|
58
|
+
signal
|
|
59
|
+
} = controller;
|
|
67
60
|
getOrgMaterialSurveyResponseList({
|
|
68
61
|
materialSurveyId: materialSurvey.id,
|
|
69
62
|
filterUserIds: [userId],
|
|
@@ -72,81 +65,55 @@ var MaterialSurveySelectOne = function MaterialSurveySelectOne() {
|
|
|
72
65
|
offset: 0,
|
|
73
66
|
count: 1
|
|
74
67
|
}, {
|
|
75
|
-
signal
|
|
76
|
-
}).then(
|
|
68
|
+
signal
|
|
69
|
+
}).then(response => {
|
|
77
70
|
var _a;
|
|
78
|
-
|
|
71
|
+
const surveyResponse = response.surveyResponses[0];
|
|
79
72
|
setMaterialSurveyResponse(surveyResponse);
|
|
80
73
|
setSelectedAnswer(typeof (surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0]) === 'string' ? undefined : (_a = surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0][0]) !== null && _a !== void 0 ? _a : undefined);
|
|
81
|
-
}).catch(
|
|
74
|
+
}).catch(error => {
|
|
82
75
|
console.error(error);
|
|
83
76
|
});
|
|
84
|
-
return
|
|
85
|
-
return controller.abort();
|
|
86
|
-
};
|
|
77
|
+
return () => controller.abort();
|
|
87
78
|
}
|
|
88
79
|
}, [materialSurvey, userId]);
|
|
89
80
|
// submit handler
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
surveyResponse = _yield$getOrgMaterial.surveyResponse;
|
|
119
|
-
setMaterialSurveyResponse(surveyResponse);
|
|
120
|
-
void refreshOrgMaterialSurvey();
|
|
121
|
-
onSubmit(true);
|
|
122
|
-
setSubmitStatus('resolved');
|
|
123
|
-
_context.next = 23;
|
|
124
|
-
break;
|
|
125
|
-
case 18:
|
|
126
|
-
_context.prev = 18;
|
|
127
|
-
_context.t0 = _context["catch"](3);
|
|
128
|
-
console.error(_context.t0);
|
|
129
|
-
onSubmit(false);
|
|
130
|
-
setSubmitStatus('rejected');
|
|
131
|
-
case 23:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context.stop();
|
|
134
|
-
}
|
|
135
|
-
}, _callee, null, [[3, 18]]);
|
|
136
|
-
}));
|
|
137
|
-
return function handleSubmit() {
|
|
138
|
-
return _ref.apply(this, arguments);
|
|
139
|
-
};
|
|
140
|
-
}();
|
|
141
|
-
return jsx(SurveyContentBox, {
|
|
81
|
+
const handleSubmit = async () => {
|
|
82
|
+
if (!materialSurvey || selectedAnswer === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setSubmitStatus('pending');
|
|
86
|
+
try {
|
|
87
|
+
const {
|
|
88
|
+
surveyResponseId
|
|
89
|
+
} = await postOrgMaterialSurveyResponseAdd({
|
|
90
|
+
materialSurveyId: materialSurvey.id,
|
|
91
|
+
answers: [[selectedAnswer]]
|
|
92
|
+
});
|
|
93
|
+
const {
|
|
94
|
+
surveyResponse
|
|
95
|
+
} = await getOrgMaterialSurveyResponseGet({
|
|
96
|
+
surveyResponseId
|
|
97
|
+
});
|
|
98
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
99
|
+
void refreshOrgMaterialSurvey();
|
|
100
|
+
onSubmit(true);
|
|
101
|
+
setSubmitStatus('resolved');
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error(error);
|
|
104
|
+
onSubmit(false);
|
|
105
|
+
setSubmitStatus('rejected');
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return React.createElement(SurveyContentBox, {
|
|
142
109
|
title: intl.formatMessage({
|
|
143
110
|
id: 'materialSurvey.myAnswer'
|
|
144
111
|
}),
|
|
145
112
|
onNext: onNext,
|
|
146
|
-
submitStatus:
|
|
113
|
+
submitStatus: React.createElement(SurveySubmitStatusText, {
|
|
147
114
|
status: submitStatus
|
|
148
115
|
}),
|
|
149
|
-
submitResult:
|
|
116
|
+
submitResult: React.createElement(SurveyResultBadge, {
|
|
150
117
|
materialSurveyResponse: materialSurveyResponse
|
|
151
118
|
}),
|
|
152
119
|
footerActions: [{
|
|
@@ -160,29 +127,27 @@ var MaterialSurveySelectOne = function MaterialSurveySelectOne() {
|
|
|
160
127
|
children: intl.formatMessage({
|
|
161
128
|
id: 'materialSurvey.submit'
|
|
162
129
|
})
|
|
163
|
-
}]
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
})
|
|
185
|
-
});
|
|
130
|
+
}]
|
|
131
|
+
}, React.createElement(QuestionRadio, {
|
|
132
|
+
selectedValue: selectedAnswer,
|
|
133
|
+
onSelect: index => {
|
|
134
|
+
if (checkUserLectureTestEnded(lecture) || !!userId) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
setSelectedAnswer(index);
|
|
138
|
+
},
|
|
139
|
+
disabled: submitStatus === 'pending' || checkUserLectureTestEnded(lecture) || !!userId
|
|
140
|
+
}, (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0].optionInfo) ? materialSurvey.questionInfoList[0].optionInfo.map((option, index) => {
|
|
141
|
+
return React.createElement(QuestionRadioOption, {
|
|
142
|
+
key: index,
|
|
143
|
+
value: index
|
|
144
|
+
}, (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? React.createElement(StyledMarkdown, {
|
|
145
|
+
dark: false,
|
|
146
|
+
children: option,
|
|
147
|
+
paddingx: 0,
|
|
148
|
+
paddingy: 0
|
|
149
|
+
}) : option);
|
|
150
|
+
}) : null));
|
|
186
151
|
};
|
|
187
152
|
|
|
188
153
|
export { MaterialSurveySelectOne as default };
|
|
@@ -1,56 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Shimmer, Vspace } from '@elice/blocks';
|
|
3
3
|
import { base } from '@elice/design-tokens';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { useMaterialSurveyState } from './context/MaterialSurveyContext.js';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const StyledShimmer = styled.div.withConfig({
|
|
8
8
|
componentId: "sc-1gtcofd-0"
|
|
9
|
-
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;"],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var StyledShimmerHeader = styled.div.withConfig({
|
|
9
|
+
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;"], ({
|
|
10
|
+
vertical
|
|
11
|
+
}) => vertical ? '0' : '8px');
|
|
12
|
+
const StyledShimmerHeader = styled.div.withConfig({
|
|
14
13
|
componentId: "sc-1gtcofd-1"
|
|
15
14
|
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;height:3.5rem;"], base.color.navy6);
|
|
16
|
-
|
|
15
|
+
const StyledShimmerBody = styled.div.withConfig({
|
|
17
16
|
componentId: "sc-1gtcofd-2"
|
|
18
17
|
})(["padding:1.5rem;background-color:", ";overflow-y:auto;height:100%;"], base.color.navy7);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
vertical
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})]
|
|
53
|
-
});
|
|
18
|
+
const MaterialSurveyShimmer = () => {
|
|
19
|
+
const {
|
|
20
|
+
vertical
|
|
21
|
+
} = useMaterialSurveyState();
|
|
22
|
+
return React.createElement(StyledShimmer, {
|
|
23
|
+
vertical: vertical
|
|
24
|
+
}, React.createElement(StyledShimmerHeader, null), React.createElement(StyledShimmerBody, null, React.createElement(Shimmer, {
|
|
25
|
+
dark: true,
|
|
26
|
+
borderRadius: '4px',
|
|
27
|
+
width: "80%",
|
|
28
|
+
height: '40px'
|
|
29
|
+
}), React.createElement(Vspace, {
|
|
30
|
+
height: 1
|
|
31
|
+
}), React.createElement(Shimmer, {
|
|
32
|
+
dark: true,
|
|
33
|
+
borderRadius: '4px',
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: '40px'
|
|
36
|
+
}), React.createElement(Vspace, {
|
|
37
|
+
height: 1
|
|
38
|
+
}), React.createElement(Shimmer, {
|
|
39
|
+
dark: true,
|
|
40
|
+
borderRadius: '4px',
|
|
41
|
+
width: "100%",
|
|
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
|
+
})));
|
|
54
51
|
};
|
|
55
52
|
|
|
56
53
|
export { MaterialSurveyShimmer as default };
|