Skip to content

Commit 0344b4d

Browse files
committed
codeOJ-Code Online Judge
0 parents  commit 0344b4d

File tree

4,569 files changed

+1511042
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,569 files changed

+1511042
-0
lines changed

README.md

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
#Code Online Judge (CodeOJ)
2+
3+
CodeOJ is a judge system used to test correctness and efficiency of programs written for various programming languages in coding contests,Recruiters can conduct Hiring Challenges and for intra-inter college coding competitions.
4+
CodeOJ aims to build an environment for the people, specifically students,around the world to interact, practice and improve their programming skills.
5+
6+
##Core Technologies Used
7+
8+
Why Choose Java : Java makes the Application platform Independent .“Write Once, Run Anywhere”
9+
10+
11+
- Java for Standard Edition (J2SE)
12+
- Java for Enterprise Edition (J2EE)
13+
- Object Relational Mapping (ORM) using Hibernate Framework 3 by JBOSS : Hibernate makes the Judge Database Independent
14+
- Java Beans
15+
- Java Mail,JSTL,JUNIT for Unit Testing
16+
- Python for Judge Script
17+
- Twitter Bootstrap,Ajax,jQuery,JSON,CSS,HTML (Frontend)
18+
- Database : Mysql
19+
- Sandboxing : chroot(jail)
20+
21+
##Features
22+
23+
- Automatic Judging
24+
- Web Interface for Portability and simplicity
25+
26+
+ Beginners Corner : Contains problems for beginners
27+
+ Practice Corner : Contains problems of previous contests
28+
+ Live Programming Contests (Past contest,Current and Upcoming)
29+
+ Admin Panel : to set the contests & problems & Rate the User
30+
31+
- Designed keeping security in mind
32+
- All code run in private mode
33+
- Judge and project run inside chroot (in linux)
34+
- Has been used for live contest
35+
36+
37+
##Sandboxing : to prevent hackers to shutdown your server
38+
39+
you can configure chroot(jail) on your system read chroot.txt (if interested)
40+
41+
- code is frequently buggy and potentially malicious.
42+
- Code must run in a restricted environment (sandbox) to prevent it from damaging the system.
43+
- Resources (particularly, CPU time and memory) must be restricted.
44+
- Programs must be limited to a single thread.
45+
Programs must not be permitted to spawn other processes.
46+
- Programs must not be permitted to initiate system calls.
47+
- Programs must not be able to communicate through TCP/IP Sockets.
48+
49+
50+
51+
##Pre-requisites and Configuration
52+
53+
- Download and install Netbeans 7.1 : Quickly and easily develop desktop, mobile and web applications
54+
with Java, JavaScript, HTML5, PHP, C/C++ and more.NetBeans IDE is FREE, open source, and has a worldwide community of users and developers.
55+
56+
+ Select Platform Linux x64 & all section
57+
+ https://netbeans.org/downloads/
58+
59+
+In terminal,navigate to download directory & run
60+
```
61+
sh netbeans-8.1-linux.sh
62+
```
63+
+ select tomcat server instead of glassfish during installation
64+
65+
66+
- Update your system : Ubuntu Source list generator: https://repogen.simplylinux.ch/generate.php
67+
68+
```
69+
sudo apt-get update
70+
sudo apt-get upgrade
71+
```
72+
73+
- Install MySQL
74+
75+
```
76+
sudo apt-get install mysql-server
77+
```
78+
79+
+ Start/Stop Mysql server
80+
81+
```
82+
sudo service mysql start
83+
sudo service mysql stop
84+
```
85+
86+
+ To log in to MySQL as the root user:
87+
88+
```
89+
mysql -u root -p
90+
```
91+
92+
+ Create a New MySQL User and Database
93+
94+
```
95+
create database testdb;
96+
create user 'testuser'@'localhost' identified by 'password';
97+
grant all on testdb.* to 'testuser';
98+
```
99+
100+
101+
102+
103+
- Install phpmyadmin : phpMyAdmin is a web application that provides a GUI to aid in MySQL database administration
104+
105+
+ Step 1: Install Apache2, PHP and MySQL. We assume you already have installed LAMP on your system.
106+
107+
- Install Apache
108+
```
109+
sudo apt-get install apache2
110+
sudo service apache2 restart
111+
```
112+
113+
- Install PHP
114+
115+
```
116+
sudo apt-get install php5
117+
```
118+
119+
-If you need MySQL support also install php5-mysql
120+
121+
```
122+
sudo apt-get install php5-mysql
123+
```
124+
125+
+ Step 2: Install phpMyAdmin.
126+
127+
```
128+
sudo apt-get install phpmyadmin
129+
```
130+
131+
- After the installation has completed, add phpmyadmin to the apache configuration.
132+
```
133+
sudo vi /etc/apache2/apache2.conf
134+
```
135+
136+
- Add the phpmyadmin config to the file.
137+
```
138+
Include /etc/phpmyadmin/apache.conf
139+
```
140+
141+
- Restart apache:
142+
```
143+
sudo service apache2 restart
144+
```
145+
146+
#Configuration
147+
148+
- Download the repository in Extract to NetBeansProjects folder of your home directory
149+
150+
- Open Netbeans and import project
151+
152+
- Change path in src/java/connection/Path.java
153+
```
154+
static String path = "/home/<YOUR_PC_USERNAME>/NetBeansProjects/codeoj/web";
155+
```
156+
157+
-Give permission to codeoj folder for creating directories & codefiles
158+
```
159+
chmod -R 777 codeoj
160+
```
161+
162+
163+
##Install packages
164+
165+
```
166+
sudo apt-get install python-psutil
167+
sudo apt-get install python-mysqldb
168+
```
169+
170+
- Install the compilers of programming languages you need on your system with sudo apt-get
171+
- Languages : Java, C, C++, Pascal,PHP, Perl, Ruby and Python,Haskell,Pike etc.
172+
173+
174+
175+
176+
177+
##Database
178+
179+
- Goto http://localhost/phpmyadmin
180+
- Create database named "code_online_judge"
181+
182+
- Change user and pass in src/java/connection/Config.java
183+
```
184+
String url = "jdbc:mysql://localhost:3306/code_online_judge";
185+
String user = "<YOUR_MYSQL_USER>";
186+
String pass = "<YOUR_MYSQL_PASSWORD>";
187+
```
188+
189+
- Open judge.py in web folder & change line 72 and line 316 with your database username and password
190+
```
191+
db = MySQLdb.connect("localhost","db_user","db_pass","code_online_judge")
192+
```
193+
194+
195+
196+
##To Run :
197+
198+
- Right click on Project codeoj & select deploy to run the project
199+
- No need to import the database as hibernate framework will take care of it.
200+
- Add username & password(md5) in Admin Table for admin panel access
201+
202+
```
203+
goto http://localhost/codeoj/ap/adminpanel.jsp
204+
```
205+
206+
- Add Entry with integer 1 in id Table for unique codefilename generator
207+
208+
- Goto admin panel to set a contest:
209+
210+
+ Contest Code(without spaces)
211+
+ Contest Name
212+
+ Contest Timing,Poster,no. of problems and instructions for contest
213+
214+
- Set problems :
215+
216+
+ problem code (should be in format CONTESTCODE<s.no>) e.g TEST1,TEST2 (if contest name is TEST)
217+
+ Problems name,setter,tester,timelimit(should be integer in seconds)
218+
+ Problems Description and Number of TEST FILES(should be in format in<s.no>.txt and out<s.no>.txt) e.g in1.txt,in2.txt,out1.txt,out2.txt
219+
220+
- During Contest User should register for contest on:
221+
222+
```
223+
http://localhost/codeoj/index.jsp
224+
```
225+
+ User can View problems,Comment on problems,View his submissions and LeaderBoard
226+
+ To Submit, select language and paste your code in the editor itself or browse the codefile & Judge will return the verdict in a while.
227+
228+
229+
- After Contest Ends :
230+
231+
+ Make solutions public by clicking on "Make public" tab
232+
+ Update the Ratings of the Users participated in contest (ELO Algorithm is used to calculate Ratings)
233+

build.xml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project name="codeoj" default="default" basedir=".">
11+
<description>Builds, tests, and runs the project codeoj.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-dist: called before archive building
30+
-post-dist: called after archive building
31+
-post-clean: called after cleaning build products
32+
-pre-run-deploy: called before deploying
33+
-post-run-deploy: called after deploying
34+
35+
Example of pluging an obfuscator after the compilation could look like
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Other way how to customize the build is by overriding existing main targets.
48+
The target of interest are:
49+
50+
init-macrodef-javac: defines macro for javac compilation
51+
init-macrodef-junit: defines macro for junit execution
52+
init-macrodef-debug: defines macro for class debugging
53+
do-dist: archive building
54+
run: execution of project
55+
javadoc-build: javadoc generation
56+
57+
Example of overriding the target for project execution could look like
58+
59+
<target name="run" depends="<PROJNAME>-impl.jar">
60+
<exec dir="bin" executable="launcher.exe">
61+
<arg file="${dist.jar}"/>
62+
</exec>
63+
</target>
64+
65+
Notice that overridden target depends on jar target and not only on
66+
compile target as regular run target does. Again, for list of available
67+
properties which you can use check the target you are overriding in
68+
nbproject/build-impl.xml file.
69+
70+
-->
71+
</project>

build/web/META-INF/MANIFEST.MF

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

build/web/META-INF/context.xml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Context antiJARLocking="true" path="/codeoj"/>

0 commit comments

Comments
 (0)