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
29 changes: 22 additions & 7 deletions cms/server/contest/handlers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def check_xsrf_cookie(self):


class ApiTaskListHandler(ApiContestHandler):
"""Handler to list all tasks and their statements."""
"""Handler to list all tasks and their metadata."""

@api_login_required
@actual_phase_required(0, 3)
Expand All @@ -119,14 +119,29 @@ def get(self):
contest = self.contest
tasks = []
for task in contest.tasks:
name = task.name
statements = [s for s in task.statements]
sub_format = task.submission_format
dataset = task.active_dataset
tasks.append(
{
"name": name,
"statements": statements,
"submission_format": sub_format,
"name": task.name,
"title": task.title,
"statements": [s for s in task.statements],
"primary_statements": task.primary_statements,
"attachments": [a for a in task.attachments],
"submission_format": task.submission_format,
"allowed_languages": task.get_allowed_languages(),
"task_type": dataset.task_type,
"time_limit": dataset.time_limit,
"memory_limit": dataset.memory_limit,
"max_score": dataset.score_type_object.max_score,
"max_public_score": dataset.score_type_object.max_public_score,
"score_precision": task.score_precision,
"score_mode": task.score_mode,
"max_submission_number": task.max_submission_number,
"min_submission_interval": (
task.min_submission_interval.total_seconds()
if task.min_submission_interval is not None
else None
),
}
)
self.json({"tasks": tasks})
Expand Down
43 changes: 34 additions & 9 deletions docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,41 @@ is running, will return the following object:
"tasks": [
{
"name": /* string */,
"title": /* string */,
"statements": [/* strings */],
"submission_format": [/* strings */]
"primary_statements": [/* strings */],
"attachments": [/* strings */],
"submission_format": [/* strings */],
"allowed_languages": [/* strings */],
"task_type": /* string */,
"time_limit": /* number or null */,
"memory_limit": /* integer or null */,
"max_score": /* number */,
"max_public_score": /* number */,
"score_precision": /* integer */,
"score_mode": /* string */,
"max_submission_number": /* integer or null */,
"min_submission_interval": /* number or null */
}
]
}


Tasks are ordered in the same order as in the UI. The ``name`` of the task is
used for additional task-specific API calls. ``statements`` contains a list of
languages for which a statement is available. ``submission_format`` contains a
list of files that will need to be submitted, where filenames containing the
``%l`` string represent source files (that will be compiled and run on the
server), and all other filenames represent output files.
used for additional task-specific API calls, while ``title`` is its
human-readable title. ``statements`` contains a list of languages for which a
statement is available, and ``primary_statements`` lists the highlighted
languages. ``attachments`` contains a list of filenames of available
attachments. ``submission_format`` contains a list of files that will need to be
submitted, where filenames containing the ``%l`` string represent source files
(that will be compiled and run on the server), and all other filenames represent
output files. ``allowed_languages`` lists the programming languages allowed for
this task. ``task_type``, ``time_limit`` (in seconds), ``memory_limit`` (in
bytes), ``max_score``, and ``max_public_score`` describe the active dataset of
the task. ``score_precision`` and ``score_mode`` describe how scores are rounded
and aggregated across submissions. ``max_submission_number`` and
``min_submission_interval`` (in seconds) specify the per-task submission limits,
if any.

Submit
======
Expand Down Expand Up @@ -83,12 +105,15 @@ in chronological order:
]
}

Task statement
==============
Task statement and attachments
==============================

A PDF version of the task statement for a given language can be retrieved by
making an authenticated ``GET`` request to
``tasks/{taskname}/statements/{lang}``.
``/tasks/{taskname}/statements/{lang}``.

Task attachments can be retrieved by making an authenticated ``GET`` request to
``/tasks/{taskname}/attachments/{filename}``.

Scoring information
===================
Expand Down
Loading