Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,9 @@ class ScoreTypeGroup(ScoreTypeAlone):
<span class="title">
{% trans index=st["idx"] %}Subtask {{ index }}{% endtrans %}
</span>
{% if "score_fraction" in st and "max_score" in st %}
{% set score = st["score_fraction"] * st["max_score"] %}
{% if "score" in st and "max_score" in st %}
<span class="score">
({{ score|round(2)|format_decimal }}
({{ st["score"]|format_decimal }}
/ {{ st["max_score"]|format_decimal }})
</span>
{% else %}
Expand Down Expand Up @@ -416,6 +415,8 @@ def compute_score(self, submission_result):
targets = self.retrieve_target_testcases()
evaluations = {ev.codename: ev for ev in submission_result.evaluations}

score_precision = submission_result.submission.task.score_precision

for st_idx, parameter in enumerate(self.parameters):
target = targets[st_idx]

Expand Down Expand Up @@ -461,6 +462,7 @@ def compute_score(self, submission_result):
[float(evaluations[tc_idx].outcome) for tc_idx in target],
parameter)
st_score = st_score_fraction * parameter[0]
rounded_score = round(st_score, score_precision)

if tc_first_lowest_idx is not None and st_score_fraction < 1.0:
for tc in testcases:
Expand All @@ -478,6 +480,8 @@ def compute_score(self, submission_result):
# with a max score of zero is still properly rendered as
# correct or incorrect.
"score_fraction": st_score_fraction,
# But we also want the properly rounded score for display.
"score": rounded_score,
"max_score": parameter[0],
"testcases": testcases})
if all(self.public_testcases[tc_idx] for tc_idx in target):
Expand All @@ -486,7 +490,7 @@ def compute_score(self, submission_result):
else:
public_subtasks.append({"idx": st_idx,
"testcases": public_testcases})
ranking_details.append("%g" % round(st_score, 2))
ranking_details.append("%g" % rounded_score)

return score, subtasks, public_score, public_subtasks, ranking_details

Expand Down
2 changes: 1 addition & 1 deletion cms/grading/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _task_score_max_subtask(
try:
subtask_scores = dict(
(subtask["idx"],
subtask["score_fraction"] * subtask["max_score"])
subtask["score"])
for subtask in details)
except Exception:
subtask_scores = None
Expand Down
3 changes: 1 addition & 2 deletions cmsranking/RankingWebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ def callback(self, entity: str, event: str, key: str, *args):
self.send(entity, "%s %s" % (event, key))

def score_callback(self, user: str, task: str, score: float):
# FIXME Use score_precision.
self.send("score", "%s %s %0.2f" % (user, task, score))
self.send("score", "%s %s %s" % (user, task, str(score)))


class SubListHandler:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_submission_result(testcases):
sr.evaluations = [
ScoreTypeTestMixin.get_evaluation(codename, 1.0)
for codename in reversed(sorted(testcases.keys()))]
sr.submission.task.score_precision = 4
return sr

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion cmstestsuite/unit_tests/grading/scoring_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def subtask(idx, max_score, score_fraction):
return {
"idx": idx,
"max_score": max_score,
"score_fraction": score_fraction
"score_fraction": score_fraction,
"score": round(max_score * score_fraction, 4) # assume a score_precision of 4 for these tests.
}

def test_no_submissions(self):
Expand Down