{% macro 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, official) -%} {# Render a submission table with all (un)official submissions passed. url (Url): the URL instance referring to the root of CWS. contest_url (Url): the URL instance referring to the main contest page. translation (Translation): locale to use to show messages. xsrf_form_html (str): input element for the XSRF protection. actual_phase (int): phase of the contest. task (Task): the task this page refers to. submissions ([Submission]): all the submissions of the participation on this task. can_use_tokens (bool): whether tokens are allowed for this task. can_play_token (bool): if can_use_tokens is true, whether the user has a token to play (possibly after waiting some time). can_play_token_now (bool): if can_play_tokens is true, whether the user does not need to wait before playing a token. submissions_download_allowed (boolean): whether to allow users to download their submissions. official (boolean): whether to display only the official (true) or unofficial (false) submissions in the submissions list. #} {% set gettext = translation.gettext %} {% set score_type = get_score_type(dataset=task.active_dataset) %} {% set show_date = not submissions|map(attribute="timestamp")|all("today") %} {% set num_cols = 2 %} {% if show_date %} {% else %} {% endif %} {% if score_type is defined %} {% if 0 < score_type.max_public_score < score_type.max_score %} {% set num_cols = num_cols + 2 %} {% else %} {% set num_cols = num_cols + 1 %} {% endif %} {% endif %} {% if submissions_download_allowed %} {% set num_cols = num_cols + 1 %} {% endif %} {% if can_use_tokens and actual_phase == 0 %} {% set num_cols = num_cols + 1 %} {% endif %} {% if show_date %} {% else %} {% endif %} {% if score_type is defined %} {% if 0 < score_type.max_public_score < score_type.max_score %} {% else %} {% endif %} {% endif %} {% if submissions_download_allowed %} {% endif %} {% if can_use_tokens and actual_phase == 0 %} {% endif %} {% set num_displayed = (submissions|selectattr("official")|list|length if official else submissions|rejectattr("official")|list|length) > 0 %} {% if num_displayed == 0 %} {% else %} {% for s in submissions|sort(attribute="timestamp")|reverse %} {% if s.official == official %} {# loop.revindex is broken: https://github.com/pallets/jinja/issues/794 #} {{ row( url, contest_url, translation, xsrf_form_html, actual_phase, s, submissions|length - loop.index0, show_date, can_use_tokens, can_play_token, can_play_token_now, submissions_download_allowed) }} {% endif %} {% endfor %} {% endif %}
{% trans %}Date and time{% endtrans %}{% trans %}Time{% endtrans %}{% trans %}Status{% endtrans %}{% trans %}Public score{% endtrans %} {% trans %}Total score{% endtrans %}{% trans %}Score{% endtrans %}{% trans %}Files{% endtrans %}{% trans %}Token{% endtrans %}
{% trans %}no submissions{% endtrans %}
{%- endmacro %} {% macro row(url, contest_url, translation, xsrf_form_html, actual_phase, s, s_num, show_date, can_use_tokens, can_play_token, can_play_token_now, submissions_download_allowed) -%} {# Render a row in a submission table. url (Url): the URL instance referring to the root of CWS. contest_url (Url): the URL instance referring to the main contest page. translation (Translation): locale to use to show messages. xsrf_form_html (str): input element for the XSRF protection. actual_phase (int): phase of the contest. s (Submission): the submission to display. s_num (int): 1-based position of the submission in the list of submissions of the currently logged in participaiton on this task. show_date (bool): whether to display only the time or also the date. can_use_tokens (bool): whether tokens are allowed for this task. can_play_token (bool): if can_use_tokens is true, whether the user has a token to play (possibly after waiting some time). can_play_token_now (bool): if can_play_tokens is true, whether the user does not need to wait before playing a token. submissions_download_allowed (bool): whether to allow users to download their submissions. #} {% set gettext = translation.gettext %} {% set task = s.task %} {% set score_type = get_score_type(dataset=task.active_dataset) %} {% set sr = s.get_result(task.active_dataset) or undefined %} {% set status = sr.get_status() if sr is defined else SubmissionResult.COMPILING %} {% if show_date %} {{ s.timestamp|format_datetime }} {% else %} {{ s.timestamp|format_time }} {% endif %} {% if status == SubmissionResult.COMPILING %} {% trans %}Compiling...{% endtrans %} {% elif status == SubmissionResult.COMPILATION_FAILED %} {% trans %}Compilation failed{% endtrans %} {% trans %}details{% endtrans %} {% elif status == SubmissionResult.EVALUATING %} {% trans %}Evaluating...{% endtrans %} {% elif status == SubmissionResult.SCORING %} {% trans %}Scoring...{% endtrans %} {% elif status == SubmissionResult.SCORED %} {% trans %}Evaluated{% endtrans %} {% trans %}details{% endtrans %} {% endif %} {% if score_type is defined and score_type.max_public_score > 0 %} {% if status == SubmissionResult.SCORED %} {{ score_type.format_score(sr.public_score, score_type.max_public_score, sr.public_score_details, task.score_precision, translation=translation) }} {% else %} {% trans %}N/A{% endtrans %} {% endif %} {% endif %} {% if score_type is defined and score_type.max_public_score < score_type.max_score %} {% if status == SubmissionResult.SCORED and (s.token is not none or actual_phase == 3) %} {{ score_type.format_score(sr.score, score_type.max_score, sr.score_details, task.score_precision, translation=translation) }} {% else %} {% trans %}N/A{% endtrans %} {% endif %} {% endif %} {% if submissions_download_allowed %} {# We replace '.%l' with the actual language only when it occurs as an extension at the end of the string and only when #} {# there isn't another file with that name. This allows to securily reverse the replacement and should work great in #} {# the common case. Yet, it still allows the marginal case of both 'foo.%l' and 'foo.c' in the submission format. #} {% if s.files|length == 0 %} {% trans %}None{% endtrans %} {% elif s.files|length == 1 %} {% set filename = next(iter(s.files.keys())) %} {% if s.language is not none %} {% set filename = filename|replace(".%l", (s.language|to_language).source_extension) %} {% endif %} {% trans %}Download{% endtrans %} {% else %}
{% trans %}Download{% endtrans %}
{% endif %} {% endif %} {% if can_use_tokens and actual_phase == 0 %} {% if s.token is not none %} {% trans %}Played{% endtrans %} {% else %} {% if can_play_token_now %} {# Can play a token right now: show the button. #}
{{ xsrf_form_html|safe }}
{% elif can_play_token or tokens_info[1] is not none %} {# Can play a token, but only after a min_interval expires, or after the next token generation: ask to wait. #} {% trans %}Wait...{% endtrans %} {% else %} {# No tokens to play at this moment, nor more will be generated: tell the user there are no tokens. #} {% trans %}No tokens{% endtrans %} {% endif %} {% endif %} {% endif %} {%- endmacro %}