Description:
MERGED change set (408:410) from web/judge in branch combined-with-judge (fixed time_limit option bug) git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@411 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r73:34ddb0155d6f - - 1 file changed: 1 inserted, 1 deleted

@@ -1,88 +1,88
1 #!/usr/bin/ruby
1 #!/usr/bin/ruby
2
2
3 require 'erb'
3 require 'erb'
4 require 'fileutils'
4 require 'fileutils'
5 require File.join(File.dirname(__FILE__),'lib/import_helper')
5 require File.join(File.dirname(__FILE__),'lib/import_helper')
6
6
7 JUDGE_ENVIRONMENTS = [:grading, :exam]
7 JUDGE_ENVIRONMENTS = [:grading, :exam]
8 ENV_INFO = {
8 ENV_INFO = {
9 :grading => {
9 :grading => {
10 :ev_dir => 'ev',
10 :ev_dir => 'ev',
11 :raw_prefix => '',
11 :raw_prefix => '',
12 },
12 },
13 :exam => {
13 :exam => {
14 :ev_dir => 'ev-exam',
14 :ev_dir => 'ev-exam',
15 :raw_prefix => 'ex.',
15 :raw_prefix => 'ex.',
16 }
16 }
17 }
17 }
18
18
19 def input_filename(dir,i)
19 def input_filename(dir,i)
20 "#{dir}/input-#{i}.txt"
20 "#{dir}/input-#{i}.txt"
21 end
21 end
22
22
23 def answer_filename(dir,i)
23 def answer_filename(dir,i)
24 "#{dir}/answer-#{i}.txt"
24 "#{dir}/answer-#{i}.txt"
25 end
25 end
26
26
27 def build_testrun_info_from_dir(num_testruns, importing_test_dir, raw_prefix='')
27 def build_testrun_info_from_dir(num_testruns, importing_test_dir, raw_prefix='')
28 filenames = Dir["#{importing_test_dir}/#{raw_prefix}*.in"].collect do |filename|
28 filenames = Dir["#{importing_test_dir}/#{raw_prefix}*.in"].collect do |filename|
29 File.basename((/(.*)\.in/.match(filename))[1])
29 File.basename((/(.*)\.in/.match(filename))[1])
30 end
30 end
31 build_testrun_info(num_testruns,filenames,raw_prefix)
31 build_testrun_info(num_testruns,filenames,raw_prefix)
32 end
32 end
33
33
34 def copy_testcase(importing_test_dir,fname,dir,i)
34 def copy_testcase(importing_test_dir,fname,dir,i)
35 system("cp #{importing_test_dir}/#{fname}.in #{input_filename(dir,i)}")
35 system("cp #{importing_test_dir}/#{fname}.in #{input_filename(dir,i)}")
36 system("cp #{importing_test_dir}/#{fname}.sol #{answer_filename(dir,i)}")
36 system("cp #{importing_test_dir}/#{fname}.sol #{answer_filename(dir,i)}")
37 end
37 end
38
38
39 def process_options(options)
39 def process_options(options)
40 - i = 4
40 + i = 3
41 while i<ARGV.length
41 while i<ARGV.length
42 if ARGV[i]=='-t'
42 if ARGV[i]=='-t'
43 options[:time_limit] = ARGV[i+1].to_f if ARGV.length>i+1
43 options[:time_limit] = ARGV[i+1].to_f if ARGV.length>i+1
44 i += 1
44 i += 1
45 end
45 end
46 if ARGV[i]=='-m'
46 if ARGV[i]=='-m'
47 options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
47 options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
48 i += 1
48 i += 1
49 end
49 end
50 i += 1
50 i += 1
51 end
51 end
52 end
52 end
53
53
54 def print_usage
54 def print_usage
55 puts "using: import_problem_new name dir check [options]
55 puts "using: import_problem_new name dir check [options]
56
56
57 where: name = problem_name (put '-' (dash) to use dir name)
57 where: name = problem_name (put '-' (dash) to use dir name)
58 dir = importing testcase directory
58 dir = importing testcase directory
59 check = check script, which can be
59 check = check script, which can be
60 'integer', 'text' (for standard script),
60 'integer', 'text' (for standard script),
61 path_to_your_script, or
61 path_to_your_script, or
62 'wrapper:(path_to_your_wrapped_script)'
62 'wrapper:(path_to_your_wrapped_script)'
63 options: -t time-limit (in seconds)
63 options: -t time-limit (in seconds)
64 -m memory-limit (in megabytes)
64 -m memory-limit (in megabytes)
65
65
66 The script looks at test data files in the dir of the forms: *.in and
66 The script looks at test data files in the dir of the forms: *.in and
67 *.sol and import them to the evaluation dir for their environment,
67 *.sol and import them to the evaluation dir for their environment,
68 based on their prefixes.
68 based on their prefixes.
69
69
70 Currently supporting environments are:"
70 Currently supporting environments are:"
71
71
72 JUDGE_ENVIRONMENTS.each do |env|
72 JUDGE_ENVIRONMENTS.each do |env|
73 prefix = ENV_INFO[env][:raw_prefix]
73 prefix = ENV_INFO[env][:raw_prefix]
74 prefix = 'no prefix' if prefix==''
74 prefix = 'no prefix' if prefix==''
75 puts " * #{env}"
75 puts " * #{env}"
76 puts " import to: #{ENV_INFO[env][:ev_dir]}"
76 puts " import to: #{ENV_INFO[env][:ev_dir]}"
77 puts " prefix with: #{prefix} (e.g., #{ENV_INFO[env][:raw_prefix]}1.in, #{ENV_INFO[env][:raw_prefix]}5a.sol)"
77 puts " prefix with: #{prefix} (e.g., #{ENV_INFO[env][:raw_prefix]}1.in, #{ENV_INFO[env][:raw_prefix]}5a.sol)"
78 end
78 end
79
79
80 puts"
80 puts"
81 For each environment, the script
81 For each environment, the script
82 * creates a directory for a problem in ev dir of that environment,
82 * creates a directory for a problem in ev dir of that environment,
83 * copies testdata in the old format and create standard testcase config file
83 * copies testdata in the old format and create standard testcase config file
84 * copies a check script for grading
84 * copies a check script for grading
85 * creates a test_request template in the ev dir + '/test_request'
85 * creates a test_request template in the ev dir + '/test_request'
86
86
87 For wrapped checked script see comment in templates/check_wrapper for
87 For wrapped checked script see comment in templates/check_wrapper for
88 information."
88 information."
You need to be logged in to leave comments. Login now