From 7bc92cb9ae3c8d5219517c09b4b45f07ba0be2f8 Mon Sep 17 00:00:00 2001 From: Ben De Meurichy Date: Thu, 16 May 2024 17:07:26 +0200 Subject: [PATCH 01/15] kleine fixes --- .../src/components/DeadlineCalendar.tsx | 61 ++++--- frontend/frontend/src/components/Header.tsx | 3 +- frontend/frontend/src/i18n/en.ts | 3 +- frontend/frontend/src/i18n/nl.ts | 4 +- .../pages/assignmentPage/AssignmentPage.tsx | 166 +++++++++++++++--- .../src/pages/subjectsPage/ProjectsView.tsx | 2 +- .../src/pages/subjectsPage/SubjectsPage.tsx | 56 +++--- .../pages/submissionPage/SubmissionPage.tsx | 49 ++++-- 8 files changed, 243 insertions(+), 101 deletions(-) diff --git a/frontend/frontend/src/components/DeadlineCalendar.tsx b/frontend/frontend/src/components/DeadlineCalendar.tsx index 8772029d..d0773591 100644 --- a/frontend/frontend/src/components/DeadlineCalendar.tsx +++ b/frontend/frontend/src/components/DeadlineCalendar.tsx @@ -5,7 +5,16 @@ import { PickersDayProps, } from '@mui/x-date-pickers' import dayjs, { Dayjs } from 'dayjs' -import { Badge, SxProps, Stack, Typography, Box, List, ListItem, ListItemButton, ListItemText } from '@mui/material' +import { + Badge, + List, + ListItem, + ListItemButton, + ListItemText, + Stack, + SxProps, + Typography, +} from '@mui/material' import { useEffect, useRef, useState } from 'react' import AssignmentIcon from '@mui/icons-material/Assignment' import { useNavigate } from 'react-router-dom' @@ -95,22 +104,26 @@ function DeadlineMenu({ assignments, selectedDay }: DeadlineMenuProps) { {assignments - .filter((assignment: project) => - dayjs(assignment.deadline).isSame(selectedDay, 'day') - ).map((assignment: project) => - - handleProjectClick(assignment.vak, assignment.project_id)} - > - - - - )} + .filter((assignment: project) => + dayjs(assignment.deadline).isSame(selectedDay, 'day') + ) + .map((assignment: project) => ( + + + handleProjectClick( + assignment.vak, + assignment.project_id + ) + } + > + + + + ))} ) @@ -121,7 +134,10 @@ interface DeadlineCalendarProps { assignments: project[] } -export function DeadlineCalendar({ deadlines, assignments }: DeadlineCalendarProps) { +export function DeadlineCalendar({ + deadlines, + assignments, +}: DeadlineCalendarProps) { const requestAbortController = useRef(null) const [isLoading, setIsLoading] = useState(false) const [highlightedDays, setHighlightedDays] = useState([]) @@ -173,9 +189,7 @@ export function DeadlineCalendar({ deadlines, assignments }: DeadlineCalendarPro return ( <> - + {/*Calendar*/} - + ) diff --git a/frontend/frontend/src/components/Header.tsx b/frontend/frontend/src/components/Header.tsx index 6ce687bb..bf43afc6 100644 --- a/frontend/frontend/src/components/Header.tsx +++ b/frontend/frontend/src/components/Header.tsx @@ -120,7 +120,8 @@ export const Header = ({ variant, title }: Props) => { {/* Back Button (if variant is not default) */} - {!(variant === 'default' || variant === 'main') && ( + {(variant === 'not_main' || + variant === 'editable') && ( { + async function fetchUser() { + setUserLoading(true) + setLoading(true) + const userResponse = await instance.get('/gebruikers/me/') + setUser(userResponse.data) + setUserLoading(false) + } + async function fetchData() { try { - setUserLoading(true) - setLoading(true) - const userResponse = await instance.get('/gebruikers/me/') - setUser(userResponse.data) - setUserLoading(false) const assignmentResponse = await instance.get( `/projecten/${assignmentId}/` ) @@ -100,15 +103,18 @@ export function AssignmentPage() { return file }) setAssignment(newAssignment) - if (userResponse.data) { + if (user) { if (user.is_lesgever) { const groupsResponse = await instance.get( `/groepen/?project=${assignmentId}` ) setGroups(groupsResponse.data) } else { + const groupResponse = await instance.get<[Group]>( + `/groepen/?student=${user.user}&project=${assignmentId}` + ) const submissionsResponse = await instance.get( - `/indieningen/?vak=${courseId}` + `/indieningen/?project=${assignmentId}&groep=${groupResponse.data[0].groep_id}` ) setSubmissions(submissionsResponse.data) } @@ -120,8 +126,14 @@ export function AssignmentPage() { } } - fetchData().catch((err) => console.error(err)) - }, [assignmentId, courseId, user.is_lesgever, submit]) + // Ensure fetchUser completes before fetchData starts + ;(async () => { + if (user.user === 0) { + await fetchUser() + } + await fetchData() // Use await here to ensure fetchData waits for fetchUser to complete + })() + }, [assignmentId, courseId, user.is_lesgever, submit, user]) // Function to download all submissions as a zip file const downloadAllSubmissions = () => { @@ -213,12 +225,10 @@ export function AssignmentPage() { }, } const groupResponse = await instance.get( - `/groepen/?student=${user.user}` + `/groepen/?student=${user.user}&project=${assignmentId}` ) if (groupResponse.data) { - const group = groupResponse.data.find( - (group: Group) => String(group.project) === assignmentId - ) + const group = groupResponse.data[0] if (group) { const formData = new FormData() formData.append('groep', group.groep_id) @@ -280,6 +290,28 @@ export function AssignmentPage() { backgroundColor: 'background.default', }} > + + + + {t('assignment')} + + + {assignment?.beschrijving} + + + {/*deadline and group button */} + {/*assignment description*/} + + + {loading ? ( + + ) : ( + <> + + {t('assignment')} + + + {assignment?.beschrijving} + + + )} + + {/*deadline and groep button */} ) : ( - - {assignment - ? dayjs( - assignment.deadline - ).format( - 'DD/MM/YYYY-HH:MM' - ) - : 'no deadline'} - + <> + {assignment !== undefined && + assignment.deadline !== + null && ( + + {assignment + ? dayjs( + assignment.deadline + ).format( + 'DD/MM/YYYY-HH:MM' + ) + : 'no deadline'} + + )} + )} @@ -633,6 +708,44 @@ export function AssignmentPage() { )} + {/*extra deadline*/} + {assignment?.extra_deadline && ( + + + Extra Deadline: + + {loading ? ( + + ) : ( + + {assignment + ? dayjs( + assignment.extra_deadline + ).format( + 'DD/MM/YYYY-HH:MM' + ) + : 'no deadline'} + + )} + + )} {/*download opgave*/} } onClick={downloadAssignment} + disabled={assignment === undefined} > {loading ? ( {assignment ? assignment.filename - : 'error'} + : t('no_assignmentfile')} )} diff --git a/frontend/frontend/src/pages/subjectsPage/ProjectsView.tsx b/frontend/frontend/src/pages/subjectsPage/ProjectsView.tsx index cbd51900..62e4d46d 100644 --- a/frontend/frontend/src/pages/subjectsPage/ProjectsView.tsx +++ b/frontend/frontend/src/pages/subjectsPage/ProjectsView.tsx @@ -1,4 +1,4 @@ -import { Card, Divider } from '../../components/CustomComponents.tsx' +import { Divider } from '../../components/CustomComponents.tsx' import { Box, Skeleton, Typography } from '@mui/material' import List from '@mui/material/List' import { t } from 'i18next' diff --git a/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx b/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx index 89aabcf2..abd72c50 100644 --- a/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx +++ b/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx @@ -71,7 +71,7 @@ export function SubjectsPage() { // State for loading the page const [loading, setLoading] = useState(true) const [userLoading, setUserLoading] = useState(true) - const [studentsLoading, setStudentsLoading] = useState(true); + const [studentsLoading, setStudentsLoading] = useState(true) useEffect(() => { // Get the data for this course. @@ -136,27 +136,27 @@ export function SubjectsPage() { useEffect(() => { async function fetchStudents() { - setStudentsLoading(true); - const temp_students = []; + setStudentsLoading(true) + const temp_students = [] for (const s of course?.studenten || []) { try { - const userResponse = await instance.get(`/gebruikers/${s}/`); - temp_students.push(userResponse.data); + const userResponse = await instance.get(`/gebruikers/${s}/`) + temp_students.push(userResponse.data) } catch (error) { - console.error('Error fetching student data:', error); - setFetchError(true); + console.error('Error fetching student data:', error) + setFetchError(true) } } // Update the state with the fetched data - setStudents(temp_students); - setStudentsLoading(false); + setStudents(temp_students) + setStudentsLoading(false) } - + // Fetch students fetchStudents().catch((error) => console.error('Error fetching students data:', error) - ); - }, [course]); + ) + }, [course]) const addProject = () => { console.log('add project') @@ -261,15 +261,13 @@ export function SubjectsPage() { }} > {/* Give the student the option to select current or archived projects. */} - {course.gearchiveerd? + {course.gearchiveerd ? ( - : + ) : ( , ]} /> - } + )}
- {course.gearchiveerd? + {course.gearchiveerd ? ( - undefined - } - archiveAssignment={() => - undefined - } + deleteAssignment={() => undefined} + archiveAssignment={() => undefined} changeVisibilityAssignment={() => undefined } courseId={courseID} /> - : + ) : ( , ]} /> - } + )} diff --git a/frontend/frontend/src/pages/submissionPage/SubmissionPage.tsx b/frontend/frontend/src/pages/submissionPage/SubmissionPage.tsx index 818534ef..cd147c51 100644 --- a/frontend/frontend/src/pages/submissionPage/SubmissionPage.tsx +++ b/frontend/frontend/src/pages/submissionPage/SubmissionPage.tsx @@ -293,21 +293,40 @@ export function SubmissionPage() { /> )} - - - Deadline - {project?.deadline - ? dayjs(project.deadline).format( - 'DD/MM/YYYY HH:mm' - ) - : 'error'} - - + {project?.deadline && ( + + + Deadline + {project?.deadline + ? dayjs(project.deadline).format( + 'DD/MM/YYYY HH:mm' + ) + : 'error'} + + + )} + {project?.extra_deadline && ( + + + Extra Deadline + {project?.extra_deadline + ? dayjs(project.extra_deadline).format( + 'DD/MM/YYYY HH:mm' + ) + : 'error'} + + + )} Date: Fri, 17 May 2024 23:16:10 +0200 Subject: [PATCH 02/15] refactor groepen --- .../src/components/GroupAccessComponent.tsx | 24 +- frontend/frontend/src/i18n/en.ts | 3 +- frontend/frontend/src/i18n/nl.ts | 3 +- .../AddChangeAssignmentPage.tsx | 50 +- .../src/pages/groupsPage/GroupsPage.tsx | 935 ++++++++++-------- frontend/frontend/src/routes.tsx | 2 +- 6 files changed, 572 insertions(+), 445 deletions(-) diff --git a/frontend/frontend/src/components/GroupAccessComponent.tsx b/frontend/frontend/src/components/GroupAccessComponent.tsx index af831496..922896bc 100644 --- a/frontend/frontend/src/components/GroupAccessComponent.tsx +++ b/frontend/frontend/src/components/GroupAccessComponent.tsx @@ -1,8 +1,6 @@ import { Button } from './CustomComponents' -import { Box, Typography } from '@mui/material' +import { Box } from '@mui/material' import { t } from 'i18next' -import Switch from '@mui/material/Switch' -import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' interface GroupAccessComponentProps { @@ -20,17 +18,12 @@ export function GroupAccessComponent({ courseid, }: GroupAccessComponentProps) { const navigate = useNavigate() - const [allowGroups, setAllowGroups] = useState(false) // Handle click event to navigate to the groups page const handleClick = () => { navigate(`/course/${courseid}/assignment/${assignmentid}/groups`) } - useEffect(() => { - //set max group size to 1 if groups are not allowed and register all students to a group of their own - }, [allowGroups]) - return ( <> {/* Button to navigate to groups page */} - {allowGroups ? ( - - ) : ( - // Show text indicating groups are not allowed - - {t('groups')} - - )} - {/* Switch to toggle group access */} - setAllowGroups(!allowGroups)} - color={'primary'} - /> + ) diff --git a/frontend/frontend/src/i18n/en.ts b/frontend/frontend/src/i18n/en.ts index 9a9b8d08..e42add02 100644 --- a/frontend/frontend/src/i18n/en.ts +++ b/frontend/frontend/src/i18n/en.ts @@ -107,7 +107,8 @@ const english = { acces: 'This gives you access to the course.', deadlines_on: 'Deadlines on', email: 'email', - copy_invite: 'Copy invitation link' + copy_invite: 'Copy invitation link', + n_of_members: 'Max Amount Of Members', } export default english diff --git a/frontend/frontend/src/i18n/nl.ts b/frontend/frontend/src/i18n/nl.ts index 0d228bc1..8ff480a3 100644 --- a/frontend/frontend/src/i18n/nl.ts +++ b/frontend/frontend/src/i18n/nl.ts @@ -107,7 +107,8 @@ const dutch = { acces: 'Dit geeft je toegang tot het vak.', deadlines_on: 'Deadlines op', email: 'email', - copy_invite: 'Kopieer uitnodigingslink' + copy_invite: 'Kopieer uitnodigingslink', + n_of_members: 'Max Aantal Leden', } export default dutch diff --git a/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx b/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx index 27a2a7dc..0068785f 100644 --- a/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx +++ b/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx @@ -99,6 +99,7 @@ export function AddChangeAssignmentPage() { const [maxScore, SetMaxScore] = useState(20) const [cleared, setCleared] = useState(false) const [filename, setFilename] = useState('indiening.zip') + const [groupSize, setGroupSize] = useState(1) // State for the error checks of the assignment const [assignmentErrors, setAssignmentErrors] = useState({ @@ -183,15 +184,11 @@ export function AddChangeAssignmentPage() { setVisible(assignment.zichtbaar) if (assignment.deadline !== null) { - setDueDate( - dayjs(assignment.deadline) - ) + setDueDate(dayjs(assignment.deadline)) console.log('deadline' + assignment.deadline) } if (assignment.extra_deadline !== null) { - setExtraDueDate( - dayjs(assignment.extra_deadline) - ) + setExtraDueDate(dayjs(assignment.extra_deadline)) console.log( 'extra deadline' + assignment.extra_deadline ) @@ -380,6 +377,7 @@ export function AddChangeAssignmentPage() { if (extraDueDate !== null) { formData.append('extra_deadline', extraDueDate.format()) } + formData.append('max_groep_grootte', groupSize.toString()) const config = { headers: { @@ -540,7 +538,7 @@ export function AddChangeAssignmentPage() { {/* Deadline section. - There is both the normal deadline, + There is both the normal deadline, and an extra deadline in case people need more time. */} + {/* change group size allowed, no need for extra group switch*/} + {!assignmentId && ( + + + {t('n_of_members')} + + {loading ? ( + + ) : ( + + setGroupSize( + parseInt(event.target.value) + ) + } + /> + )} + + )} {/* This section allows the teacher to set the maximum score for the assignment.*/} @@ -414,149 +416,126 @@ export function GroupsPage() { <> {user?.is_lesgever ? ( // Rendering UI for teacher - <> - -
- + - - -
+ + + - {t('groups')} - - - - - - {t('amount')} {t('members')}/ - {t('group')} - - - - {loading ? ( - - ) : ( - { - if ( - parseInt( - newValue.target - .value - ) < 1 - ) - return - handleGroupSizeChange( - parseInt( - newValue.target - .value + + {t('groups')} + + + + + + {t('amount')}{' '} + {t('members')}/ + {t('group')} + + + + {loading ? ( + + ) : ( + { + if ( + parseInt( + newValue + .target + .value + ) < 1 ) - ) - }} - variant="outlined" - sx={{ width: 80 }} - /> - )} + return + handleGroupSizeChange( + parseInt( + newValue + .target + .value + ) + ) + }} + variant="outlined" + sx={{ + width: 80, + }} + /> + )} + - - - - {loading ? ( - - ) : ( - - )} - + - - {t('students_choose')} - {loading ? ( ) : ( - + )} - - - + + + {t('students_choose')} + + {loading ? ( + + ) : ( + + )} + + +
- - - - - - - - {t('students')} - - - - - - {loading ? ( - [...Array(3)].map( - (_, index) => ( - - ) - ) - ) : ( - <> - {availableStudents.map( - (student) => ( - - - {studentNames.get( - student - ) === '' - ? student - : studentNames.get( - student - )} - = - newGroupSize - : true - } - onClick={() => { - assignStudent( - student, - parseInt( - currentGroup - ) - ) - }} - > - - - - - ) - )} - - )} - -
-
- - + - - - - - {t('group')} - - {loading ? ( - - ) : ( - <> - - - )} - - - - - {loading ? ( - [...Array(3)].map( - (_, index) => ( - + /> + ) ) - ) - ) : ( - <> - {newGroups[ - parseInt(currentGroup) - ] && - newGroups[ - parseInt( - currentGroup - ) - ].studenten.map( - (student) => ( + ) : ( + <> + {availableStudents.map( + ( + student + ) => ( {studentNames.get( student - )} - = + newGroupSize + : true + } onClick={() => { - removeStudent( + assignStudent( student, parseInt( currentGroup @@ -801,97 +721,286 @@ export function GroupsPage() { ) }} > - + ) )} - - )} - -
-
+ + )} + + + + + + + + + + {t( + 'group' + )} + + {loading ? ( + + ) : ( + <> + + + )} + + + + + {loading ? ( + [ + ...Array(3), + ].map( + ( + _, + index + ) => ( + + ) + ) + ) : ( + <> + {newGroups[ + parseInt( + currentGroup + ) + ] && + newGroups[ + parseInt( + currentGroup + ) + ].studenten.map( + ( + student + ) => ( + + + {studentNames.get( + student + )} + { + removeStudent( + student, + parseInt( + currentGroup + ) + ) + }} + > + + + + + ) + )} + + )} + +
+
+
- - - - - - - - - - - - {loading ? ( - + + + + + - ) : ( - <> - + + + + + {loading ? ( + - - - - )} - - - + /> + ) : ( + <> + + + + + )} + + + + - - {/* Warning popup for when the user wants to confirm the group changes */} - - - ):( - navigate('/course/' + courseId + '/assignment/' + assignmentId + '/groups/choose') - )} - - )} - -)} + {/* Warning popup for when the user wants to confirm the group changes */} + + + ) : ( + navigate( + '/course/' + + courseId + + '/assignment/' + + assignmentId + + '/groups/choose' + ) + )} + + )} + + ) +} diff --git a/frontend/frontend/src/routes.tsx b/frontend/frontend/src/routes.tsx index c16f12a7..598e9b66 100644 --- a/frontend/frontend/src/routes.tsx +++ b/frontend/frontend/src/routes.tsx @@ -8,7 +8,7 @@ import ErrorPage from './pages/ErrorPage.tsx' import MainPage from './pages/mainPage/MainPage.tsx' import { GroupsPage } from './pages/groupsPage/GroupsPage.tsx' import { AssignmentPage } from './pages/assignmentPage/AssignmentPage.tsx' -import {ChooseGroup} from "./pages/groupsPage/ChooseGroup.tsx"; +import { ChooseGroup } from './pages/groupsPage/ChooseGroup.tsx' //TODO: add change/add course page when implemented const router = createBrowserRouter([ From c5f9d58bf9bc6e726ce6d0de8047da6fb36261c9 Mon Sep 17 00:00:00 2001 From: Ben De Meurichy Date: Sat, 18 May 2024 16:08:52 +0200 Subject: [PATCH 03/15] refactor groepen, group grootte is niet aanpasbaar na aanmaken groepen --- frontend/frontend/src/i18n/en.ts | 3 + frontend/frontend/src/i18n/nl.ts | 3 + .../pages/assignmentPage/AssignmentPage.tsx | 18 +- .../src/pages/groupsPage/GroupsPage.tsx | 208 ++++-------------- 4 files changed, 61 insertions(+), 171 deletions(-) diff --git a/frontend/frontend/src/i18n/en.ts b/frontend/frontend/src/i18n/en.ts index e42add02..4d62824d 100644 --- a/frontend/frontend/src/i18n/en.ts +++ b/frontend/frontend/src/i18n/en.ts @@ -109,6 +109,9 @@ const english = { email: 'email', copy_invite: 'Copy invitation link', n_of_members: 'Max Amount Of Members', + existing_submissions: + 'This could impact existing submissions. Are you sure?', + divide_groups: 'Divide Groups', } export default english diff --git a/frontend/frontend/src/i18n/nl.ts b/frontend/frontend/src/i18n/nl.ts index 8ff480a3..6db82aa3 100644 --- a/frontend/frontend/src/i18n/nl.ts +++ b/frontend/frontend/src/i18n/nl.ts @@ -109,6 +109,9 @@ const dutch = { email: 'email', copy_invite: 'Kopieer uitnodigingslink', n_of_members: 'Max Aantal Leden', + existing_submissions: + 'Dit kan invloed hebben op bestaande indieningen. Weet je het zeker?', + divide_groups: 'Verdeel Groepen', } export default dutch diff --git a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx index 7f0c136a..f72ed703 100644 --- a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx +++ b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx @@ -336,12 +336,20 @@ export function AssignmentPage() { }} /> ) : ( - + {(assignment?.max_groep_grootte + ? assignment.max_groep_grootte + : 1) > 1 && ( + )} - courseid={parseInt(courseId)} - /> + )} diff --git a/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx b/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx index 5507032e..7e392958 100644 --- a/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx +++ b/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx @@ -16,7 +16,6 @@ import { TableContainer, TableHead, TableRow, - TextField, Tooltip, Typography, } from '@mui/material' @@ -59,15 +58,17 @@ export function GroupsPage() { ) //state for new groups and new groupSize, don't change the old groups and groupSize until the user clicks save const [newGroups, setNewGroups] = useState([]) - const [newGroupSize, setNewGroupSize] = useState(1) const [currentGroup, setCurrentGroup] = useState('') const [availableStudents, setAvailableStudents] = useState([]) const [projectName, setProjectName] = useState('') const [user, setUser] = useState() - + const [max_group_size, setMaxGroupSize] = useState(0) // confirmation dialog state const [confirmOpen, setConfirmOpen] = useState(false) + //random groups dialog state + const [randomOpen, setRandomOpen] = useState(false) + // state for correct loading of the page const [loading, setLoading] = useState(true) const [userLoading, setUserLoading] = useState(true) @@ -106,17 +107,15 @@ export function GroupsPage() { } else { // update the old groups with the new groups for (const group of newGroups) { - if (group.studenten.length !== 0) { - instance - .put('/groepen/' + group.groep_id + '/', { - groep_id: group.groep_id, - studenten: group.studenten, - project: parseInt(assignmentId), - }) - .catch((error) => { - console.log(error) - }) - } + instance + .put('/groepen/' + group.groep_id + '/', { + groep_id: group.groep_id, + studenten: group.studenten, + project: parseInt(assignmentId), + }) + .catch((error) => { + console.log(error) + }) } } navigate('/course/' + courseId + '/assignment/' + assignmentId) @@ -138,46 +137,6 @@ export function GroupsPage() { navigate('/course/' + courseId + '/assignment/' + assignmentId) } - // Change max group size - const handleGroupSizeChange = (newValue: number) => { - setNewGroupSize(newValue) - setAvailableStudents(() => Array.from(studentNames.keys())) - setCurrentGroup('0') - setNewGroups(() => { - const newGroups = [] - for ( - let i = 0; - i < Math.ceil(availableStudents.length / newValue); - i++ - ) { - newGroups.push({ - studenten: [], - project: parseInt(assignmentId), - }) - } - return newGroups - }) - async function fetchCourse() { - setLoading(true) - instance - .get('/vakken/' + courseId) - .then((response) => { - setAvailableStudents(response.data.studenten) - }) - .catch((error) => { - console.error(error) - }) - setLoading(false) - } - fetchCourse() - .catch((error) => { - console.error(error) - }) - .catch((error) => { - console.log(error) - }) - } - //get the current groups and group size from the backend useEffect(() => { async function fetchData() { @@ -236,7 +195,8 @@ export function GroupsPage() { .get('/projecten/' + assignmentId) .then((response) => { setProjectName(response.data.titel) - setNewGroupSize(response.data.max_groep_grootte) + + setMaxGroupSize(response.data.max_groep_grootte) }) .catch((error) => { console.log(error) @@ -251,21 +211,6 @@ export function GroupsPage() { .get(`/groepen/?project=${assignmentId}`) .then((response) => { const newgroups: Group[] = response.data - if ( - newgroups.length < - Math.ceil(studentNames.size / newGroupSize) - ) { - for ( - let i = newgroups.length; - i < Math.ceil(studentNames.size / newGroupSize); - i++ - ) { - newgroups.push({ - studenten: [], - project: parseInt(assignmentId), - }) - } - } setNewGroups(newgroups) }) .catch((error) => { @@ -276,14 +221,11 @@ export function GroupsPage() { setLoading(false) } - fetchData() - .catch((error) => { - console.error(error) - }) - .catch((error) => { - console.log(error) - }) - }, [assignmentId, courseId, newGroupSize, studentNames.size]) + fetchData().catch((error) => { + console.error(error) + }) + setCurrentGroup('0') + }, [assignmentId, courseId, studentNames.size]) useEffect(() => { setAvailableStudents(() => @@ -296,34 +238,6 @@ export function GroupsPage() { ) }, [newGroups, studentNames]) - // Create new groups when the group size changes - useEffect(() => { - if (newGroups.length === 0) { - setAvailableStudents(() => Array.from(studentNames.keys())) - setCurrentGroup('0') - setNewGroups(() => { - const newGroups = [] - for ( - let i = 0; - i < Math.ceil(availableStudents.length / newGroupSize); - i++ - ) { - newGroups.push({ - studenten: [], - project: parseInt(assignmentId), - }) - } - return newGroups - }) - } - }, [ - assignmentId, - availableStudents.length, - newGroupSize, - newGroups.length, - studentNames, - ]) - //Handle current group change const handleCurrentGroupChange = (event: SelectChangeEvent) => { setCurrentGroup(event.target.value as string) @@ -332,22 +246,18 @@ export function GroupsPage() { // Randomise groups const randomGroups = () => { const students = Array.from(studentNames.keys()) - const newGroups: Group[] = [] - for (let i = 0; i < Math.ceil(students.length / newGroupSize); i++) { - newGroups.push({ - studenten: [], - project: parseInt(assignmentId), + const shuffledStudents = students.sort(() => Math.random() - 0.5) + const randomisedGroups: Group[] = [] + for (const group of newGroups) { + const sliceSize = Math.min(max_group_size, shuffledStudents.length) + randomisedGroups.push({ + ...group, + studenten: shuffledStudents.slice(0, sliceSize), }) + shuffledStudents.splice(0, sliceSize) + if (shuffledStudents.length === 0) break } - for (let i = 0; i < students.length; i++) { - let randomGroup = Math.floor(Math.random() * newGroups.length) - while (newGroups[randomGroup].studenten.length >= newGroupSize) { - randomGroup = Math.floor(Math.random() * newGroups.length) - } - newGroups[randomGroup].studenten.push(students[i]) - } - - setNewGroups(newGroups) + setNewGroups(randomisedGroups) } // assign a student to a group @@ -479,50 +389,6 @@ export function GroupsPage() { {t('group')} - - {loading ? ( - - ) : ( - { - if ( - parseInt( - newValue - .target - .value - ) < 1 - ) - return - handleGroupSizeChange( - parseInt( - newValue - .target - .value - ) - ) - }} - variant="outlined" - sx={{ - width: 80, - }} - /> - )} - + setRandomOpen(true) + } > = - newGroupSize + max_group_size : true } onClick={() => { @@ -989,6 +857,14 @@ export function GroupsPage() { handleClose={handleCloseConfirm} doAction={confirmSave} /> + setRandomOpen(false)} + doAction={randomGroups} + /> ) : ( navigate( From 12d18d842c07c0e507171df13ec00db25cbafd8b Mon Sep 17 00:00:00 2001 From: Gus Vanpoucke <159711661+gusvanpoucke@users.noreply.github.com> Date: Sat, 18 May 2024 21:46:54 +0200 Subject: [PATCH 04/15] assignmentpage crasht niet meer als de student niet ingeschreven is in een groep --- .../src/pages/assignmentPage/AssignmentPage.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx index 20d62583..14a2ca6f 100644 --- a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx +++ b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx @@ -128,10 +128,12 @@ export function AssignmentPage() { const groupResponse = await instance.get<[Group]>( `/groepen/?student=${user.user}&project=${assignmentId}` ) - const submissionsResponse = await instance.get( - `/indieningen/?project=${assignmentId}&groep=${groupResponse.data[0].groep_id}` - ) - setSubmissions(submissionsResponse.data) + if (groupResponse.data.length > 0){ + const submissionsResponse = await instance.get( + `/indieningen/?project=${assignmentId}&groep=${groupResponse.data[0].groep_id}` + ) + setSubmissions(submissionsResponse.data) + } } } } catch (error) { From ef6022fc95084f221ac9653cfe0d48b631c76634 Mon Sep 17 00:00:00 2001 From: Robbe Date: Sun, 19 May 2024 02:54:05 +0200 Subject: [PATCH 05/15] error 404: commit message not found --- frontend/frontend/src/pages/FourOFourPage.tsx | 106 ++++++++++++++++++ frontend/frontend/src/routes.tsx | 7 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 frontend/frontend/src/pages/FourOFourPage.tsx diff --git a/frontend/frontend/src/pages/FourOFourPage.tsx b/frontend/frontend/src/pages/FourOFourPage.tsx new file mode 100644 index 00000000..b4e2098d --- /dev/null +++ b/frontend/frontend/src/pages/FourOFourPage.tsx @@ -0,0 +1,106 @@ +import { Box, Typography } from '@mui/material' +import { t } from 'i18next' + +export default function FourOFourPage() { + return ( + <> + + + + + + + + {"404"} + + + {"Error: Page not found"} + + + + + + + ) +} \ No newline at end of file diff --git a/frontend/frontend/src/routes.tsx b/frontend/frontend/src/routes.tsx index c16f12a7..bb1d3b5d 100644 --- a/frontend/frontend/src/routes.tsx +++ b/frontend/frontend/src/routes.tsx @@ -5,6 +5,7 @@ import { ProjectScoresPage } from './pages/scoresPage/ProjectScoresPage.tsx' import { AddChangeAssignmentPage } from './pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx' import { AddChangeSubjectPage } from './pages/subjectsPage/AddChangeSubjectPage.tsx' import ErrorPage from './pages/ErrorPage.tsx' +import FourOFourPage from "./pages/FourOFourPage.tsx"; import MainPage from './pages/mainPage/MainPage.tsx' import { GroupsPage } from './pages/groupsPage/GroupsPage.tsx' import { AssignmentPage } from './pages/assignmentPage/AssignmentPage.tsx' @@ -63,9 +64,13 @@ const router = createBrowserRouter([ errorElement: , }, { - path: '*', + path: '/error', element: , }, + { + path: '*', + element: , + }, ]) export default router From 06c1c46746cc13194f2999476a89d6ff1c0906fd Mon Sep 17 00:00:00 2001 From: Alexandre Paice Date: Sun, 19 May 2024 13:08:03 +0200 Subject: [PATCH 06/15] studentpopup op assignmentpage --- frontend/frontend/src/i18n/en.ts | 1 - frontend/frontend/src/i18n/nl.ts | 1 - .../pages/assignmentPage/AssignmentPage.tsx | 86 +++++++++++++++---- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/frontend/frontend/src/i18n/en.ts b/frontend/frontend/src/i18n/en.ts index b2b33236..a533e24c 100644 --- a/frontend/frontend/src/i18n/en.ts +++ b/frontend/frontend/src/i18n/en.ts @@ -109,7 +109,6 @@ const english = { deadlines_on: 'Deadlines on', no_assignmentfile: 'No assignment file', email: 'email', - copy_invite: 'Copy invitation link', n_of_members: 'Max Amount Of Members', existing_submissions: 'This could impact existing submissions. Are you sure?', diff --git a/frontend/frontend/src/i18n/nl.ts b/frontend/frontend/src/i18n/nl.ts index fcff447d..bfcb54c1 100644 --- a/frontend/frontend/src/i18n/nl.ts +++ b/frontend/frontend/src/i18n/nl.ts @@ -109,7 +109,6 @@ const dutch = { no_assignmentfile: 'Geen opdrachtbestand', deadlines_on: 'Deadlines op', email: 'email', - copy_invite: 'Kopieer uitnodigingslink', n_of_members: 'Max Aantal Leden', existing_submissions: 'Dit kan invloed hebben op bestaande indieningen. Weet je het zeker?', diff --git a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx index 058d36a8..e833ba36 100644 --- a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx +++ b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx @@ -25,6 +25,8 @@ import { GroupAccessComponent } from '../../components/GroupAccessComponent.tsx' import dayjs from 'dayjs' import DownloadIcon from '@mui/icons-material/Download' import WarningPopup from '../../components/WarningPopup.tsx' +import { User } from '../subjectsPage/AddChangeSubjectPage.tsx' +import StudentPopUp from '../subjectsPage/StudentPopUp.tsx' // group interface export interface Group { @@ -62,9 +64,12 @@ export function AssignmentPage() { const [groups, setGroups] = useState([]) const [submissionFile, setSubmissionFile] = useState() const [submit, setSubmit] = useState(false) + const [students, setStudents] = useState([]) + //state for loading the page const [loading, setLoading] = useState(true) const [userLoading, setUserLoading] = useState(true) + const [studentsLoading, setStudentsLoading] = useState(true) // state for the warning popup const [openNoGroup, setOpenNoGroup] = useState(false) @@ -153,6 +158,30 @@ export function AssignmentPage() { })() }, [assignmentId, courseId, user.is_lesgever, submit, user]) + useEffect(() => { + async function fetchStudents() { + setStudentsLoading(true) + const groupResponse = await instance.get(`groepen/?student=${user.user}&project=${assignmentId}`) + const group: Group = groupResponse.data[0] + const temp_students = [] + for (const s of group.studenten || []) { + try { + const userResponse = await instance.get(`/gebruikers/${s}/`) + temp_students.push(userResponse.data) + } catch (error) { + console.error('Error fetching student data:', error) + } + } + // Update the state with the fetched data + setStudents(temp_students) + setStudentsLoading(false) + } + // Fetch students + fetchStudents().catch((error) => + console.error('Error fetching students data:', error) + ) + }, [user, assignment, groups]) + // Function to download all submissions as a zip file const downloadAllSubmissions = () => { const zip = new JSZip() @@ -665,7 +694,8 @@ export function AssignmentPage() { backgroundColor: 'background.default', }} > - + ) : ( <> - {assignment?.student_groep && ( - + ) : ( + + {assignment?.max_groep_grootte === 1 ? ( + + {user.first_name + ' ' + user.last_name} - - )} - + ) : ( + <> + {console.log(students)} + + + )} + + )} + )} From 1da472259b7ee2682708001ddfd8c58f73d0dafc Mon Sep 17 00:00:00 2001 From: Ben De Meurichy Date: Sun, 19 May 2024 14:26:10 +0200 Subject: [PATCH 07/15] error met inladen user --- .../AddChangeAssignmentPage.tsx | 1217 +++++++++-------- .../subjectsPage/AddChangeSubjectPage.tsx | 326 ++--- 2 files changed, 831 insertions(+), 712 deletions(-) diff --git a/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx b/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx index 54e32149..667d5978 100644 --- a/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx +++ b/frontend/frontend/src/pages/addChangeAssignmentPage/AddChangeAssignmentPage.tsx @@ -163,14 +163,15 @@ export function AddChangeAssignmentPage() { //set the initial values of the assignment if it is an edit useEffect(() => { //get the data - const fetchData = async () => { - //begin loading -> set loading to true + const fetchUser = async () => { setUserLoading(true) - setLoading(true) const userResponse = await instance.get('/gebruikers/me/') setUser(userResponse.data) setUserLoading(false) - + } + const fetchData = async () => { + //begin loading -> set loading to true + setLoading(true) //get the assignment await instance .get(`/projecten/${assignmentId}`) @@ -262,6 +263,9 @@ export function AddChangeAssignmentPage() { } //if there is an assignmentId, get the data else use the default values + fetchUser().catch((error) => { + console.error(error) + }) if (assignmentId !== undefined) { fetchData().catch((error) => { console.error(error) @@ -470,567 +474,664 @@ export function AddChangeAssignmentPage() { <> {user?.is_lesgever ? ( // Rendering UI for teacher - <> - {/* Stack container for layout */} - - {/*very ugly but it works functionally*/} - {loading ? ( -
- ) : ( -
- )} - {/* Form for submitting assignment */} - - - - {/* Here the user gets to specify the assignment name */} - - {t('assignmentName')} - - {loading ? ( - - ) : ( - - setTitle(event.target.value) - } - /> - )} - - {/* File Upload button */} - - {loading ? ( - { - console.log('loading') - }} - fileTypes={['.pdf', '.zip']} - path={new File([], 'loading...')} - /> - ) : ( - - )} - - - {/* Deadline section. + <> + {/* Stack container for layout */} + + {/*very ugly but it works functionally*/} + {loading ? ( +
+ ) : ( +
+ )} + {/* Form for submitting assignment */} + + + + {/* Here the user gets to specify the assignment name */} + + {t('assignmentName')} + + {loading ? ( + + ) : ( + + setTitle( + event.target.value + ) + } + /> + )} + + {/* File Upload button */} + + {loading ? ( + { + console.log('loading') + }} + fileTypes={['.pdf', '.zip']} + path={ + new File( + [], + 'loading...' + ) + } + /> + ) : ( + + )} + + + {/* Deadline section. There is both the normal deadline, and an extra deadline in case people need more time. */} - - - {/* This section renders the normal deadline. */} - - Deadline: - - {loading ? ( - - ) : ( - - - SetDeadlineError(newError) - } - slotProps={{ - field: { - clearable: true, - onClear: () => setCleared(true), - }, - textField: { - helperText: errorMessage, - }, - }} - onChange={(newValue) => - setDueDate(newValue) - } - /> - - )} - - - {/* This section renders the extra deadline. */} - - Extra Deadline: - - {loading ? ( - - ) : ( - - setCleared(true), - }, - textField: { - error: deadlineCheckError, - helperText: deadlineCheckError - ? t('deadlineCheck') - : '', - }, + - setExtraDueDate(newValue) - } - /> - - )} - - - {/* Description section */} - - - - {t('description')} - - {loading ? ( - - ) : ( - - setDescription(event.target.value) - } - fullWidth - error={assignmentErrors.description} - // Show an error message if the description is not filled in. - helperText={ - assignmentErrors.description - ? t('descriptionName') + - ' ' + - t('is_required') - : '' - } - sx={{ - overflowY: 'auto', - maxHeight: '25svh', - }} - /> - )} - - - {/* Restrictions section */} - - - - {t('restrictions')} - - - {/*This list will render the restrictions that are added to the assignment.*/} - - {loading ? ( - - ) : ( - <> - {restrictions.map( - (restriction, index) => { - return ( - - - - ) - } - )} - - )} - - - - - - setRestrictions(newRestrictions) - } - > - - - - - {/* Main actions section */} - - - - {visible ? ( - setVisible(!visible)} + gap={5} > - - - ) : ( - setVisible(!visible)} - > - - - )} - - + {/* This section renders the normal deadline. */} + + Deadline: + + {loading ? ( + + ) : ( + + + SetDeadlineError( + newError + ) + } + slotProps={{ + field: { + clearable: true, + onClear: () => + setCleared( + true + ), + }, + textField: { + helperText: + errorMessage, + }, + }} + onChange={(newValue) => + setDueDate(newValue) + } + /> + + )} + + + {/* This section renders the extra deadline. */} + + Extra Deadline: + + {loading ? ( + + ) : ( + + + setCleared( + true + ), + }, + textField: { + error: deadlineCheckError, + helperText: + deadlineCheckError + ? t( + 'deadlineCheck' + ) + : '', + }, + }} + onChange={(newValue) => + setExtraDueDate( + newValue + ) + } + /> + + )} + + + {/* Description section */} + + + + {t('description')} + + {loading ? ( + + ) : ( + + setDescription( + event.target.value + ) + } + fullWidth + error={ + assignmentErrors.description + } + // Show an error message if the description is not filled in. + helperText={ + assignmentErrors.description + ? t( + 'descriptionName' + ) + + ' ' + + t('is_required') + : '' + } + sx={{ + overflowY: 'auto', + maxHeight: '25svh', + }} + /> + )} + + + {/* Restrictions section */} + - - - - - {/* change group size allowed, no need for extra group switch*/} - {!assignmentId && ( - - + + {t('restrictions')} + + + {/*This list will render the restrictions that are added to the assignment.*/} + + {loading ? ( + + ) : ( + <> + {restrictions.map( + ( + restriction, + index + ) => { + return ( + + + + ) + } + )} + + )} + + + + + + setRestrictions( + newRestrictions + ) + } + > + + + + + {/* Main actions section */} + - {t('n_of_members')} - - {loading ? ( - - ) : ( - - setGroupSize( - parseInt(event.target.value) - ) - } - /> - )} - - )} - {/* This section allows the teacher to set the maximum score for the assignment.*/} - - - Max Score - - {loading ? ( - - ) : ( - { - if (event.target.value !== '') { - const newScore = Math.max( - parseInt( - event.target.value - ), - 0 - ) - SetMaxScore - ? SetMaxScore(newScore) - : undefined - } else { - SetMaxScore - ? SetMaxScore( - parseInt( - event.target.value - ) - ) - : undefined - } - }} - /> - )} - - - {/* Submit and Cancel buttons */} - - - setCancelConfirmation(true)} - sx={{ - backgroundColor: 'secondary.main', - borderRadius: 2, - }} - > - - - - - - - - - - - + + + {visible ? ( + + setVisible(!visible) + } + > + + + ) : ( + + setVisible(!visible) + } + > + + + )} + + + + + + + {/* change group size allowed, no need for extra group switch*/} + {!assignmentId && ( + + + {t('n_of_members')} + + {loading ? ( + + ) : ( + + setGroupSize( + parseInt( + event + .target + .value + ) + ) + } + /> + )} + + )} + {/* This section allows the teacher to set the maximum score for the assignment.*/} + + + Max Score + + {loading ? ( + + ) : ( + { + if ( + event.target + .value !== + '' + ) { + const newScore = + Math.max( + parseInt( + event + .target + .value + ), + 0 + ) + SetMaxScore + ? SetMaxScore( + newScore + ) + : undefined + } else { + SetMaxScore + ? SetMaxScore( + parseInt( + event + .target + .value + ) + ) + : undefined + } + }} + /> + )} + + + {/* Submit and Cancel buttons */} + + + + setCancelConfirmation( + true + ) + } + sx={{ + backgroundColor: + 'secondary.main', + borderRadius: 2, + }} + > + + + + + + + + + + + - {/* Popup for adding restrictions */} + {/* Popup for adding restrictions */} - {/* Confirmation popup for deleting project */} + {/* Confirmation popup for deleting project */} - - {/* Confirmation popup for saving project */} - - {/* Confirmation popup for canceling changes*/} - - + + {/* Confirmation popup for saving project */} + + {/* Confirmation popup for canceling changes*/} + + + + ) : ( + navigate('*') + )} + + )} - ):( - navigate('*') - )} - -)} - -)} + ) +} diff --git a/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx b/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx index 7868a6fc..58bae7af 100644 --- a/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx +++ b/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx @@ -1,6 +1,7 @@ -import { Divider, Card } from '../../components/CustomComponents.tsx' +import { Button, Card, Divider } from '../../components/CustomComponents.tsx' import { Box, + CircularProgress, IconButton, ListItem, ListItemButton, @@ -9,10 +10,8 @@ import { Stack, TextField, Typography, - CircularProgress } from '@mui/material' import { Header } from '../../components/Header' -import { Button } from '../../components/CustomComponents.tsx' import React, { ChangeEvent, useEffect, useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' import List from '@mui/material/List' @@ -572,157 +571,176 @@ export function AddChangeSubjectPage() { <> {user?.is_lesgever ? ( // Rendering UI for teacher - <> - -
- - - - - {t('subject_name') + ':'} - - {loading ? ( - + +
- ) : ( - - setTitle(event.target.value) - } - sx={{ height: 60 }} - /> - )} - - - - - - - - - {t('students')} - - - - {UserList( - loading, - students, - setSelectedStudent, - setOpenStudent - )} - - - - {UploadPart( - studentFile, - handleStudentFileChange, - setEmailStudent, - handleAddStudent, - t('upload_students') - )} - - - {DialogWindow( - handleCloseStudent, - openStudent, - handleRemoveStudent, - t('delete_student') - )} - - - - - {t('teachers')} - - - - {UserList( - loading, - teachers, - setSelectedTeacher, - setOpenTeacher - )} - - - - {UploadPart( - teacherFile, - handleTeacherFileChange, - setEmailTeacher, - handleAddTeacher, - t('upload_teachers') - )} - - - {DialogWindow( - handleCloseTeacher, - openTeacher, - handleRemoveTeacher, - t('delete_teacher') + + + + + {t('subject_name') + ':'} + + {loading ? ( + + ) : ( + + setTitle( + event.target.value + ) + } + sx={{ height: 60 }} + /> + )} + + + + + + + + + {t('students')} + + + + {UserList( + loading, + students, + setSelectedStudent, + setOpenStudent + )} + + + + {UploadPart( + studentFile, + handleStudentFileChange, + setEmailStudent, + handleAddStudent, + t('upload_students') + )} + + + {DialogWindow( + handleCloseStudent, + openStudent, + handleRemoveStudent, + t('delete_student') + )} + + + + + {t('teachers')} + + + + {UserList( + loading, + teachers, + setSelectedTeacher, + setOpenTeacher + )} + + + + {UploadPart( + teacherFile, + handleTeacherFileChange, + setEmailTeacher, + handleAddTeacher, + t('upload_teachers') + )} + + + {DialogWindow( + handleCloseTeacher, + openTeacher, + handleRemoveTeacher, + t('delete_teacher') + )} + + + + ) : ( + navigate('*') )} - - + + )} - ):( - navigate('*') - )} - -)} - -)} + ) +} From 54a2e64f04f6e52cf3761bdf463c6fe13f927b0f Mon Sep 17 00:00:00 2001 From: Gus Vanpoucke <159711661+gusvanpoucke@users.noreply.github.com> Date: Sun, 19 May 2024 14:51:48 +0200 Subject: [PATCH 08/15] groep ids kloppen nu op assignment page voor leerkrachten --- .../SubmissionListItemTeacherPage.tsx | 6 +++--- .../pages/assignmentPage/AssignmentPage.tsx | 21 +++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/frontend/frontend/src/components/SubmissionListItemTeacherPage.tsx b/frontend/frontend/src/components/SubmissionListItemTeacherPage.tsx index 27a4f734..3b5650c1 100644 --- a/frontend/frontend/src/components/SubmissionListItemTeacherPage.tsx +++ b/frontend/frontend/src/components/SubmissionListItemTeacherPage.tsx @@ -15,7 +15,7 @@ import { t } from 'i18next' import dayjs from 'dayjs' interface SubmissionListItemTeacherPageProps { - relative_group_id: string + group_name: string group_id: string assignment_id: string course_id: string @@ -32,7 +32,7 @@ export interface Score { * @param {SubmissionListItemTeacherPageProps} props - Props for SubmissionListItemTeacherPage component */ export function SubmissionListItemTeacherPage({ - relative_group_id, + group_name, group_id, assignment_id, course_id, @@ -148,7 +148,7 @@ export function SubmissionListItemTeacherPage({ color: 'primary.light', }, }} - primary={relative_group_id} + primary={group_name} /> {/* Display submission timestamp */} - {groups.map((group) => ( + {groups.map((group, index) => ( - group.groep_id - ) - ) + - 1 - ).toString()} + group_name={ + assignment + ? assignment.max_groep_grootte > 1 + ? t('group') + ' ' + (index + 1).toString() + : t('group') + ' ' + (index + 1).toString() //TODO Dit vervangen door de naam van de student + : '' + } group_id={group.groep_id.toString()} assignment_id={ assignmentId From 5d0c2222dabba54292d0a344b949578c561a86d9 Mon Sep 17 00:00:00 2001 From: Gus Vanpoucke <159711661+gusvanpoucke@users.noreply.github.com> Date: Sun, 19 May 2024 16:09:29 +0200 Subject: [PATCH 09/15] project pagina werkt terug als er geen opdrachtsbestand is --- .../pages/assignmentPage/AssignmentPage.tsx | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx index 5102d5a8..92a9fb05 100644 --- a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx +++ b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx @@ -100,28 +100,30 @@ export function AssignmentPage() { `/projecten/${assignmentId}/` ) const newAssignment: Project = assignmentResponse.data - newAssignment.filename = - assignmentResponse.data.opgave_bestand.replace( - /^.*[\\/]/, - '' - ) - newAssignment.opgave_bestand = await instance - .get(`/projecten/${assignmentId}/opgave_bestand/`, { - responseType: 'blob', - }) - .then((res) => { - let filename = 'indiening.zip' - if (newAssignment.filename) { - filename = newAssignment.filename - } - const blob = new Blob([res.data], { - type: res.headers['content-type'], + if (assignmentResponse.data.opgave_bestand) { + newAssignment.filename = + assignmentResponse.data.opgave_bestand.replace( + /^.*[\\/]/, + '' + ) + newAssignment.opgave_bestand = await instance + .get(`/projecten/${assignmentId}/opgave_bestand/`, { + responseType: 'blob', }) - const file: File = new File([blob], filename, { - type: res.headers['content-type'], + .then((res) => { + let filename = 'indiening.zip' + if (newAssignment.filename) { + filename = newAssignment.filename + } + const blob = new Blob([res.data], { + type: res.headers['content-type'], + }) + const file: File = new File([blob], filename, { + type: res.headers['content-type'], + }) + return file }) - return file - }) + } setAssignment(newAssignment) if (user) { if (user.is_lesgever) { @@ -854,7 +856,7 @@ export function AssignmentPage() { - ) : ( - - {assignment?.max_groep_grootte === 1 ? ( - - {user.first_name + ' ' + user.last_name} + {assignment?.student_groep ? ( + + ) : ( + + {assignment?.max_groep_grootte === + 1 ? ( + + {user.first_name + + ' ' + + user.last_name} + + ) : ( + <> + {console.log( + students + )} + + + )} + + )} + )} @@ -871,7 +893,10 @@ export function AssignmentPage() {