Description:
add: grader copies std script
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@24 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r11:98be78095b33 - - 2 files changed: 34 inserted, 1 deleted
@@ -69,6 +69,30 | |||||
|
69 | submission.save |
|
69 | submission.save |
|
70 | end |
|
70 | end |
|
71 |
|
71 | ||
|
|
72 | + def copy_script(problem_home) | ||
|
|
73 | + script_dir = "#{problem_home}/script" | ||
|
|
74 | + std_script_dir = File.dirname(__FILE__) + '/std-scripts' | ||
|
|
75 | + scripts = Dir[std_script_dir + '/*'] | ||
|
|
76 | + | ||
|
|
77 | + copied = [] | ||
|
|
78 | + | ||
|
|
79 | + scripts.each do |s| | ||
|
|
80 | + fname = File.basename(s) | ||
|
|
81 | + if !FileTest.exist?("#{script_dir}/#{fname}") | ||
|
|
82 | + copied << fname | ||
|
|
83 | + system("cp #{s} #{script_dir}") | ||
|
|
84 | + end | ||
|
|
85 | + end | ||
|
|
86 | + | ||
|
|
87 | + return copied | ||
|
|
88 | + end | ||
|
|
89 | + | ||
|
|
90 | + def clear_script(problem_home,log) | ||
|
|
91 | + log.each do |s| | ||
|
|
92 | + system("rm #{problem_home}/script/#{s}") | ||
|
|
93 | + end | ||
|
|
94 | + end | ||
|
|
95 | + | ||
|
72 | def grade(submission_id) |
|
96 | def grade(submission_id) |
|
73 | current_dir = `pwd`.chomp |
|
97 | current_dir = `pwd`.chomp |
|
74 |
|
98 | ||
@@ -94,9 +118,14 | |||||
|
94 | source_name = "#{problem.name}.#{lang_ext}" |
|
118 | source_name = "#{problem.name}.#{lang_ext}" |
|
95 |
|
119 | ||
|
96 | save_source(sub,problem_out_dir,source_name) |
|
120 | save_source(sub,problem_out_dir,source_name) |
|
|
121 | + | ||
|
|
122 | + copy_log = copy_script(problem_home) | ||
|
|
123 | + | ||
|
97 | call_judge(problem_home,language,problem_out_dir,source_name) |
|
124 | call_judge(problem_home,language,problem_out_dir,source_name) |
|
98 | save_result(sub,read_result("#{problem_out_dir}/test-result")) |
|
125 | save_result(sub,read_result("#{problem_out_dir}/test-result")) |
|
99 |
|
126 | ||
|
|
127 | + clear_script(copy_log,problem_home) | ||
|
|
128 | + | ||
|
100 | Dir.chdir(current_dir) |
|
129 | Dir.chdir(current_dir) |
|
101 | end |
|
130 | end |
|
102 |
|
131 | ||
@@ -112,6 +141,10 | |||||
|
112 | system("rm " + File.dirname(__FILE__) + '/stop') |
|
141 | system("rm " + File.dirname(__FILE__) + '/stop') |
|
113 | end |
|
142 | end |
|
114 |
|
143 | ||
|
|
144 | + ######################################### | ||
|
|
145 | + # main program | ||
|
|
146 | + ######################################### | ||
|
|
147 | + | ||
|
115 | # reading environment and options |
|
148 | # reading environment and options |
|
116 | if (ARGV.length >= 1) and (ARGV[0]=='stop') |
|
149 | if (ARGV.length >= 1) and (ARGV[0]=='stop') |
|
117 | stop_grader |
|
150 | stop_grader |
@@ -57,7 +57,7 | |||||
|
57 | system("mkdir #{problem}") |
|
57 | system("mkdir #{problem}") |
|
58 | system("mkdir #{problem}/script") |
|
58 | system("mkdir #{problem}/script") |
|
59 | system("mkdir #{problem}/test_cases") |
|
59 | system("mkdir #{problem}/test_cases") |
|
60 | - system("cp #{GRADER_DIR}/std-script/* #{problem}/script") |
|
60 | + #system("cp #{GRADER_DIR}/std-script/* #{problem}/script") |
|
61 |
|
61 | ||
|
62 | puts "copying testcases" |
|
62 | puts "copying testcases" |
|
63 |
|
63 |
You need to be logged in to leave comments.
Login now