Skip to content
sunner edited this page Mar 25, 2011 · 11 revisions

1. Download

1.1. Download source package

Untar/unzip, rename dirname to onlinejudge and put it into <Installed Moodle Directory>/mod/assignment/type/

1.2. Download via git

cd <Installed Moodle Directory>/mod/assignment/type/
git clone git://github.com/hit-moodle/onlinejudge.git

2. Make sandbox

Linux only. Windows users skip to next step.

Prerequisite:

  • make

  • gcc, g++

  • libc-dev-i386, libstdc++-multilib (64 bit only)

In mod/assignment/type/onlinejudge/sandbox/, run:

$ make

The last line of make’s output must be All testcases are OK.

3. Configure

Users who want to use ideone.com should do this step. Windows users can use ideone.com only

Prerequisite: php with soap extension

  1. register here: http://ideone.com/account/register

  2. After activation, login and set API password here: http://ideone.com/account/

  3. Open config.php and add the following lines:

$CFG->assignment_oj_ideone_username = 'change_me_to_ideone_username'; 
$CFG->assignment_oj_ideone_password = 'change_me_to_ideone_API_password'; 

4. Apply

  1. Login moodle as admin

  2. Access http://your.moodle.domain/admin/index.php

  3. Follow the instructions

5. Make Judge Work

There are two recommended routines to make the judge work. The first is the most recommended but it works in Linux only.

5.1. Create Judge Daemon Through Cron

(Linux only)

Setup moodle’s cron job to be called by php cli. In crontab, put a command which is similar with:

php -q /PATH/TO/MOODLE/admin/cron.php

That’s all! Read http://docs.moodle.org/en/Cron for detail about how to setup moodle cron job triggered by php cli (Not wget, curl and etc.).

If it works, a judge daemon would be created. Use

ps -FC php

to ensure the daemon is running.

5.2. Create Judge Daemon in Command Line

If you can NOT trigger cron through php cli or are using Windows, then use this method.

In Linux

Run the following command to create judge daemon:

sudo -u APACHE-USER php /PATH/TO/MOODLE/mod/assignment/type/onlinejudge/judged.php

The APACHE-USER means the username of apache in your system. It is www-data in debian, apache in fedora. Perhaps `ps aux|grep apache` or `ps aux|grep httpd` can help you getting the correct username.

Use

ps -FC php

to ensure the daemon is running.

In Windows

Run the following command to create judge daemon:

C:\PHP\php.exe MOODLE\mod\assignment\type\onlinejudge\judged.php

Make sure the current user has the permission to access moodle code and files in moodledata.