-
Notifications
You must be signed in to change notification settings - Fork 5
/
documentation_eclipseoj.tex
206 lines (200 loc) · 11.7 KB
/
documentation_eclipseoj.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
\documentclass[hidelinks, a4paper,12pt, titlepage]{article}
\usepackage[a4paper,bottom = 1.5in,left = 1in,right = 1in,top = 1.5in]{geometry}
\usepackage{fontspec}
\usepackage{xunicode,xltxtra,url,parskip}
\usepackage{graphicx}
\usepackage{lipsum}% for auto generating text
\usepackage{afterpage}% for "\afterpage"
\usepackage{pagecolor}
\usepackage{hyperref}
\usepackage{sectsty}
\sectionfont{\fontsize{18}{24}\selectfont}
\setmainfont[BoldFont = Lato-Bold.ttf,ItalicFont = Lato-LightItalic.ttf]{Lato-Light.ttf}
\usepackage[usenames,dvipsnames]{xcolor}
\begin{document}
\newpagecolor{black}\afterpage{\restorepagecolor}
\vspace{0pt}
{\center \includegraphics[scale=0.44]{logo.png}}
\vspace{20pt}
{\center \color{white} \fontsize{47}{57}\selectfont DOCUMENTATION\\}
\setmainfont[BoldFont = Lato-Bold.ttf,ItalicFont = Lato-Italic.ttf]{Lato-Regular.ttf}
\vspace{150pt}
{\center \color{white} \fontsize{20}{22}\selectfont TEAM ECLIPSE\\}
\vspace{10pt}
\setmainfont[BoldFont = Lato-Bold.ttf,ItalicFont = Lato-LightItalic.ttf]{Lato-Light.ttf}
{\center \color{white} \fontsize{15}{18}\selectfont October 21,\, 2017\\}
\setmainfont[BoldFont = Lato-Bold.ttf,ItalicFont = Lato-Italic.ttf]{Lato-Regular.ttf}
\vspace{75pt}
{\center \color{white} \fontsize{15}{18}\selectfont Vighnesh Reddy Konda\hfill|\hfill Naman Jain\hfill|\hfill Satti Vamsi Krishna Reddy\\}
\newpage
{ \renewcommand{\baselinestretch}{1.5}
\tableofcontents
}
\newpage
\section{Models}
\subsection{Profile}
This model is an extension to the User model from django.contrib.auth.models through a OneToOneField
This model is used to store all the additional fields like First Name, Last Name, Country, City, Institute, Email, Rating
\subsection{Problem}
This model is related to a Contest through a ForeignKey
This model is used to store all the necessary details of a problem like Body, Marks, TimeLimit
\subsection{Test Case}
This model is related to Problem through a ForeignKey
This model is used to store all the test cases in separate files related to the problems
\subsection{Contest}
This model is related to the User model from django.contrib.auth.models through a ManyToManyField to keep track of registered users
This model is used to store all the Details of a contest like its Start Time, End Time, Registered Users
\subsection{Queue}
This model is used to process the submissions in a first in first out manner. It calls the function grader from judge.models and gives the verdict based on the submitted code and the test cases
\subsection{Submission}
This model is related to Queue, Problem, User using ForeignKeys
It is required to store the uploaded file and the corresponding language which the user submits
\subsection{Score}
This model is related to Contest, User using ForeignKeys
It stores all the user scores in a contest and some boolean fields for the problems
\section{Apps}
\subsection{core}
This model takes care of the following url's:
\subsection{contests}
\subsection{problems}
\subsection{discuss}
\subsection{leaderboard}
\subsection{judge}
\section{Requirements - Softwares and other Tools}
\begin{itemize}
\item Git
\item Django
\item Docker
\item FlipClock.js
\item Ace
\item Mathjax
\end{itemize}
Git
Bootstrap4
Docker
FlipClock.js
Ace
\section{What's an OJ (Online Judge)?}
\begin{itemize}
\item An online judge is an online system to test programs in programming contests.
\item They are also used to practice for such contests.
\item The system can compile and execute code, and test them with pre-constructed expected output data.
\item Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on.
\item The output of the code will be captured by the system, and compared with the standard output. The system will then return the result.
\item Online Judges have rank lists based on user ratings
\end{itemize}
\section{Abstract}
Eclipse OJ is an online system to test programs in programming contests and also used to practice for such contests. The system can compile and execute code, and test them with pre-constructed data. Submitted code can be run with restrictions, including time limit and memory limit. The output of the code will be captured by the system, and compared with the standard output, the system will then return the result.
The salient features of our Eclipse OJ would be:
\begin{enumerate}
\item Create a website for hosting programming contests and maintaining a database of problems in a categorized fashion.
\item Login for existing users / Registration facility for new users and storing their details in a database.
\item Implement a judge/checker that supports C, C++, Python, Java.
\item Implement a Discussion Forum where users can discuss and post regarding various questions and their solutions.
\item Implement a proper admin portal, where questions can be uploaded and contests hosted.
\item Implement a rating feature, rating will get updated after every contest, a statistical approach to calculate ratings appropriately.
\item Extend the rating feature to leaderboards ranked according to ratings and categorised in various ways (according to say institution).
\item Prevent execution of potential `malware/untrusted' code that can be uploaded by a user intentionally.
\item Implement a private messaging interface which also supports file-transfers for users to interact and collaborate.*
\end{enumerate}
\hfill\textit{*To be done if time permits}
\section{Prior Artwork \& Survey}
\subsection{Popular Online Judges}
Some popular Online Judges already out there include SPOJ, Codeforces, Codechef, HackerRank, Hackerearth ...\emph{etc}.
In general, it was felt that the messaging systems of many OJs weren't good as they were:
\begin{enumerate}
\item Not so comfortable and appealing visually.
\item Tough to collaborate in real-time with such an UI.
\end{enumerate}
\includegraphics[width=\textwidth]{cf_msgs.png}
\newpage
Some important unique features of various OJs are:
\subsubsection{Codeforces}
\begin{itemize}
\item Users are divided into two major divisions based on their rating with each div. having its own difficulty.
\item Virtual participation in a contest.
\item Hacking someone else’s solution who is in the same room during a contest.
\end{itemize}
\subsubsection{SPOJ}
\begin{itemize}
\item Huge collection of problems.
\item Problems are well categorized based on the tags given to them.
\item Supports upto 5 spoken languages. (world-wide community)
\end{itemize}
\subsection{Security from Untrusted Code}
We intend to prevent any harm to server caused by execution of ‘untrusted code’. This is commonly called ‘Sandboxing’ in Computer Security. So, what we stumbled across as some possible options for this:\hfill\cite{sandbox}\cite{sandbox1}
\begin{itemize}
\item Chroot jail - Isolates a particular directory - mimics itself as the root.
\item LXB Containers (Linux Containers)
\item Docker.io (an interesting open-source extension to Linux Containers, easier to handle) - something awesome! - but we felt it’s beyond our ‘scope’ :(
\item Libsandbox (not OS specific - more related to code itself)
\item Using VMWare / Virtual Box - even run an OS inside another? - you know what I mean.
\end{itemize}
\subsection{Why Django?}
\subsubsection{Django \emph{vs.} Rails}
A popular alternative available to Django is Ruby-on-Rails. Despite that, we choose Django because:
\begin{itemize}
\item Ruby-on-Rails is based on Ruby while Django on Python. We are relatively more familiar with python, so Django became a preference.
\item Django takes care of user authentication system (i.e. django.contrib.auth), and their security — right out of the box unlike Rails.
\end{itemize}
\subsubsection{Why Django?}
Other reasons to choose django were:
\begin{itemize}
\item It’s Open Source (so is Rails).
\item Databases are simple to be managed on frameworks like Django.
\item We felt Django’s Model-Template-View framework system and it being python based makes it a lot simple to code.
\item Also, django has additional extensions like Channels which can be used for developing messaging systems.
\vspace{10pt}
{\begin{center}
And finally because what its creators call it: \\
``the web framework of perfectionists with deadlines''\\
\vspace{10pt}
\includegraphics[scale=0.6]{django.png}\flushright\cite{logo} \end{center}}
\end{itemize}
\subsubsection{Security in Django}
\begin{itemize}
\item Django by-default uses ‘hashing’ to manage passwords of users securely.
\item The choice of hashing algorithm is left to the user.
\item Many of which popular ones like md5, bcrypt, pbkdf2, argon2, sha1 etc. already implemented in-the-box at ‘django.contrib.auth.hashers’.\hspace{130pt}\cite{security}
\end{itemize}
\subsection{A Sneak-Peek}
\begin{center}\includegraphics[scale=0.5]{login.png}\end{center}
\subsection{Ranking System}
We want to put a Leaderboard such that it keeps people motivated in order to improve. For this we need a rating system, some of the popular ones include Elo, Chess, Glicko rating system ...etc.
\begin{itemize}
\item The Elo rating system is a method for calculating the relative skill levels of players in multiplayer type of games.
\item We found that Elo rating system is most appropriate for us and also Codechef and Hackerrank implement their rating system mainly based on Elo (though not entirely the same)
\end{itemize}
Most of the popular OJs do not keep their rating mechanisms open and the number of factors the rating depends on is huge
\subsection{Django Channels}
In order to create a modern chat application using Django we found that there are two approaches one using jQuery and the other using Websockets. Django channels is to make Django able to handle more than just plain HTTP requests, including WebSockets and HTTP2.\hfill\cite{message}\\
We chose websockets, because we didn’t want our website to use jQuery for messaging which makes tons of useless state-check requests to the server. Also, websockets work instantly — opposing to jQuery approach, which can only pull data every N milliseconds.
\section{Motivation}
Programming contests are fun but organising one is difficult if the number of participants is large, so it is nice to automate the skill testing in such contests. Also it is good to maintain a collection of all the problems in previous contests so that people can practice.
It would be nice if one can submit their code in multiple languages All these can be achieved by having an Online Judge.
Major factors that motivated us to create an Online Judge were:
\begin{itemize}
\item Most of the popular online judges today ask for a price to hold a contest.
\item No big and famous `open-source OJs' - so felt the need of one.
\item Additionally IIT Bombay doesn't have an online judge of it's own, so we decided to make a state-of-the-art Online judge for our institute, which we strongly believe will increase the community of sport programmers in our insti.
\item Team collaboration has been difficult, specifically for learners initially. Messaging systems (if any) already seem to be naive and not user-friendly.
\end{itemize}
\newpage
\begin{minipage}{400pt}
\begin{thebibliography}{20}
\addcontentsline{toc}{section}{Bibliography}
\bibitem{elo}
Image:\hspace{10pt}\url{http://en.wikipedia.org/wiki/Elo_rating_system#Mathematical_details}
\bibitem{logo}
Image:\hspace{10pt}\url{https://www.djangoproject.com/}
\bibitem{security}
Link:\hspace{10pt}\url{https://docs.djangoproject.com/en/1.11/topics/auth/passwords/}
\bibitem{message}
Link:\hspace{10pt}\url{https://medium.com/@bearle/django-chat-app-2017-approach-6be1ff17ad6a}
\bibitem{sandbox}
Link:\hspace{10pt}\url{https://blog.remoteinterview.io/how-we-used-docker-to-compile-and-run-untrusted-code-2fafbffe2ad5}
\bibitem{sandbox1}
Link:\hspace{10pt}\url{https://stackoverflow.com/questions/1014505/how-does-the-acm-icpc-online-judge-prevent-malicious-attacks}
\end{thebibliography}
\end{minipage}
\end{document}