diff --git a/cms/server/contest/handlers/api.py b/cms/server/contest/handlers/api.py index 3eb6ff0311..8698a8daef 100644 --- a/cms/server/contest/handlers/api.py +++ b/cms/server/contest/handlers/api.py @@ -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) @@ -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}) diff --git a/docs/API.rst b/docs/API.rst index da55725e1d..4daa8d0f48 100644 --- a/docs/API.rst +++ b/docs/API.rst @@ -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 ====== @@ -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 ===================