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

bij projecten zonder groepen worden nu student namen getoond #277

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
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
19 changes: 17 additions & 2 deletions frontend/frontend/src/pages/assignmentPage/AssignmentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function AssignmentPage() {
const [assignment, setAssignment] = useState<Project>()
const [submissions, setSubmissions] = useState<Submission[]>([])
const [groups, setGroups] = useState<Group[]>([])
const [singleStudents, setSingleStudents] = useState<User[]>([])
const [submissionFile, setSubmissionFile] = useState<File>()
const [submit, setSubmit] = useState(false)
const [students, setStudents] = useState<User[]>([])
Expand Down Expand Up @@ -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}`
Expand Down Expand Up @@ -495,7 +508,7 @@ export function AssignmentPage() {
pr={3}
>
<Typography sx={{ fontWeight: 'bold' }}>
{t('group')}
Student
</Typography>
<Typography sx={{ fontWeight: 'bold' }}>
{t('time')}
Expand Down Expand Up @@ -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()}
Expand Down