@elice/material-quiz 1.230220.2 → 1.230306.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/cjs/components/material-quiz/MaterialQuiz.i18n.js +2 -2
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +21 -30
- package/es/components/material-quiz/MaterialQuiz.i18n.js +2 -2
- package/es/components/material-quiz/context/MaterialQuizContext.js +22 -31
- package/package.json +8 -8
|
@@ -41,8 +41,8 @@ const ko = {
|
|
|
41
41
|
'materialQuiz.submittedAnswer': '제출한 답',
|
|
42
42
|
'materialQuiz.answer': '정답',
|
|
43
43
|
'materialQuiz.next': '다음 문제로 이동 >',
|
|
44
|
-
'materialQuiz.selectOne.answer.title': '
|
|
45
|
-
'materialQuiz.selectMultiple.answer.title': '
|
|
44
|
+
'materialQuiz.selectOne.answer.title': '알맞은 답을 선택해 주세요.',
|
|
45
|
+
'materialQuiz.selectMultiple.answer.title': '알맞은 답을 선택해 주세요. (중복 선택 가능)',
|
|
46
46
|
'materialQuiz.selectMultipleOrder.answer.title': '답안을 드래그 앤 드롭하세요.',
|
|
47
47
|
'materialQuiz.text.answer.title': '답안을 작성해 주세요.',
|
|
48
48
|
'materialQuiz.empty.title': '퀴즈가 준비 중 입니다.',
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var apiClient = require('@elice/api-client');
|
|
7
7
|
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
8
|
+
var types = require('@elice/types');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
11
|
|
|
@@ -25,10 +26,18 @@ function MaterialQuizProvider({
|
|
|
25
26
|
}) {
|
|
26
27
|
const [course, setCourse] = React__default["default"].useState();
|
|
27
28
|
const [lecture, setLecture] = React__default["default"].useState();
|
|
28
|
-
const [materialQuiz, setMaterialQuiz] = React__default["default"].useState();
|
|
29
29
|
const [initStatus, setInitStatus] = React__default["default"].useState('idle');
|
|
30
30
|
const [vertical, setVertical] = React__default["default"].useState(false);
|
|
31
31
|
const canInit = materialSharedUtils.useMaterialConfigApiClientUpdate(apiClient.config.init);
|
|
32
|
+
const {
|
|
33
|
+
materialQuiz,
|
|
34
|
+
materialLecturePage,
|
|
35
|
+
refetch: refreshOrgMaterialQuiz
|
|
36
|
+
} = materialSharedUtils.useMaterialFetchRaw(types.enums.LectureMaterialType.Quiz, React__default["default"].useCallback(signal => apiClient.getOrgMaterialQuizGet({
|
|
37
|
+
materialQuizId
|
|
38
|
+
}, {
|
|
39
|
+
signal
|
|
40
|
+
}), [materialQuizId]), canInit);
|
|
32
41
|
const init = React__default["default"].useCallback(async () => {
|
|
33
42
|
const controller = new AbortController();
|
|
34
43
|
const {
|
|
@@ -36,20 +45,17 @@ function MaterialQuizProvider({
|
|
|
36
45
|
} = controller;
|
|
37
46
|
|
|
38
47
|
try {
|
|
39
|
-
setInitStatus('pending');
|
|
48
|
+
setInitStatus('pending');
|
|
49
|
+
|
|
50
|
+
if (!materialLecturePage) {
|
|
51
|
+
throw new Error('materialSurvey is not ready');
|
|
52
|
+
} // fetch course
|
|
40
53
|
|
|
41
|
-
const {
|
|
42
|
-
materialQuiz
|
|
43
|
-
} = await apiClient.getOrgMaterialQuizGet({
|
|
44
|
-
materialQuizId
|
|
45
|
-
}, {
|
|
46
|
-
signal
|
|
47
|
-
}); // fetch course
|
|
48
54
|
|
|
49
55
|
const {
|
|
50
56
|
course
|
|
51
57
|
} = await apiClient.getOrgCourseGet({
|
|
52
|
-
courseId:
|
|
58
|
+
courseId: materialLecturePage.courseId
|
|
53
59
|
}, {
|
|
54
60
|
signal
|
|
55
61
|
}); // fetch lecture
|
|
@@ -57,11 +63,10 @@ function MaterialQuizProvider({
|
|
|
57
63
|
const {
|
|
58
64
|
lecture
|
|
59
65
|
} = await apiClient.getOrgLectureGet({
|
|
60
|
-
lectureId:
|
|
66
|
+
lectureId: materialLecturePage.lectureId
|
|
61
67
|
}, {
|
|
62
68
|
signal
|
|
63
69
|
});
|
|
64
|
-
setMaterialQuiz(materialQuiz);
|
|
65
70
|
setCourse(course);
|
|
66
71
|
setLecture(lecture);
|
|
67
72
|
setInitStatus('resolved');
|
|
@@ -71,31 +76,17 @@ function MaterialQuizProvider({
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
return () => controller.abort();
|
|
74
|
-
}, [
|
|
79
|
+
}, [materialLecturePage]);
|
|
75
80
|
React__default["default"].useEffect(() => {
|
|
76
|
-
if (canInit) {
|
|
81
|
+
if (canInit && materialLecturePage) {
|
|
77
82
|
void init();
|
|
78
83
|
}
|
|
79
|
-
}, [canInit, init]);
|
|
80
|
-
//
|
|
81
|
-
// materialQuiz refresher
|
|
82
|
-
|
|
83
|
-
const refreshOrgMaterialQuiz = React__default["default"].useCallback(signal => {
|
|
84
|
-
return apiClient.getOrgMaterialQuizGet({
|
|
85
|
-
materialQuizId
|
|
86
|
-
}, {
|
|
87
|
-
signal
|
|
88
|
-
}).then(response => {
|
|
89
|
-
setMaterialQuiz(response.materialQuiz);
|
|
90
|
-
}).catch(error => {
|
|
91
|
-
console.error(error);
|
|
92
|
-
});
|
|
93
|
-
}, [materialQuizId]);
|
|
84
|
+
}, [canInit, materialLecturePage, init]);
|
|
94
85
|
return React__default["default"].createElement(StateContext.Provider, {
|
|
95
86
|
value: {
|
|
96
87
|
course,
|
|
97
88
|
lecture,
|
|
98
|
-
materialQuiz,
|
|
89
|
+
materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
|
|
99
90
|
userId,
|
|
100
91
|
vertical,
|
|
101
92
|
initStatus
|
|
@@ -37,8 +37,8 @@ const ko = {
|
|
|
37
37
|
'materialQuiz.submittedAnswer': '제출한 답',
|
|
38
38
|
'materialQuiz.answer': '정답',
|
|
39
39
|
'materialQuiz.next': '다음 문제로 이동 >',
|
|
40
|
-
'materialQuiz.selectOne.answer.title': '
|
|
41
|
-
'materialQuiz.selectMultiple.answer.title': '
|
|
40
|
+
'materialQuiz.selectOne.answer.title': '알맞은 답을 선택해 주세요.',
|
|
41
|
+
'materialQuiz.selectMultiple.answer.title': '알맞은 답을 선택해 주세요. (중복 선택 가능)',
|
|
42
42
|
'materialQuiz.selectMultipleOrder.answer.title': '답안을 드래그 앤 드롭하세요.',
|
|
43
43
|
'materialQuiz.text.answer.title': '답안을 작성해 주세요.',
|
|
44
44
|
'materialQuiz.empty.title': '퀴즈가 준비 중 입니다.',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { config, getOrgMaterialQuizGet, getOrgCourseGet, getOrgLectureGet } from '@elice/api-client';
|
|
3
|
-
import { useMaterialConfigApiClientUpdate } from '@elice/material-shared-utils';
|
|
3
|
+
import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
|
|
4
|
+
import { enums } from '@elice/types';
|
|
4
5
|
|
|
5
6
|
const StateContext = React.createContext(undefined);
|
|
6
7
|
const DispatchContext = React.createContext(undefined);
|
|
@@ -17,10 +18,18 @@ function MaterialQuizProvider({
|
|
|
17
18
|
}) {
|
|
18
19
|
const [course, setCourse] = React.useState();
|
|
19
20
|
const [lecture, setLecture] = React.useState();
|
|
20
|
-
const [materialQuiz, setMaterialQuiz] = React.useState();
|
|
21
21
|
const [initStatus, setInitStatus] = React.useState('idle');
|
|
22
22
|
const [vertical, setVertical] = React.useState(false);
|
|
23
23
|
const canInit = useMaterialConfigApiClientUpdate(config.init);
|
|
24
|
+
const {
|
|
25
|
+
materialQuiz,
|
|
26
|
+
materialLecturePage,
|
|
27
|
+
refetch: refreshOrgMaterialQuiz
|
|
28
|
+
} = useMaterialFetchRaw(enums.LectureMaterialType.Quiz, React.useCallback(signal => getOrgMaterialQuizGet({
|
|
29
|
+
materialQuizId
|
|
30
|
+
}, {
|
|
31
|
+
signal
|
|
32
|
+
}), [materialQuizId]), canInit);
|
|
24
33
|
const init = React.useCallback(async () => {
|
|
25
34
|
const controller = new AbortController();
|
|
26
35
|
const {
|
|
@@ -28,20 +37,17 @@ function MaterialQuizProvider({
|
|
|
28
37
|
} = controller;
|
|
29
38
|
|
|
30
39
|
try {
|
|
31
|
-
setInitStatus('pending');
|
|
40
|
+
setInitStatus('pending');
|
|
41
|
+
|
|
42
|
+
if (!materialLecturePage) {
|
|
43
|
+
throw new Error('materialSurvey is not ready');
|
|
44
|
+
} // fetch course
|
|
32
45
|
|
|
33
|
-
const {
|
|
34
|
-
materialQuiz
|
|
35
|
-
} = await getOrgMaterialQuizGet({
|
|
36
|
-
materialQuizId
|
|
37
|
-
}, {
|
|
38
|
-
signal
|
|
39
|
-
}); // fetch course
|
|
40
46
|
|
|
41
47
|
const {
|
|
42
48
|
course
|
|
43
49
|
} = await getOrgCourseGet({
|
|
44
|
-
courseId:
|
|
50
|
+
courseId: materialLecturePage.courseId
|
|
45
51
|
}, {
|
|
46
52
|
signal
|
|
47
53
|
}); // fetch lecture
|
|
@@ -49,11 +55,10 @@ function MaterialQuizProvider({
|
|
|
49
55
|
const {
|
|
50
56
|
lecture
|
|
51
57
|
} = await getOrgLectureGet({
|
|
52
|
-
lectureId:
|
|
58
|
+
lectureId: materialLecturePage.lectureId
|
|
53
59
|
}, {
|
|
54
60
|
signal
|
|
55
61
|
});
|
|
56
|
-
setMaterialQuiz(materialQuiz);
|
|
57
62
|
setCourse(course);
|
|
58
63
|
setLecture(lecture);
|
|
59
64
|
setInitStatus('resolved');
|
|
@@ -63,31 +68,17 @@ function MaterialQuizProvider({
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
return () => controller.abort();
|
|
66
|
-
}, [
|
|
71
|
+
}, [materialLecturePage]);
|
|
67
72
|
React.useEffect(() => {
|
|
68
|
-
if (canInit) {
|
|
73
|
+
if (canInit && materialLecturePage) {
|
|
69
74
|
void init();
|
|
70
75
|
}
|
|
71
|
-
}, [canInit, init]);
|
|
72
|
-
//
|
|
73
|
-
// materialQuiz refresher
|
|
74
|
-
|
|
75
|
-
const refreshOrgMaterialQuiz = React.useCallback(signal => {
|
|
76
|
-
return getOrgMaterialQuizGet({
|
|
77
|
-
materialQuizId
|
|
78
|
-
}, {
|
|
79
|
-
signal
|
|
80
|
-
}).then(response => {
|
|
81
|
-
setMaterialQuiz(response.materialQuiz);
|
|
82
|
-
}).catch(error => {
|
|
83
|
-
console.error(error);
|
|
84
|
-
});
|
|
85
|
-
}, [materialQuizId]);
|
|
76
|
+
}, [canInit, materialLecturePage, init]);
|
|
86
77
|
return React.createElement(StateContext.Provider, {
|
|
87
78
|
value: {
|
|
88
79
|
course,
|
|
89
80
|
lecture,
|
|
90
|
-
materialQuiz,
|
|
81
|
+
materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
|
|
91
82
|
userId,
|
|
92
83
|
vertical,
|
|
93
84
|
initStatus
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-quiz",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.230306.0",
|
|
4
4
|
"description": "User view and editing components of Elice material quiz",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@elice/api-client": "1.
|
|
32
|
+
"@elice/api-client": "^1.230306.0",
|
|
33
33
|
"@elice/blocks": "^1.220803.0",
|
|
34
34
|
"@elice/design-tokens": "^1.220803.0",
|
|
35
35
|
"@elice/icons": "^1.220803.0",
|
|
36
36
|
"@elice/markdown": "^1.220803.0",
|
|
37
37
|
"@elice/material-shared-types": "*",
|
|
38
38
|
"@elice/material-shared-utils": "*",
|
|
39
|
-
"@elice/types": "1.
|
|
39
|
+
"@elice/types": "^1.230306.0",
|
|
40
40
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
41
41
|
"react-intl": "^5.0.0",
|
|
42
42
|
"react-use": "^17.0.0",
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"tslib": "^2.3.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@elice/api-client": "1.
|
|
55
|
+
"@elice/api-client": "^1.230306.0",
|
|
56
56
|
"@elice/blocks": "1.220930.0",
|
|
57
57
|
"@elice/design-tokens": "^1.220803.0",
|
|
58
58
|
"@elice/icons": "^1.220803.0",
|
|
59
59
|
"@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
|
|
60
60
|
"@elice/markdown": "^1.220803.0",
|
|
61
|
-
"@elice/material-shared-types": "1.
|
|
62
|
-
"@elice/material-shared-utils": "1.
|
|
63
|
-
"@elice/types": "1.
|
|
61
|
+
"@elice/material-shared-types": "1.230306.0",
|
|
62
|
+
"@elice/material-shared-utils": "1.230306.0",
|
|
63
|
+
"@elice/types": "^1.230306.0",
|
|
64
64
|
"@types/classnames": "^2.3.1",
|
|
65
65
|
"@types/jquery": "^3.5.13",
|
|
66
66
|
"@types/jqueryui": "^1.12.16",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-use": "^17.2.4",
|
|
74
74
|
"styled-components": "^5.3.0"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "2ba30b7324d9fd782970a0343a6573827159b737"
|
|
77
77
|
}
|