A minimilistic Online Jury written in PHP and Python. This project is a basic setup for all Online Juries. It is simple to install and configure. I have pen down the steps of installation in details. I hope that you find it useful. Don't forget to star the repository.
- Supports two languages (from compilation to run) C++ and Java. Additional languages can be added similarly.
- Adding problems is simple. I have not included an Admin Panel. You can build your own if you wish.
- Submissions are stored directly in database.
- Leaderboard is auto-updated.
- Simple and light-weighted. The whole source code is no more than 1 MB in size (including graphics).
-
Install the compilers. For C++ install MinGW (Command 'g++' must work). For Java install Java8 (Command 'javac' & 'java' must work). Adding other compilers depends upon your choice.
-
Install Apache, PHP, Python3, MySQL, PhpMyAdmin. Check the documentation of these softwares for more information on installation.
-
Copy all the files to Server root (or whichever folder you would like to host the site on).
-
Change the permission of 'Problems' folder. Set it to 000.
sudo chmod -R 000 Problems/
This would make the Problems folder inaccessible from outer web.
-
Login to phpmyadmin and create new database. Import the SQL file 'judge.sql' into the database.
-
Open 'judge/dbconfig.php' and set the values of the database configuration fields (servername, username, password, databasename) accordingly.
-
Open 'judge/judge.py' and set the values of database configuration fields (servername, username, password, databasename) accordingly.
-
Create new user named 'oj'.
sudo adduser oj
This user will be used to run the program as.
-
Use pip to install pymysql. 'pymysql' is the only external library on which this software is dependent.
pip install pymysql
OR
pip3 install pymysql
If pip is not present, you may install it for your corresponding OS.
-
Run the python script 'judge.py'. It MUST be run as root.
sudo python3 judge.py
This script will automatically judge the submissions. This script is what the judge is all about.
-
Open the page in your browser. Register for a new account. Then login and make a new submission. If the submission is judged, your installation was fine.
-
That's all :).
- Login to PhpMyAdmin and add the new problem in the 'problems' table. Each problem has a unique CAPITALIZED code of maximum 10 alphabets called 'problemcode'. Set the 'users_solved' field to 0. Add short description, problem statement and sample I/O. You can use HTML syntax in these fields. Set the time limit in seconds and the level of difficulty (0 for Easy, 1 for Medium, 2 for Hard, 3 for Extreme).
- The I/O files over which the program will be checked is to be kept in 'Problems/' directory. Inside the directory, create a new folder named same as the problem code. Create a folder named 'input' and put your input files (numbered serially 1,2,3,4....) each having extension '.in' in the folder. Create another folder 'output' and put your corresponding output files (numbered serially 1,2,3,4....) each having extension '.out' in that folder.
- Done :). Submit and check.
-
The judge runs on port number 8080. If you need to change the port number, change the same in 'judge.py' and 'judge/index.php'. Just search for '8080' and replace it with your required port number.
-
The judge does strict comparison of expected and actual output. Even whitespaces may result in WA. You can modify the judge to ignore the whitespaces character.
-
The 'Leaderboard' and 'My Submissions' load only the top 100 records by default. The corresponding scripts can be modified to featch even more records.
-
You can send messages to individuals that would appear as popup. To send a new message, add the username and message to 'msg' table in the database.
-
If you would like to run the judge.py in the background, then use nohup:
nohup sudo python3 judge.py &
Type in some other command and exit from the terminal.
-
You can add more languages yourself. The code is simple to read. If you have any doubts or queries, please ping me. :)