Add contest freeze
This commit is contained in:
parent
2c39774ff7
commit
a35ea0f6d5
13 changed files with 338 additions and 215 deletions
|
@ -10,7 +10,7 @@ from django.utils.translation import gettext_lazy
|
|||
|
||||
from judge.contest_format.default import DefaultContestFormat
|
||||
from judge.contest_format.registry import register_contest_format
|
||||
from judge.timezone import from_database_time
|
||||
from judge.timezone import from_database_time, to_database_time
|
||||
from judge.utils.timedelta import nice_repr
|
||||
|
||||
|
||||
|
@ -55,6 +55,10 @@ class ICPCContestFormat(DefaultContestFormat):
|
|||
score = 0
|
||||
format_data = {}
|
||||
|
||||
frozen_time = self.contest.end_time
|
||||
if self.contest.freeze_after:
|
||||
frozen_time = participation.start + self.contest.freeze_after
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
|
@ -67,9 +71,10 @@ class ICPCContestFormat(DefaultContestFormat):
|
|||
FROM judge_contestproblem cp INNER JOIN
|
||||
judge_contestsubmission cs ON (cs.problem_id = cp.id AND cs.participation_id = %s) LEFT OUTER JOIN
|
||||
judge_submission sub ON (sub.id = cs.submission_id)
|
||||
WHERE sub.date < %s
|
||||
GROUP BY cp.id
|
||||
""",
|
||||
(participation.id, participation.id),
|
||||
(participation.id, participation.id, to_database_time(frozen_time)),
|
||||
)
|
||||
|
||||
for points, time, prob in cursor.fetchall():
|
||||
|
@ -102,6 +107,7 @@ class ICPCContestFormat(DefaultContestFormat):
|
|||
format_data[str(prob)] = {"time": dt, "points": points, "penalty": prev}
|
||||
score += points
|
||||
|
||||
self.handle_frozen_state(participation, format_data)
|
||||
participation.cumtime = max(0, cumtime + penalty)
|
||||
participation.score = score
|
||||
participation.tiebreaker = last # field is sorted from least to greatest
|
||||
|
@ -116,7 +122,7 @@ class ICPCContestFormat(DefaultContestFormat):
|
|||
'<small style="color:red"> +{penalty}</small>',
|
||||
penalty=floatformat(format_data["penalty"]),
|
||||
)
|
||||
if format_data["penalty"]
|
||||
if format_data.get("penalty")
|
||||
else ""
|
||||
)
|
||||
return format_html(
|
||||
|
@ -131,6 +137,7 @@ class ICPCContestFormat(DefaultContestFormat):
|
|||
+ self.best_solution_state(
|
||||
format_data["points"], contest_problem.points
|
||||
)
|
||||
+ (" frozen" if format_data.get("frozen") else "")
|
||||
),
|
||||
url=reverse(
|
||||
"contest_user_submissions_ajax",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue