Page 1 of 2
Online Judge
Posted: Mon Dec 28, 2009 10:51 pm
by DeimonDB
Hi, I'm a newbie in php, but I have experience in other programming language such as C++.
I'm trying to make an online judge system, such as
http://uva.onlinejudge.org/.
Taken From wikipedia :
An online judge is an online system to test programs in programming contests. They are also used to practice for such contests. Many of these systems organise their own contests.
The system can compile and execute your code, and test your code with pre-constructed data. Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on. The output of the code will be captured by the system, and compared with the standard output. The system will then return the result. When mistakes were found in a standard output, rejudgement using the same method must be made.
Is this can be done via PHP? Can someone help me code this?
Re: Online Judge
Posted: Mon Dec 28, 2009 10:56 pm
by JNettles
Are you trying to do this to PHP web apps or compiled apps? Its certainly possible, at least on the web end but I think you'd end up using a whole array of technologies to complete something like this, especially if you end up needing to compile source code.
Re: Online Judge
Posted: Mon Dec 28, 2009 11:07 pm
by DeimonDB
Are you trying to do this to PHP web apps or compiled apps?
I want it to be web apps.
Its certainly possible, at least on the web end but I think you'd end up using a whole array of technologies to complete something like this, especially if you end up needing to compile source code.
I'll Try to learn it -- as long as there are people guiding me
But Is it possible without using system function such as exec()?
Because I think we need to use exec to tell the compiler to compile the source code, and many web hosting did not give access to such functions.
Re: Online Judge
Posted: Tue Dec 29, 2009 12:23 am
by JNettles
What kind of web apps are you wanting to do that you would need to compile? If you're just going to be running tests on PHP web apps then you wouldn't need to do any compiling.
Re: Online Judge
Posted: Tue Dec 29, 2009 1:20 am
by DeimonDB
Uhm I'm Sorry, but I don't quite understand what you are saying.
Here is what the online judge would do:
Receive user source code
compile the souce code
check it with multiple input datas
notify the user one of the following:
- Accepted : if the program run within time limit, and memory limit, and outputs the correctt answer on all test data.
- Wrong answer: if the program outputs wrong answer
- Time Limit Exceeded : if the program exceeds the time limit
- Memory Limit Exceeded : if the programs exceeds the memory usage limit
Re: Online Judge
Posted: Tue Dec 29, 2009 2:10 am
by omniuni
You can do it without using exec(), but you'll need the system to handle the execution and reporting. The easiest way to do this would be to have users upload their files, and they would go into a queue. A process running on the server would watch for new files in the queue, run the tests, produce the results, and write them into a database, and flag the project as having been tested. At that point, the results would be available to PHP via the database, and it could display the results to the user.
Re: Online Judge
Posted: Tue Dec 29, 2009 6:08 am
by DeimonDB
so, how do I make this 'watcher' process?
Re: Online Judge
Posted: Tue Dec 29, 2009 7:02 am
by omniuni
That's up to you. You can use chron jobs, or daemons, or find a way to have it triggered via PHP.
Re: Online Judge
Posted: Tue Dec 29, 2009 7:06 am
by DeimonDB
Hmm, OK. Say I have cron job with interval every 10 minutes, executing a php script.
This php script would use the exec() function too, isn't it?
Re: Online Judge
Posted: Tue Dec 29, 2009 7:49 am
by omniuni
Well, most likely, you would not use PHP, unless you're testing PHP. You'd need the chron to run a Java program for Java, C for C/C++ etc. You'll need to figure out the bindings for all those languages, and you should probably have your chron jobs check every 30 seconds or so, not every 10 minutes, or users will become very impatient! As a student who has had to use WebCAT (horrid!) just waiting 3 minutes due to the system being backed up was bad enough!
Re: Online Judge
Posted: Tue Dec 29, 2009 8:28 am
by DeimonDB
can you give me example?
Re: Online Judge
Posted: Tue Dec 29, 2009 9:32 am
by JNettles
I don't mean to sound harsh or anything but this project seems pretty advanced for someone of your skill level. You're talking about implementing a fairly advanced system before you even look at the PHP side of things. Unless you have a pretty thorough grounding in compilers, build tools, chrons/daemons and command scripts you may want to put this on the back-burner until later. And would this need to be multi-language? I imagine that you'd have to use a Java, .NET, and C++ compiler, create both ANT and NANT build tools.......
Re: Online Judge
Posted: Tue Dec 29, 2009 8:26 pm
by omniuni
I'm afraid JNettles is probably right.
Re: Online Judge
Posted: Tue Dec 29, 2009 11:30 pm
by DeimonDB
well, how about installing this,
http://mooshak.dcc.fc.up.pt/
does this require advanced skill too?
can you help me install this?
Re: Online Judge
Posted: Wed Dec 30, 2009 8:40 am
by omniuni
Just curious, but do you have your hosting set up yet? If so, what kind of plan?