Skip to content

Commit

Permalink
Merge pull request #32 from BaCa2-project/dev
Browse files Browse the repository at this point in the history
v.1.4.2-beta [FIX] exclude legacy tasks from course overview info, version shift
  • Loading branch information
k-kalita authored Jun 3, 2024
2 parents 26db4a0 + 1737e1c commit cffc50d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BaCa2/core/settings/base.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
26 changes: 19 additions & 7 deletions BaCa2/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit cffc50d

Please sign in to comment.