diff --git a/grader b/grader --- a/grader +++ b/grader @@ -69,6 +69,30 @@ submission.save end +def copy_script(problem_home) + script_dir = "#{problem_home}/script" + std_script_dir = File.dirname(__FILE__) + '/std-scripts' + scripts = Dir[std_script_dir + '/*'] + + copied = [] + + scripts.each do |s| + fname = File.basename(s) + if !FileTest.exist?("#{script_dir}/#{fname}") + copied << fname + system("cp #{s} #{script_dir}") + end + end + + return copied +end + +def clear_script(problem_home,log) + log.each do |s| + system("rm #{problem_home}/script/#{s}") + end +end + def grade(submission_id) current_dir = `pwd`.chomp @@ -94,9 +118,14 @@ source_name = "#{problem.name}.#{lang_ext}" save_source(sub,problem_out_dir,source_name) + + copy_log = copy_script(problem_home) + call_judge(problem_home,language,problem_out_dir,source_name) save_result(sub,read_result("#{problem_out_dir}/test-result")) + clear_script(copy_log,problem_home) + Dir.chdir(current_dir) end @@ -112,6 +141,10 @@ system("rm " + File.dirname(__FILE__) + '/stop') end +######################################### +# main program +######################################### + # reading environment and options if (ARGV.length >= 1) and (ARGV[0]=='stop') stop_grader diff --git a/import_problem b/import_problem --- a/import_problem +++ b/import_problem @@ -57,7 +57,7 @@ system("mkdir #{problem}") system("mkdir #{problem}/script") system("mkdir #{problem}/test_cases") -system("cp #{GRADER_DIR}/std-script/* #{problem}/script") +#system("cp #{GRADER_DIR}/std-script/* #{problem}/script") puts "copying testcases"