Skip to content

API Task

Elena edited this page Apr 5, 2021 · 7 revisions

Table of Contents

Description

The task model is used to manage programming tasks for the TaskTracker plugin users.

You can add, view, and remove programming tasks via API. Alternatively, you can change the tasks available to your students by editing your tasks config file directly and then regenerating the database.

Model

Field Type Description
key String Unique user-defined identifier of the task.
examples Array Code examples. Each item has two fields: input (type: String) and output (type: String).
{lng_key} Object Task text as shown to users in the language specified by the interface language key (en, ru, de, and others). For example, en stands for a task in English.

Public fields

Field Type Description
key String Unique user-defined identifier of the task.
examples Array Code examples.
infoTranslation Array Task texts in different languages. See a response example below.

Available languages in the default configuration:

  • en - English
  • ru - Russian

Response example

{
  "key": "max_digit",
  "examples": 
  [
    {
      "input": "11111111",
      "output": "1"
    },
    {
      "input": "123034655943",
      "output": "9"
    },
    {
      "input": "4",
      "output": "4"
    }
  ],
  "infoTranslation": 
  [
    { "key":"en" },
    {
      "name": "Max digit",
      "description": "Find the largest digit in a string of digits.",
      "input": "The program receives a string of nonzero length containing only digits.",
      "output": "Print the maximum digit that appears in the input string."
    },
    { "key":"ru" },
    {
      "name": "Наибольшая цифра",
      "description": "Найти наибольшую цифру в строке, состоящей из цифр.",
      "input": "Программа получает на вход строку ненулевой длины, содержащую только десятичные цифры.",
      "output": "Выведите максимальную цифру, которая встречается во введенной строке."
    }
  ]
}

Operations

Create a task

Operation

Endpoint Method Description
/api/task POST Create a new task in the database.

Request parameters

Parameter Type Description
key String Unique user-defined identifier of the task. Must be unique in the database,
descriptions Array Task descriptions in different languages.
examples Array Code examples.

Request example

{
  "key": "max_digit",
  "descriptions": 
  [
    {
      "language": "en",
      "info": {
        "name": "Max digit",
        "description": "Find the largest digit in a string of digits.",
        "input": "The program receives a string of nonzero length containing only digits.",
        "output": "Print the maximum digit that appears in the input string."
      }
    },
    {
      "language": "ru",
      "info": {
        "name": "Наибольшая цифра",
        "description": "Найти наибольшую цифру в строке, состоящей из цифр.",
        "input": "Программа получает на вход строку ненулевой длины, содержащую только десятичные цифры.",
        "output": "Выведите максимальную цифру, которая встречается во введенной строке."
      }
    }
  ],
  "examples": 
  [
    {
      "input": "11111111",
      "output": "1"
    },
    {
      "input": "123034655943",
      "output": "9"
    },
    {
      "input": "4",
      "output": "4"
    }
  ] 
}

Response

Public fields of the task.

Request example in Postman


Get tasks

Operation

Endpoint Method Description
/api/task/all GET Get all tasks.

Request body

Empty body.

Response

Array of tasks. Each task has the public fields of the task model.


Get a task

Operation

Endpoint Method Description
/api/task/:key GET Get a task by the task key.

Request body

Empty body.

Response

Public fields of the task.


Delete a task

Operation

Endpoint Method Description
/api/task/:key DELETE Delete a task by the task key.

Request body

Empty body.

Response

Public fields of the task.