Skip to content

Commit

Permalink
Revert "chore: better submission status"
Browse files Browse the repository at this point in the history
This reverts commit b695f02.
  • Loading branch information
francisvaut committed May 13, 2024
1 parent b695f02 commit 33d118d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 68 deletions.
55 changes: 7 additions & 48 deletions backend/api/serializers/project_serializer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from api.logic.parse_zip_files import parse_zip
from api.models.group import Group
from api.models.project import Project
from api.models.submission import Submission, ExtraCheckResult, StructureCheckResult, StateEnum
from api.models.submission import Submission
from api.serializers.course_serializer import CourseSerializer
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.utils import timezone
Expand All @@ -14,69 +14,28 @@
class SubmissionStatusSerializer(serializers.Serializer):
non_empty_groups = serializers.IntegerField(read_only=True)
groups_submitted = serializers.IntegerField(read_only=True)
structure_checks_passed = serializers.IntegerField(read_only=True)
extra_checks_passed = serializers.IntegerField(read_only=True)
submissions_passed = serializers.IntegerField(read_only=True)

def to_representation(self, instance: Project):
"""Return the submission status of the project"""
if not isinstance(instance, Project):
raise ValidationError(gettext("project.errors.invalid_instance"))

non_empty_groups = Group.objects.filter(project=instance, students__isnull=False).distinct().count()

groups_submitted_ids = Submission.objects.filter(group__project=instance).values_list('group__id', flat=True)
unique_groups = set(groups_submitted_ids)
groups_submitted = len(unique_groups)

# The total amount of groups with at least one submission should never exceed the total number of non empty groups
# (the seeder does not account for this restriction)
if (groups_submitted > non_empty_groups):
non_empty_groups = groups_submitted

passed_structure_checks_submission_ids = StructureCheckResult.objects.filter(
submission__group__project=instance,
submission__is_valid=True,
result=StateEnum.SUCCESS
).values_list('submission__id', flat=True)

passed_structure_checks_group_ids = Submission.objects.filter(
id__in=passed_structure_checks_submission_ids
).values_list('group_id', flat=True)

unique_groups = set(passed_structure_checks_group_ids)
structure_checks_passed = len(unique_groups)

passed_extra_checks_submission_ids = ExtraCheckResult.objects.filter(
submission__group__project=instance,
submission__is_valid=True,
result=StateEnum.SUCCESS
).values_list('submission__id', flat=True)

passed_extra_checks_group_ids = Submission.objects.filter(
id__in=passed_extra_checks_submission_ids
).values_list('group_id', flat=True)

unique_groups = set(passed_extra_checks_group_ids)
extra_checks_passed = len(unique_groups)

# The total number of passed extra checks combined with the number of passed structure checks
# can never exceed the total number of submissions (the seeder does not account for this restriction)
if (structure_checks_passed + extra_checks_passed > groups_submitted):
extra_checks_passed = groups_submitted - structure_checks_passed
non_empty_groups = instance.groups.filter(students__isnull=False).count()
groups_submitted = Submission.objects.filter(group__project=instance).count()
submissions_passed = Submission.objects.filter(group__project=instance, is_valid=True).count()

return {
"non_empty_groups": non_empty_groups,
"groups_submitted": groups_submitted,
"structure_checks_passed": structure_checks_passed,
"extra_checks_passed": extra_checks_passed
"submissions_passed": submissions_passed,
}

class Meta:
fields = [
"non_empty_groups",
"groups_submitted",
"structure_checks_passed",
"extra_checks_passed"
"submissions_passed",
]


Expand Down
3 changes: 1 addition & 2 deletions frontend/src/assets/lang/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@
"noSubmissions": "This project does not have any submissions",
"submissions": "Submission | Submissions",
"groups": "Group | Groups",
"structureTestsSucceed": "Succeeded structure tests",
"extraTestsSucceed": "Succeeded extra tests",
"testsSucceed": "Succeeded tests",
"testsFail": "Failed tests",
"submit": "Submit"
},
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/assets/lang/app/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@
"noSubmissions": "Dit project heeft geen indieningen",
"submissions": "Indiening | Indieningen",
"groups": "Groep | Groepen",
"structureTestsSucceed": "Geslaagde structuur testen",
"extraTestsSucceed": "Geslaagde extra testen",
"testsSucceed": "Geslaagde testen",
"testsFail": "Gefaalde testen",
"submit": "Indienen"
},
Expand Down
16 changes: 4 additions & 12 deletions frontend/src/components/projects/ProjectMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,15 @@ const { t } = useI18n();
const meterItems = computed(() => {
const groups = props.project !== null ? props.project.status.non_empty_groups : 0;
const groupsSubmitted = props.project !== null ? props.project.status.groups_submitted : 0;
const structureChecksPassed = props.project !== null ? props.project.status.structure_checks_passed : 0;
const extraChecksPassed = props.project !== null ? props.project.status.extra_checks_passed : 0;
const submissionsFailed = groupsSubmitted - structureChecksPassed;
const submissionsPassed = props.project !== null ? props.project.status.submissions_passed : 0;
const submissionsFailed = groupsSubmitted - submissionsPassed;
return [
{
value: (extraChecksPassed / groups) * 100,
value: (submissionsPassed / groups) * 100,
color: '#749b68',
label: t('components.card.extraTestsSucceed'),
label: t('components.card.testsSucceed'),
icon: 'pi pi-check',
},
{
value: (structureChecksPassed / groups) * 100,
color: '#fa9746',
label: t('components.card.structureTestsSucceed'),
icon: 'pi pi-exclamation-circle',
},
{
value: (submissionsFailed / groups) * 100,
color: '#FF5445',
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/types/SubmisionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ export class SubmissionStatus {
constructor(
public non_empty_groups: number,
public groups_submitted: number,
public structure_checks_passed: number,
public extra_checks_passed: number,
public submissions_passed: number,
) {}

/**
Expand All @@ -15,8 +14,7 @@ export class SubmissionStatus {
return new SubmissionStatus(
submissionStatus.non_empty_groups,
submissionStatus.groups_submitted,
submissionStatus.structure_checks_passed,
submissionStatus.extra_checks_passed,
submissionStatus.submissions_passed,
);
}
}

0 comments on commit 33d118d

Please sign in to comment.