Description:
[grader] formatting output of test_request git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@140 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

r38:53204d348092 - - 1 file changed: 1 inserted, 1 deleted

@@ -128,49 +128,49
128 :comment => "",
128 :comment => "",
129 :cmp_msg => cmp_msg}
129 :cmp_msg => cmp_msg}
130 else
130 else
131 return {
131 return {
132 :running_stat => "",
132 :running_stat => "",
133 :comment => "Compilation error",
133 :comment => "Compilation error",
134 :cmp_msg => cmp_msg}
134 :cmp_msg => cmp_msg}
135 end
135 end
136 end
136 end
137
137
138 def format_running_stat(results)
138 def format_running_stat(results)
139 running_time_line = results[-1]
139 running_time_line = results[-1]
140
140
141 run_stat = ""
141 run_stat = ""
142 if !(/[Cc]orrect/.match(results[0]))
142 if !(/[Cc]orrect/.match(results[0]))
143 run_stat = results[0].chomp
143 run_stat = results[0].chomp
144 end
144 end
145
145
146 if res = /r(.*)u(.*)s/.match(running_time_line)
146 if res = /r(.*)u(.*)s/.match(running_time_line)
147 seconds = (res[1].to_f + res[2].to_f)
147 seconds = (res[1].to_f + res[2].to_f)
148 time_stat = "Time used: #{seconds} sec."
148 time_stat = "Time used: #{seconds} sec."
149 else
149 else
150 time_stat = "Time used: n/a sec."
150 time_stat = "Time used: n/a sec."
151 end
151 end
152 - return "#{run_stat}#{time_stat}"
152 + return "#{run_stat}\n#{time_stat}"
153 end
153 end
154
154
155 def save_result(test_request,result)
155 def save_result(test_request,result)
156 if result[:output_file_name]!=nil
156 if result[:output_file_name]!=nil
157 test_request.output_file_name = link_output_file(test_request,
157 test_request.output_file_name = link_output_file(test_request,
158 result[:output_file_name])
158 result[:output_file_name])
159 end
159 end
160 test_request.graded_at = Time.now
160 test_request.graded_at = Time.now
161 test_request.compiler_message = (result[:cmp_msg] or '')
161 test_request.compiler_message = (result[:cmp_msg] or '')
162 test_request.grader_comment = (result[:comment] or '')
162 test_request.grader_comment = (result[:comment] or '')
163 test_request.running_stat = (result[:running_stat] or '')
163 test_request.running_stat = (result[:running_stat] or '')
164 test_request.save
164 test_request.save
165 end
165 end
166
166
167 protected
167 protected
168 def link_output_file(test_request, fname)
168 def link_output_file(test_request, fname)
169 target_file_name = random_output_file_name(test_request.user,
169 target_file_name = random_output_file_name(test_request.user,
170 test_request.problem)
170 test_request.problem)
171 FileUtils.mkdir_p(File.dirname(target_file_name))
171 FileUtils.mkdir_p(File.dirname(target_file_name))
172 cmd = "ln -s #{fname} #{target_file_name}"
172 cmd = "ln -s #{fname} #{target_file_name}"
173 if !system(cmd)
173 if !system(cmd)
174 raise "TestRequestReporter: cannot move output file"
174 raise "TestRequestReporter: cannot move output file"
175 end
175 end
176 return target_file_name
176 return target_file_name
You need to be logged in to leave comments. Login now