From 26ddf1d7625a3837d8269a2da08c2d9613be32b0 Mon Sep 17 00:00:00 2001 From: Bram Meir Date: Thu, 9 May 2024 15:42:10 +0200 Subject: [PATCH 01/15] fix: make project creation working again after backend changes --- backend/api/serializers/project_serializer.py | 19 +++++++--- frontend/src/assets/lang/app/en.json | 2 +- .../composables/services/project.service.ts | 36 +++++++++++-------- .../src/views/projects/CreateProjectView.vue | 20 ++++++----- 4 files changed, 48 insertions(+), 29 deletions(-) diff --git a/backend/api/serializers/project_serializer.py b/backend/api/serializers/project_serializer.py index 0f705cf5..087fa6f6 100644 --- a/backend/api/serializers/project_serializer.py +++ b/backend/api/serializers/project_serializer.py @@ -111,11 +111,7 @@ def create(self, validated_data): project = super().create(validated_data) # Create groups for the project, if specified - if number_groups: - for _ in range(number_groups): - Group.objects.create(project=project) - - elif project.group_size == 1: + if project.group_size == 1: # If the group_size is set to one, create a group for each student students = project.course.students.all() @@ -123,6 +119,19 @@ def create(self, validated_data): group = Group.objects.create(project=project) group.students.add(student) + elif number_groups: + + for _ in range(number_groups): + Group.objects.create(project=project) + + else: + # If no number of groups is passed, create #students / group_size groups + number_students = project.course.students.count() + group_size = project.group_size + + for _ in range(0, number_students, group_size): + group = Group.objects.create(project=project) + # If a zip_structure is provided, parse it to create the structure checks zip_structure: InMemoryUploadedFile | None = self.context['request'].FILES.get('zip_structure') if zip_structure: diff --git a/frontend/src/assets/lang/app/en.json b/frontend/src/assets/lang/app/en.json index d2f951a7..7e1905fc 100644 --- a/frontend/src/assets/lang/app/en.json +++ b/frontend/src/assets/lang/app/en.json @@ -69,7 +69,7 @@ "max_score": "Maximum score that can be achieved", "visibility": "Make project visible to students", "scoreVisibility": "Make score, when uploaded, automatically visible to students", - "dockerUpload": "Upload a Dockerfile", + "bashUpload": "Upload a bash script for automatic testing", "submissionStructure": "Structure of how a submission should be made", "noStudents": "No students in this group", "locked": "Closed", diff --git a/frontend/src/composables/services/project.service.ts b/frontend/src/composables/services/project.service.ts index 9c3bdbd4..fc0bd13c 100644 --- a/frontend/src/composables/services/project.service.ts +++ b/frontend/src/composables/services/project.service.ts @@ -75,22 +75,30 @@ export function useProject(): ProjectState { async function createProject(projectData: Project, courseId: string, numberOfGroups: number): Promise { const endpoint = endpoints.projects.byCourse.replace('{courseId}', courseId); + + // Initialize an empty object to hold the data to send + const requestData: Record = { + name: projectData.name, + description: projectData.description, + visible: projectData.visible, + archived: projectData.archived, + locked_groups: projectData.locked_groups, + start_date: projectData.start_date, + deadline: projectData.deadline, + max_score: projectData.max_score, + score_visible: projectData.score_visible, + group_size: projectData.group_size, + zip_structure: projectData.structure_file, + }; + + // Check if the number of groups should be included, only if it is greater than 0 + if (numberOfGroups > 0) { + requestData.number_groups = numberOfGroups; + } + await create( endpoint, - { - name: projectData.name, - description: projectData.description, - visible: projectData.visible, - archived: projectData.archived, - locked_groups: projectData.locked_groups, - start_date: projectData.start_date, - deadline: projectData.deadline, - max_score: projectData.max_score, - score_visible: projectData.score_visible, - group_size: projectData.group_size, - number_groups: numberOfGroups, - zip_structure: projectData.structure_file, - }, + requestData, project, Project.fromJSON, 'multipart/form-data', diff --git a/frontend/src/views/projects/CreateProjectView.vue b/frontend/src/views/projects/CreateProjectView.vue index 88c83ec7..6ad707d4 100644 --- a/frontend/src/views/projects/CreateProjectView.vue +++ b/frontend/src/views/projects/CreateProjectView.vue @@ -9,6 +9,7 @@ import Editor from '@/components/forms/Editor.vue'; import Button from 'primevue/button'; import InputNumber from 'primevue/inputnumber'; import InputSwitch from 'primevue/inputswitch'; +import { SubmissionStatus } from '@/types/SubmisionStatus'; import { reactive, computed } from 'vue'; import { useRouter, useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; @@ -38,7 +39,7 @@ const form = reactive({ maxScore: 10, visibility: true, scoreVisibility: false, - dockerScript: null, + bashScript: null, submissionStructure: null, }); @@ -56,9 +57,9 @@ const rules = computed(() => { }; }); -// Function to handle the file upload of a docker script -const onDockerScriptUpload = (event: any): void => { - form.dockerScript = event.files[0]; +// Function to handle the file upload of a bash script +const onBashScriptUpload = (event: any): void => { + form.bashScript = event.files[0]; }; // Function to handle the file upload of a zip file containing the submission structure @@ -96,6 +97,7 @@ async function submitProject(): Promise { form.scoreVisibility, form.groupSize, course.value, + new SubmissionStatus(0, 0, 0), // Default submission status form.submissionStructure, ), params.courseId as string, @@ -226,18 +228,18 @@ async function submitProject(): Promise {
- +
-
From adec3f1113e63a09344a71cafa33770061aa23dd Mon Sep 17 00:00:00 2001 From: Bram Meir Date: Thu, 9 May 2024 18:14:12 +0200 Subject: [PATCH 02/15] chore: init layout extra checks --- frontend/src/assets/lang/app/nl.json | 13 +- .../components/projects/ExtraChecksUpload.vue | 195 ++++++++++++++++++ .../src/views/projects/CreateProjectView.vue | 22 +- 3 files changed, 211 insertions(+), 19 deletions(-) create mode 100644 frontend/src/components/projects/ExtraChecksUpload.vue diff --git a/frontend/src/assets/lang/app/nl.json b/frontend/src/assets/lang/app/nl.json index 92456aa0..2d05624a 100644 --- a/frontend/src/assets/lang/app/nl.json +++ b/frontend/src/assets/lang/app/nl.json @@ -69,9 +69,18 @@ "max_score": "Maximale te behalen score", "visibility": "Project zichtbaar maken voor studenten", "scoreVisibility": "Maak score, wanneer ingevuld, automatisch zichtbaar voor studenten", - "dockerUpload": "Upload een Dockerfile", "submissionStructure": "Structuur van hoe de indiening moet gebeuren", - "noStudents": "Geen studenten in deze groep" + "noStudents": "Geen studenten in deze groep", + "extraChecks": { + "title": "Voeg een automatische check toe", + "add": "Nieuwe check", + "name": "Naam", + "bashScript": "Bash script", + "dockerImage": "Docker image", + "timeLimit": "Tijdslimiet voor de uitvoering (in seconden)", + "memoryLimit": "Geheugenlimiet voor de uitvoering (in MB)", + "showLog": "Toon logbestand aan studenten" + } }, "submissions": { "title": "Inzendingen", diff --git a/frontend/src/components/projects/ExtraChecksUpload.vue b/frontend/src/components/projects/ExtraChecksUpload.vue new file mode 100644 index 00000000..cf7b1767 --- /dev/null +++ b/frontend/src/components/projects/ExtraChecksUpload.vue @@ -0,0 +1,195 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/projects/CreateProjectView.vue b/frontend/src/views/projects/CreateProjectView.vue index 6ad707d4..b1c5ae82 100644 --- a/frontend/src/views/projects/CreateProjectView.vue +++ b/frontend/src/views/projects/CreateProjectView.vue @@ -18,6 +18,7 @@ import { useProject } from '@/composables/services/project.service'; import { required, helpers } from '@vuelidate/validators'; import { useVuelidate } from '@vuelidate/core'; import { useCourses } from '@/composables/services/course.service'; +import ExtraChecksUpload from '@/components/projects/ExtraChecksUpload.vue'; /* Composable injections */ const { t } = useI18n(); @@ -39,7 +40,6 @@ const form = reactive({ maxScore: 10, visibility: true, scoreVisibility: false, - bashScript: null, submissionStructure: null, }); @@ -57,11 +57,6 @@ const rules = computed(() => { }; }); -// Function to handle the file upload of a bash script -const onBashScriptUpload = (event: any): void => { - form.bashScript = event.files[0]; -}; - // Function to handle the file upload of a zip file containing the submission structure const onZipStructureUpload = (event: any): void => { form.submissionStructure = event.files[0]; @@ -229,18 +224,11 @@ async function submitProject(): Promise {
-
-