From b1d68b7c38f681d6cbb44e10ca4a812aa71f0aff Mon Sep 17 00:00:00 2001 From: prandla Date: Sun, 11 Aug 2024 01:48:22 +0300 Subject: [PATCH] change formatting of CPU time when getting TLE emphasizes that time limit exceeded means the submission was terminated early. by default this would show the time as "10.035 sec" or similar, which has misled people in the past. --- cms/grading/scoretypes/abc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cms/grading/scoretypes/abc.py b/cms/grading/scoretypes/abc.py index 0fcfb99827..ae240b32b0 100644 --- a/cms/grading/scoretypes/abc.py +++ b/cms/grading/scoretypes/abc.py @@ -36,6 +36,7 @@ from cms import FEEDBACK_LEVEL_RESTRICTED from cms.db import SubmissionResult +from cms.grading.steps import EVALUATION_MESSAGES from cms.locale import Translation, DEFAULT_TRANSLATION from cms.server.jinja2_toolbox import GLOBAL_ENVIRONMENT from jinja2 import Template @@ -295,7 +296,9 @@ class ScoreTypeGroup(ScoreTypeAlone): {% if feedback_level == FEEDBACK_LEVEL_FULL %} - {% if "time" in tc and tc["time"] is not none %} + {% if "time_limit_was_exceeded" in tc and tc["time_limit_was_exceeded"] %} + > {{ tc["time_limit"]|format_duration }} + {% elif "time" in tc and tc["time"] is not none %} {{ tc["time"]|format_duration }} {% else %} {% trans %}N/A{% endtrans %} @@ -430,11 +433,17 @@ def compute_score(self, submission_result): tc_outcome = self.get_public_outcome( tc_score, parameter) + time_limit_was_exceeded = False + if evaluations[tc_idx].text == [EVALUATION_MESSAGES.get("timeout").message]: + time_limit_was_exceeded = True + testcases.append({ "idx": tc_idx, "outcome": tc_outcome, "text": evaluations[tc_idx].text, "time": evaluations[tc_idx].execution_time, + "time_limit": evaluations[tc_idx].dataset.time_limit, + "time_limit_was_exceeded": time_limit_was_exceeded, "memory": evaluations[tc_idx].execution_memory, "show_in_restricted_feedback": self.public_testcases[tc_idx], "show_in_oi_restricted_feedback": self.public_testcases[tc_idx]})