Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaVandewalle committed May 23, 2024
2 parents 77b27db + 2546385 commit 1877197
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 19 deletions.
2 changes: 2 additions & 0 deletions backend/fill_database_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ def fill_database_mock() -> None:
admin1 = create_student(session, "Bart Coppens", "[email protected]")
admin2 = create_student(session, "Bart Mesuere", "[email protected]")
admin3 = create_student(session, "Annick Van Daele", "[email protected]")
admin4 = create_student(session, "Charlotte Van Petegem", "[email protected]")
modify_user_roles(session, admin1.id, [Role.STUDENT, Role.TEACHER, Role.ADMIN])
modify_user_roles(session, admin2.id, [Role.STUDENT, Role.TEACHER, Role.ADMIN])
modify_user_roles(session, admin3.id, [Role.STUDENT, Role.TEACHER, Role.ADMIN])
modify_user_roles(session, admin4.id, [Role.STUDENT, Role.TEACHER, Role.ADMIN])
session.commit()
session.close()

Expand Down
5 changes: 5 additions & 0 deletions docs/documentatie.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ Zie [simple constraints](simple_constraints.md) voor meer uitleg hoe je basis be
Hier kan je ook een docker file uploaden voor jouw geautomatiseerde testen.
Lees de documentatie van hoe deze werken op de [officiele docker site](https://docs.docker.com/reference/dockerfile/).

Enkele extra dingen om rekening mee te houden.
- Je kan aan de indiening door de kijken in het bestand `/submission` in de docker container.
- status code van het commando geeft aan als het geslaagd is of niet
- alles dat geprint wordt naar stdout tijdens het uitvoeren van de docker file wordt getoond aan de studenten.

## Cursussen pagina

Hier krijg je een oplijsting van al jouw cursussen, ook van de reeds gearchiveerde.
Expand Down
5 changes: 3 additions & 2 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
},
"save_button": "Save",
"error_title": "Oops, something went wrong!",
"error_text": "You don't have any courses yet, please create a course first in order to create a project"
"error_text": "You don't have any courses yet, please create a course first in order to create a project",
"enable_constraints": "Enable file constraints"
},
"submission_files": {
"root_switch": {
Expand Down Expand Up @@ -282,4 +283,4 @@
"download": {
"download_all": "Download all submissions"
}
}
}
3 changes: 2 additions & 1 deletion frontend/public/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
},
"save_button": "Opslaan",
"error_title": "Oeps, er is iets fout gegaan!",
"error_text": "Je hebt nog geen vakken, maak eerst een vak aan om een project te kunnen maken."
"error_text": "Je hebt nog geen vakken, maak eerst een vak aan om een project te kunnen maken.",
"enable_constraints": "Zet bestandsvoorwaarden aan"
},
"submission_files": {
"root_switch": {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/ManageCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import adminLoader from "../dataloaders/AdminLoader.ts";
async function get_teachers(current_teachers: { name: string, email: string, id: number }[]) {
const data = await adminLoader(); // Replace this with your actual data fetching logic
const users = data.users.filter((user) => user.user_roles.includes("TEACHER"));
console.log(users)
return users.map((user) => ({
name: user.user_name,
email: user.user_email,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/ProjectStudentComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ProjectInfo(props: { project: ProjectStudent }): JSX.Element {
</div>
<FieldWithLabel fieldLabel={"> " + t('project.description')}
fieldBody={props.project.description} arrow={false}/>
<div className="field is-horizontal">
{props.project.requiredFiles != null && <div className="field is-horizontal">
<div className="field-label">
<label className="label">{"> " + t('project.submission_files') + ":"}</label>
</div>
Expand All @@ -52,7 +52,7 @@ function ProjectInfo(props: { project: ProjectStudent }): JSX.Element {
/>
</div>
</div>
</div>
</div>}
</div>
)
}
Expand Down
35 changes: 32 additions & 3 deletions frontend/src/components/ProjectTeacherComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,31 @@ export function ProjectTeacherComponent(props: {
document.body.removeChild(a);
}
}

function toggleRequirements(enabled: boolean) {
if (enabled) {
setRequiredFiles({
type: "SUBMISSION",
root_constraint: {
type: "FILE",
file_name: "CHANGE_ME"
}
});
} else {
setRequiredFiles(null);
}
}
async function handleSaveClick() {
let requirements = "";
if (requiredFiles != null) {
requirements = JSON.stringify(requiredFiles);
}
const projectInput: ProjectInput = {
name: projectName,
deadline: deadline,
visible: visible,
archived: archived,
description: description,
requirements: JSON.stringify(requiredFiles),
requirements: requirements,
max_students: max_students == 0 ? 1 : max_students,
dockerfile: dockerString
}
Expand Down Expand Up @@ -395,6 +411,19 @@ export function ProjectTeacherComponent(props: {
</div>
{/* SUBMISSION FIELD */}
<div className="field is-horizontal">
<div className="field-label">
<label className="label">{t('create_project.enable_constraints')}</label>
</div>
<div className="field-body is-fullwidth is-align-content-center">
<Switch
type="checkbox"
onColor="#006edc"
checked={requiredFiles != null}
onChange={(e) => toggleRequirements(e)}
/>
</div>
</div>
{requiredFiles != null && <div className="field is-horizontal">
<div className="field-label">
<label className="label">{t('create_project.submission_files.tag')}</label>
</div>
Expand All @@ -408,7 +437,7 @@ export function ProjectTeacherComponent(props: {
/>
</div>
</div>
</div>
</div>}

{/* VISIBLE FIELD*/}
<div className="field is-horizontal">
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/dataloaders/ProjectsTeacherLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export async function LoadProjectsForTeacher(filter_on_current: boolean = false,

const allGroups: (Group[]|undefined)[] = (await groupPromises)
const groups: Group[][] = allGroups.filter(group => group !== undefined) as Group[][]
const groupsR = await Promise.all(groups.map(groupArray => Promise.all(groupArray.map(group => apiFetch<Backend_submission>(`/groups/${group.group_id}/submission`)))));
const amount_of_submissions: number[] = []
for (const groupArray of groups) {
for (const groupArray of groupsR) {
let amount = 0
for (const group of groupArray) {
for (const submissionData of groupArray) {
try {
const submissionData = await apiFetch<Backend_submission>(`/groups/${group.group_id}/submission`);
if (!submissionData.ok){
continue
}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/pages/student/ProjectViewStudent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ export default function ProjectViewStudent(): JSX.Element {
lastSubmission: project_data.submission_student_id === member?.user_id
}
});
let requiredFiles;
if (project_data.project_requirements == "") {
requiredFiles = null;
} else {
requiredFiles = JSON.parse(project_data.project_requirements) as object
}
const project: ProjectStudent = {
projectId: project_data.project_id,
projectName: project_data.project_name,
courseName: project_data.course_name,
deadline: deadline_to_string(project_data.project_deadline),
status: project_status,
description: project_data.project_description,
requiredFiles: JSON.parse(project_data.project_requirements) as object,
requiredFiles: requiredFiles,
group_id: project_data.group_id,
groups_info: project_data.groups_info,
groupMembers: groupMembers,
Expand All @@ -71,4 +77,4 @@ export default function ProjectViewStudent(): JSX.Element {
</div>
</>
)
}
}
9 changes: 7 additions & 2 deletions frontend/src/pages/teacher/ProjectViewTeacher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export default function ProjectViewTeacher() {
if (!projectName){
setProjectName(project_data.project_name)
}

let requiredFiles;
if (project_data.project_requirements == "") {
requiredFiles = null;
} else {
requiredFiles = JSON.parse(project_data.project_requirements) as object
}
const project: ProjectTeacher = {
projectId: project_data.project_id,
projectName: project_data.project_name,
Expand All @@ -38,7 +43,7 @@ export default function ProjectViewTeacher() {
archived: project_data.project_archived,
description: project_data.project_description,
maxGroupMembers: project_data.project_max_students,
requiredFiles: JSON.parse(project_data.project_requirements) as object,
requiredFiles: requiredFiles,
otherFilesAllow: true,
groupProject: project_data.project_max_students > 1,
dockerFile: project_data.project_dockerfile,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ProjectTeacher = {
visible: boolean,
archived: boolean,
description: string,
requiredFiles: object,
requiredFiles: object | null,
otherFilesAllow: boolean,
groupProject: boolean,
maxGroupMembers: number,
Expand All @@ -36,7 +36,7 @@ export type ProjectStudent = {
deadline: string,
status: ProjectStatus,
description: string,
requiredFiles: object,
requiredFiles: object | null,
group_id: number,
groups_info: GroupInfo[] | undefined,
groupMembers: {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/utils/api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function modify_language(language: string): void {
}

export function modify_roles(userId: number, roles: string[]): void {
console.log(JSON.stringify(roles))
void apiFetch(`/users/${userId}?roles=${JSON.stringify({roles})}`, {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
Expand Down

0 comments on commit 1877197

Please sign in to comment.