Show More
Commit Description:
added problem import...
Commit Description:
added problem import git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@435 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
lib/grader_script.rb | 58 lines | 1.4 KiB | text/x-ruby | RubyLexer |
module GraderScript
def self.grader_control_enabled?
if defined? GRADER_ROOT_DIR
GRADER_ROOT_DIR != ''
else
false
end
end
def self.raw_dir
File.join GRADER_ROOT_DIR, "raw"
end
def self.call_grader(params)
if GraderScript.grader_control_enabled?
cmd = File.join(GRADER_ROOT_DIR, "scripts/grader") + " " + params
system(cmd)
end
end
def self.stop_grader(pid)
GraderScript.call_grader "stop #{pid}"
end
def self.stop_graders(pids)
pid_str = (pids.map { |process| process.pid.to_a }).join ' '
GraderScript.call_grader "stop #{pid_str}"
end
def self.start_grader(env)
GraderScript.call_grader "#{env} queue &"
GraderScript.call_grader "#{env} test_request &"
end
def self.call_import_problem(problem_name,
problem_dir,
time_limit=1,
memory_limit=32,
checker_name='text')
if GraderScript.grader_control_enabled?
cur_dir = `pwd`.chomp
Dir.chdir(GRADER_ROOT_DIR)
script_name = File.join(GRADER_ROOT_DIR, "scripts/import_problem")
cmd = "#{script_name} #{problem_name} #{problem_dir} #{checker_name}" +
" -t #{time_limit} -m #{memory_limit}"
output = `#{cmd}`
Dir.chdir(cur_dir)
return output
end
return ''
end
end