{% import 'macro/submission.html' as macro_submission %} {% extends "contest.html" %} {% set page = "task_submissions" %} {% set score_type = get_score_type(dataset=task.active_dataset) %} {# Whether tokens are allowed on this contest. #} {% set can_use_tokens_in_contest = tokens_contest != TOKEN_MODE_DISABLED and tokens_tasks != TOKEN_MODE_DISABLED %} {# Whether tokens are allowed on this task. #} {% set can_use_tokens = tokens_contest != TOKEN_MODE_DISABLED and tokens_task != TOKEN_MODE_DISABLED %} {# Whether the user has a token to play (maybe after waiting some time). #} {% set can_play_token = can_use_tokens and actual_phase == 0 and (tokens_info[0] > 0 or tokens_info[0] == -1) %} {# Whether the user can play a token right now (only meaningful when can_play_token = true). #} {% set can_play_token_now = can_play_token and tokens_info[2] is none %} {% block additional_js %} $(document).on("click", ".submission_list tbody tr td.status .details", function (event) { var submission_id = $(this).parent().parent().attr("data-submission"); var modal = $("#submission_detail"); var modal_body = modal.children(".modal-body"); modal_body.html('
{% trans %}loading...{% endtrans %}
'); modal_body.load(utils.contest_url("tasks", "{{ task.name }}", "submissions", submission_id, "details"), function() { $(".score_details .subtask .subtask-head").each(function () { $(this).prepend(""); }); $(".score_details .subtask .subtask-head").click(function () { $(this).parent().toggleClass("open"); if ($(this).parent().hasClass("open")) { $(this).children("i").removeClass("icon-chevron-right").addClass("icon-chevron-down"); } else { $(this).children("i").removeClass("icon-chevron-down").addClass("icon-chevron-right"); } }); $(".score_details table.testcase-list").addClass("table table-bordered table-striped"); $(".score_details table.testcase-list tbody tr:not(.undefined) td.outcome").each(function () { $(this).html("" + $(this).text() + ""); }); }); modal.modal("show"); }); function is_status_terminal (status) { return status == {{ SubmissionResult.COMPILATION_FAILED }} || status == {{ SubmissionResult.SCORED }}; }; function get_score_class (score, max_score) { if (score <= 0) { return "score_0"; } else if (score >= max_score) { return "score_100"; } else { return "score_0_100"; } }; /** * Update the score (public or tokened) in the UI (both in the task score and in * the submission row) given the results of a newly scored submisson * * score_elem: table cell with the submission score to update. * task_score_elem: container element of the task score to update. * score (Number): the score of the submission. * score_message (String): the score of the submission as a string. * task_score (Number): the current score of the task. * task_score_message (String): the current score of the task as a string. * task_score_is_partial (Boolean): if some submission has yet to be scored. * max_score (Number): maximum score of the task. */ update_score = function(score_elem, task_score_elem, score, score_message, task_score, task_score_message, task_score_is_partial, max_score) { // Submission row. if (score !== undefined) { score_elem.addClass(get_score_class(score, max_score)); score_elem.removeClass("undefined"); score_elem.text(score_message); } // Task score. var task_score_span = task_score_elem.find(".score"); task_score_span.text(task_score_message); if (task_score_is_partial) { task_score_span.append( $("")); } task_score_elem.removeClass("undefined"); task_score_elem.removeClass("score_0"); task_score_elem.removeClass("score_0_100"); task_score_elem.removeClass("score_100"); task_score_elem.addClass(get_score_class(task_score, max_score)); }; update_scores = function (submission_id, data) { var row = $(".submission_list tbody tr[data-submission=\"" + submission_id + "\"]"); row.attr("data-status", data["status"]); row.children("td.status").text(data["status_text"]); var terminal_status = is_status_terminal(data["status"]); if (!terminal_status) { row.children("td.status").append( $("")); } else { row.children("td.status").append( $("{% trans %}details{% endtrans %}")); } if (terminal_status) { update_score( row.children("td.public_score"), $("#task_score_public"), data["public_score"], data["public_score_message"], data["task_public_score"], data["task_public_score_message"], data["task_score_is_partial"], data["max_public_score"]); {% if can_use_tokens %} update_score( row.children("td.total_score"), $("#task_score_tokened"), data["score"], data["score_message"], data["task_tokened_score"], data["task_tokened_score_message"], data["task_score_is_partial"], data["max_score"]); {% endif %} } else { schedule_update_scores(submission_id); } }; schedule_update_scores = function (submission_id) { if (typeof(schedule_update_scores.delays) === "undefined") { schedule_update_scores.delays = {}; } if (!schedule_update_scores.delays[submission_id]) { schedule_update_scores.delays[submission_id] = 1000.0; } else { // We want exponential backoff, but slightly staggered across submissions to // avoid asking about all of them at the same time, so we use 1.4 plus a // value depending on the submission id. var hash = (37 * parseInt(submission_id)) % 100 / 100.0; schedule_update_scores.delays[submission_id] = schedule_update_scores.delays[submission_id] * (1.4 + hash * 0.2); } setTimeout(function () { $.get(utils.contest_url("tasks", "{{ task.name }}", "submissions", submission_id), function (data) { update_scores(submission_id, data); }); }, schedule_update_scores.delays[submission_id]); }; $(document).ready(function () { $('.submission_list tbody tr[data-status][data-status!="{{ SubmissionResult.COMPILATION_FAILED }}"][data-status!="{{ SubmissionResult.SCORED }}"]').each(function (idx, elem) { schedule_update_scores($(this).attr("data-submission")); }); }); {% endblock additional_js %} {% block core %}
{% if score_type is defined %} {% set two_task_scores = score_type.max_public_score > 0 and score_type.max_public_score < score_type.max_score %}
{% if score_type.max_public_score > 0 %} {# Show the public score (alone, if everything is public or tokens are disabled, or together with the tokened score). #}
{% if score_type.max_public_score == score_type.max_score %} {% trans %}Score:{% endtrans %} {% else %} {% trans %}Public score:{% endtrans %} {% endif %}
{{ score_type.format_score(public_score, score_type.max_public_score, none, task.score_precision, translation=translation) }} {% if is_score_partial %} {% endif %}
{% endif %} {% if score_type.max_public_score < score_type.max_score %} {# Show the tokened score (alone if everything is non-public, or together with the public score). #}
{% if can_use_tokens %} {% trans %}Score of tokened submissions:{% endtrans %} {% else %} {% trans %}Total score:{% endtrans %} {% endif %}
{% if can_use_tokens %} {{ score_type.format_score(tokened_score, score_type.max_score, none, task.score_precision, translation=translation) }} {% if is_score_partial %} {% endif %} {% else %} {% trans %}N/A{% endtrans %} {% endif %}
{% endif %}
{% endif %}

{% trans %}Submit a solution{% endtrans %}

{% set task_type = get_task_type(dataset=task.active_dataset) %} {% if task_type.ALLOW_PARTIAL_SUBMISSION %}

{% trans %}You may submit any subset of outputs in a single submission.{% endtrans %}

{% endif %} {% if submissions_left is not none %}

{% trans submissions_left=submissions_left %}You can submit {{ submissions_left }} more solution(s).{% endtrans %}

{% endif %}
{{ xsrf_form_html|safe }}
{% for filename in task.submission_format %}
{% endfor %} {% if task.submission_format|any("endswith", ".%l") %}
{% endif %}
{% if task.submission_format|length > 1 and not task.submission_format|any("endswith", ".%l") %}
{{ xsrf_form_html|safe }}
{% endif %}

{% trans %}Previous submissions{% endtrans %}

{% if can_use_tokens_in_contest and actual_phase == 0 %}
{% if not can_use_tokens %} {% trans %}Tokens are not allowed on this task.{% endtrans %} {% elif can_play_token %} {% if tokens_info[0] == -1 %} {% trans %}Right now, you have infinite tokens available on this task.{% endtrans %} {% elif tokens_info[0] == 1 %} {% trans %}Right now, you have one token available on this task.{% endtrans %} {% else %} {% trans tokens=tokens_info[0] %}Right now, you have {{ tokens }} tokens available on this task.{% endtrans %} {% endif %} {% if not can_play_token_now %} {% trans expiration_time=tokens_info[2]|format_datetime_smart %} But you have to wait until {{ expiration_time }} to use them. {% endtrans %} {% endif %} {% if tokens_info[1] is not none %} {% trans gen_time=tokens_info[1]|format_datetime_smart %} You will receive a new token at {{ gen_time }}. {% endtrans %} {% else %} {% trans %}In the current situation, no more tokens will be generated.{% endtrans %} {% endif %} {% else %} {% trans %}Right now, you do not have tokens available for this task.{% endtrans %} {% if actual_phase == 0 and tokens_info[1] is not none %} {% trans gen_time=tokens_info[1]|format_datetime_smart %} You will receive a new token at {{ gen_time }}. {% endtrans %} {% if tokens_info[2] is not none and tokens_info[2] > tokens_info[1] %} {% trans expiration_time=tokens_info[2]|format_datetime_smart %} But you will have to wait until {{ expiration_time }} to use it. {% endtrans %} {% endif %} {% else %} {% trans %}In the current situation, no more tokens will be generated.{% endtrans %} {% endif %} {% endif %}
{% endif %} {% if submissions|rejectattr("official")|list|length > 0 %}

{% trans %}Unofficial submissions{% endtrans %}

{{ macro_submission.rows( url, contest_url, translation, xsrf_form_html, actual_phase, task, submissions, can_use_tokens, can_play_token, can_play_token_now, submissions_download_allowed, false) }}

{% trans %}Official submissions{% endtrans %}

{% endif %} {{ macro_submission.rows( url, contest_url, translation, xsrf_form_html, actual_phase, task, submissions, can_use_tokens, can_play_token, can_play_token_now, submissions_download_allowed, true) }}
{% endblock core %}