Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge problemen oplossen #289

Merged
merged 31 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7c1276f
unused import
sPAICEcake May 20, 2024
f3f6387
logo login terug gezet
Bendemeurichy May 20, 2024
414d4c3
assignmentpage zou in orde moeten zijn terug, lijn per lijn nagekeken…
Bendemeurichy May 20, 2024
57d4511
index laten beginnen van 1 ipv 0
Bendemeurichy May 20, 2024
20101c0
tijdsformaat van dayjs gefixt op assignmentpage
gusvanpoucke May 20, 2024
d5aa7ec
kleine taalfix GroepsNummer -> Groepnummer
gusvanpoucke May 20, 2024
e98c1a7
'geen score' op subjectPage ipv 0/20
gusvanpoucke May 20, 2024
b31e8f1
cancel + alert add change subject
Bendemeurichy May 20, 2024
2a9f0d2
kotjes deadlines terug opgeschoond
Bendemeurichy May 20, 2024
3fe2e92
fix restrictions dialog
mathis2003 May 20, 2024
a88b7fa
groepsleden knop geeft nu geen error meer, maar laat weten aan de stu…
gusvanpoucke May 20, 2024
2550f05
Merge branch 'merge_problems_fix' of https://github.com/SELab-2/UGent…
gusvanpoucke May 20, 2024
6c9d245
headers for restrictions list
mathis2003 May 20, 2024
7ba0357
opdracht icons worden nu wel geupdate op verandering van jaar in kale…
gusvanpoucke May 20, 2024
22e6eb2
status op mainpage in orde gebracht
Bendemeurichy May 20, 2024
87b2811
studentPopUp fixed
sPAICEcake May 20, 2024
bea5be1
pin icon verschijnt rechtsboven
gusvanpoucke May 20, 2024
afd8c57
'geen deadline' word nu overal correct getoond
gusvanpoucke May 20, 2024
423ba47
verwijderen restricties mogelijk + toevoegknop verplaatst
Bendemeurichy May 20, 2024
943f6e3
patch fix
Bendemeurichy May 20, 2024
80e9b75
Merge pull request #291 from SELab-2/restrictions_list_view
Bendemeurichy May 20, 2024
259e4ec
voeg jezelf toe bij nieuw vak, geen spookvakken meer
Bendemeurichy May 20, 2024
3e9aae3
Merge remote-tracking branch 'origin/merge_problems_fix' into merge_p…
Bendemeurichy May 20, 2024
f5727c6
cleanup restrictions box in addchangeAssigmentPage
friedrecursion May 20, 2024
68dc6dd
vakken renderen op jaartal
sPAICEcake May 20, 2024
feb5ff3
Merge branch 'merge_problems_fix' of https://github.com/SELab-2/UGent…
sPAICEcake May 20, 2024
ea950d4
Merge pull request #293 from SELab-2/restrictions_list_view
mathis2003 May 20, 2024
9cb42df
er verschijnen nu alerts als je op de addchangesubjectpage ongeldige …
gusvanpoucke May 20, 2024
13760ea
Merge branch 'merge_problems_fix' of https://github.com/SELab-2/UGent…
gusvanpoucke May 20, 2024
2b7145e
popup weggewerkt en jaarkeuze andere kleur
Bendemeurichy May 20, 2024
6b0f8cb
remove unused import
Bendemeurichy May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 70 additions & 25 deletions frontend/frontend/src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { Course, project } from '../pages/mainPage/MainPage.tsx'
import dayjs from 'dayjs'

import { CourseCardSkeleton } from './CourseCardSkeleton.tsx'
import { Submission } from '../pages/submissionPage/SubmissionPage.tsx'
import { Group } from '../pages/groupsPage/GroupsPage.tsx'
import axios from 'axios'
/*
* CourseCard component displays a card with course information and a list of assignments
* @param courseId: string, the id of the course
Expand All @@ -29,6 +32,7 @@ import { CourseCardSkeleton } from './CourseCardSkeleton.tsx'
//TODO: fix archived with state so that the card moves to ArchivedView when archived

interface CourseCardProps {
userid: number
courseId: string
archived: boolean
isStudent: boolean
Expand All @@ -38,6 +42,7 @@ interface CourseCardProps {
}

export function CourseCard({
userid,
courseId,
archived,
isStudent,
Expand All @@ -49,11 +54,15 @@ export function CourseCard({
const [course, setCourse] = useState<Course>({
vak_id: 0,
naam: '',
jaartal: 0,
studenten: [],
lesgevers: [],
gearchiveerd: false,
})
const [assignments, setAssignments] = useState<project[]>([])
const [groupsWithSubmissions, setGroupsWithSubmissions] = useState<Group[]>(
[]
)
const [teachers, setTeachers] = useState<
{ first_name: string; last_name: string }[]
>([])
Expand All @@ -77,6 +86,32 @@ export function CourseCard({
setCourse(courseResponse.data)
setAssignments(assignmentsResponse.data)

//fetch submissions as well if user is student
if (isStudent) {
const groups: Group[] = await instance
.get(`/groepen/?student=${userid}`)
.then((response) => response.data)
const submissionPromises = groups.map(async (group) => {
const response = await instance.get<Submission>(
`/indieningen/?project=${group.project}`
)
return response.data
})
const submissions = await axios.all(submissionPromises)

console.log(groups)
const validGroups = groups.filter((group) =>
submissions
.flat(Infinity)
.some(
(submission) =>
submission.groep === group.groep_id
)
)

setGroupsWithSubmissions(validGroups)
}

if (courseResponse.data && courseResponse.data.lesgevers) {
const lesgevers = []
for (const teacherId of courseResponse.data.lesgevers) {
Expand Down Expand Up @@ -198,10 +233,6 @@ export function CourseCard({
</Box>
{/* Number of students enrolled */}
<Box>
<Typography variant={'subtitle1'}>
{t('students') + ': '}
{course.studenten.length || 0}
</Typography>
<Box
display={'flex'}
flexDirection={'column'}
Expand All @@ -227,6 +258,10 @@ export function CourseCard({
)}
</IconButton>
</Box>
<Typography variant={'subtitle1'}>
{t('students') + ': '}
{course.studenten.length || 0}
</Typography>
</Box>
</Box>
</CardActionArea>
Expand Down Expand Up @@ -340,16 +375,19 @@ export function CourseCard({
assignment.titel
}
dueDate={
dayjs(
assignment.deadline
).format(
'DD/MM/YYYY HH:mm'
) || undefined
assignment.deadline
? dayjs(
assignment.deadline
).format(
'DD/MM/YYYY HH:mm'
)
: undefined
}
status={
assignment.project_id ===
1
} //TODO dit moet nog aangepast worden
status={groupsWithSubmissions.some(
(group) =>
group.project ===
assignment.project_id
)}
isStudent={isStudent}
/>
))}
Expand Down Expand Up @@ -378,16 +416,22 @@ export function CourseCard({
assignment.titel
}
dueDate={
dayjs(
assignment.deadline
).format(
'DD/MM/YYYY HH:mm'
) ||
undefined
assignment.deadline
? dayjs(
assignment.deadline
).format(
'DD/MM/YYYY HH:mm'
)
: undefined
}
status={
assignment.project_id ===
1
groupsWithSubmissions.some(
(
group
) =>
group.project ===
assignment.project_id
)
//TODO: status has to check if there is already a submission
}
isStudent={
Expand Down Expand Up @@ -429,10 +473,11 @@ export function CourseCard({
) ||
undefined
}
status={
assignment.project_id ===
1
}
status={groupsWithSubmissions.some(
(group) =>
group.project ===
assignment.project_id
)}
isStudent={
isStudent
}
Expand Down
32 changes: 26 additions & 6 deletions frontend/frontend/src/components/DeadlineCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
import dayjs, { Dayjs } from 'dayjs'
import {
Badge,
SxProps,
Stack,
Typography,
List,
ListItem,
ListItemButton,
ListItemText,
Stack,
SxProps,
Typography,
} from '@mui/material'
import { useEffect, useRef, useState } from 'react'
import AssignmentIcon from '@mui/icons-material/Assignment'
Expand Down Expand Up @@ -125,7 +125,14 @@ function DeadlineMenu({ assignments, selectedDay }: DeadlineMenuProps) {
<ListItem>
<ListItemButton
sx={{
border: 1,
border: 0.5,
borderColor: 'primary.main',
textAlign: 'center',
width: '100%',
borderRadius: 2,
'&:hover': {
backgroundColor: 'primary.light',
},
}}
onClick={() =>
handleProjectClick(
Expand All @@ -134,8 +141,14 @@ function DeadlineMenu({ assignments, selectedDay }: DeadlineMenuProps) {
)
}
>
<ListItemText primary={assignment.titel} />

<ListItemText sx={{ maxWidth: '100%' }}>
<Typography
textOverflow={'ellipsis'}
color={'text.primary'}
>
{assignment.titel}
</Typography>
</ListItemText>
</ListItemButton>
</ListItem>
))}
Expand Down Expand Up @@ -202,6 +215,12 @@ export function DeadlineCalendar({
fetchHighlightedDays(date)
}

const handleYearChange = (date: Dayjs) => {
setIsLoading(true)
setHighlightedDays([])
fetchHighlightedDays(date)
}

return (
<>
<Stack direction={'column'}>
Expand All @@ -211,6 +230,7 @@ export function DeadlineCalendar({
value={value}
onChange={(newValue) => setValue(newValue)}
onMonthChange={(newValue) => handleMonthChange(newValue)}
onYearChange={(newValue) => handleYearChange(newValue)}
renderLoading={() => <DayCalendarSkeleton />}
loading={isLoading}
sx={dateStyle}
Expand Down
2 changes: 1 addition & 1 deletion frontend/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const Header = ({ variant, title }: Props) => {
>
{variant === 'main' && (
<Box
id='logo'
id="logo"
component="img"
src={'assets/logo_duif_top_wit.png'}
alt="logo_app"
Expand Down
39 changes: 18 additions & 21 deletions frontend/frontend/src/components/RestrictionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { restriction } from '../pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx'
import { Box, IconButton, Switch, Typography } from '@mui/material'
import { IconButton, Switch, Typography } from '@mui/material'
import CloseIcon from '@mui/icons-material/Close'
import React from 'react'
import { EvenlySpacedRow } from './CustomComponents.tsx'

interface RestrictionCardProps {
restriction: restriction
Expand All @@ -28,26 +29,22 @@ export function RestrictionCard({

return (
<>
<Box
display={'flex'}
flexDirection={'row'}
width={'100%'}
justifyContent={'space-between'}
>
<Typography id="script" variant={'body2'}>
{restriction.script.replace(/^.*[\\/]/, '')}
</Typography>
<Switch
id="mustPassSwitch"
value={mustPass}
checked={mustPass}
onChange={() => handleMustPassChange()}
/>

<IconButton id="closeButton" onClick={handleRemove}>
<CloseIcon />
</IconButton>
</Box>
<EvenlySpacedRow
items={[
<Typography id="script" variant={'body2'}>
{restriction.script.replace(/^.*[\\/]/, '')}
</Typography>,
<Switch
id="mustPassSwitch"
value={mustPass}
checked={mustPass}
onChange={() => handleMustPassChange()}
/>,
<IconButton id="closeButton" onClick={handleRemove}>
<CloseIcon />
</IconButton>,
]}
/>
</>
)
}
4 changes: 4 additions & 0 deletions frontend/frontend/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ const english = {
open_with_ui: 'Open with UI',
choose_existing: 'Choose existing',
make_new_script: 'Make new script',
cant_add_teachers_to_student_list: 'You cannot add teachers to the student list',
cant_add_students_to_teacher_list: 'You cannot add students to the teacher list',
cant_add_users_twice: 'You cannot add users to a subject twice',
this_user_doesnt_exist: 'This user does not exist',
}

export default english
6 changes: 5 additions & 1 deletion frontend/frontend/src/i18n/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ const dutch = {
noGroup: 'Je lijkt nog geen groep te hebben.',
chooseGroup: 'Kies een groep voor je indient',
contactTeacher: 'Gelieve contact op te nemen met je lesgever.',
group_number: 'GroepsNummer',
group_number: 'Groepnummer',
open_with_ui: 'Open met UI',
choose_existing: 'Kies een bestaand script',
make_new_script: 'Maak nieuw script aan',
cant_add_teachers_to_student_list: 'Je kan geen leerkrachten aan de studenten lijst toevoegen',
cant_add_students_to_teacher_list: 'Je kan geen studenten aan de leerkrachten lijst toevoegen',
cant_add_users_twice: 'Je kan gebruikers geen twee keer toevoegen',
this_user_doesnt_exist: 'Deze gebruiker bestaat niet',
}

export default dutch
Loading
Loading