Skip to content

Commit 03dbc91

Browse files
artikzstefano-maggiolo
authored andcommitted
Fix comments, made score modes constants instead of strings
1 parent a169a58 commit 03dbc91

6 files changed

Lines changed: 21 additions & 15 deletions

File tree

cms/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"LANGUAGE_NAMES", "LANGUAGES", "DEFAULT_LANGUAGES",
3939
"SOURCE_EXT_TO_LANGUAGE_MAP",
4040
"LANGUAGE_TO_SOURCE_EXT_MAP", "LANGUAGE_TO_HEADER_EXT_MAP",
41+
"SCORE_MODE_IOI_MAX", "SCORE_MODE_IOI_MAX_TOKENED_LAST",
4142
# log
4243
# Nothing intended for external use, no need to advertise anything.
4344
# util
@@ -103,6 +104,12 @@
103104
LANG_PASCAL: "lib.pas",
104105
}
105106

107+
# Task score modes.
108+
109+
# Maximum score amongst all submissions.
110+
SCORE_MODE_IOI_MAX = "ioi_max"
111+
# Maximum score among all tokened submissions and the last submission.
112+
SCORE_MODE_IOI_MAX_TOKENED_LAST = "ioi_max_tokened_last"
106113

107114
from .util import ConfigError, mkdir, utf8_decoder, Address, ServiceCoord, \
108115
get_safe_shard, get_service_address, get_service_shards, \

cms/db/task.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
from . import Base, Contest
4242
from .smartmappedcollection import smart_mapped_collection
43+
from cms import SCORE_MODE_IOI_MAX, SCORE_MODE_IOI_MAX_TOKENED_LAST
4344

4445

4546
class Task(Base):
@@ -192,12 +193,10 @@ class Task(Base):
192193
default=0)
193194

194195
# Score mode for the task.
195-
# - ioi_max_tokened_last: score = max(last_score, max_tokened_score).
196-
# - ioi_max: score = max(scores).
197196
score_mode = Column(
198-
Enum("ioi_max_tokened_last", "ioi_max", name="score_mode"),
197+
Enum(SCORE_MODE_IOI_MAX_TOKENED_LAST, SCORE_MODE_IOI_MAX, name="score_mode"),
199198
nullable=False,
200-
default="ioi_max_tokened_last")
199+
default=SCORE_MODE_IOI_MAX_TOKENED_LAST)
201200

202201
# Active Dataset (id and object) currently being used for scoring.
203202
# The ForeignKeyConstraint for this column is set at table-level.

cms/grading/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,10 @@ def task_score(user, task):
777777

778778
score = 0.0
779779

780-
if task.score_mode == "ioi_max":
780+
if task.score_mode == SCORE_MODE_IOI_MAX:
781781
# Modern IOI score mode: maximum score amongst all submissions.
782782

783-
# The maximum score amongst all submissions (invalid
783+
# The maximum score amongst all submissions (not yet computed
784784
# scores count as 0.0).
785785
max_score = 0.0
786786

@@ -796,9 +796,9 @@ def task_score(user, task):
796796
# Legacy IOI score mode: maximum score among all tokened submissions
797797
# and the last submission.
798798

799-
# The score of the last submission (if valid, otherwise 0.0).
799+
# The score of the last submission (if computed, otherwise 0.0).
800800
last_score = 0.0
801-
# The maximum score amongst the tokened submissions (invalid
801+
# The maximum score amongst the tokened submissions (not yet computed
802802
# scores count as 0.0).
803803
max_tokened_score = 0.0
804804

cms/server/templates/admin/add_task.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{% end %}
1515

1616
{% block core %}
17-
{% from cms import plugin_list %}
17+
{% from cms import plugin_list, SCORE_MODE_IOI_MAX_TOKENED_LAST, SCORE_MODE_IOI_MAX %}
1818
{% set task_type_list = plugin_list("cms.grading.tasktypes", "tasktypes") %}
1919
{% set score_type_list = plugin_list("cms.grading.scoretypes", "scoretypes") %}
2020

@@ -196,8 +196,8 @@ <h2 id="title_score_options" class="toggling_on">Score Options</h2>
196196
<td>Score mode</td>
197197
<td>
198198
<select name="score_mode">
199-
<option value="ioi_max_tokened_last" selected>Legacy IOI (maximum score among all tokened submissions and the last submission)</option>
200-
<option value="ioi_max">Modern IOI (maximum score amongst all submissions)</option>
199+
<option value="{{ SCORE_MODE_IOI_MAX_TOKENED_LAST }}" selected>Legacy IOI (maximum score among all tokened submissions and the last submission)</option>
200+
<option value="{{ SCORE_MODE_IOI_MAX }}">Modern IOI (maximum score amongst all submissions)</option>
201201
</select>
202202
</td>
203203
</tr>

cms/server/templates/admin/task.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
{% block core %}
2121
{% from cms.server import format_dataset_attrs %}
22-
{% from cms import plugin_list %}
22+
{% from cms import plugin_list, SCORE_MODE_IOI_MAX_TOKENED_LAST, SCORE_MODE_IOI_MAX %}
2323
{% set task_type_list = plugin_list("cms.grading.tasktypes", "tasktypes") %}
2424
{% set score_type_list = plugin_list("cms.grading.scoretypes", "scoretypes") %}
2525

@@ -356,8 +356,8 @@ <h2 id="title_score_options" class="toggling_on">Score Options</h2>
356356
<td>Score mode</td>
357357
<td>
358358
<select name="score_mode">
359-
<option value="ioi_max_tokened_last" {{ "selected" if task.score_mode == "ioi_max_tokened_last" else "" }}>Legacy IOI (maximum score among all tokened submissions and the last submission)</option>
360-
<option value="ioi_max" {{ "selected" if task.score_mode == "ioi_max" else "" }}>Modern IOI (maximum score amongst all submissions)</option>
359+
<option value="{{ SCORE_MODE_IOI_MAX_TOKENED_LAST }}" {{ "selected" if task.score_mode == SCORE_MODE_IOI_MAX_TOKENED_LAST else "" }}>Legacy IOI (maximum score among all tokened submissions and the last submission)</option>
360+
<option value="{{ SCORE_MODE_IOI_MAX }}" {{ "selected" if task.score_mode == SCORE_MODE_IOI_MAX else "" }}>Modern IOI (maximum score amongst all submissions)</option>
361361
</select>
362362
</td>
363363
</tr>

cmsranking/Scoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Score(object):
7676
# On the other hand, different subchanges may have the same time
7777
# but cms assures that the order in which the subchanges have to
7878
# be processed is the ascending order of their keys (actually,
79-
# this is enforced only for suchanges with the same time).
79+
# this is enforced only for subchanges with the same time).
8080
def __init__(self, score_mode="ioi_max_tokened_last"):
8181
# The submissions in their current status.
8282
self._submissions = dict()

0 commit comments

Comments
 (0)