diff --git a/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx b/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx index 7fefa1f6..0adc7412 100644 --- a/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx +++ b/frontend/frontend/src/pages/groupsPage/GroupsPage.tsx @@ -22,7 +22,7 @@ import { } from '@mui/material' import Switch from '@mui/material/Switch' import { t } from 'i18next' -import { FormEvent, useEffect, useState } from 'react' +import { FormEvent, useEffect, useState, ChangeEvent } from 'react' import { useNavigate, useParams } from 'react-router-dom' import instance from '../../axiosConfig.ts' import CancelIcon from '@mui/icons-material/Cancel' @@ -65,6 +65,7 @@ export function GroupsPage() { const [projectName, setProjectName] = useState('') const [user, setUser] = useState() const [max_group_size, setMaxGroupSize] = useState(0) + const [studentsCanChoose, setStudentsCanChoose] = useState(false) // confirmation dialog state const [confirmOpen, setConfirmOpen] = useState(false) @@ -78,6 +79,10 @@ export function GroupsPage() { // handle confirmation dialog const confirmSave = async () => { + await instance.patch('/projecten/' + assignmentId + '/', { + student_groep: studentsCanChoose, + }) + if (newGroups[0].groep_id === undefined) { // delete the old groups and replace them with the new groups await instance @@ -176,13 +181,15 @@ export function GroupsPage() { console.error(error) }) - // Get the max group size and project name + // Get the max group size, project name and students can choose await instance .get('/projecten/' + assignmentId) .then((response) => { setProjectName(response.data.titel) + setStudentsCanChoose(response.data.student_groep) setMaxGroupSize(response.data.max_groep_grootte) + setStudentChoose(response.data.student_groep) }) .catch((error) => { console.log(error) @@ -470,7 +477,19 @@ export function GroupsPage() { }} /> ) : ( - + + setStudentsCanChoose( + !studentsCanChoose + ) + } + /> )} diff --git a/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx b/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx index 1949639e..510f084b 100644 --- a/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx +++ b/frontend/frontend/src/pages/subjectsPage/SubjectsPage.tsx @@ -322,21 +322,33 @@ export function SubjectsPage() { )} - - + + + + + + +