Skip to content

in-silico/judge-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

judge-backend

Dependency Status

Build Status

Backend service for UTPJudge project, basically aims to serve the info (statements, constraints, etc) for programming contests through a RESTful API. This API will be used by the judge-frontent.

The second aim for this backend service is to talk with the judge-bot service.

RESTful API

url method description params
/users GET returns all the users
/users POST creates a new user
  • email
  • name
  • username
/users/:id PUT modifies user data
  • email
  • name
  • username
/users/:id DELETE remove a user
/problems GET returns all the problems
/problems/:id GET returns a specific problem
/problems POST creates a new problem
  • author
  • description
  • title
/problems/:id/tc POST adds one or more test cases to one problem You can send a pair of (.in, .out) files or you can send a .tar.gz file with several test cases inside.

If you decide to send a .tar.gz, take care of the name of files, we will add one test case for each file which the .in and .out match.

For example, if the .tar.gz contains the files 'a.in', 'a.out' , 'b1.in', 'b3.out', only the test case (a.in, a.out) will be added.
/problems/:id PUT modifies problem data
/problems/:id DELETE remove a problem
/submissions GET returns all the submissions
/submissions POST creates a new submission
  • problem_id
  • contest_id
  • user_id, temporal: must be taken from session
  • source_code: attached as multipart/form file
/submissions/pending GET returns all the pending submissions
/contests GET returns all the contests
/contests/:id GET returns a specific contest
/contests POST creates a new contests
  • description
  • title
/contests/:id/add POST add one or more problems to a contest with id equals to :id Object with
  • problem_id
  • memory_limit (optional)
  • time_limit (optional)
or one array with several objects of that type.
/contests/:id PUT modifies contest data
/contests/:id DELETE remove a contest

Bot API.

All the messages are sent through TCP connections and must be parsable to JSON arrays.

Important: All the messages must be ended with the '\0' character.

The first element in the array defines the type of the operation.

The exact message schema is outlined here

bot-to-backend messages.

['judgement', verdict] : judgement result. An event must be emited with this message.
['ready'] : bot announcing that is ready to judge
['file', path] : file solicitation.

backend-to-bot messages.

['submission', data] : submission solicitation. Exactly format of 'data' will be defined HERE(TO DO).
['file', file_identifier, buffer] : part of the file 'file_identifier' contained into a NodeJS buffer.
['endfile', file_identifier] : Announce that the file 'file_identifier' was completely sent.

Requirements/Dependencies

Installation

npm install

In order to authenticate users with the github API you need to do some extra work:

Testing

npm run test

Run

npm start

Using judge-backend from command line

The judge-backend can be used with curl, here you have some examples.

We strongly recommend you to use prettyJSON

  • create a new user:

      $ curl -H "Content-Type: application/json" -X POST -d '{"name": "Toby"}' localhost:8080/users | prettyjson
    

    You will receive the following:

      __v:       0
      updatedAt: 2016-01-13T19:25:59.000Z
      createdAt: 2016-01-13T19:25:59.000Z
      _id:       5696a4c78acb3a8559df3371
      username:
      email:
      name:      Toby
    
  • get all the users:

      curl localhost:8080/users | prettyjson
    
  • submmit solution:

      curl -X POST -F "[email protected]" localhost:8080/submissions | prettyjson
    

Contributing

Contribution to this project is welcome and it is suggested using pull requests in github that will then be reviewed and merged or commented on. A more specific contribution guideline is outlined on the zmq site, we use that guide as reference.

Please feel free to add yourself to the COLLABORATORS file in an alphanumerically sorted way before you raise the pull request.

Licensing

The project is released under the MPLv2 license.

Please see LICENSE for full details.


Developed by In-silico.

Releases

No releases published

Packages

No packages published