Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit fd63748

Browse files
Update 2 (#1029)
* Update * Done hightlight * Công khai tất cả buổi học * Công khai tất cả bài tập * Công khai tất cả tài liệu * Công khai tất cả bài tập trắc nghiệm * Thêm cột chưa làm/ đã làm bài tập * hightlight bài tập chưa làm gần nhất * Popup
1 parent 1f7ecf5 commit fd63748

File tree

13 files changed

+855
-85
lines changed

13 files changed

+855
-85
lines changed

packages/web/src/graphql/generated.tsx

Lines changed: 543 additions & 0 deletions
Large diffs are not rendered by default.

packages/web/src/modules/DetailCourse/DetailCourse.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ const DetailCourse: FC<DetailCourseProps> = () => {
274274
Thêm giảng viên
275275
</Button>
276276
<Popover
277-
style={{ width: '89%' }}
277+
style={{
278+
right: 50,
279+
}}
278280
id={idOpenLecturer}
279281
open={openLec}
280282
anchorEl={openLecturer}
@@ -348,7 +350,9 @@ const DetailCourse: FC<DetailCourseProps> = () => {
348350
Thêm học viên
349351
</Button>
350352
<Popover
351-
style={{ width: '89%' }}
353+
style={{
354+
right: 50,
355+
}}
352356
id={idOpenStudent}
353357
open={openStu}
354358
anchorEl={openStudent}

packages/web/src/modules/StudyingCourse/Components/ClassworkLessons/ClassworkLessons.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,7 @@ const ClassworkLessons: FC<ClassworkLessonsProps> = () => {
9595
</Grid>
9696
)
9797
}
98-
// const checkTime = (time: Date) => {
99-
// const timeBefore = new Date(time)
100-
// const timeNow = new Date()
101-
// if (timeBefore < timeNow) {
102-
// return true
103-
// }
104-
// return false
105-
// }
98+
10699
return (
107100
<>
108101
<Grid container spacing={DASHBOARD_SPACING}>

packages/web/src/modules/StudyingCourse/Components/ListOfSubmittedAssignments/ListOfSubmittedAssignments.gql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ query ListClassworkAssignmentsByStudentIdInCourse(
77
classworkAssignmentsTitle
88
dueDate
99
classworkSubmissionGrade
10-
classworkSubmissionGrade
1110
classworkSubmissionUpdatedAt
1211
classworkSubmissionDescription
1312
}

packages/web/src/modules/StudyingCourse/Components/ListOfSubmittedAssignments/ListOfSubmittedAssignments.tsx

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ const ListOfSubmittedAssignments: FC<ListOfSubmittedAssignmentsProps> = (
6464
dataOfSubmitted?.listClassworkAssignmentsByStudentIdInCourse.list ?? [],
6565
[dataOfSubmitted?.listClassworkAssignmentsByStudentIdInCourse.list],
6666
)
67+
const classworkSubmit: ANY[] = useMemo(
68+
() =>
69+
classworkOfSubmits.map((item: ANY) => {
70+
const current = new Date()
71+
const duaDateSubmit = new Date(item.dueDate)
72+
73+
if (
74+
item.classworkSubmissionUpdatedAt === null &&
75+
current.getMonth() === duaDateSubmit.getMonth() &&
76+
current.getFullYear() === duaDateSubmit.getFullYear()
77+
) {
78+
if (
79+
current.getDate() === duaDateSubmit.getDate() ||
80+
current.getDate() + 1 === duaDateSubmit.getDate()
81+
) {
82+
return {
83+
...item,
84+
isNext: true,
85+
}
86+
}
87+
}
88+
return {
89+
...item,
90+
isNext: false,
91+
}
92+
}),
93+
[classworkOfSubmits],
94+
)
6795
const totalCount = useMemo(
6896
() =>
6997
dataOfSubmitted?.listClassworkAssignmentsByStudentIdInCourse.count ?? 0,
@@ -131,9 +159,9 @@ const ListOfSubmittedAssignments: FC<ListOfSubmittedAssignmentsProps> = (
131159
]}
132160
>
133161
<CardContent>
134-
{classworkOfSubmits.length ? (
162+
{classworkSubmit.length ? (
135163
<DataTable
136-
data={classworkOfSubmits}
164+
data={classworkSubmit}
137165
rowKey="id"
138166
loading={loadingOfSubmitted}
139167
columns={[
@@ -143,15 +171,19 @@ const ListOfSubmittedAssignments: FC<ListOfSubmittedAssignmentsProps> = (
143171
render: (classworkOfSubmit) => (
144172
<>
145173
<Link
174+
className={
175+
classworkOfSubmit.isNext ? 'title-hightlight' : ''
176+
}
146177
to={buildPath(
147178
STUDYING_COURSE_DETAIL_CONTENT_CLASSWORK_ASSIGNMENTS,
148179
{
149180
id: classworkOfSubmit.classworkAssignmentId as ANY,
150181
},
151182
)}
152183
>
153-
<Typography variant="body1">
184+
<Typography variant="body1" fontWeight="bold">
154185
{classworkOfSubmit.classworkAssignmentsTitle}
186+
{classworkOfSubmit.isNext ? ' (Bài tập cần làm)' : ''}
155187
</Typography>
156188
</Link>
157189
</>
@@ -216,6 +248,35 @@ const ListOfSubmittedAssignments: FC<ListOfSubmittedAssignmentsProps> = (
216248
</>
217249
),
218250
},
251+
{
252+
label: 'Trạng thái',
253+
align: 'right',
254+
skeleton: <Skeleton />,
255+
render: (classworkOfSubmit) => (
256+
<>
257+
<Typography>
258+
{classworkOfSubmit.classworkSubmissionUpdatedAt ===
259+
null ? (
260+
<>
261+
<Chip
262+
variant="outlined"
263+
color="default"
264+
label="Chưa nộp"
265+
/>
266+
</>
267+
) : (
268+
<>
269+
<Chip
270+
variant="outlined"
271+
color="primary"
272+
label="Đã nộp"
273+
/>
274+
</>
275+
)}
276+
</Typography>
277+
</>
278+
),
279+
},
219280
]}
220281
pagination={{
221282
count: totalCount,

packages/web/src/modules/TeachingCourse/Components/ClassworkAssignments/ClassworkAssignments.gql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
query ClassworkAssignmentList($skip: Int!, $limit: Int!, $courseId: ID!) {
2-
classworkAssignments(pageOptions: { skip: $skip, limit: $limit },courseId: $courseId) {
2+
classworkAssignments(
3+
pageOptions: { skip: $skip, limit: $limit }
4+
courseId: $courseId
5+
) {
36
classworkAssignments {
47
id
58
orgId
@@ -14,3 +17,10 @@ query ClassworkAssignmentList($skip: Int!, $limit: Int!, $courseId: ID!) {
1417
count
1518
}
1619
}
20+
#Công khai tất cả các bài tập
21+
mutation PublishAllClassworkAssignmentsOfTheCourse($courseId: ID!) {
22+
publishAllClassworkAssignmentsOfTheCourse(courseId: $courseId) {
23+
id
24+
courseId
25+
}
26+
}

packages/web/src/modules/TeachingCourse/Components/ClassworkAssignments/ClassworkAssignments.tsx

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { FC, useMemo } from 'react'
1+
import { FC, useMemo, useCallback } from 'react'
22

33
import { CardContent, Grid, Skeleton, makeStyles } from '@material-ui/core'
44
import PublicationChip from 'components/PublicationChip'
55
import format from 'date-fns/format'
6+
import { useSnackbar } from 'notistack'
67
import { FilePlus } from 'phosphor-react'
78
import { useParams } from 'react-router-dom'
89

@@ -20,6 +21,8 @@ import {
2021
import {
2122
useCourseDetailQuery,
2223
useClassworkAssignmentListQuery,
24+
ClassworkAssignmentListDocument,
25+
usePublishAllClassworkAssignmentsOfTheCourseMutation,
2326
} from 'graphql/generated'
2427
import {
2528
buildPath,
@@ -57,6 +60,28 @@ const ClassworkAssignments: FC<ClassworkAssignmentsProps> = () => {
5760
() => dataClasswork?.classworkAssignments.count ?? 0,
5861
[dataClasswork?.classworkAssignments.count],
5962
)
63+
// Công khai tất cả ----
64+
const { enqueueSnackbar } = useSnackbar()
65+
const [publishAll] = usePublishAllClassworkAssignmentsOfTheCourseMutation({
66+
refetchQueries: [{ query: ClassworkAssignmentListDocument }],
67+
})
68+
const handlePublishAll = useCallback(async () => {
69+
try {
70+
await publishAll({
71+
variables: {
72+
courseId,
73+
},
74+
})
75+
enqueueSnackbar(`Tất cả đã được công khai`, {
76+
variant: 'success',
77+
})
78+
} catch (error) {
79+
enqueueSnackbar(`Công khai thất bại`, {
80+
variant: 'warning',
81+
})
82+
}
83+
}, [courseId, publishAll, enqueueSnackbar])
84+
// Công khai tất cả ----
6085

6186
if (loadingCourse) {
6287
return (
@@ -87,15 +112,23 @@ const ClassworkAssignments: FC<ClassworkAssignmentsProps> = () => {
87112
title="Bài tập"
88113
gridItem={{ xs: 12 }}
89114
action={
90-
<Button
91-
className={classes.buttonTextColor}
92-
startIcon={<FilePlus size={24} />}
93-
link={buildPath(TEACHING_COURSE_CREATE_CLASSWORK_ASSIGNMENT, {
94-
id: courseId,
95-
})}
96-
>
97-
Thêm bài tập
98-
</Button>
115+
<>
116+
<Button
117+
onClick={handlePublishAll}
118+
className={classes.buttonTextColor}
119+
>
120+
Công khai tất cả
121+
</Button>
122+
<Button
123+
className={classes.buttonTextColor}
124+
startIcon={<FilePlus size={24} />}
125+
link={buildPath(TEACHING_COURSE_CREATE_CLASSWORK_ASSIGNMENT, {
126+
id: courseId,
127+
})}
128+
>
129+
Thêm bài tập
130+
</Button>
131+
</>
99132
}
100133
>
101134
<CardContent>

packages/web/src/modules/TeachingCourse/Components/ClassworkLessons/ClassworkLessions.gql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,11 @@ mutation UpdateLesson(
8888
courseId
8989
}
9090
}
91+
92+
#Công khai tất cả các buổi học
93+
mutation PublishAllLessonsOfTheCourse($courseId: ID!) {
94+
publishAllLessonsOfTheCourse(courseId: $courseId) {
95+
id
96+
courseId
97+
}
98+
}

packages/web/src/modules/TeachingCourse/Components/ClassworkLessons/ClassworkLessons.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { FC, useMemo } from 'react'
1+
import { FC, useMemo, useCallback } from 'react'
22

33
import { CardContent, Grid, Skeleton, makeStyles } from '@material-ui/core'
44
import PublicationChip from 'components/PublicationChip'
55
import format from 'date-fns/format'
6+
import { useSnackbar } from 'notistack'
67
import { FilePlus } from 'phosphor-react'
78
import { useParams } from 'react-router-dom'
89

@@ -23,6 +24,8 @@ import {
2324
Permission,
2425
useCourseDetailQuery,
2526
useListLessonsQuery,
27+
usePublishAllLessonsOfTheCourseMutation,
28+
ListLessonsDocument,
2629
} from 'graphql/generated'
2730
import {
2831
buildPath,
@@ -68,7 +71,28 @@ const ClassworkLesson: FC<ClassworkLessonProps> = () => {
6871
() => dataClasswork?.lessons.count ?? 0,
6972
[dataClasswork?.lessons.count],
7073
)
71-
74+
// Công khai tất cả ----
75+
const { enqueueSnackbar } = useSnackbar()
76+
const [publishAll] = usePublishAllLessonsOfTheCourseMutation({
77+
refetchQueries: [{ query: ListLessonsDocument }],
78+
})
79+
const handlePublishAll = useCallback(async () => {
80+
try {
81+
await publishAll({
82+
variables: {
83+
courseId,
84+
},
85+
})
86+
enqueueSnackbar(`Tất cả đã được công khai`, {
87+
variant: 'success',
88+
})
89+
} catch (error) {
90+
enqueueSnackbar(`Công khai thất bại`, {
91+
variant: 'warning',
92+
})
93+
}
94+
}, [courseId, publishAll, enqueueSnackbar])
95+
// Công khai tất cả ----
7296
if (loadingCourse) {
7397
return (
7498
<Grid container spacing={DASHBOARD_SPACING}>
@@ -96,15 +120,23 @@ const ClassworkLesson: FC<ClassworkLessonProps> = () => {
96120
title="Lộ trình"
97121
gridItem={{ xs: 12 }}
98122
action={
99-
<Button
100-
className={classes.buttonTextColor}
101-
startIcon={<FilePlus size={24} />}
102-
link={buildPath(TEACHING_COURSE_CREATE_CLASSWORK_LESSON, {
103-
id: courseId,
104-
})}
105-
>
106-
Thêm buổi học
107-
</Button>
123+
<>
124+
<Button
125+
onClick={handlePublishAll}
126+
className={classes.buttonTextColor}
127+
>
128+
Công khai tất cả
129+
</Button>
130+
<Button
131+
className={classes.buttonTextColor}
132+
startIcon={<FilePlus size={24} />}
133+
link={buildPath(TEACHING_COURSE_CREATE_CLASSWORK_LESSON, {
134+
id: courseId,
135+
})}
136+
>
137+
Thêm buổi học
138+
</Button>
139+
</>
108140
}
109141
>
110142
<CardContent>

packages/web/src/modules/TeachingCourse/Components/ClassworkMaterials/ClassworkMaterials.gql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,10 @@ mutation RemoveVideoFromClassworkMaterial(
148148
id
149149
}
150150
}
151+
#Công khai tất cả các tài liệu
152+
mutation PublishAllClassworkMaterialsOfTheCourse($courseId: ID!) {
153+
publishAllClassworkMaterialsOfTheCourse(courseId: $courseId) {
154+
id
155+
courseId
156+
}
157+
}

0 commit comments

Comments
 (0)