From 1737e1c78e73d7cc24abd7df004feda8e19a1c2b Mon Sep 17 00:00:00 2001 From: k-kalita Date: Mon, 3 Jun 2024 20:56:34 +0200 Subject: [PATCH] [FIX] exclude legacy tasks from course overview info, version shift --- BaCa2/core/settings/base.py | 2 +- BaCa2/main/models.py | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/BaCa2/core/settings/base.py b/BaCa2/core/settings/base.py index bc78728..6b57337 100644 --- a/BaCa2/core/settings/base.py +++ b/BaCa2/core/settings/base.py @@ -1,4 +1,4 @@ -BACA2_VERSION = '1.4.1-beta' +BACA2_VERSION = '1.4.2-beta' ROOT_URLCONF = 'core.urls' WSGI_APPLICATION = 'core.wsgi.application' diff --git a/BaCa2/main/models.py b/BaCa2/main/models.py index 0ee7438..89bbe33 100644 --- a/BaCa2/main/models.py +++ b/BaCa2/main/models.py @@ -1243,11 +1243,23 @@ def action(self: Course, *args, **kwargs) -> Any: # Metadata retrieval -------- - #: Returns the number of tasks in the course - get_tasks_number = inside_course()(Task.objects.filter(is_legacy=False).count) + @inside_course(course_method=True) + def get_tasks_number(self) -> int: + """ + :return: The number of tasks in the course. + :rtype: int + """ + from course.models import Task + return Task.objects.filter(is_legacy=False).count() - #: Returns the number of submits in the course - get_submits_number = inside_course()(Submit.objects.count) + @inside_course(course_method=True) + def get_submits_number(self) -> int: + """ + :return: The number of submits in the course. + :rtype: int + """ + from course.models import Submit + return Submit.objects.filter(task__is_legacy=False).count() @inside_course(course_method=True) def get_member_cleared_tasks_number(self, user: User | str | int) -> int: @@ -1281,7 +1293,7 @@ def get_member_submits_number(self, user: User | str | int) -> int: """ from course.models import Submit user = ModelsRegistry.get_user(user) - return Submit.objects.filter(usr=user.id).count() + return Submit.objects.filter(usr=user.id, task__is_legacy=False).count() @inside_course(course_method=True) def get_total_points(self) -> float: @@ -1290,7 +1302,7 @@ def get_total_points(self) -> float: :rtype: float """ from course.models import Task - return Task.objects.aggregate(Sum('points'))['points__sum'] or 0 + return Task.objects.filter(is_legacy=False).aggregate(Sum('points'))['points__sum'] or 0 @inside_course(course_method=True) def get_member_points(self, user: User | str | int) -> float: @@ -1302,7 +1314,7 @@ def get_member_points(self, user: User | str | int) -> float: """ from course.models import Task - tasks = Task.objects.all() + tasks = Task.objects.filter(is_legacy=False) score = 0 for task in tasks: