DEV Community

Pranav Raj
Pranav Raj

Posted on

Judges are tough!

Turing Online Judge

-- A basic online judge in Python

When I was a fresher and came across all the online judges, like spoj, codeforces, a2oj, I wondered how they worked, how they managed to enforce all those limits and test the solutions.

I decided to make one on my own, it may not have all the advanced features but still it should be able to judge the solutions agains the test cases and enforce different constraints over the execution of the solution submitted by a user.

Tech

  • Django (Web framework)
  • MySql (Database)
  • Python (for the judge script)
  • Bash (for some system calls)

Checkout the project:

GitHub logo pranavraj219 / turingoj

An Online Judge written in Django and Python

TuringOJ

An Online Judge written in Django and Python

Project Setup (for development)

  • Copy the whole project to a directory.
  • Open /turingoj/settings.py and update the database variables.
  • Here PostgreSQL is used, update the Database Engine accordingly.
  • Setup the SECRET_KEY file and the DB_PASS file.
  • Setup the ALLOWED_HOSTS variable.
  • Setup the virtual environment according to the requirements.txt.
  • Set DEBUG=True for development purposes.
  • Make migrations for the models to be migrated to the database.

Judge Setup (scripts/judge.py)

  • Create a jail for secure execution of the judge and ensure that the compilers to be used are installed and available.
  • Update the CHROOTPATH var to be equal to the path of the jail root.
  • Change TIME_QUANTUM in accordance with the speed of the judge you want, keep in mind that decreasing it to a very low value will result in thrashing and poor performance.
  • Run scripts/judge.py as sudo python3 judge.py to start judging submissions.

Work in Progress

Top comments (0)