@elice/material-quiz 1.240811.0 → 1.240814.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.js +12 -7
- package/cjs/components/material-quiz/context/CourseApiContext.d.ts +14 -0
- package/cjs/components/material-quiz/context/CourseApiContext.js +58 -0
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +4 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +40 -20
- package/cjs/components/shared/QuestionBox.js +3 -2
- package/es/components/material-quiz/MaterialQuiz.js +12 -7
- package/es/components/material-quiz/context/CourseApiContext.d.ts +14 -0
- package/es/components/material-quiz/context/CourseApiContext.js +48 -0
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +4 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +40 -20
- package/es/components/shared/QuestionBox.js +3 -2
- package/package.json +5 -3
|
@@ -13,6 +13,7 @@ var types = require('@elice/types');
|
|
|
13
13
|
var material = require('@mui/material');
|
|
14
14
|
var styled = require('styled-components');
|
|
15
15
|
var element = require('../../constant/element.js');
|
|
16
|
+
var CourseApiContext = require('./context/CourseApiContext.js');
|
|
16
17
|
var MaterialQuizContext = require('./context/MaterialQuizContext.js');
|
|
17
18
|
var en = require('./locales/en.json.js');
|
|
18
19
|
var ko = require('./locales/ko.json.js');
|
|
@@ -147,6 +148,7 @@ var MaterialQuiz = function MaterialQuiz() {
|
|
|
147
148
|
var MaterialQuizContainer = function MaterialQuizContainer(_ref7) {
|
|
148
149
|
var materialQuizId = _ref7.materialQuizId,
|
|
149
150
|
userId = _ref7.userId,
|
|
151
|
+
eliceCourseApiConfiguration = _ref7.eliceCourseApiConfiguration,
|
|
150
152
|
onDirty = _ref7.onDirty,
|
|
151
153
|
onSubmit = _ref7.onSubmit,
|
|
152
154
|
onNext = _ref7.onNext,
|
|
@@ -155,13 +157,16 @@ var MaterialQuizContainer = function MaterialQuizContainer(_ref7) {
|
|
|
155
157
|
value: __intl,
|
|
156
158
|
children: jsxRuntime.jsx(material.ThemeProvider, {
|
|
157
159
|
theme: eliceTheme,
|
|
158
|
-
children: jsxRuntime.jsx(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
children: jsxRuntime.jsx(CourseApiContext.default, {
|
|
161
|
+
eliceCourseApiConfiguration: eliceCourseApiConfiguration,
|
|
162
|
+
children: jsxRuntime.jsx(MaterialQuizContext.MaterialQuizProvider, {
|
|
163
|
+
materialQuizId: materialQuizId,
|
|
164
|
+
userId: userId,
|
|
165
|
+
onDirty: onDirty,
|
|
166
|
+
onSubmit: onSubmit,
|
|
167
|
+
onNext: onNext,
|
|
168
|
+
children: jsxRuntime.jsx(MaterialQuiz, {})
|
|
169
|
+
})
|
|
165
170
|
})
|
|
166
171
|
})
|
|
167
172
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CourseApi as EliceCourseCourseApi } from '@elice/openapi-client-course';
|
|
3
|
+
import type { Configuration as EliceCourseApiConfiguration } from '@elice/openapi-client-course';
|
|
4
|
+
export interface CourseApiContextValue {
|
|
5
|
+
course: EliceCourseCourseApi;
|
|
6
|
+
}
|
|
7
|
+
export interface CourseApiContextProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
eliceCourseApiConfiguration: EliceCourseApiConfiguration;
|
|
10
|
+
}
|
|
11
|
+
export declare const CourseApiContext: React.Context<CourseApiContextValue>;
|
|
12
|
+
export declare const useCourseApiContext: () => CourseApiContextValue;
|
|
13
|
+
declare const CourseApiContextProvider: React.FC<CourseApiContextProps>;
|
|
14
|
+
export default CourseApiContextProvider;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var openapiClientCourse = require('@elice/openapi-client-course');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
var CourseApiContext = React__default.default.createContext({});
|
|
18
|
+
var useCourseApiContext = function useCourseApiContext() {
|
|
19
|
+
return React__default.default.useContext(CourseApiContext);
|
|
20
|
+
};
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
var CourseApiContextProvider = function CourseApiContextProvider(_ref) {
|
|
25
|
+
var children = _ref.children,
|
|
26
|
+
eliceCourseApiConfiguration = _ref.eliceCourseApiConfiguration;
|
|
27
|
+
var createCourseApi = function createCourseApi() {
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
course: new openapiClientCourse.CourseApi(eliceCourseApiConfiguration)
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
//
|
|
33
|
+
//
|
|
34
|
+
//
|
|
35
|
+
var _React$useState = React__default.default.useState(createCourseApi),
|
|
36
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
37
|
+
courseApi = _React$useState2[0],
|
|
38
|
+
setCourseApi = _React$useState2[1];
|
|
39
|
+
//
|
|
40
|
+
//
|
|
41
|
+
//
|
|
42
|
+
React__default.default.useEffect(function () {
|
|
43
|
+
return setCourseApi(createCourseApi);
|
|
44
|
+
},
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
[eliceCourseApiConfiguration]);
|
|
47
|
+
//
|
|
48
|
+
//
|
|
49
|
+
//
|
|
50
|
+
return jsxRuntime.jsx(CourseApiContext.Provider, {
|
|
51
|
+
children: children,
|
|
52
|
+
value: courseApi
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.CourseApiContext = CourseApiContext;
|
|
57
|
+
exports.default = CourseApiContextProvider;
|
|
58
|
+
exports.useCourseApiContext = useCourseApiContext;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { APIStatus } from '@elice/material-shared-types';
|
|
3
3
|
import type { GetOrgCourseGetResponses, GetOrgLectureGetResponses, GetOrgMaterialQuizGetResponses } from '@elice/types';
|
|
4
|
+
import type { CourseApiContextProps } from './CourseApiContext';
|
|
4
5
|
export interface State {
|
|
5
6
|
course?: GetOrgCourseGetResponses['course'];
|
|
6
7
|
lecture?: GetOrgLectureGetResponses['lecture'];
|
|
@@ -10,16 +11,18 @@ export interface State {
|
|
|
10
11
|
initStatus: APIStatus;
|
|
11
12
|
isLongPassage: boolean;
|
|
12
13
|
isInitialLoading: boolean;
|
|
14
|
+
isRecommendLecture: boolean;
|
|
13
15
|
}
|
|
14
16
|
export type MaterialQuizProps = {
|
|
15
17
|
materialQuizId: number;
|
|
18
|
+
eliceCourseApiConfiguration: CourseApiContextProps['eliceCourseApiConfiguration'];
|
|
16
19
|
userId?: number;
|
|
17
20
|
locale?: string;
|
|
18
21
|
onDirty: (isDirty: boolean) => void;
|
|
19
22
|
onSubmit?: (isSucceeded: boolean, isCorrect?: boolean) => void;
|
|
20
23
|
onNext?: () => void;
|
|
21
24
|
};
|
|
22
|
-
interface MaterialQuizProviderProps extends Omit<MaterialQuizProps, 'locale'> {
|
|
25
|
+
interface MaterialQuizProviderProps extends Omit<MaterialQuizProps, 'locale' | 'eliceCourseApiConfiguration'> {
|
|
23
26
|
children: React.ReactNode;
|
|
24
27
|
}
|
|
25
28
|
interface DispatchContextType {
|
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var apiClient = require('@elice/api-client');
|
|
7
7
|
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
8
8
|
var types = require('@elice/types');
|
|
9
|
+
var CourseApiContext = require('./CourseApiContext.js');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -33,22 +34,28 @@ function MaterialQuizProvider(_ref) {
|
|
|
33
34
|
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
34
35
|
lecture = _React$useState4[0],
|
|
35
36
|
setLecture = _React$useState4[1];
|
|
36
|
-
var
|
|
37
|
+
var _useCourseApiContext = CourseApiContext.useCourseApiContext(),
|
|
38
|
+
eliceCourseApi = _useCourseApiContext.course;
|
|
39
|
+
var _React$useState5 = React__default.default.useState(false),
|
|
37
40
|
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var _React$useState7 = React__default.default.useState(
|
|
41
|
+
isRecommendLecture = _React$useState6[0],
|
|
42
|
+
setIsRecommendLecture = _React$useState6[1];
|
|
43
|
+
var _React$useState7 = React__default.default.useState('idle'),
|
|
41
44
|
_React$useState8 = _rollupPluginBabelHelpers.slicedToArray(_React$useState7, 2),
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
initStatus = _React$useState8[0],
|
|
46
|
+
setInitStatus = _React$useState8[1];
|
|
44
47
|
var _React$useState9 = React__default.default.useState(false),
|
|
45
48
|
_React$useState10 = _rollupPluginBabelHelpers.slicedToArray(_React$useState9, 2),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var _React$useState11 = React__default.default.useState(
|
|
49
|
+
vertical = _React$useState10[0],
|
|
50
|
+
setVertical = _React$useState10[1];
|
|
51
|
+
var _React$useState11 = React__default.default.useState(false),
|
|
49
52
|
_React$useState12 = _rollupPluginBabelHelpers.slicedToArray(_React$useState11, 2),
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
isLongPassage = _React$useState12[0],
|
|
54
|
+
setIsLongPassage = _React$useState12[1];
|
|
55
|
+
var _React$useState13 = React__default.default.useState(true),
|
|
56
|
+
_React$useState14 = _rollupPluginBabelHelpers.slicedToArray(_React$useState13, 2),
|
|
57
|
+
isInitialLoading = _React$useState14[0],
|
|
58
|
+
setIsInitialLoading = _React$useState14[1];
|
|
52
59
|
var canInit = materialSharedUtils.useMaterialConfigApiClientUpdate(apiClient.config.init);
|
|
53
60
|
var resetLayout = function resetLayout() {
|
|
54
61
|
setIsInitialLoading(true);
|
|
@@ -89,7 +96,7 @@ function MaterialQuizProvider(_ref) {
|
|
|
89
96
|
materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
|
|
90
97
|
refreshOrgMaterialQuiz = _useMaterialFetchRaw.refetch;
|
|
91
98
|
var init = React__default.default.useCallback( /*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee2() {
|
|
92
|
-
var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
|
|
99
|
+
var _a, _b, controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture, recommendLectureId;
|
|
93
100
|
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
94
101
|
while (1) switch (_context2.prev = _context2.next) {
|
|
95
102
|
case 0:
|
|
@@ -121,26 +128,38 @@ function MaterialQuizProvider(_ref) {
|
|
|
121
128
|
case 12:
|
|
122
129
|
_yield$getOrgLectureG = _context2.sent;
|
|
123
130
|
_lecture = _yield$getOrgLectureG.lecture;
|
|
131
|
+
_context2.next = 16;
|
|
132
|
+
return eliceCourseApi.courseCourseIdGet({
|
|
133
|
+
courseId: (_a = _course === null || _course === void 0 ? void 0 : _course.id) !== null && _a !== void 0 ? _a : 0,
|
|
134
|
+
eliceCourseId: (_b = _course === null || _course === void 0 ? void 0 : _course.id) !== null && _b !== void 0 ? _b : 0
|
|
135
|
+
}, {
|
|
136
|
+
signal: signal
|
|
137
|
+
}).then(function (eliceCourse) {
|
|
138
|
+
return eliceCourse.recommendLectureId;
|
|
139
|
+
});
|
|
140
|
+
case 16:
|
|
141
|
+
recommendLectureId = _context2.sent;
|
|
124
142
|
setCourse(_course);
|
|
125
143
|
setLecture(_lecture);
|
|
144
|
+
setIsRecommendLecture(_lecture.id === recommendLectureId);
|
|
126
145
|
setInitStatus('resolved');
|
|
127
|
-
_context2.next =
|
|
146
|
+
_context2.next = 27;
|
|
128
147
|
break;
|
|
129
|
-
case
|
|
130
|
-
_context2.prev =
|
|
148
|
+
case 23:
|
|
149
|
+
_context2.prev = 23;
|
|
131
150
|
_context2.t0 = _context2["catch"](2);
|
|
132
151
|
console.error(_context2.t0);
|
|
133
152
|
setInitStatus('rejected');
|
|
134
|
-
case
|
|
153
|
+
case 27:
|
|
135
154
|
return _context2.abrupt("return", function () {
|
|
136
155
|
return controller.abort();
|
|
137
156
|
});
|
|
138
|
-
case
|
|
157
|
+
case 28:
|
|
139
158
|
case "end":
|
|
140
159
|
return _context2.stop();
|
|
141
160
|
}
|
|
142
|
-
}, _callee2, null, [[2,
|
|
143
|
-
})), [materialLecturePage]);
|
|
161
|
+
}, _callee2, null, [[2, 23]]);
|
|
162
|
+
})), [materialLecturePage, eliceCourseApi]);
|
|
144
163
|
React.useEffect(function () {
|
|
145
164
|
if (materialQuizId) {
|
|
146
165
|
resetLayout();
|
|
@@ -160,7 +179,8 @@ function MaterialQuizProvider(_ref) {
|
|
|
160
179
|
vertical: vertical,
|
|
161
180
|
initStatus: initStatus,
|
|
162
181
|
isLongPassage: isLongPassage,
|
|
163
|
-
isInitialLoading: isInitialLoading
|
|
182
|
+
isInitialLoading: isInitialLoading,
|
|
183
|
+
isRecommendLecture: isRecommendLecture
|
|
164
184
|
},
|
|
165
185
|
children: jsxRuntime.jsx(DispatchContext.Provider, {
|
|
166
186
|
value: {
|
|
@@ -88,7 +88,8 @@ var QuestionBox = function QuestionBox(_a) {
|
|
|
88
88
|
var intl$1 = intl.useRawEliceIntl();
|
|
89
89
|
var _useMaterialQuizState = MaterialQuizContext.useMaterialQuizState(),
|
|
90
90
|
vertical = _useMaterialQuizState.vertical,
|
|
91
|
-
isLongPassage = _useMaterialQuizState.isLongPassage
|
|
91
|
+
isLongPassage = _useMaterialQuizState.isLongPassage,
|
|
92
|
+
isRecommendLecture = _useMaterialQuizState.isRecommendLecture;
|
|
92
93
|
var intersectionRef = React__default.default.useRef(null);
|
|
93
94
|
var headerRef = React__default.default.useRef(null);
|
|
94
95
|
var bodyRef = React__default.default.useRef(null);
|
|
@@ -176,7 +177,7 @@ var QuestionBox = function QuestionBox(_a) {
|
|
|
176
177
|
}, action, {
|
|
177
178
|
children: action.children
|
|
178
179
|
}), index);
|
|
179
|
-
}), isNextActive ? jsxRuntime.jsx(StyledPrimaryButton, {
|
|
180
|
+
}), isNextActive && !isRecommendLecture ? jsxRuntime.jsx(StyledPrimaryButton, {
|
|
180
181
|
isFluid: vertical,
|
|
181
182
|
size: "small",
|
|
182
183
|
border: false,
|
|
@@ -9,6 +9,7 @@ import { enums } from '@elice/types';
|
|
|
9
9
|
import { ThemeProvider } from '@mui/material';
|
|
10
10
|
import styled from 'styled-components';
|
|
11
11
|
import { MATERIAL_QUIZ_CONTAINER_ID } from '../../constant/element.js';
|
|
12
|
+
import CourseApiContextProvider from './context/CourseApiContext.js';
|
|
12
13
|
import { MaterialQuizProvider, useMaterialQuizState, useMaterialQuizDispatch } from './context/MaterialQuizContext.js';
|
|
13
14
|
import messageEn from './locales/en.json.js';
|
|
14
15
|
import messageKo from './locales/ko.json.js';
|
|
@@ -138,6 +139,7 @@ var MaterialQuiz = function MaterialQuiz() {
|
|
|
138
139
|
var MaterialQuizContainer = function MaterialQuizContainer(_ref7) {
|
|
139
140
|
var materialQuizId = _ref7.materialQuizId,
|
|
140
141
|
userId = _ref7.userId,
|
|
142
|
+
eliceCourseApiConfiguration = _ref7.eliceCourseApiConfiguration,
|
|
141
143
|
onDirty = _ref7.onDirty,
|
|
142
144
|
onSubmit = _ref7.onSubmit,
|
|
143
145
|
onNext = _ref7.onNext,
|
|
@@ -146,13 +148,16 @@ var MaterialQuizContainer = function MaterialQuizContainer(_ref7) {
|
|
|
146
148
|
value: __intl,
|
|
147
149
|
children: jsx(ThemeProvider, {
|
|
148
150
|
theme: eliceTheme,
|
|
149
|
-
children: jsx(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
children: jsx(CourseApiContextProvider, {
|
|
152
|
+
eliceCourseApiConfiguration: eliceCourseApiConfiguration,
|
|
153
|
+
children: jsx(MaterialQuizProvider, {
|
|
154
|
+
materialQuizId: materialQuizId,
|
|
155
|
+
userId: userId,
|
|
156
|
+
onDirty: onDirty,
|
|
157
|
+
onSubmit: onSubmit,
|
|
158
|
+
onNext: onNext,
|
|
159
|
+
children: jsx(MaterialQuiz, {})
|
|
160
|
+
})
|
|
156
161
|
})
|
|
157
162
|
})
|
|
158
163
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CourseApi as EliceCourseCourseApi } from '@elice/openapi-client-course';
|
|
3
|
+
import type { Configuration as EliceCourseApiConfiguration } from '@elice/openapi-client-course';
|
|
4
|
+
export interface CourseApiContextValue {
|
|
5
|
+
course: EliceCourseCourseApi;
|
|
6
|
+
}
|
|
7
|
+
export interface CourseApiContextProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
eliceCourseApiConfiguration: EliceCourseApiConfiguration;
|
|
10
|
+
}
|
|
11
|
+
export declare const CourseApiContext: React.Context<CourseApiContextValue>;
|
|
12
|
+
export declare const useCourseApiContext: () => CourseApiContextValue;
|
|
13
|
+
declare const CourseApiContextProvider: React.FC<CourseApiContextProps>;
|
|
14
|
+
export default CourseApiContextProvider;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { CourseApi } from '@elice/openapi-client-course';
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
var CourseApiContext = React.createContext({});
|
|
10
|
+
var useCourseApiContext = function useCourseApiContext() {
|
|
11
|
+
return React.useContext(CourseApiContext);
|
|
12
|
+
};
|
|
13
|
+
//
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
var CourseApiContextProvider = function CourseApiContextProvider(_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
eliceCourseApiConfiguration = _ref.eliceCourseApiConfiguration;
|
|
19
|
+
var createCourseApi = function createCourseApi() {
|
|
20
|
+
return Object.freeze({
|
|
21
|
+
course: new CourseApi(eliceCourseApiConfiguration)
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
//
|
|
25
|
+
//
|
|
26
|
+
//
|
|
27
|
+
var _React$useState = React.useState(createCourseApi),
|
|
28
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
29
|
+
courseApi = _React$useState2[0],
|
|
30
|
+
setCourseApi = _React$useState2[1];
|
|
31
|
+
//
|
|
32
|
+
//
|
|
33
|
+
//
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
return setCourseApi(createCourseApi);
|
|
36
|
+
},
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
[eliceCourseApiConfiguration]);
|
|
39
|
+
//
|
|
40
|
+
//
|
|
41
|
+
//
|
|
42
|
+
return jsx(CourseApiContext.Provider, {
|
|
43
|
+
children: children,
|
|
44
|
+
value: courseApi
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { CourseApiContext, CourseApiContextProvider as default, useCourseApiContext };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { APIStatus } from '@elice/material-shared-types';
|
|
3
3
|
import type { GetOrgCourseGetResponses, GetOrgLectureGetResponses, GetOrgMaterialQuizGetResponses } from '@elice/types';
|
|
4
|
+
import type { CourseApiContextProps } from './CourseApiContext';
|
|
4
5
|
export interface State {
|
|
5
6
|
course?: GetOrgCourseGetResponses['course'];
|
|
6
7
|
lecture?: GetOrgLectureGetResponses['lecture'];
|
|
@@ -10,16 +11,18 @@ export interface State {
|
|
|
10
11
|
initStatus: APIStatus;
|
|
11
12
|
isLongPassage: boolean;
|
|
12
13
|
isInitialLoading: boolean;
|
|
14
|
+
isRecommendLecture: boolean;
|
|
13
15
|
}
|
|
14
16
|
export type MaterialQuizProps = {
|
|
15
17
|
materialQuizId: number;
|
|
18
|
+
eliceCourseApiConfiguration: CourseApiContextProps['eliceCourseApiConfiguration'];
|
|
16
19
|
userId?: number;
|
|
17
20
|
locale?: string;
|
|
18
21
|
onDirty: (isDirty: boolean) => void;
|
|
19
22
|
onSubmit?: (isSucceeded: boolean, isCorrect?: boolean) => void;
|
|
20
23
|
onNext?: () => void;
|
|
21
24
|
};
|
|
22
|
-
interface MaterialQuizProviderProps extends Omit<MaterialQuizProps, 'locale'> {
|
|
25
|
+
interface MaterialQuizProviderProps extends Omit<MaterialQuizProps, 'locale' | 'eliceCourseApiConfiguration'> {
|
|
23
26
|
children: React.ReactNode;
|
|
24
27
|
}
|
|
25
28
|
interface DispatchContextType {
|
|
@@ -4,6 +4,7 @@ import React, { useEffect } from 'react';
|
|
|
4
4
|
import { config, getOrgMaterialQuizGet, postOrgMaterialQuizOptionsSetSelect, getOrgLectureGet, getOrgCourseGet } from '@elice/api-client';
|
|
5
5
|
import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
|
|
6
6
|
import { enums } from '@elice/types';
|
|
7
|
+
import { useCourseApiContext } from './CourseApiContext.js';
|
|
7
8
|
|
|
8
9
|
var StateContext = React.createContext(undefined);
|
|
9
10
|
var DispatchContext = React.createContext(undefined);
|
|
@@ -27,22 +28,28 @@ function MaterialQuizProvider(_ref) {
|
|
|
27
28
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
28
29
|
lecture = _React$useState4[0],
|
|
29
30
|
setLecture = _React$useState4[1];
|
|
30
|
-
var
|
|
31
|
+
var _useCourseApiContext = useCourseApiContext(),
|
|
32
|
+
eliceCourseApi = _useCourseApiContext.course;
|
|
33
|
+
var _React$useState5 = React.useState(false),
|
|
31
34
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _React$useState7 = React.useState(
|
|
35
|
+
isRecommendLecture = _React$useState6[0],
|
|
36
|
+
setIsRecommendLecture = _React$useState6[1];
|
|
37
|
+
var _React$useState7 = React.useState('idle'),
|
|
35
38
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
initStatus = _React$useState8[0],
|
|
40
|
+
setInitStatus = _React$useState8[1];
|
|
38
41
|
var _React$useState9 = React.useState(false),
|
|
39
42
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _React$useState11 = React.useState(
|
|
43
|
+
vertical = _React$useState10[0],
|
|
44
|
+
setVertical = _React$useState10[1];
|
|
45
|
+
var _React$useState11 = React.useState(false),
|
|
43
46
|
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
isLongPassage = _React$useState12[0],
|
|
48
|
+
setIsLongPassage = _React$useState12[1];
|
|
49
|
+
var _React$useState13 = React.useState(true),
|
|
50
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
51
|
+
isInitialLoading = _React$useState14[0],
|
|
52
|
+
setIsInitialLoading = _React$useState14[1];
|
|
46
53
|
var canInit = useMaterialConfigApiClientUpdate(config.init);
|
|
47
54
|
var resetLayout = function resetLayout() {
|
|
48
55
|
setIsInitialLoading(true);
|
|
@@ -83,7 +90,7 @@ function MaterialQuizProvider(_ref) {
|
|
|
83
90
|
materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
|
|
84
91
|
refreshOrgMaterialQuiz = _useMaterialFetchRaw.refetch;
|
|
85
92
|
var init = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
86
|
-
var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
|
|
93
|
+
var _a, _b, controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture, recommendLectureId;
|
|
87
94
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
88
95
|
while (1) switch (_context2.prev = _context2.next) {
|
|
89
96
|
case 0:
|
|
@@ -115,26 +122,38 @@ function MaterialQuizProvider(_ref) {
|
|
|
115
122
|
case 12:
|
|
116
123
|
_yield$getOrgLectureG = _context2.sent;
|
|
117
124
|
_lecture = _yield$getOrgLectureG.lecture;
|
|
125
|
+
_context2.next = 16;
|
|
126
|
+
return eliceCourseApi.courseCourseIdGet({
|
|
127
|
+
courseId: (_a = _course === null || _course === void 0 ? void 0 : _course.id) !== null && _a !== void 0 ? _a : 0,
|
|
128
|
+
eliceCourseId: (_b = _course === null || _course === void 0 ? void 0 : _course.id) !== null && _b !== void 0 ? _b : 0
|
|
129
|
+
}, {
|
|
130
|
+
signal: signal
|
|
131
|
+
}).then(function (eliceCourse) {
|
|
132
|
+
return eliceCourse.recommendLectureId;
|
|
133
|
+
});
|
|
134
|
+
case 16:
|
|
135
|
+
recommendLectureId = _context2.sent;
|
|
118
136
|
setCourse(_course);
|
|
119
137
|
setLecture(_lecture);
|
|
138
|
+
setIsRecommendLecture(_lecture.id === recommendLectureId);
|
|
120
139
|
setInitStatus('resolved');
|
|
121
|
-
_context2.next =
|
|
140
|
+
_context2.next = 27;
|
|
122
141
|
break;
|
|
123
|
-
case
|
|
124
|
-
_context2.prev =
|
|
142
|
+
case 23:
|
|
143
|
+
_context2.prev = 23;
|
|
125
144
|
_context2.t0 = _context2["catch"](2);
|
|
126
145
|
console.error(_context2.t0);
|
|
127
146
|
setInitStatus('rejected');
|
|
128
|
-
case
|
|
147
|
+
case 27:
|
|
129
148
|
return _context2.abrupt("return", function () {
|
|
130
149
|
return controller.abort();
|
|
131
150
|
});
|
|
132
|
-
case
|
|
151
|
+
case 28:
|
|
133
152
|
case "end":
|
|
134
153
|
return _context2.stop();
|
|
135
154
|
}
|
|
136
|
-
}, _callee2, null, [[2,
|
|
137
|
-
})), [materialLecturePage]);
|
|
155
|
+
}, _callee2, null, [[2, 23]]);
|
|
156
|
+
})), [materialLecturePage, eliceCourseApi]);
|
|
138
157
|
useEffect(function () {
|
|
139
158
|
if (materialQuizId) {
|
|
140
159
|
resetLayout();
|
|
@@ -154,7 +173,8 @@ function MaterialQuizProvider(_ref) {
|
|
|
154
173
|
vertical: vertical,
|
|
155
174
|
initStatus: initStatus,
|
|
156
175
|
isLongPassage: isLongPassage,
|
|
157
|
-
isInitialLoading: isInitialLoading
|
|
176
|
+
isInitialLoading: isInitialLoading,
|
|
177
|
+
isRecommendLecture: isRecommendLecture
|
|
158
178
|
},
|
|
159
179
|
children: jsx(DispatchContext.Provider, {
|
|
160
180
|
value: {
|
|
@@ -78,7 +78,8 @@ var QuestionBox = function QuestionBox(_a) {
|
|
|
78
78
|
var intl = useRawEliceIntl();
|
|
79
79
|
var _useMaterialQuizState = useMaterialQuizState(),
|
|
80
80
|
vertical = _useMaterialQuizState.vertical,
|
|
81
|
-
isLongPassage = _useMaterialQuizState.isLongPassage
|
|
81
|
+
isLongPassage = _useMaterialQuizState.isLongPassage,
|
|
82
|
+
isRecommendLecture = _useMaterialQuizState.isRecommendLecture;
|
|
82
83
|
var intersectionRef = React.useRef(null);
|
|
83
84
|
var headerRef = React.useRef(null);
|
|
84
85
|
var bodyRef = React.useRef(null);
|
|
@@ -166,7 +167,7 @@ var QuestionBox = function QuestionBox(_a) {
|
|
|
166
167
|
}, action, {
|
|
167
168
|
children: action.children
|
|
168
169
|
}), index);
|
|
169
|
-
}), isNextActive ? jsx(StyledPrimaryButton, {
|
|
170
|
+
}), isNextActive && !isRecommendLecture ? jsx(StyledPrimaryButton, {
|
|
170
171
|
isFluid: vertical,
|
|
171
172
|
size: "small",
|
|
172
173
|
border: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-quiz",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.240814.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",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@elice/mui-system": "^5",
|
|
36
36
|
"@elice/types": "^1",
|
|
37
37
|
"@elice/wysiwyg": "^1",
|
|
38
|
+
"@elice/openapi-client-course": "^1",
|
|
38
39
|
"@emotion/react": "^11.10.0",
|
|
39
40
|
"@emotion/styled": "^11.10.0",
|
|
40
41
|
"@fortawesome/pro-regular-svg-icons": "^6",
|
|
@@ -66,9 +67,10 @@
|
|
|
66
67
|
"@elice/icons-legacy": "npm:@elice/icons@0.230814.0",
|
|
67
68
|
"@elice/intl": "0.240425.0-rc.2",
|
|
68
69
|
"@elice/markdown": "^1.240124.0",
|
|
69
|
-
"@elice/material-shared-types": "1.
|
|
70
|
-
"@elice/material-shared-utils": "1.
|
|
70
|
+
"@elice/material-shared-types": "1.240814.0",
|
|
71
|
+
"@elice/material-shared-utils": "1.240814.0",
|
|
71
72
|
"@elice/mui-system": "^5.240108.1",
|
|
73
|
+
"@elice/openapi-client-course": "^1.230814.0",
|
|
72
74
|
"@elice/types": "1.240709.0",
|
|
73
75
|
"@elice/wysiwyg": "1.240716.1",
|
|
74
76
|
"@emotion/react": "^11.10.5",
|