Skip to content

Problem Queries

Bowen Yu edited this page Apr 26, 2016 · 43 revisions

For problem batches and tests, see problem batches and tests.

Type Definitions

Queries

Todo: Get PDF Statement, Add user groups and testing for owner/admin for permission, add batches and testfiles


Type Definitions

Coda Problem

{
  id: string,                    // problem id, the same as the query parameter
  checkerType: string,           // default = "diff", checkerID of corresponding checkerType
  title: string,                 // problem title (may contain any character)
  usePdf: boolean,               // default = False, whether the problem uses pdf statement
  timeLimit: number,             // default = 0, in milliseconds
  memoryLimit: number,           // default = 100,000,000 in bytes
  languages: !Array<coda.Language>      // supported languages
  description: string,           // contains text description if usePDF = False
  input: string,                 // input description, markdown and mathjax supported
  output: string,                // output description, markdown and mathjax supported
  explanation: string,           // problem explanation typically for samples, markdown and mathjax supported
  samples: Array<coda.Sample>,
  batches: Array<coda.Batch>
}

Coda Sample

{
  input: string,
  output: string,
  sampleId: number
}

Coda Batch

{
  constraints: string          // constraints for each batch
}

Coda Language

@enum {string}

It is defined by

/** @enum {string} */
coda.Language = {
  C: 'c',
  CPP: 'c++',
  JAVA: 'java',
  PYTHON: 'python'
};

Coda Checker

{
  id: string,           // the checker id
  onlyExec: boolean     // true if the checker is exec'd directly, false if using a flavor of diff
}

Queries

Get Checker Types

Retrieves the valid checker types

problem/getCheckerTypes

Params

Return

!Array<coda.Checker>

Create Problem

Creates a problem with given id.

problem/createProblem

Params

problemId: string

Return

"Success Message"

Get Problem IDs

Gets list of problem IDs

problem/getProblemIDs

Params

Return

Array<string> // problem IDs

Get Problem Info

Gets the problem info, including description, time/memory limit, batches, constraints, etc.

problem/getProblemInfo/problemID

URL Params

problemID: string

Return

coda.Problem

Get Contest Problem Info

Gets the problem info, with a problem index of a specified contest.

problem/getContestProblemInfo/

Params

contestId: string,              // contest id
problemIndex: string            // 'A', 'B', ...

Return

{
  problemID: string,             // problem id, the same as the query parameter
  checkerType: string,           // default = "diff", checkerID of corresponding checkerType
  title: string,
  usePdf: boolean,               // default = False, whether the problem uses pdf statement
  timeLimit: number,             // default = 0, in milliseconds
  memoryLimit: number,           // default = 100,000,000 in bytes
  langs: !Array<string>          // supported languages
  statement: string,            //Statement if usePDF = False
  input: string,
  output: string,
  samples: Array<{
    input: string,
    output: string,
    sampleID: number
  }>,
  batches: Array<{
    constraints: string          // constraints for each batch
  }>
}

Set Problem Info

Sets the problem info, including statement, time/memory limit, batches, constraints, etc.

problem/setProblemInfo/problemID

URL Params

problemId: string

Params

// Only non-null elements in info are to be set.
info: {
  title: ?string,
  usePdf: ?boolean,               //if usePdf, problem statement can be set by uploadPdfStatement or by multipart form
  statement: ?string,             // problem description
  input: ?string,
  output: ?string,
}

Multipart Form File Params

//Optionally upload pdfStatement
pdfStatement : ?file    

Return

"Success message"

Add Sample

Adds a sample to a problem

problem/addSample/problemID

URL Params

problemID: string

Params

input: string,
output: string

Return

"Success message"

Set Sample

Sets a sample to a problem

problem/addSample/problemID/sampleID

URL Params

problemID: string
sampleID: number

Params

input: string,
output: string

Return

"Success message"

Delete Sample

Deletes a sample of a problem and renumbers all later samples to maintain a consecutive list

problem/deleteSample/problemID/sampleID

URL Params

problemID: string,
sampleID: number

Params

Return

"Success message"

Reorder Samples

Reorder samples

problem/reorderSamples/problemID

URL Params

problemID: string

Params

newSampleIDs : Array<number> //Must have same length as number of samples and be sequentially numbered

Return

"Success message"

Upload PDF Statment

Uploads a PDF statment by posting a file.

uploadPdfStatement(problemId, file)

Params

problemId: string,
file: File (sent via post multi-part form)

Return

{
  // empty or failure message
}

Exist Problem Id

Checks if a problem id exists.

existProblemId(problemId)

Params

problemId: string

Return

boolean

Problem Submissions

Gets all submissions (across sessions) for a given problem. This is for moderator. Usually submissions are under sessions and are queried by sessionSubmissions.

problemSubmissions(problemId)

Params

problemId: string

Return

{
  submissions: !Array<{
    id: string,       // submission id
    user: string,     // who submitted
    time: number,     // Posix time
    lang: string,     // source language ('c', 'c++', 'java')
    size: number,     // source file size in bytes
    verdict: string   // result of submission
  }>
}