Skip to content

Commit

Permalink
Merge branch 'refs/heads/run_checks_fix_frontend' into run_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DeLany123 committed May 6, 2024
2 parents 7edea0c + d886bfe commit dc15f83
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/projects/ProjectDetailCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function isInGroup(): boolean {
>: {{ project.getFormattedDeadline() }}<br />
</div>
<div>
<ProjectMeter :submission-status="project.status" />
<ProjectMeter :project="project" />
</div>
</template>
<template #footer>
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/components/projects/ProjectMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
import MeterGroup from 'primevue/metergroup';
import Skeleton from 'primevue/skeleton';
import { computed } from 'vue';
import { type SubmissionStatus } from '@/types/SubmisionStatus.ts';
import { useI18n } from 'vue-i18n';
import { type Project } from '@/types/Project.ts';
/* Props */
const props = defineProps<{
submissionStatus: SubmissionStatus | null;
project: Project | null;
}>();
/* Composable injections */
const { t } = useI18n();
/* State */
const meterItems = computed(() => {
const groups = props.submissionStatus !== null ? props.submissionStatus.non_empty_groups : 0;
const groupsSubmitted = props.submissionStatus !== null ? props.submissionStatus.groups_submitted : 0;
const submissionsPassed = props.submissionStatus !== null ? props.submissionStatus.submissions_passed : 0;
const groups = props.project !== null ? props.project.status.non_empty_groups : 0;
const groupsSubmitted = props.project !== null ? props.project.status.groups_submitted : 0;
const submissionsPassed = props.project !== null ? props.project.status.submissions_passed : 0;
const submissionsFailed = groupsSubmitted - submissionsPassed;
return [
{
Expand All @@ -37,18 +37,18 @@ const meterItems = computed(() => {
</script>

<template>
<template v-if="submissionStatus !== null">
<template v-if="submissionStatus.groups_submitted > 0">
<template v-if="project !== null && project.status !== null">
<template v-if="project.status.groups_submitted > 0">
<MeterGroup :value="meterItems" labelOrientation="vertical">
<template #start>
<div class="flex justify-between mt-2 relative">
<span>
{{ submissionStatus.groups_submitted }}
{{ t('components.card.submissions', submissionStatus.groups_submitted) }}
{{ project.status.groups_submitted }}
{{ t('components.card.submissions', project.status.groups_submitted) }}
</span>
<span class="w-full absolute text-right">
{{ submissionStatus.non_empty_groups }}
{{ t('components.card.groups', submissionStatus.non_empty_groups) }}
{{ project.status.non_empty_groups }}
{{ t('components.card.groups', project.status.non_empty_groups) }}
</span>
</div>
</template>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/composables/services/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export function useSubmission(): SubmissionState {

async function createSubmission(uploadedFiles: File[], groupId: string): Promise<void> {
const endpoint = endpoints.submissions.byGroup.replace('{groupId}', groupId);
await create(endpoint, uploadedFiles, submission, Submission.fromJSONCreate, 'multipart/form-data');
// formData is necessary with multiform data (otherwise files value is changed to files[] by axios)
const formData = new FormData();
uploadedFiles.forEach((file: File) => {
formData.append('files', file); // Gebruik 'files' in plaats van 'files[]'
});
await create(endpoint, formData, submission, Submission.fromJSONCreate, 'multipart/form-data');
}

async function deleteSubmission(id: string): Promise<void> {
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/types/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export class Project {
* @returns True if the project is locked, false otherwise.
*/
public isLocked(): boolean {
return !this.visible || this.archived || this.locked_groups || moment(this.start_date).isBefore();
return (
!this.visible ||
this.archived ||
this.locked_groups ||
moment(this.start_date).isBefore(moment().startOf('day'))
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/types/submission/Submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Submission {
public id: string,
public submission_number: number,
public submission_time: Date,
public files: File[] = [],
public zip: File,
public extraCheckResults: ExtraCheckResult[] = [],
public structureCheckResults: StructureCheckResult[] = [],
public is_valid: boolean,
Expand Down Expand Up @@ -61,7 +61,7 @@ export class Submission {
submission.id,
submission.submission_number,
new Date(submission.submission_time),
submission.files,
submission.zip,
extraCheckResults,
structureCheckResult,
submission.is_valid,
Expand All @@ -78,7 +78,7 @@ class ResponseSubmission {
public id: string,
public submission_number: number,
public submission_time: Date,
public files: File[] = [],
public zip: File,
public results: any[],
public is_valid: boolean,
) {}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/views/projects/roles/StudentProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ async function loadStudentGroups(): Promise<void> {
</template>
<template v-else>
<SubmissionCard class="mb-3" :group="group" />
<JoinedGroupCard :group="group" @group-left="loadStudentGroups"></JoinedGroupCard>
<JoinedGroupCard
v-if="project.group_size !== 1"
:group="group"
@group-left="loadStudentGroups"
></JoinedGroupCard>
</template>
</template>
<template v-else>
Expand Down
21 changes: 2 additions & 19 deletions frontend/src/views/projects/roles/TeacherProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,14 @@ import Skeleton from 'primevue/skeleton';
import { type Teacher } from '@/types/users/Teacher.ts';
import { type Project } from '@/types/Project.ts';
import ProjectInfo from '@/components/projects/ProjectInfo.vue';
import { useSubmissionStatus } from '@/composables/services/submission_status.service.ts';
import { watch } from 'vue';
import ProjectMeter from '@/components/projects/ProjectMeter.vue';
/* Props */
const props = defineProps<{
defineProps<{
teacher: Teacher;
project: Project | null;
}>();
/* Composable injections */
const { submissionStatus, getSubmissionStatusByProject } = useSubmissionStatus();
/* Watchers */
watch(
() => props.project,
() => {
if (props.project !== null) {
getSubmissionStatusByProject(props.project.id);
}
},
{
immediate: true,
},
);
</script>

<template>
Expand All @@ -52,7 +35,7 @@ watch(
</template>
</div>
<div class="col-12 md:col-4">
<ProjectMeter :submission-status="submissionStatus" />
<ProjectMeter :project="project" />
</div>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/submissions/SubmissionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ onMounted(async () => {
const onUpload = async (callback: () => void): Promise<void> => {
if (group.value !== null) {
console.log(files.value as File[])
await createSubmission(files.value as File[], group.value.id);
if (submission.value != null) {
submissions.value = [...(submissions.value ?? []), submission.value];
Expand Down

0 comments on commit dc15f83

Please sign in to comment.