Skip to content

Commit 291f3f6

Browse files
aguss787veluca93
authored andcommitted
Add unofficial submission setting
1 parent fccf68f commit 291f3f6

6 files changed

Lines changed: 25 additions & 3 deletions

File tree

cms/db/contest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class Contest(Base):
101101
nullable=False,
102102
default=True)
103103

104+
# Allow unofficial submission before analysis mode
105+
allow_unofficial_submission_before_analysis_mode = Column(
106+
Boolean,
107+
nullable=False,
108+
default=False)
109+
104110
# Whether to prevent hidden participations to log in.
105111
block_hidden_participations: bool = Column(
106112
Boolean,

cms/server/admin/handlers/contest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def post(self, contest_id: str):
9696
self.get_bool(attrs, "submissions_download_allowed")
9797
self.get_bool(attrs, "allow_questions")
9898
self.get_bool(attrs, "allow_user_tests")
99+
self.get_bool(attrs, "allow_unofficial_submission_before_analysis_mode")
99100
self.get_bool(attrs, "block_hidden_participations")
100101
self.get_bool(attrs, "allow_password_authentication")
101102
self.get_bool(attrs, "allow_registration")

cms/server/admin/templates/contest.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ <h1>Contest configuration</h1>
8181
</td>
8282
<td><input type="text" name="score_precision" value="{{ contest.score_precision }}"></td>
8383
</tr>
84+
<tr>
85+
<td>
86+
<span class="info" title="Allow contestant to make unofficial submission before analysis mode"></span>
87+
Allow unofficial submission before analysis mode
88+
</td>
89+
<td>
90+
<input type="checkbox" id="allow_unofficial_submission_before_analysis_mode" name="allow_unofficial_submission_before_analysis_mode" {{ "checked" if contest.allow_unofficial_submission_before_analysis_mode else "" }}/>
91+
</td>
92+
</tr>
8493

8594
<tr><td colspan=2><h2>Logging in</h2></td></tr>
8695
<tr>

cms/server/contest/handlers/tasksubmission.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ class SubmitHandler(ContestHandler):
7878
"""
7979

8080
@tornado_web.authenticated
81-
@actual_phase_required(0, 3)
81+
@actual_phase_required(0, 1, 2, 3)
8282
@multi_contest
8383
def post(self, task_name):
84+
# Reject submission if the contest disallow unofficial submission outside of official window or analysis mode
85+
if 0 < self.r_params["actual_phase"] < 3 and \
86+
not self.contest.allow_unofficial_submission_before_analysis_mode:
87+
self.redirect(self.contest_url())
88+
return
89+
8490
task = self.get_task(task_name)
8591
if task is None:
8692
raise tornado_web.HTTPError(404)

cms/server/contest/templates/overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ <h2>{% trans %}General information{% endtrans %}</h2>
179179

180180

181181

182-
{% if actual_phase == 0 or actual_phase == 3%}
182+
{% if actual_phase == 0 or actual_phase == 3 or participation.unrestricted or (0 <= actual_phase <= 3 and contest.allow_unofficial_submission_before_analysis_mode)%}
183183
<h2>{% trans %}Task overview{% endtrans %}</h2>
184184

185185
<table class="table table-bordered table-striped">

cms/server/contest/templates/task_submissions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ <h1>{% trans name=task.title, short_name=task.name %}{{ name }} ({{ short_name }
225225
</div>
226226
{% endif %}
227227

228-
{% if actual_phase == 0 or actual_phase == 3 or participation.unrestricted %}
228+
{% if actual_phase == 0 or actual_phase == 3 or participation.unrestricted or (0 <= actual_phase <= 3 and contest.allow_unofficial_submission_before_analysis_mode) %}
229229

230230
<h2 style="margin-bottom: 10px">{% trans %}Submit a solution{% endtrans %}</h2>
231231

0 commit comments

Comments
 (0)