@elice/material-survey 1.240718.0-trasncript.0 → 1.240718.0-trasncript.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/_virtual/_rollupPluginBabelHelpers.js +399 -0
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-survey/MaterialSurvey.js +82 -57
- package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
- package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
- package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
- package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
- package/cjs/components/material-survey/index.js +9 -0
- package/cjs/components/material-survey/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
- package/cjs/components/material-survey-edit/context.js +8 -2
- package/cjs/components/material-survey-edit/index.js +7 -0
- package/cjs/components/material-survey-edit/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/SurveyContentBox.js +85 -74
- package/cjs/components/shared/index.js +13 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
- package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-survey/MaterialSurvey.js +77 -57
- package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
- package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
- package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
- package/es/components/material-survey/MaterialSurveyText.js +109 -75
- package/es/components/material-survey/SurveyResultBadge.js +13 -10
- package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
- package/es/components/material-survey/index.js +2 -0
- package/es/components/material-survey/locales/index.js +4 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
- package/es/components/material-survey-edit/context.js +4 -2
- package/es/components/material-survey-edit/index.js +1 -0
- package/es/components/material-survey-edit/locales/index.js +4 -0
- package/es/components/material-survey-edit/utils/editValue.js +17 -11
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +81 -74
- package/es/components/shared/index.js +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
- package/package.json +9 -12
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { useMeasure } from 'react-use';
|
|
3
5
|
import { base } from '@elice/design-tokens';
|
|
@@ -10,83 +12,101 @@ import messageKo from './locales/ko.json.js';
|
|
|
10
12
|
import MaterialSurveyShimmer from './MaterialSurveyShimmer.js';
|
|
11
13
|
import MaterialSurveyInfo from './MaterialSurveyInfo.js';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
var AsyncMaterialSurveySelectMultiple = React.lazy(function () {
|
|
16
|
+
return import('./MaterialSurveySelectMultiple.js');
|
|
17
|
+
});
|
|
18
|
+
var AsyncMaterialSurveyText = React.lazy(function () {
|
|
19
|
+
return import('./MaterialSurveyText.js');
|
|
20
|
+
});
|
|
21
|
+
var AsyncMaterialSurveySelectOne = React.lazy(function () {
|
|
22
|
+
return import('./MaterialSurveySelectOne.js');
|
|
23
|
+
});
|
|
24
|
+
var StyledMaterialSurveyInfo = styled.div.withConfig({
|
|
17
25
|
componentId: "sc-1fyzkvm-0"
|
|
18
26
|
})([""]);
|
|
19
|
-
|
|
27
|
+
var StyledMaterialSurveyContent = styled.div.withConfig({
|
|
20
28
|
componentId: "sc-1fyzkvm-1"
|
|
21
29
|
})([""]);
|
|
22
|
-
|
|
30
|
+
var StyledMaterialSurveyWrapper = styled.div.withConfig({
|
|
23
31
|
componentId: "sc-1fyzkvm-2"
|
|
24
|
-
})(["display:flex;height:100%;flex-direction:", ";& > *{flex:", ";}& > *:first-child{margin-right:", ";margin-bottom:", ";}", "{height:", ";overflow-y:", ";}"], ({
|
|
25
|
-
vertical
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
vertical
|
|
30
|
-
}
|
|
31
|
-
vertical
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
vertical
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
})(["display:flex;height:100%;flex-direction:", ";& > *{flex:", ";}& > *:first-child{margin-right:", ";margin-bottom:", ";}", "{height:", ";overflow-y:", ";}"], function (_ref) {
|
|
33
|
+
var vertical = _ref.vertical;
|
|
34
|
+
return vertical ? 'column' : 'row';
|
|
35
|
+
}, function (_ref2) {
|
|
36
|
+
var vertical = _ref2.vertical;
|
|
37
|
+
return vertical ? 'auto' : '1 0 calc(50% - 1rem);';
|
|
38
|
+
}, function (_ref3) {
|
|
39
|
+
var vertical = _ref3.vertical;
|
|
40
|
+
return vertical ? '0' : '1rem';
|
|
41
|
+
}, function (_ref4) {
|
|
42
|
+
var vertical = _ref4.vertical;
|
|
43
|
+
return vertical ? '1rem' : '0';
|
|
44
|
+
}, StyledMaterialSurveyInfo, function (_ref5) {
|
|
45
|
+
var vertical = _ref5.vertical;
|
|
46
|
+
return vertical ? 'auto' : '100%';
|
|
47
|
+
}, function (_ref6) {
|
|
48
|
+
var vertical = _ref6.vertical;
|
|
49
|
+
return vertical ? 'intial' : 'auto';
|
|
50
|
+
});
|
|
51
|
+
var MaterialSurvey = function MaterialSurvey() {
|
|
52
|
+
var _useMaterialSurveySta = useMaterialSurveyState(),
|
|
53
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey,
|
|
54
|
+
vertical = _useMaterialSurveySta.vertical;
|
|
55
|
+
var _useMaterialSurveyDis = useMaterialSurveyDispatch(),
|
|
56
|
+
setVertical = _useMaterialSurveyDis.setVertical;
|
|
57
|
+
var _useMeasure = useMeasure(),
|
|
58
|
+
_useMeasure2 = _slicedToArray(_useMeasure, 2),
|
|
59
|
+
ref = _useMeasure2[0],
|
|
60
|
+
width = _useMeasure2[1].width;
|
|
61
|
+
React.useEffect(function () {
|
|
49
62
|
if (width > 0) {
|
|
50
63
|
setVertical(width <= base.screen.medium);
|
|
51
64
|
}
|
|
52
65
|
}, [width, setVertical]);
|
|
53
|
-
|
|
66
|
+
var Component = null;
|
|
54
67
|
switch (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0].optionType) {
|
|
55
68
|
case enums.SurveyOptionType.SelectOne:
|
|
56
|
-
Component =
|
|
69
|
+
Component = jsx(AsyncMaterialSurveySelectOne, {});
|
|
57
70
|
break;
|
|
58
71
|
case enums.SurveyOptionType.SelectMultiple:
|
|
59
|
-
Component =
|
|
72
|
+
Component = jsx(AsyncMaterialSurveySelectMultiple, {});
|
|
60
73
|
break;
|
|
61
74
|
case enums.SurveyOptionType.Text:
|
|
62
|
-
Component =
|
|
75
|
+
Component = jsx(AsyncMaterialSurveyText, {});
|
|
63
76
|
break;
|
|
64
77
|
default:
|
|
65
|
-
Component =
|
|
78
|
+
Component = jsx(MaterialSurveyShimmer, {});
|
|
66
79
|
break;
|
|
67
80
|
}
|
|
68
|
-
return
|
|
69
|
-
fallback: null
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
return jsx(React.Suspense, {
|
|
82
|
+
fallback: null,
|
|
83
|
+
children: jsxs(StyledMaterialSurveyWrapper, {
|
|
84
|
+
ref: ref,
|
|
85
|
+
vertical: vertical,
|
|
86
|
+
children: [jsx(StyledMaterialSurveyInfo, {
|
|
87
|
+
children: jsx(MaterialSurveyInfo, {})
|
|
88
|
+
}), jsx(StyledMaterialSurveyContent, {
|
|
89
|
+
children: Component
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
74
93
|
};
|
|
75
|
-
|
|
76
|
-
materialSurveyId,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
var MaterialSurveyContainer = function MaterialSurveyContainer(_ref7) {
|
|
95
|
+
var materialSurveyId = _ref7.materialSurveyId,
|
|
96
|
+
userId = _ref7.userId,
|
|
97
|
+
onSubmit = _ref7.onSubmit,
|
|
98
|
+
onNext = _ref7.onNext,
|
|
99
|
+
__intl = _ref7.__intl;
|
|
100
|
+
return jsx(RawEliceIntlProvider, {
|
|
101
|
+
value: __intl,
|
|
102
|
+
children: jsx(MaterialSurveyProvider, {
|
|
103
|
+
materialSurveyId: materialSurveyId,
|
|
104
|
+
userId: userId,
|
|
105
|
+
onSubmit: onSubmit,
|
|
106
|
+
onNext: onNext,
|
|
107
|
+
children: jsx(MaterialSurvey, {})
|
|
108
|
+
})
|
|
109
|
+
});
|
|
90
110
|
};
|
|
91
111
|
var MaterialSurvey$1 = new IntlComponentBuilder(MaterialSurveyContainer).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
|
|
92
112
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Flex, Text, Shimmer, Vspace } from '@elice/blocks';
|
|
3
3
|
import { base } from '@elice/design-tokens';
|
|
4
4
|
import { MarkdownSSR } from '@elice/markdown';
|
|
@@ -7,66 +7,72 @@ import styled from 'styled-components';
|
|
|
7
7
|
import SurveyContentBox from '../shared/SurveyContentBox.js';
|
|
8
8
|
import { useMaterialSurveyState } from './context/MaterialSurveyContext.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var StyledMarkdownSSR = styled(MarkdownSSR).withConfig({
|
|
11
11
|
componentId: "sc-1b9l43w-0"
|
|
12
12
|
})(["", ""], EliceWysiwygEditorTheme.resetMarkdownSSR);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
materialSurvey
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
13
|
+
var MaterialSurveyInfo = function MaterialSurveyInfo() {
|
|
14
|
+
var _useMaterialSurveySta = useMaterialSurveyState(),
|
|
15
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey;
|
|
16
|
+
return jsxs(SurveyContentBox, {
|
|
17
|
+
title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title,
|
|
18
|
+
children: [materialSurvey ? jsxs(Flex, {
|
|
19
|
+
children: [jsx(Text, {
|
|
20
|
+
bold: true,
|
|
21
|
+
size: "large",
|
|
22
|
+
customStyles: {
|
|
23
|
+
color: base.color.primary3,
|
|
24
|
+
marginRight: '0.5rem'
|
|
25
|
+
},
|
|
26
|
+
children: 'Q.'
|
|
27
|
+
}), jsx(Text, {
|
|
28
|
+
bold: true,
|
|
29
|
+
role: "white",
|
|
30
|
+
size: "large",
|
|
31
|
+
wordBreak: "break-word",
|
|
32
|
+
children: materialSurvey.questionInfoList[0].questionTitle
|
|
33
|
+
})]
|
|
34
|
+
}) : jsx(Shimmer, {
|
|
35
|
+
dark: true,
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
width: "80%",
|
|
38
|
+
height: '40px'
|
|
39
|
+
}), jsx(Vspace, {
|
|
40
|
+
height: 1
|
|
41
|
+
}), materialSurvey ? jsx(StyledMarkdownSSR, {
|
|
42
|
+
children: materialSurvey.questionInfoList[0].questionDescription,
|
|
43
|
+
dark: true,
|
|
44
|
+
paddingx: 0,
|
|
45
|
+
paddingy: 0
|
|
46
|
+
}) : jsxs(Fragment, {
|
|
47
|
+
children: [jsx(Shimmer, {
|
|
48
|
+
dark: true,
|
|
49
|
+
borderRadius: '4px',
|
|
50
|
+
width: "80%",
|
|
51
|
+
height: '40px'
|
|
52
|
+
}), jsx(Vspace, {
|
|
53
|
+
height: 1
|
|
54
|
+
}), jsx(Shimmer, {
|
|
55
|
+
dark: true,
|
|
56
|
+
borderRadius: '4px',
|
|
57
|
+
width: "100%",
|
|
58
|
+
height: '40px'
|
|
59
|
+
}), jsx(Vspace, {
|
|
60
|
+
height: 1
|
|
61
|
+
}), jsx(Shimmer, {
|
|
62
|
+
dark: true,
|
|
63
|
+
borderRadius: '4px',
|
|
64
|
+
width: "100%",
|
|
65
|
+
height: '40px'
|
|
66
|
+
}), jsx(Vspace, {
|
|
67
|
+
height: 1
|
|
68
|
+
}), jsx(Shimmer, {
|
|
69
|
+
dark: true,
|
|
70
|
+
borderRadius: '4px',
|
|
71
|
+
width: "100%",
|
|
72
|
+
height: '40px'
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
70
76
|
};
|
|
71
77
|
|
|
72
78
|
export { MaterialSurveyInfo as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
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';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
|
|
3
5
|
import { useRawEliceIntl } from '@elice/intl';
|
|
@@ -12,52 +14,57 @@ import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/Mat
|
|
|
12
14
|
import SurveyResultBadge from './SurveyResultBadge.js';
|
|
13
15
|
import SurveySubmitStatusText from './SurveySubmitStatusText.js';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
|
|
16
18
|
var _a;
|
|
17
19
|
// context
|
|
18
|
-
|
|
19
|
-
course,
|
|
20
|
-
lecture,
|
|
21
|
-
materialSurvey,
|
|
22
|
-
userId
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
refreshOrgMaterialSurvey
|
|
28
|
-
} = useMaterialSurveyDispatch();
|
|
20
|
+
var _useMaterialSurveySta = useMaterialSurveyState(),
|
|
21
|
+
course = _useMaterialSurveySta.course,
|
|
22
|
+
lecture = _useMaterialSurveySta.lecture,
|
|
23
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey,
|
|
24
|
+
userId = _useMaterialSurveySta.userId;
|
|
25
|
+
var _useMaterialSurveyDis = useMaterialSurveyDispatch(),
|
|
26
|
+
onSubmit = _useMaterialSurveyDis.onSubmit,
|
|
27
|
+
onNext = _useMaterialSurveyDis.onNext,
|
|
28
|
+
refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
|
|
29
29
|
// state
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
var intl = useRawEliceIntl();
|
|
31
|
+
var _React$useState = React.useState([]),
|
|
32
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
33
|
+
selectedAnswer = _React$useState2[0],
|
|
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];
|
|
34
43
|
// survey response fetcher
|
|
35
|
-
React.useEffect(()
|
|
44
|
+
React.useEffect(function () {
|
|
36
45
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
signal
|
|
40
|
-
} = controller;
|
|
46
|
+
var controller = new AbortController();
|
|
47
|
+
var signal = controller.signal;
|
|
41
48
|
getOrgMaterialSurveyResponseGet({
|
|
42
49
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
43
50
|
}, {
|
|
44
|
-
signal
|
|
45
|
-
}).then(response
|
|
51
|
+
signal: signal
|
|
52
|
+
}).then(function (response) {
|
|
46
53
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
47
54
|
setSelectedAnswer(response.surveyResponse.answers[0]);
|
|
48
|
-
}).catch(error
|
|
55
|
+
}).catch(function (error) {
|
|
49
56
|
console.error(error);
|
|
50
57
|
});
|
|
51
|
-
return ()
|
|
58
|
+
return function () {
|
|
59
|
+
return controller.abort();
|
|
60
|
+
};
|
|
52
61
|
}
|
|
53
62
|
}, [materialSurvey, userId]);
|
|
54
63
|
// survey response fetcher
|
|
55
|
-
React.useEffect(()
|
|
64
|
+
React.useEffect(function () {
|
|
56
65
|
if (userId && materialSurvey) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
signal
|
|
60
|
-
} = controller;
|
|
66
|
+
var controller = new AbortController();
|
|
67
|
+
var signal = controller.signal;
|
|
61
68
|
getOrgMaterialSurveyResponseList({
|
|
62
69
|
materialSurveyId: materialSurvey.id,
|
|
63
70
|
filterUserIds: [userId],
|
|
@@ -66,10 +73,10 @@ const MaterialSurveySelectMultiple = () => {
|
|
|
66
73
|
offset: 0,
|
|
67
74
|
count: 1
|
|
68
75
|
}, {
|
|
69
|
-
signal
|
|
70
|
-
}).then(response
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
signal: signal
|
|
77
|
+
}).then(function (response) {
|
|
78
|
+
var surveyResponse = response.surveyResponses[0];
|
|
79
|
+
var getAnswer = function getAnswer() {
|
|
73
80
|
if (!surveyResponse) {
|
|
74
81
|
return [];
|
|
75
82
|
}
|
|
@@ -83,49 +90,75 @@ const MaterialSurveySelectMultiple = () => {
|
|
|
83
90
|
};
|
|
84
91
|
setMaterialSurveyResponse(surveyResponse);
|
|
85
92
|
setSelectedAnswer(getAnswer());
|
|
86
|
-
}).catch(error
|
|
93
|
+
}).catch(function (error) {
|
|
87
94
|
console.error(error);
|
|
88
95
|
});
|
|
89
|
-
return ()
|
|
96
|
+
return function () {
|
|
97
|
+
return controller.abort();
|
|
98
|
+
};
|
|
90
99
|
}
|
|
91
100
|
}, [materialSurvey, userId]);
|
|
92
101
|
// submit handler
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
102
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
103
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
104
|
+
var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
|
|
105
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
106
|
+
while (1) switch (_context.prev = _context.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
if (materialSurvey) {
|
|
109
|
+
_context.next = 2;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return _context.abrupt("return");
|
|
113
|
+
case 2:
|
|
114
|
+
setSubmitStatus('pending');
|
|
115
|
+
_context.prev = 3;
|
|
116
|
+
_context.next = 6;
|
|
117
|
+
return postOrgMaterialSurveyResponseAdd({
|
|
118
|
+
materialSurveyId: materialSurvey.id,
|
|
119
|
+
answers: [selectedAnswer]
|
|
120
|
+
});
|
|
121
|
+
case 6:
|
|
122
|
+
_yield$postOrgMateria = _context.sent;
|
|
123
|
+
surveyResponseId = _yield$postOrgMateria.surveyResponseId;
|
|
124
|
+
_context.next = 10;
|
|
125
|
+
return getOrgMaterialSurveyResponseGet({
|
|
126
|
+
surveyResponseId: surveyResponseId
|
|
127
|
+
});
|
|
128
|
+
case 10:
|
|
129
|
+
_yield$getOrgMaterial = _context.sent;
|
|
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, {
|
|
121
154
|
title: intl.formatMessage({
|
|
122
155
|
id: 'materialSurvey.myAnswer'
|
|
123
156
|
}),
|
|
124
157
|
onNext: onNext,
|
|
125
|
-
submitResult:
|
|
158
|
+
submitResult: jsx(SurveyResultBadge, {
|
|
126
159
|
materialSurveyResponse: materialSurveyResponse
|
|
127
160
|
}),
|
|
128
|
-
submitStatus:
|
|
161
|
+
submitStatus: jsx(SurveySubmitStatusText, {
|
|
129
162
|
status: submitStatus
|
|
130
163
|
}),
|
|
131
164
|
footerActions: [{
|
|
@@ -139,30 +172,34 @@ const MaterialSurveySelectMultiple = () => {
|
|
|
139
172
|
children: intl.formatMessage({
|
|
140
173
|
id: 'materialSurvey.submit'
|
|
141
174
|
})
|
|
142
|
-
}]
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
}],
|
|
176
|
+
children: jsx(QuestionCheckbox, {
|
|
177
|
+
onSelect: function onSelect(index) {
|
|
178
|
+
if (checkUserLectureTestEnded(lecture) || !!userId) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
setSelectedAnswer(function (prevState) {
|
|
182
|
+
var newState = prevState.includes(index) ? prevState.filter(function (ident) {
|
|
183
|
+
return ident !== index;
|
|
184
|
+
}) : [].concat(_toConsumableArray(prevState), [index]);
|
|
185
|
+
return newState;
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
selectedOptions: selectedAnswer,
|
|
189
|
+
disabled: submitStatus === 'pending' || checkUserLectureTestEnded(lecture) || !!userId,
|
|
190
|
+
children: (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0]) ? (_a = materialSurvey.questionInfoList[0].optionInfo) === null || _a === void 0 ? void 0 : _a.map(function (option, index) {
|
|
191
|
+
return jsx(QuestionCheckboxOption, {
|
|
192
|
+
value: index,
|
|
193
|
+
children: (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? jsx(StyledMarkdown, {
|
|
194
|
+
dark: false,
|
|
195
|
+
children: option,
|
|
196
|
+
paddingx: 0,
|
|
197
|
+
paddingy: 0
|
|
198
|
+
}) : option
|
|
199
|
+
}, index);
|
|
200
|
+
}) : null
|
|
201
|
+
})
|
|
202
|
+
});
|
|
166
203
|
};
|
|
167
204
|
|
|
168
205
|
export { MaterialSurveySelectMultiple as default };
|