From 881b2f10c62eefaccfc0056a9bd49b1cbfb36c5f Mon Sep 17 00:00:00 2001 From: Gus Vanpoucke <159711661+gusvanpoucke@users.noreply.github.com> Date: Sun, 19 May 2024 16:40:54 +0200 Subject: [PATCH] bij projecten zonder groepen worden nu student namen getoond --- .../pages/assignmentPage/AssignmentPage.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx index 92a9fb05..e537b83f 100644 --- a/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx +++ b/frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx @@ -62,6 +62,7 @@ export function AssignmentPage() { const [assignment, setAssignment] = useState() const [submissions, setSubmissions] = useState([]) const [groups, setGroups] = useState([]) + const [singleStudents, setSingleStudents] = useState([]) const [submissionFile, setSubmissionFile] = useState() const [submit, setSubmit] = useState(false) const [students, setStudents] = useState([]) @@ -131,6 +132,18 @@ export function AssignmentPage() { `/groepen/?project=${assignmentId}` ) setGroups(groupsResponse.data) + if(newAssignment.max_groep_grootte == 1) { + const temp_students = [] + for (const g of groupsResponse.data) { + try { + const userResponse = await instance.get(`/gebruikers/${g.studenten[0]}/`) + temp_students.push(userResponse.data) + } catch (error) { + console.error('Error fetching student data:', error) + } + } + setSingleStudents(temp_students) + } } else { const groupResponse = await instance.get<[Group]>( `/groepen/?student=${user.user}&project=${assignmentId}` @@ -495,7 +508,7 @@ export function AssignmentPage() { pr={3} > - {t('group')} + Student {t('time')} @@ -550,7 +563,9 @@ export function AssignmentPage() { 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 + : singleStudents[index] + ? singleStudents[index].first_name + ' ' + singleStudents[index].last_name + : '' : '' } group_id={group.groep_id.toString()}