Show More
Commit Description:
handle the case when problem id or submission id is null. Grader will simply skip such request. Add more report on console (for command line grading)...
Commit Description:
handle the case when problem id or submission id is null. Grader will simply skip such request. Add more report on console (for command line grading) (mercurial grafted from d233105d3965c5368c9b33125f390e39b25f910e)
File last commit:
Show/Diff file:
Action:
new_problem | 73 lines | 1.6 KiB | text/plain | TextLexer |
#!/usr/bin/ruby
# new_problem:
# * creates a directory for a problem in the current directory,
# * create standard testcase config file
require 'erb'
def process_options(options)
i = 2
while i<ARGV.length
if ARGV[i]=='-t'
options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
if ARGV[i]=='-m'
options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
i += 1
end
end
puts "This script is out of dated, shall be fixed soon"
puts "Right now, you can create raw_ev and import"
exit(0)
GRADER_DIR = File.dirname(__FILE__)
# print usage
if ARGV.length < 2
puts <<USAGE
using: new_problem problem number_of_testcase [options]
* creates a directory for a problem in the current directory,
* create standard testcase config file
* options: -t time-limit (in seconds)
-m mem-limit (in MB)
USAGE
exit(127)
end
# processing arguments
problem = ARGV[0]
num_testcases = ARGV[1].to_i
options = {:time_limit => 1, :mem_limit => 16}
process_options(options)
# start working
puts "creating directories"
system("mkdir #{problem}")
system("mkdir #{problem}/script")
system("mkdir #{problem}/test_cases")
puts "creating testcases directories"
1.upto(num_testcases) do |i|
system("mkdir #{problem}/test_cases/#{i}")
end
# generating all_tests.cfg
puts "generating testcase config file"
template = File.open(File.dirname(__FILE__) + "/templates/all_tests.cfg.erb").read
all_test_cfg = ERB.new(template)
cfg_file = File.open("#{problem}/test_cases/all_tests.cfg","w")
cfg_file.puts all_test_cfg.result
cfg_file.close
puts "done"