ผลต่างระหว่างรุ่นของ "ฐานความรู้"
Jittat (คุย | มีส่วนร่วม) (→Judge) |
Jittat (คุย | มีส่วนร่วม) |
||
แถว 88: | แถว 88: | ||
===Judge modes=== | ===Judge modes=== | ||
− | Currently there are | + | Currently there are 3 modes. Only the first two are relevant to normal usage. |
+ | * '''exam''' | ||
+ | * '''grading''' | ||
+ | * '''test''' | ||
===How to install=== | ===How to install=== |
รุ่นแก้ไขเมื่อ 10:39, 16 มีนาคม 2551
Apache2 on Ubuntu
Enabling User Directory
This is how to set up Apache2 on Ubuntu so that, when hxxp://server/~username is accessed, the browser returns the content in /home/username/public_html.
First, user directory is now a mod in Ubuntu's apache2. If you have not installed the mod, then execute the following command:
sudo a2enmod userdir
Second, edit /etc/apache2/apache2.conf and add the following lines:
<IfModule mod_userdir.c> UserDir public_html </IfModule> <Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Options Indexes SymLinksIfOwnerMatch IncludesNoExec </Directory>
Third, execute the following command:
cd /etc/apache2/mods-enabled sudo ln -s /etc/apache2/mods-available/userdir.conf userdir.conf sudo ln -s /etc/apache2/mods-available/userdir.load userdir.load
Forth, restart your apache2:
sudo /etc/init.d/apache2 restart
Installing Grader Web Interface
Installing HAML
The grader makes use of HAML. So you need to install it first.
gem install haml --no-ri
Checking out the Grader Web Interface
First, make a directory that will contain all the grader files. In my case, I make a directory called "grader" inside my home directory.
mkdir ~/grader
Inside the directory, you check out the web interface.
svn co http://theory.cpe.ku.ac.th/grader/web/trunk ~/grader/web
Setting up the Database
cd ~/grader/web/config cp database.yml.SAMPLE database.yml
Then, edit database.yml so that it reflects the database setting of your machine.
Note: In Ubuntu, the database socket is not located at /tmp/mysql.sock as it is in other distributions. You need to add one extra line in database.yml to tell rails this:
adapter: mysql socket: /var/run/mysqld/mysqld.sock database: ioi username: ioi password: whateverpassword host: localhost
Next, you do the migration:
cd ~/grader/web rake db:migrate
Check your MySQL to see if the tables actually appear.
Test the Grader for the First Time
Then, run the server
ruby script/server
Go check http://localhost:3000. You can login as root and the password is ioionrails. You should change the password immediately and logout.
Judge
Judge system reads user submissions and test submissions and grades. It can be run with different configurations (called modes) depending on the situations, e.g., during the exam, the judge probably grades with example test cases but while grading it grades with different sets of test cases. This multiple configurations can be done with multiple modes where configured so that the judge finds different sets of test data.
Basic directory structure
/[judge-root] /ev (containing grading information for each problem) /problem_1 ... /problem_n /test_request (containing TEST interface template for each problem) /problem_1 ... /problem_n /result (containing grading results) /user_1 /problem_1 /submission_1 ... /user_n /scripts (where all script are) /config (where all config files are) /lib /std-script (grading scripts) /templates (used for importing scripts) /test /log
Judge modes
Currently there are 3 modes. Only the first two are relevant to normal usage.
- exam
- grading
- test
How to install
Check out the scripts directory from the SVN
Edit config files
Config files are in (judge-home)/scripts/config. In that, you will find sample config files (under *.SAMPLE).
- First you have to copy and edit environment.rb.
- RAILS_ROOT --- The judge accesses submissions through Rails ActiveRecord; therefore, it has to run Rails' environment. You should set RAILS_ROOT to point to where the root of Rails application for the web interface is. (There is a drawback for this design: you have to install and configure the web interface even when you just want to run the judge system.)
- GRADER_ROOT --- This is the directory where the scripts are. It should be (judge-home)/scripts/config. (Notes: This should actually read JUDGE_SCRIPT_ROOT, will fix it later ---Jittat 17:35, 16 มีนาคม 2008 (ICT))
- For each mode, you'll have to edit its configuration. For mode (MODE), configuration file will be env_(MODE).rb. In that you'll have to edit: