Description:
does not record login time in analysis mode
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r317:df35763dc517 - - 1 file changed: 3 inserted, 1 deleted
@@ -169,210 +169,212 | |||||
|
169 | render :nothing => true |
|
169 | render :nothing => true |
|
170 | else |
|
170 | else |
|
171 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
171 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
172 | end |
|
172 | end |
|
173 | end |
|
173 | end |
|
174 |
|
174 | ||
|
175 | def error |
|
175 | def error |
|
176 | @user = User.find(session[:user_id]) |
|
176 | @user = User.find(session[:user_id]) |
|
177 | end |
|
177 | end |
|
178 |
|
178 | ||
|
179 | # announcement refreshing and hiding methods |
|
179 | # announcement refreshing and hiding methods |
|
180 |
|
180 | ||
|
181 | def announcements |
|
181 | def announcements |
|
182 | if params.has_key? 'recent' |
|
182 | if params.has_key? 'recent' |
|
183 | prepare_announcements(params[:recent]) |
|
183 | prepare_announcements(params[:recent]) |
|
184 | else |
|
184 | else |
|
185 | prepare_announcements |
|
185 | prepare_announcements |
|
186 | end |
|
186 | end |
|
187 | render(:partial => 'announcement', |
|
187 | render(:partial => 'announcement', |
|
188 | :collection => @announcements, |
|
188 | :collection => @announcements, |
|
189 | :locals => {:announcement_effect => true}) |
|
189 | :locals => {:announcement_effect => true}) |
|
190 | end |
|
190 | end |
|
191 |
|
191 | ||
|
192 | def confirm_contest_start |
|
192 | def confirm_contest_start |
|
193 | user = User.find(session[:user_id]) |
|
193 | user = User.find(session[:user_id]) |
|
194 | if request.method == :post |
|
194 | if request.method == :post |
|
195 | user.update_start_time |
|
195 | user.update_start_time |
|
196 | redirect_to :action => 'list' |
|
196 | redirect_to :action => 'list' |
|
197 | else |
|
197 | else |
|
198 | @contests = user.contests |
|
198 | @contests = user.contests |
|
199 | @user = user |
|
199 | @user = user |
|
200 | end |
|
200 | end |
|
201 | end |
|
201 | end |
|
202 |
|
202 | ||
|
203 | protected |
|
203 | protected |
|
204 |
|
204 | ||
|
205 | def prepare_announcements(recent=nil) |
|
205 | def prepare_announcements(recent=nil) |
|
206 | if Configuration.show_tasks_to?(@user) |
|
206 | if Configuration.show_tasks_to?(@user) |
|
207 | @announcements = Announcement.find_published(true) |
|
207 | @announcements = Announcement.find_published(true) |
|
208 | else |
|
208 | else |
|
209 | @announcements = Announcement.find_published |
|
209 | @announcements = Announcement.find_published |
|
210 | end |
|
210 | end |
|
211 | if recent!=nil |
|
211 | if recent!=nil |
|
212 | recent_id = recent.to_i |
|
212 | recent_id = recent.to_i |
|
213 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
213 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
214 | end |
|
214 | end |
|
215 | end |
|
215 | end |
|
216 |
|
216 | ||
|
217 | def prepare_list_information |
|
217 | def prepare_list_information |
|
218 | @user = User.find(session[:user_id]) |
|
218 | @user = User.find(session[:user_id]) |
|
219 | if not Configuration.multicontests? |
|
219 | if not Configuration.multicontests? |
|
220 | @problems = @user.available_problems |
|
220 | @problems = @user.available_problems |
|
221 | else |
|
221 | else |
|
222 | @contest_problems = @user.available_problems_group_by_contests |
|
222 | @contest_problems = @user.available_problems_group_by_contests |
|
223 | @problems = @user.available_problems |
|
223 | @problems = @user.available_problems |
|
224 | end |
|
224 | end |
|
225 | @prob_submissions = {} |
|
225 | @prob_submissions = {} |
|
226 | @problems.each do |p| |
|
226 | @problems.each do |p| |
|
227 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
227 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
228 | if sub!=nil |
|
228 | if sub!=nil |
|
229 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
229 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
230 | else |
|
230 | else |
|
231 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
231 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
232 | end |
|
232 | end |
|
233 | end |
|
233 | end |
|
234 | prepare_announcements |
|
234 | prepare_announcements |
|
235 | end |
|
235 | end |
|
236 |
|
236 | ||
|
237 | def check_viewability |
|
237 | def check_viewability |
|
238 | @user = User.find(session[:user_id]) |
|
238 | @user = User.find(session[:user_id]) |
|
239 | if (!Configuration.show_tasks_to?(@user)) and |
|
239 | if (!Configuration.show_tasks_to?(@user)) and |
|
240 | ((action_name=='submission') or (action_name=='submit')) |
|
240 | ((action_name=='submission') or (action_name=='submit')) |
|
241 | redirect_to :action => 'list' and return |
|
241 | redirect_to :action => 'list' and return |
|
242 | end |
|
242 | end |
|
243 | end |
|
243 | end |
|
244 |
|
244 | ||
|
245 | def prepare_grading_result(submission) |
|
245 | def prepare_grading_result(submission) |
|
246 | if Configuration.task_grading_info.has_key? submission.problem.name |
|
246 | if Configuration.task_grading_info.has_key? submission.problem.name |
|
247 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
247 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
248 | else |
|
248 | else |
|
249 | # guess task info from problem.full_score |
|
249 | # guess task info from problem.full_score |
|
250 | cases = submission.problem.full_score / 10 |
|
250 | cases = submission.problem.full_score / 10 |
|
251 | grading_info = { |
|
251 | grading_info = { |
|
252 | 'testruns' => cases, |
|
252 | 'testruns' => cases, |
|
253 | 'testcases' => cases |
|
253 | 'testcases' => cases |
|
254 | } |
|
254 | } |
|
255 | end |
|
255 | end |
|
256 | @test_runs = [] |
|
256 | @test_runs = [] |
|
257 | if grading_info['testruns'].is_a? Integer |
|
257 | if grading_info['testruns'].is_a? Integer |
|
258 | trun_count = grading_info['testruns'] |
|
258 | trun_count = grading_info['testruns'] |
|
259 | trun_count.times do |i| |
|
259 | trun_count.times do |i| |
|
260 | @test_runs << [ read_grading_result(@user.login, |
|
260 | @test_runs << [ read_grading_result(@user.login, |
|
261 | submission.problem.name, |
|
261 | submission.problem.name, |
|
262 | submission.id, |
|
262 | submission.id, |
|
263 | i+1) ] |
|
263 | i+1) ] |
|
264 | end |
|
264 | end |
|
265 | else |
|
265 | else |
|
266 | grading_info['testruns'].keys.sort.each do |num| |
|
266 | grading_info['testruns'].keys.sort.each do |num| |
|
267 | run = [] |
|
267 | run = [] |
|
268 | testrun = grading_info['testruns'][num] |
|
268 | testrun = grading_info['testruns'][num] |
|
269 | testrun.each do |c| |
|
269 | testrun.each do |c| |
|
270 | run << read_grading_result(@user.login, |
|
270 | run << read_grading_result(@user.login, |
|
271 | submission.problem.name, |
|
271 | submission.problem.name, |
|
272 | submission.id, |
|
272 | submission.id, |
|
273 | c) |
|
273 | c) |
|
274 | end |
|
274 | end |
|
275 | @test_runs << run |
|
275 | @test_runs << run |
|
276 | end |
|
276 | end |
|
277 | end |
|
277 | end |
|
278 | end |
|
278 | end |
|
279 |
|
279 | ||
|
280 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
280 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
281 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
281 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
282 | end |
|
282 | end |
|
283 |
|
283 | ||
|
284 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
284 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
285 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
285 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
286 | return "#{dir}/output.txt" |
|
286 | return "#{dir}/output.txt" |
|
287 | end |
|
287 | end |
|
288 |
|
288 | ||
|
289 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
289 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
290 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
290 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
291 | result_file_name = "#{dir}/result" |
|
291 | result_file_name = "#{dir}/result" |
|
292 | if !FileTest.exists?(result_file_name) |
|
292 | if !FileTest.exists?(result_file_name) |
|
293 | return {:num => case_num, :msg => 'program did not run'} |
|
293 | return {:num => case_num, :msg => 'program did not run'} |
|
294 | else |
|
294 | else |
|
295 | results = File.open(result_file_name).readlines |
|
295 | results = File.open(result_file_name).readlines |
|
296 | run_stat = extract_running_stat(results) |
|
296 | run_stat = extract_running_stat(results) |
|
297 | output_filename = "#{dir}/output.txt" |
|
297 | output_filename = "#{dir}/output.txt" |
|
298 | if FileTest.exists?(output_filename) |
|
298 | if FileTest.exists?(output_filename) |
|
299 | output_file = true |
|
299 | output_file = true |
|
300 | output_size = File.size(output_filename) |
|
300 | output_size = File.size(output_filename) |
|
301 | else |
|
301 | else |
|
302 | output_file = false |
|
302 | output_file = false |
|
303 | output_size = 0 |
|
303 | output_size = 0 |
|
304 | end |
|
304 | end |
|
305 |
|
305 | ||
|
306 | return { |
|
306 | return { |
|
307 | :num => case_num, |
|
307 | :num => case_num, |
|
308 | :msg => results[0], |
|
308 | :msg => results[0], |
|
309 | :run_stat => run_stat, |
|
309 | :run_stat => run_stat, |
|
310 | :output => output_file, |
|
310 | :output => output_file, |
|
311 | :output_size => output_size |
|
311 | :output_size => output_size |
|
312 | } |
|
312 | } |
|
313 | end |
|
313 | end |
|
314 | end |
|
314 | end |
|
315 |
|
315 | ||
|
316 | # copied from grader/script/lib/test_request_helper.rb |
|
316 | # copied from grader/script/lib/test_request_helper.rb |
|
317 | def extract_running_stat(results) |
|
317 | def extract_running_stat(results) |
|
318 | running_stat_line = results[-1] |
|
318 | running_stat_line = results[-1] |
|
319 |
|
319 | ||
|
320 | # extract exit status line |
|
320 | # extract exit status line |
|
321 | run_stat = "" |
|
321 | run_stat = "" |
|
322 | if !(/[Cc]orrect/.match(results[0])) |
|
322 | if !(/[Cc]orrect/.match(results[0])) |
|
323 | run_stat = results[0].chomp |
|
323 | run_stat = results[0].chomp |
|
324 | else |
|
324 | else |
|
325 | run_stat = 'Program exited normally' |
|
325 | run_stat = 'Program exited normally' |
|
326 | end |
|
326 | end |
|
327 |
|
327 | ||
|
328 | logger.info "Stat line: #{running_stat_line}" |
|
328 | logger.info "Stat line: #{running_stat_line}" |
|
329 |
|
329 | ||
|
330 | # extract running time |
|
330 | # extract running time |
|
331 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
331 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
332 | seconds = (res[1].to_f + res[2].to_f) |
|
332 | seconds = (res[1].to_f + res[2].to_f) |
|
333 | time_stat = "Time used: #{seconds} sec." |
|
333 | time_stat = "Time used: #{seconds} sec." |
|
334 | else |
|
334 | else |
|
335 | seconds = nil |
|
335 | seconds = nil |
|
336 | time_stat = "Time used: n/a sec." |
|
336 | time_stat = "Time used: n/a sec." |
|
337 | end |
|
337 | end |
|
338 |
|
338 | ||
|
339 | # extract memory usage |
|
339 | # extract memory usage |
|
340 | if res = /s(.*)m/.match(running_stat_line) |
|
340 | if res = /s(.*)m/.match(running_stat_line) |
|
341 | memory_used = res[1].to_i |
|
341 | memory_used = res[1].to_i |
|
342 | else |
|
342 | else |
|
343 | memory_used = -1 |
|
343 | memory_used = -1 |
|
344 | end |
|
344 | end |
|
345 |
|
345 | ||
|
346 | return { |
|
346 | return { |
|
347 | :msg => "#{run_stat}\n#{time_stat}", |
|
347 | :msg => "#{run_stat}\n#{time_stat}", |
|
348 | :running_time => seconds, |
|
348 | :running_time => seconds, |
|
349 | :exit_status => run_stat, |
|
349 | :exit_status => run_stat, |
|
350 | :memory_usage => memory_used |
|
350 | :memory_usage => memory_used |
|
351 | } |
|
351 | } |
|
352 | end |
|
352 | end |
|
353 |
|
353 | ||
|
354 | def confirm_and_update_start_time |
|
354 | def confirm_and_update_start_time |
|
355 | user = User.find(session[:user_id]) |
|
355 | user = User.find(session[:user_id]) |
|
356 | if (Configuration.indv_contest_mode? and |
|
356 | if (Configuration.indv_contest_mode? and |
|
357 | Configuration['contest.confirm_indv_contest_start'] and |
|
357 | Configuration['contest.confirm_indv_contest_start'] and |
|
358 | !user.contest_started?) |
|
358 | !user.contest_started?) |
|
359 | redirect_to :action => 'confirm_contest_start' and return |
|
359 | redirect_to :action => 'confirm_contest_start' and return |
|
360 | end |
|
360 | end |
|
361 | - user.update_start_time |
|
361 | + if not Configuration.analysis_mode? |
|
|
362 | + user.update_start_time | ||
|
|
363 | + end | ||
|
362 | end |
|
364 | end |
|
363 |
|
365 | ||
|
364 | def reject_announcement_refresh_when_logged_out |
|
366 | def reject_announcement_refresh_when_logged_out |
|
365 | if not session[:user_id] |
|
367 | if not session[:user_id] |
|
366 | render :text => 'Access forbidden', :status => 403 |
|
368 | render :text => 'Access forbidden', :status => 403 |
|
367 | end |
|
369 | end |
|
368 |
|
370 | ||
|
369 | if Configuration.multicontests? |
|
371 | if Configuration.multicontests? |
|
370 | user = User.find(session[:user_id]) |
|
372 | user = User.find(session[:user_id]) |
|
371 | if user.contest_stat.forced_logout |
|
373 | if user.contest_stat.forced_logout |
|
372 | render :text => 'Access forbidden', :status => 403 |
|
374 | render :text => 'Access forbidden', :status => 403 |
|
373 | end |
|
375 | end |
|
374 | end |
|
376 | end |
|
375 | end |
|
377 | end |
|
376 |
|
378 | ||
|
377 | end |
|
379 | end |
|
378 |
|
380 |
You need to be logged in to leave comments.
Login now