From ba614408431a8116ee28c7c137e2febfe32069e4 Mon Sep 17 00:00:00 2001 From: hoangvu5 Date: Sat, 1 Feb 2025 11:14:06 -0500 Subject: [PATCH 1/2] Add last_submission field in Team model --- src/contestadmin/tasks.py | 1 + src/core/views.py | 6 +++--- .../migrations/0004_team_last_submission.py | 18 ++++++++++++++++++ src/register/models.py | 3 +++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/register/migrations/0004_team_last_submission.py diff --git a/src/contestadmin/tasks.py b/src/contestadmin/tasks.py index 4f26a85d..157850ee 100644 --- a/src/contestadmin/tasks.py +++ b/src/contestadmin/tasks.py @@ -378,6 +378,7 @@ def process_contest_results(): team = Team.objects.get(contest_id=id) team.questions_answered = row[3] team.score = row[4] + team.last_submission = row[5] team.save() except: logger.error( diff --git a/src/core/views.py b/src/core/views.py index 6398ffb0..ebc50474 100644 --- a/src/core/views.py +++ b/src/core/views.py @@ -114,19 +114,19 @@ def get_context_data(self, **kwargs): # Aggregate upper division team and participant info upper_teams_set = teams_set.filter(division=1).filter(faculty=False).exclude(num_members=0) - context['upper_teams'] = upper_teams_set.order_by('-questions_answered', 'score', 'name') + context['upper_teams'] = upper_teams_set.order_by('-questions_answered', 'score', 'last_submission', 'name') context['num_upper_teams'] = upper_teams_set.count() context['num_upper_participants'] = participants_set.filter(team__division=1).count() # Aggregate lower division team and participant info lower_teams_set = teams_set.filter(division=2).filter(faculty=False).exclude(num_members=0) - context['lower_teams'] = lower_teams_set.order_by('-questions_answered', 'score', 'name') + context['lower_teams'] = lower_teams_set.order_by('-questions_answered', 'score', 'last_submission', 'name') context['num_lower_teams'] = lower_teams_set.count() context['num_lower_participants'] = participants_set.filter(team__division=2).count() # Aggregate faculty team and participant info faculty_teams_set = teams_set.filter(faculty=True).exclude(num_members=0) - context['faculty_teams'] = faculty_teams_set.order_by('-questions_answered', 'score', 'name') + context['faculty_teams'] = faculty_teams_set.order_by('-questions_answered', 'score', 'last_submission', 'name') context['num_faculty_teams'] = faculty_teams_set.count() context['num_faculty_participants'] = participants_set.filter(team__faculty=True).count() diff --git a/src/register/migrations/0004_team_last_submission.py b/src/register/migrations/0004_team_last_submission.py new file mode 100644 index 00000000..3ad26b98 --- /dev/null +++ b/src/register/migrations/0004_team_last_submission.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.4 on 2025-02-01 15:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('register', '0003_team_faculty'), + ] + + operations = [ + migrations.AddField( + model_name='team', + name='last_submission', + field=models.PositiveSmallIntegerField(default=0), + ), + ] diff --git a/src/register/models.py b/src/register/models.py index 231d3a31..90170d71 100644 --- a/src/register/models.py +++ b/src/register/models.py @@ -26,6 +26,8 @@ class Team(models.Model): score (PositiveSmallIntegerField): the team's final DOMjudge score + last_submission (PositiveSmallIntegerField): the team's last submission time + num_members (PositiveSmallIntegerField): the number of users on the team faculty (BooleanField): If True, the team contains at least one faculty member. Otherwise the team does not contain a faculty member. @@ -43,6 +45,7 @@ class Team(models.Model): contest_password = models.CharField(max_length=6, unique=True, blank=True, null=True) questions_answered = models.PositiveSmallIntegerField(default=0) score = models.PositiveSmallIntegerField(default=0) + last_submission = models.PositiveSmallIntegerField(default=0) num_members = models.PositiveSmallIntegerField(default=0) faculty = models.BooleanField(default=False) From 9edf41bf93b15dc78c72ab7e30c38a45741eb451 Mon Sep 17 00:00:00 2001 From: hoangvu5 Date: Sat, 1 Feb 2025 11:16:48 -0500 Subject: [PATCH 2/2] Edit FAQ to add scoring rule with last submission --- src/core/templates/core/faq.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/templates/core/faq.html b/src/core/templates/core/faq.html index 6f57dedf..5a1cc450 100644 --- a/src/core/templates/core/faq.html +++ b/src/core/templates/core/faq.html @@ -228,7 +228,8 @@
How does scoring work?
Teams are ranked by the number of questions they have solved. If multiple teams have answered the same number of questions, then they are ranked by a point system based on least total time to submit a correct solution - for the questions, as well as fewest attempts to get the correct solution. + for the questions, as well as fewest attempts to get the correct solution. If multiple teams have the same + number of questions solved and points, then they are ranked by time of their last submission.

You receive points when you successfully solve a problem, and the amount of points is based on how many