Skip to content

Commit

Permalink
Submission view (#333)
Browse files Browse the repository at this point in the history
* feat: allsubmissions view

* Better academic year selector, filtering and sorting (#292)

* feat: academic year selector, better pagination and filtering composables

* chore: added course pagination

* Run submission checks (#268)

* chore: celery #206

* chore: Support partial update for project

* chore: support patch for project 2

* refactor!: rework checks and submissions

* chore: allow models passed to tasks

* feat: added -k to test.sh

* chore: improved layout

* feat: allsubmissions view 2

* Run submission checks (#268)

* chore: celery #206

* chore: Support partial update for project

* chore: support patch for project 2

* refactor!: rework checks and submissions

* chore: allow models passed to tasks

* feat: added -k to test.sh

* chore: improved layout

* Frontend rebased submission view

* chore: commit before merge

* chore: commit before rebasing

* fix: Frontend works on new submissions

* Better academic year selector, filtering and sorting (#292)

* feat: academic year selector, better pagination and filtering composables

* chore: added course pagination

* Run submission checks (#268)

* chore: celery #206

* chore: Support partial update for project

* chore: support patch for project 2

* refactor!: rework checks and submissions

* chore: allow models passed to tasks

* feat: added -k to test.sh

* chore: improved layout

* Frontend rebased submission view

* chore: commit before merge

* chore: finish logic submissionView.vue

* chore: bugfixes and layout

* chore: Finished submissionView

* chore: lint fixes for #333

* chore: Removed useless checks #333

* chore: impossible to fail now #333

* chore: impossible to fail now v2 #333

* chore: changes to make Ewout happy

---------

Co-authored-by: Ewout Verlinde <ewoutverlinde@hotmail.com>
Co-authored-by: Vincent Vallaeys <vincent@vallaeys.com>
  • Loading branch information
3 people authored Apr 18, 2024
1 parent 6856324 commit 56c21f7
Show file tree
Hide file tree
Showing 24 changed files with 411 additions and 105 deletions.
7 changes: 7 additions & 0 deletions backend/api/tasks/extra_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from api.models.submission import Submission
from celery import shared_task


@shared_task
def task_extra_check_start(submission_id):
pass
2 changes: 1 addition & 1 deletion backend/api/tasks/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# TODO
# ! This works
# ! But not async | I can obviouly do this in the same function dummy
# ! But not async | I can obviously do this in the same function dummy
def test_print(id, result):
print("result: " + str(result), flush=True)

Expand Down
3 changes: 2 additions & 1 deletion backend/api/views/group_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@ def _add_submission(self, request: Request, **_):
serializer.save(group=group)

return Response({
"message": gettext("group.success.submissions.add")
"message": gettext("group.success.submissions.add"),
"submission": serializer.data
})
4 changes: 0 additions & 4 deletions backend/setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
echo "Installing dependencies..."
pip install poetry > /dev/null 2>&1
poetry install > /dev/null

echo "Migrating database..."
python manage.py migrate > /dev/null

echo "Compiling translations..."
django-admin compilemessages > /dev/null

echo "Generating Swagger documentation..."
echo "yes" | python manage.py collectstatic > /dev/null

echo "Done"
17 changes: 16 additions & 1 deletion frontend/src/assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@
"title": "Submissions",
"submit": "Submit",
"course": "Course",
"chooseFile": "Choose a file"
"chooseFile": "Choose a file",
"hoverText": {
"allChecksFailed": "Structure and extra checks failed",
"allChecksPassed": "All checks passed",
"extraChecksFailed": "Extra checks failed",
"structureChecksFailed": "Structure checks failed"
},
"timeSince": {
"today": "Today",
"daysAgo": "day(s) ago",
"weekAgo": "More than a week ago",
"monthAgo": "More than a month ago"
}
},
"courses": {
"create": "Create course",
Expand Down Expand Up @@ -150,6 +162,9 @@
"teacher": "Teacher"
}
},
"helpers": {
"loading": "Loading...,"
},
"toasts": {
"messages": {
"success": "Success",
Expand Down
22 changes: 18 additions & 4 deletions frontend/src/assets/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@
"title": "Inzendingen",
"submit": "Indienen",
"course": "Vak",
"chooseFile": "Kies bestand(en)"
"chooseFile": "Kies bestand(en)",
"hoverText": {
"allChecksFailed": "Structuur en extra checks gefaald",
"allChecksPassed": "Alle checks geslaagd",
"extraChecksFailed": "Extra checks gefaald",
"structureChecksFailed": "Structuur checks gefaald"
},
"timeSince": {
"today": "Vandaag",
"daysAgo": "dag(en) geleden",
"weekAgo": "Meer dan een week geleden",
"monthAgo": "Meer dan een maand geleden"
}
},
"courses": {
"create": "Creëer vak",
Expand Down Expand Up @@ -126,9 +138,8 @@
}
},
"components": {
"button": {
"academic_year": "Academiejaar {0}",
"createProject": "Maak een nieuw project"
"buttons": {
"academic_year": "Academiejaar {0}"
},
"card": {
"open": "Details",
Expand All @@ -151,6 +162,9 @@
"teacher": "Professor"
}
},
"helpers": {
"loading": "Laden...,"
},
"toasts": {
"messages": {
"success": "Succes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
// theme
.p-tooltip {
.p-tooltip-text {
background: $tooltipBg;
background: $primaryColor;
color: $tooltipTextColor;
padding: $tooltipPadding;
box-shadow: $inputOverlayShadow;
Expand All @@ -66,25 +66,25 @@

&.p-tooltip-right {
.p-tooltip-arrow {
border-right-color: $tooltipBg;
border-right-color: $primaryColor;
}
}

&.p-tooltip-left {
.p-tooltip-arrow {
border-left-color: $tooltipBg;
border-left-color: $primaryColor;
}
}

&.p-tooltip-top {
.p-tooltip-arrow {
border-top-color: $tooltipBg;
border-top-color: $primaryColor;
}
}

&.p-tooltip-bottom {
.p-tooltip-arrow {
border-bottom-color: $tooltipBg;
border-bottom-color: $primaryColor;
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/layout/base/BaseLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Footer from '@/components/layout/Footer.vue';
</script>

<template>
<div id="layout" class="w-12 lg:w-11 xl:w-9 mx-auto h-100">
<div id="layout" class="w-12 lg:w-11 xl:w-9 mx-auto">
<Header />

<Body id="body">
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/projects/ProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ watch(
>: {{ formattedDeadline }}<br />
</div>
<div>
<i :class="['pi', PrimeIcons.INFO_CIRCLE, 'icon-color']" class="mr-2"></i>
<b>{{ t('views.projects.submissionStatus') }}</b
>:
<MeterGroup
v-if="(submissionStatus?.groups_submitted || 0) > 0"
:value="meterItems"
Expand Down
45 changes: 43 additions & 2 deletions frontend/src/components/projects/SubmissionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { computed, onMounted } from 'vue';
import { useSubmission } from '@/composables/services/submission.service.ts';
import { type Group } from '@/types/Group.ts';
import Button from 'primevue/button';
import { type Submission } from '@/types/submission/Submission.ts';
import { type ExtraCheckResult } from '@/types/submission/ExtraCheckResult.ts';
import { type StructureCheckResult } from '@/types/submission/StructureCheckResult.ts';
const { t } = useI18n();
const { submissions, getSubmissionByGroup } = useSubmission();
Expand All @@ -26,6 +29,35 @@ const formattedDeadline = computed(() => {
const date = new Date(props.project.deadline);
return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`;
});
/**
* Returns the icon name, color and hover text for the submission
* @param submission
*/
const parseSubmissionStatus = (submission: Submission): string => {
if (
!(
submission.extraCheckResults.map((check: ExtraCheckResult) => check.result === 'SUCCESS').every(Boolean) ||
submission.structureCheckResults
.map((check: StructureCheckResult) => check.result === 'SUCCESS')
.every(Boolean)
)
) {
return t('views.submissions.hoverText.allChecksPassed');
} else if (
!submission.extraCheckResults.map((check: ExtraCheckResult) => check.result === 'SUCCESS').every(Boolean)
) {
return t('views.submissions.hoverText.extraChecksFailed');
} else if (
!submission.structureCheckResults
.map((check: StructureCheckResult) => check.result === 'SUCCESS')
.every(Boolean)
) {
return t('views.submissions.hoverText.structureChecksFailed');
} else {
return t('views.submissions.hoverText.allChecksPassed');
}
};
</script>

<template>
Expand All @@ -39,12 +71,21 @@ const formattedDeadline = computed(() => {
<div>
<i :class="['pi', PrimeIcons.INFO_CIRCLE, 'icon-color']" class="mr-2"></i>
{{ t('views.projects.submissionStatus') }}:
{{ submissions ? submissions.at(-1)?.structure_checks_passed : 'false' }}
{{
submissions && submissions.length > 0
? parseSubmissionStatus(submissions.at(-1)!)
: t('helpers.loading')
}}
</div>
</div>
</template>
<template #footer>
<RouterLink :to="{ name: 'submission' }">
<RouterLink
:to="{
name: 'submission',
params: { groupId: props.group.id },
}"
>
<Button :icon="PrimeIcons.ARROW_RIGHT" :label="t('components.submission')" icon-pos="right" outlined />
</RouterLink>
</template>
Expand Down
157 changes: 157 additions & 0 deletions frontend/src/components/submissions/AllSubmission.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import { Submission } from '@/types/submission/Submission.ts';
import { ExtraCheckResult } from '@/types/submission/ExtraCheckResult.ts';
import { StructureCheckResult } from '@/types/submission/StructureCheckResult.ts';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const tempSubmissions = ref<Submission[]>([]);
const testSubmissions = ref<Submission[]>([
new Submission(
'4',
4,
new Date(),
[],
[new ExtraCheckResult('3', 'SUCCESS', null, null, 2, 1, 'ExtraCheckResult')],
[new StructureCheckResult('3', 'SUCCESS', null, 2, 1, 'StructureCheckResult')],
true,
),
new Submission(
'3',
3,
new Date(2024, 3, 14),
[],
[new ExtraCheckResult('3', 'FAILURE', null, null, 2, 1, 'ExtraCheckResult')],
[new StructureCheckResult('3', 'SUCCESS', null, 2, 1, 'StructureCheckResult')],
true,
),
new Submission(
'2',
2,
new Date(2024, 3, 1),
[],
[new ExtraCheckResult('2', 'SUCCESS', null, null, 2, 1, 'ExtraCheckResult')],
[new StructureCheckResult('2', 'FAILURE', null, 2, 1, 'StructureCheckResult')],
true,
),
new Submission(
'1',
1,
new Date(2024, 2, 12),
[],
[new ExtraCheckResult('1', 'FAILURE', null, null, 1, 1, 'ExtraCheckResult')],
[new StructureCheckResult('1', 'FAILURE', null, 1, 1, 'StructureCheckResult')],
true,
),
]);
const props = defineProps<{
submissions: Submission[];
}>();
onMounted(async () => {
tempSubmissions.value = [...(props.submissions ?? []), ...testSubmissions.value].reverse();
});
watch(
() => props.submissions,
(newSubmissions) => {
tempSubmissions.value = [...newSubmissions, ...testSubmissions.value].reverse();
},
{
immediate: true, // Zal ook uitvoeren onMounted, dus je kan de logica uit onMounted verwijderen als je dit gebruikt
},
);
/**
* Returns the extra information for the submission
*/
const submissionsExtra = computed(() => {
return tempSubmissions.value.map((submission) => {
const iconDetails = getExtraSubmissionInformation(submission);
return {
...submission,
iconName: iconDetails.iconName,
color: iconDetails.color,
hoverText: iconDetails.hoverText,
};
});
});
/**
* Returns the icon name, color and hover text for the submission
* @param submission
*/
const getExtraSubmissionInformation = (
submission: Submission,
): { iconName: string; color: string; hoverText: string } => {
if (
!(
submission.extraCheckResults.map((check: ExtraCheckResult) => check.result === 'SUCCESS').every(Boolean) ||
submission.structureCheckResults
.map((check: StructureCheckResult) => check.result === 'SUCCESS')
.every(Boolean)
)
) {
return { iconName: 'times', color: 'red', hoverText: t('views.submissions.hoverText.allChecksFailed') };
} else if (
!submission.extraCheckResults.map((check: ExtraCheckResult) => check.result === 'SUCCESS').every(Boolean)
) {
return { iconName: 'cloud', color: 'lightblue', hoverText: t('views.submissions.hoverText.extraChecksFailed') };
} else if (
!submission.structureCheckResults
.map((check: StructureCheckResult) => check.result === 'SUCCESS')
.every(Boolean)
) {
return { iconName: 'bolt', color: 'yellow', hoverText: t('views.submissions.hoverText.structureChecksFailed') };
} else {
return { iconName: 'check', color: 'lightgreen', hoverText: t('views.submissions.hoverText.allChecksPassed') };
}
};
const timeSince = (submissionDate: Date): string => {
const today = new Date();
const diffTime = new Date(today.getTime() - submissionDate.getTime());
const diffDays = Math.floor(diffTime.getTime() / (1000 * 60 * 60 * 24));
if (diffDays === 0) {
return t('views.submissions.timeSince.today');
} else if (diffDays <= 7) {
return `${diffDays} ${t('views.submissions.timeSince.daysAgo')}`;
} else if (diffDays <= 30) {
return t('views.submissions.timeSince.weekAgo');
} else {
return t('views.submissions.timeSince.monthAgo');
}
};
</script>

<template>
<div>
<div
v-for="submission in submissionsExtra?.reverse()"
:key="submission.id"
class="flex submission align-content-center align-items-center"
v-tooltip="submission.hoverText"
>
<p
:class="'font-semibold m-2 p-1 pi pi-' + submission.iconName"
:style="{ color: submission.color, fontSize: '1.25rem' }"
></p>
<label class="font-semibold m-2 p-1">#{{ submission.submission_number }} </label>
<p>{{ timeSince(submission.submission_time) }}</p>
</div>
</div>
</template>
<style scoped lang="scss">
@import '@/assets/scss/theme/theme.scss';
.submission {
border-bottom: 1.5px solid var(--primary-color);
}
.submission:last-child {
border-bottom: none;
}
</style>
Loading

0 comments on commit 56c21f7

Please sign in to comment.