Add contest freeze
This commit is contained in:
parent
2c39774ff7
commit
a35ea0f6d5
13 changed files with 338 additions and 215 deletions
|
@ -1,4 +1,5 @@
|
|||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
from django.db.models import Max
|
||||
|
||||
|
||||
class abstractclassmethod(classmethod):
|
||||
|
@ -95,3 +96,17 @@ class BaseContestFormat(metaclass=ABCMeta):
|
|||
if points == total:
|
||||
return "full-score"
|
||||
return "partial-score"
|
||||
|
||||
def handle_frozen_state(self, participation, format_data):
|
||||
if not self.contest.freeze_after:
|
||||
return
|
||||
queryset = participation.submissions.values("problem_id").annotate(
|
||||
time=Max("submission__date")
|
||||
)
|
||||
for result in queryset:
|
||||
problem = str(result["problem_id"])
|
||||
if format_data.get(problem):
|
||||
if result["time"] >= self.contest.freeze_after + participation.start:
|
||||
format_data[problem]["frozen"] = True
|
||||
else:
|
||||
format_data[problem] = {"time": 0, "points": 0, "frozen": True}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue