Description:
fixed timing stat bug when used with single user mode
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r245:4658efe40e96 - - 2 files changed: 7 inserted, 1 deleted

@@ -1,40 +1,39
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 def index
3 def index
4 # show login screen
4 # show login screen
5 reset_session
5 reset_session
6 redirect_to :controller => 'main', :action => 'login'
6 redirect_to :controller => 'main', :action => 'login'
7 end
7 end
8
8
9 def login
9 def login
10 if user = User.authenticate(params[:login], params[:password])
10 if user = User.authenticate(params[:login], params[:password])
11 session[:user_id] = user.id
11 session[:user_id] = user.id
12 session[:admin] = user.admin?
12 session[:admin] = user.admin?
13 - UserContestStat.update_user_start_time(user)
14 redirect_to :controller => 'main', :action => 'list'
13 redirect_to :controller => 'main', :action => 'list'
15 else
14 else
16 flash[:notice] = 'Wrong password'
15 flash[:notice] = 'Wrong password'
17 redirect_to :controller => 'main', :action => 'login'
16 redirect_to :controller => 'main', :action => 'login'
18 end
17 end
19 end
18 end
20
19
21 def site_login
20 def site_login
22 begin
21 begin
23 site = Site.find(params[:login][:site_id])
22 site = Site.find(params[:login][:site_id])
24 rescue ActiveRecord::RecordNotFound
23 rescue ActiveRecord::RecordNotFound
25 site = nil
24 site = nil
26 end
25 end
27 if site==nil
26 if site==nil
28 flash[:notice] = 'Wrong site'
27 flash[:notice] = 'Wrong site'
29 redirect_to :controller => 'main', :action => 'login' and return
28 redirect_to :controller => 'main', :action => 'login' and return
30 end
29 end
31 if (site.password) and (site.password == params[:login][:password])
30 if (site.password) and (site.password == params[:login][:password])
32 session[:site_id] = site.id
31 session[:site_id] = site.id
33 redirect_to :controller => 'site', :action => 'index'
32 redirect_to :controller => 'site', :action => 'index'
34 else
33 else
35 flash[:notice] = 'Wrong site password'
34 flash[:notice] = 'Wrong site password'
36 redirect_to :controller => 'site', :action => 'login'
35 redirect_to :controller => 'site', :action => 'login'
37 end
36 end
38 end
37 end
39
38
40 end
39 end
@@ -1,197 +1,199
1 class MainController < ApplicationController
1 class MainController < ApplicationController
2
2
3 before_filter :authenticate, :except => [:index, :login]
3 before_filter :authenticate, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
5
5
6 + append_before_filter :update_user_start_time, :except => [:index, :login]
7 +
6 # COMMENTED OUT: filter in each action instead
8 # COMMENTED OUT: filter in each action instead
7 # before_filter :verify_time_limit, :only => [:submit]
9 # before_filter :verify_time_limit, :only => [:submit]
8
10
9 verify :method => :post, :only => [:submit, :download_input, :submit_solution],
11 verify :method => :post, :only => [:submit, :download_input, :submit_solution],
10 :redirect_to => { :action => :index }
12 :redirect_to => { :action => :index }
11
13
12 # COMMENT OUT: only need when having high load
14 # COMMENT OUT: only need when having high load
13 # caches_action :index, :login
15 # caches_action :index, :login
14
16
15 # NOTE: This method is not actually needed, 'config/routes.rb' has
17 # NOTE: This method is not actually needed, 'config/routes.rb' has
16 # assigned action login as a default action.
18 # assigned action login as a default action.
17 def index
19 def index
18 redirect_to :action => 'login'
20 redirect_to :action => 'login'
19 end
21 end
20
22
21 def login
23 def login
22 saved_notice = flash[:notice]
24 saved_notice = flash[:notice]
23 reset_session
25 reset_session
24 flash.now[:notice] = saved_notice
26 flash.now[:notice] = saved_notice
25
27
26 # EXPERIMENT:
28 # EXPERIMENT:
27 # Hide login if in single user mode and the url does not
29 # Hide login if in single user mode and the url does not
28 # explicitly specify /login
30 # explicitly specify /login
29 #
31 #
30 # logger.info "PATH: #{request.path}"
32 # logger.info "PATH: #{request.path}"
31 # if Configuration['system.single_user_mode'] and
33 # if Configuration['system.single_user_mode'] and
32 # request.path!='/main/login'
34 # request.path!='/main/login'
33 # @hidelogin = true
35 # @hidelogin = true
34 # end
36 # end
35
37
36 @announcements = Announcement.find_for_frontpage
38 @announcements = Announcement.find_for_frontpage
37 render :action => 'login', :layout => 'empty'
39 render :action => 'login', :layout => 'empty'
38 end
40 end
39
41
40 def list
42 def list
41 prepare_list_information
43 prepare_list_information
42 end
44 end
43
45
44 def help
46 def help
45 @user = User.find(session[:user_id])
47 @user = User.find(session[:user_id])
46 end
48 end
47
49
48 def submit
50 def submit
49 user = User.find(session[:user_id])
51 user = User.find(session[:user_id])
50
52
51 @submission = Submission.new(params[:submission])
53 @submission = Submission.new(params[:submission])
52 @submission.user = user
54 @submission.user = user
53 @submission.language_id = 0
55 @submission.language_id = 0
54 if (params['file']) and (params['file']!='')
56 if (params['file']) and (params['file']!='')
55 @submission.source = params['file'].read
57 @submission.source = params['file'].read
56 @submission.source_filename = params['file'].original_filename
58 @submission.source_filename = params['file'].original_filename
57 end
59 end
58 @submission.submitted_at = Time.new.gmtime
60 @submission.submitted_at = Time.new.gmtime
59
61
60 if Configuration.time_limit_mode? and user.contest_finished?
62 if Configuration.time_limit_mode? and user.contest_finished?
61 @submission.errors.add_to_base "The contest is over."
63 @submission.errors.add_to_base "The contest is over."
62 prepare_list_information
64 prepare_list_information
63 render :action => 'list' and return
65 render :action => 'list' and return
64 end
66 end
65
67
66 if @submission.valid?
68 if @submission.valid?
67 if @submission.save == false
69 if @submission.save == false
68 flash[:notice] = 'Error saving your submission'
70 flash[:notice] = 'Error saving your submission'
69 elsif Task.create(:submission_id => @submission.id,
71 elsif Task.create(:submission_id => @submission.id,
70 :status => Task::STATUS_INQUEUE) == false
72 :status => Task::STATUS_INQUEUE) == false
71 flash[:notice] = 'Error adding your submission to task queue'
73 flash[:notice] = 'Error adding your submission to task queue'
72 end
74 end
73 else
75 else
74 prepare_list_information
76 prepare_list_information
75 render :action => 'list' and return
77 render :action => 'list' and return
76 end
78 end
77 redirect_to :action => 'list'
79 redirect_to :action => 'list'
78 end
80 end
79
81
80 def source
82 def source
81 submission = Submission.find(params[:id])
83 submission = Submission.find(params[:id])
82 if submission.user_id == session[:user_id]
84 if submission.user_id == session[:user_id]
83 send_data(submission.source,
85 send_data(submission.source,
84 {:filename => submission.download_filename,
86 {:filename => submission.download_filename,
85 :type => 'text/plain'})
87 :type => 'text/plain'})
86 else
88 else
87 flash[:notice] = 'Error viewing source'
89 flash[:notice] = 'Error viewing source'
88 redirect_to :action => 'list'
90 redirect_to :action => 'list'
89 end
91 end
90 end
92 end
91
93
92 def compiler_msg
94 def compiler_msg
93 @submission = Submission.find(params[:id])
95 @submission = Submission.find(params[:id])
94 if @submission.user_id == session[:user_id]
96 if @submission.user_id == session[:user_id]
95 render :action => 'compiler_msg', :layout => 'empty'
97 render :action => 'compiler_msg', :layout => 'empty'
96 else
98 else
97 flash[:notice] = 'Error viewing source'
99 flash[:notice] = 'Error viewing source'
98 redirect_to :action => 'list'
100 redirect_to :action => 'list'
99 end
101 end
100 end
102 end
101
103
102 def submission
104 def submission
103 # protect the action for Code Jom
105 # protect the action for Code Jom
104 redirect_to :action => 'list'
106 redirect_to :action => 'list'
105
107
106 @user = User.find(session[:user_id])
108 @user = User.find(session[:user_id])
107 @problems = Problem.find_available_problems
109 @problems = Problem.find_available_problems
108 if params[:id]==nil
110 if params[:id]==nil
109 @problem = nil
111 @problem = nil
110 @submissions = nil
112 @submissions = nil
111 else
113 else
112 @problem = Problem.find_by_name(params[:id])
114 @problem = Problem.find_by_name(params[:id])
113 if not @problem.available
115 if not @problem.available
114 redirect_to :action => 'list'
116 redirect_to :action => 'list'
115 flash[:notice] = 'Error: submissions for that problem are not viewable.'
117 flash[:notice] = 'Error: submissions for that problem are not viewable.'
116 return
118 return
117 end
119 end
118 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
120 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
119 end
121 end
120 end
122 end
121
123
122 def result
124 def result
123 if !Configuration.show_grading_result
125 if !Configuration.show_grading_result
124 redirect_to :action => 'list' and return
126 redirect_to :action => 'list' and return
125 end
127 end
126 @user = User.find(session[:user_id])
128 @user = User.find(session[:user_id])
127 @submission = Submission.find(params[:id])
129 @submission = Submission.find(params[:id])
128 if @submission.user!=@user
130 if @submission.user!=@user
129 flash[:notice] = 'You are not allowed to view result of other users.'
131 flash[:notice] = 'You are not allowed to view result of other users.'
130 redirect_to :action => 'list' and return
132 redirect_to :action => 'list' and return
131 end
133 end
132 prepare_grading_result(@submission)
134 prepare_grading_result(@submission)
133 end
135 end
134
136
135 def load_output
137 def load_output
136 if !Configuration.show_grading_result or params[:num]==nil
138 if !Configuration.show_grading_result or params[:num]==nil
137 redirect_to :action => 'list' and return
139 redirect_to :action => 'list' and return
138 end
140 end
139 @user = User.find(session[:user_id])
141 @user = User.find(session[:user_id])
140 @submission = Submission.find(params[:id])
142 @submission = Submission.find(params[:id])
141 if @submission.user!=@user
143 if @submission.user!=@user
142 flash[:notice] = 'You are not allowed to view result of other users.'
144 flash[:notice] = 'You are not allowed to view result of other users.'
143 redirect_to :action => 'list' and return
145 redirect_to :action => 'list' and return
144 end
146 end
145 case_num = params[:num].to_i
147 case_num = params[:num].to_i
146 out_filename = output_filename(@user.login,
148 out_filename = output_filename(@user.login,
147 @submission.problem.name,
149 @submission.problem.name,
148 @submission.id,
150 @submission.id,
149 case_num)
151 case_num)
150 if !FileTest.exists?(out_filename)
152 if !FileTest.exists?(out_filename)
151 flash[:notice] = 'Output not found.'
153 flash[:notice] = 'Output not found.'
152 redirect_to :action => 'list' and return
154 redirect_to :action => 'list' and return
153 end
155 end
154
156
155 response.headers['Content-Type'] = "application/force-download"
157 response.headers['Content-Type'] = "application/force-download"
156 response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\""
158 response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\""
157 response.headers["X-Sendfile"] = out_filename
159 response.headers["X-Sendfile"] = out_filename
158 response.headers['Content-length'] = File.size(out_filename)
160 response.headers['Content-length'] = File.size(out_filename)
159 render :nothing => true
161 render :nothing => true
160 end
162 end
161
163
162 def error
164 def error
163 @user = User.find(session[:user_id])
165 @user = User.find(session[:user_id])
164 end
166 end
165
167
166 # announcement refreshing and hiding methods
168 # announcement refreshing and hiding methods
167
169
168 def announcements
170 def announcements
169 if params.has_key? 'recent'
171 if params.has_key? 'recent'
170 prepare_announcements(params[:recent])
172 prepare_announcements(params[:recent])
171 else
173 else
172 prepare_announcements
174 prepare_announcements
173 end
175 end
174 render(:partial => 'announcement',
176 render(:partial => 'announcement',
175 :collection => @announcements,
177 :collection => @announcements,
176 :locals => {:announcement_effect => true})
178 :locals => {:announcement_effect => true})
177 end
179 end
178
180
179 #
181 #
180 # actions for Code Jom
182 # actions for Code Jom
181 #
183 #
182 def download_input
184 def download_input
183 user = User.find(session[:user_id])
185 user = User.find(session[:user_id])
184
186
185 if Configuration.time_limit_mode? and user.contest_finished?
187 if Configuration.time_limit_mode? and user.contest_finished?
186 redirect_to :action => 'list' and return
188 redirect_to :action => 'list' and return
187 end
189 end
188
190
189 problem = Problem.find(params[:id])
191 problem = Problem.find(params[:id])
190 if user.can_request_new_test_pair_for? problem
192 if user.can_request_new_test_pair_for? problem
191 assignment = user.get_new_test_pair_assignment_for problem
193 assignment = user.get_new_test_pair_assignment_for problem
192 assignment.save
194 assignment.save
193
195
194 send_data(assignment.test_pair.input,
196 send_data(assignment.test_pair.input,
195 { :filename => "#{problem.name}-#{assignment.request_number}.in",
197 { :filename => "#{problem.name}-#{assignment.request_number}.in",
196 :type => 'text/plain' })
198 :type => 'text/plain' })
197 else
199 else
@@ -266,194 +268,199
266 else
268 else
267 session[:current_problem_id] = problem.id
269 session[:current_problem_id] = problem.id
268 flash[:notice] = 'Incorrect solution.'
270 flash[:notice] = 'Incorrect solution.'
269 end
271 end
270 redirect_to :action => 'list'
272 redirect_to :action => 'list'
271 end
273 end
272
274
273 protected
275 protected
274
276
275 def prepare_announcements(recent=nil)
277 def prepare_announcements(recent=nil)
276 if Configuration.show_tasks_to?(@user)
278 if Configuration.show_tasks_to?(@user)
277 @announcements = Announcement.find_published(true)
279 @announcements = Announcement.find_published(true)
278 else
280 else
279 @announcements = Announcement.find_published
281 @announcements = Announcement.find_published
280 end
282 end
281 if recent!=nil
283 if recent!=nil
282 recent_id = recent.to_i
284 recent_id = recent.to_i
283 @announcements = @announcements.find_all { |a| a.id > recent_id }
285 @announcements = @announcements.find_all { |a| a.id > recent_id }
284 end
286 end
285 end
287 end
286
288
287 def prepare_timeout_information(problems)
289 def prepare_timeout_information(problems)
288 @submission_timeouts = {}
290 @submission_timeouts = {}
289 problems.each do |problem|
291 problems.each do |problem|
290 assignment = @user.get_recent_test_pair_assignment_for(problem)
292 assignment = @user.get_recent_test_pair_assignment_for(problem)
291 if assignment == nil
293 if assignment == nil
292 timeout = nil
294 timeout = nil
293 else
295 else
294 if (assignment.expired?) or (assignment.submitted)
296 if (assignment.expired?) or (assignment.submitted)
295 timeout = 0
297 timeout = 0
296 else
298 else
297 timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
299 timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
298 end
300 end
299 end
301 end
300 @submission_timeouts[problem.id] = timeout
302 @submission_timeouts[problem.id] = timeout
301 end
303 end
302 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
304 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
303 end
305 end
304
306
305 def prepare_list_information
307 def prepare_list_information
306 @user = User.find(session[:user_id])
308 @user = User.find(session[:user_id])
307
309
308 all_problems = Problem.find_available_problems
310 all_problems = Problem.find_available_problems
309
311
310 passed = {}
312 passed = {}
311 sub_count = {}
313 sub_count = {}
312 @user.submission_statuses.each do |status|
314 @user.submission_statuses.each do |status|
313 if status.passed
315 if status.passed
314 passed[status.problem_id] = true
316 passed[status.problem_id] = true
315 end
317 end
316 sub_count[status.problem_id] = status.submission_count
318 sub_count[status.problem_id] = status.submission_count
317 end
319 end
318
320
319 if session.has_key? :current_problem_id
321 if session.has_key? :current_problem_id
320 @current_problem_id = session[:current_problem_id]
322 @current_problem_id = session[:current_problem_id]
321 session.delete(:current_problem_id)
323 session.delete(:current_problem_id)
322 else
324 else
323 @current_problem_id = nil
325 @current_problem_id = nil
324 end
326 end
325
327
326 @problems = all_problems.reject { |problem| passed.has_key? problem.id }
328 @problems = all_problems.reject { |problem| passed.has_key? problem.id }
327
329
328 prepare_timeout_information(@problems)
330 prepare_timeout_information(@problems)
329
331
330 @prob_submissions = Array.new
332 @prob_submissions = Array.new
331 @problems.each do |p|
333 @problems.each do |p|
332 if sub_count.has_key? p.id
334 if sub_count.has_key? p.id
333 @prob_submissions << { :count => sub_count[p.id] }
335 @prob_submissions << { :count => sub_count[p.id] }
334 else
336 else
335 @prob_submissions << { :count => 0 }
337 @prob_submissions << { :count => 0 }
336 end
338 end
337 end
339 end
338 prepare_announcements
340 prepare_announcements
339 end
341 end
340
342
341 def check_viewability
343 def check_viewability
342 @user = User.find(session[:user_id])
344 @user = User.find(session[:user_id])
343 if (!Configuration.show_tasks_to?(@user)) and
345 if (!Configuration.show_tasks_to?(@user)) and
344 ((action_name=='submission') or (action_name=='submit'))
346 ((action_name=='submission') or (action_name=='submit'))
345 redirect_to :action => 'list' and return
347 redirect_to :action => 'list' and return
346 end
348 end
347 end
349 end
348
350
349 def prepare_grading_result(submission)
351 def prepare_grading_result(submission)
350 if Configuration.task_grading_info.has_key? submission.problem.name
352 if Configuration.task_grading_info.has_key? submission.problem.name
351 grading_info = Configuration.task_grading_info[submission.problem.name]
353 grading_info = Configuration.task_grading_info[submission.problem.name]
352 else
354 else
353 # guess task info from problem.full_score
355 # guess task info from problem.full_score
354 cases = submission.problem.full_score / 10
356 cases = submission.problem.full_score / 10
355 grading_info = {
357 grading_info = {
356 'testruns' => cases,
358 'testruns' => cases,
357 'testcases' => cases
359 'testcases' => cases
358 }
360 }
359 end
361 end
360 @test_runs = []
362 @test_runs = []
361 if grading_info['testruns'].is_a? Integer
363 if grading_info['testruns'].is_a? Integer
362 trun_count = grading_info['testruns']
364 trun_count = grading_info['testruns']
363 trun_count.times do |i|
365 trun_count.times do |i|
364 @test_runs << [ read_grading_result(@user.login,
366 @test_runs << [ read_grading_result(@user.login,
365 submission.problem.name,
367 submission.problem.name,
366 submission.id,
368 submission.id,
367 i+1) ]
369 i+1) ]
368 end
370 end
369 else
371 else
370 grading_info['testruns'].keys.sort.each do |num|
372 grading_info['testruns'].keys.sort.each do |num|
371 run = []
373 run = []
372 testrun = grading_info['testruns'][num]
374 testrun = grading_info['testruns'][num]
373 testrun.each do |c|
375 testrun.each do |c|
374 run << read_grading_result(@user.login,
376 run << read_grading_result(@user.login,
375 submission.problem.name,
377 submission.problem.name,
376 submission.id,
378 submission.id,
377 c)
379 c)
378 end
380 end
379 @test_runs << run
381 @test_runs << run
380 end
382 end
381 end
383 end
382 end
384 end
383
385
384 def grading_result_dir(user_name, problem_name, submission_id, case_num)
386 def grading_result_dir(user_name, problem_name, submission_id, case_num)
385 return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}"
387 return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}"
386 end
388 end
387
389
388 def output_filename(user_name, problem_name, submission_id, case_num)
390 def output_filename(user_name, problem_name, submission_id, case_num)
389 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
391 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
390 return "#{dir}/output.txt"
392 return "#{dir}/output.txt"
391 end
393 end
392
394
393 def read_grading_result(user_name, problem_name, submission_id, case_num)
395 def read_grading_result(user_name, problem_name, submission_id, case_num)
394 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
396 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
395 result_file_name = "#{dir}/result"
397 result_file_name = "#{dir}/result"
396 if !FileTest.exists?(result_file_name)
398 if !FileTest.exists?(result_file_name)
397 return {:num => case_num, :msg => 'program did not run'}
399 return {:num => case_num, :msg => 'program did not run'}
398 else
400 else
399 results = File.open(result_file_name).readlines
401 results = File.open(result_file_name).readlines
400 run_stat = extract_running_stat(results)
402 run_stat = extract_running_stat(results)
401 output_filename = "#{dir}/output.txt"
403 output_filename = "#{dir}/output.txt"
402 if FileTest.exists?(output_filename)
404 if FileTest.exists?(output_filename)
403 output_file = true
405 output_file = true
404 output_size = File.size(output_filename)
406 output_size = File.size(output_filename)
405 else
407 else
406 output_file = false
408 output_file = false
407 output_size = 0
409 output_size = 0
408 end
410 end
409
411
410 return {
412 return {
411 :num => case_num,
413 :num => case_num,
412 :msg => results[0],
414 :msg => results[0],
413 :run_stat => run_stat,
415 :run_stat => run_stat,
414 :output => output_file,
416 :output => output_file,
415 :output_size => output_size
417 :output_size => output_size
416 }
418 }
417 end
419 end
418 end
420 end
419
421
420 # copied from grader/script/lib/test_request_helper.rb
422 # copied from grader/script/lib/test_request_helper.rb
421 def extract_running_stat(results)
423 def extract_running_stat(results)
422 running_stat_line = results[-1]
424 running_stat_line = results[-1]
423
425
424 # extract exit status line
426 # extract exit status line
425 run_stat = ""
427 run_stat = ""
426 if !(/[Cc]orrect/.match(results[0]))
428 if !(/[Cc]orrect/.match(results[0]))
427 run_stat = results[0].chomp
429 run_stat = results[0].chomp
428 else
430 else
429 run_stat = 'Program exited normally'
431 run_stat = 'Program exited normally'
430 end
432 end
431
433
432 logger.info "Stat line: #{running_stat_line}"
434 logger.info "Stat line: #{running_stat_line}"
433
435
434 # extract running time
436 # extract running time
435 if res = /r(.*)u(.*)s/.match(running_stat_line)
437 if res = /r(.*)u(.*)s/.match(running_stat_line)
436 seconds = (res[1].to_f + res[2].to_f)
438 seconds = (res[1].to_f + res[2].to_f)
437 time_stat = "Time used: #{seconds} sec."
439 time_stat = "Time used: #{seconds} sec."
438 else
440 else
439 seconds = nil
441 seconds = nil
440 time_stat = "Time used: n/a sec."
442 time_stat = "Time used: n/a sec."
441 end
443 end
442
444
443 # extract memory usage
445 # extract memory usage
444 if res = /s(.*)m/.match(running_stat_line)
446 if res = /s(.*)m/.match(running_stat_line)
445 memory_used = res[1].to_i
447 memory_used = res[1].to_i
446 else
448 else
447 memory_used = -1
449 memory_used = -1
448 end
450 end
449
451
450 return {
452 return {
451 :msg => "#{run_stat}\n#{time_stat}",
453 :msg => "#{run_stat}\n#{time_stat}",
452 :running_time => seconds,
454 :running_time => seconds,
453 :exit_status => run_stat,
455 :exit_status => run_stat,
454 :memory_usage => memory_used
456 :memory_usage => memory_used
455 }
457 }
456 end
458 end
457
459
460 + def update_user_start_time
461 + user = User.find(session[:user_id])
462 + UserContestStat.update_user_start_time(user)
463 + end
464 +
458 end
465 end
459
466
You need to be logged in to leave comments. Login now