Description:
Fixed Individual Contest confirmation
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r371:6d2e9920049d - - 2 files changed: 2 inserted, 2 deleted
@@ -3,379 +3,379 | |||||
|
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 :confirm_and_update_start_time, |
|
6 | append_before_filter :confirm_and_update_start_time, |
|
7 | :except => [:index, |
|
7 | :except => [:index, |
|
8 | :login, |
|
8 | :login, |
|
9 | :confirm_contest_start] |
|
9 | :confirm_contest_start] |
|
10 |
|
10 | ||
|
11 | # to prevent log in box to be shown when user logged out of the |
|
11 | # to prevent log in box to be shown when user logged out of the |
|
12 | # system only in some tab |
|
12 | # system only in some tab |
|
13 | prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
13 | prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
14 | :only => [:announcements] |
|
14 | :only => [:announcements] |
|
15 |
|
15 | ||
|
16 | # COMMENTED OUT: filter in each action instead |
|
16 | # COMMENTED OUT: filter in each action instead |
|
17 | # before_filter :verify_time_limit, :only => [:submit] |
|
17 | # before_filter :verify_time_limit, :only => [:submit] |
|
18 |
|
18 | ||
|
19 | verify :method => :post, :only => [:submit], |
|
19 | verify :method => :post, :only => [:submit], |
|
20 | :redirect_to => { :action => :index } |
|
20 | :redirect_to => { :action => :index } |
|
21 |
|
21 | ||
|
22 | # COMMENT OUT: only need when having high load |
|
22 | # COMMENT OUT: only need when having high load |
|
23 | # caches_action :index, :login |
|
23 | # caches_action :index, :login |
|
24 |
|
24 | ||
|
25 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
25 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
26 | # assigned action login as a default action. |
|
26 | # assigned action login as a default action. |
|
27 | def index |
|
27 | def index |
|
28 | redirect_to :action => 'login' |
|
28 | redirect_to :action => 'login' |
|
29 | end |
|
29 | end |
|
30 |
|
30 | ||
|
31 | def login |
|
31 | def login |
|
32 | saved_notice = flash[:notice] |
|
32 | saved_notice = flash[:notice] |
|
33 | reset_session |
|
33 | reset_session |
|
34 | flash.now[:notice] = saved_notice |
|
34 | flash.now[:notice] = saved_notice |
|
35 |
|
35 | ||
|
36 | # EXPERIMENT: |
|
36 | # EXPERIMENT: |
|
37 | # Hide login if in single user mode and the url does not |
|
37 | # Hide login if in single user mode and the url does not |
|
38 | # explicitly specify /login |
|
38 | # explicitly specify /login |
|
39 | # |
|
39 | # |
|
40 | # logger.info "PATH: #{request.path}" |
|
40 | # logger.info "PATH: #{request.path}" |
|
41 | # if GraderConfiguration['system.single_user_mode'] and |
|
41 | # if GraderConfiguration['system.single_user_mode'] and |
|
42 | # request.path!='/main/login' |
|
42 | # request.path!='/main/login' |
|
43 | # @hidelogin = true |
|
43 | # @hidelogin = true |
|
44 | # end |
|
44 | # end |
|
45 |
|
45 | ||
|
46 | @announcements = Announcement.find_for_frontpage |
|
46 | @announcements = Announcement.find_for_frontpage |
|
47 | render :action => 'login', :layout => 'empty' |
|
47 | render :action => 'login', :layout => 'empty' |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | def list |
|
50 | def list |
|
51 | prepare_list_information |
|
51 | prepare_list_information |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
|
54 | def help |
|
54 | def help |
|
55 | @user = User.find(session[:user_id]) |
|
55 | @user = User.find(session[:user_id]) |
|
56 | end |
|
56 | end |
|
57 |
|
57 | ||
|
58 | def submit |
|
58 | def submit |
|
59 | user = User.find(session[:user_id]) |
|
59 | user = User.find(session[:user_id]) |
|
60 |
|
60 | ||
|
61 | @submission = Submission.new |
|
61 | @submission = Submission.new |
|
62 | @submission.problem_id = params[:submission][:problem_id] |
|
62 | @submission.problem_id = params[:submission][:problem_id] |
|
63 | @submission.user = user |
|
63 | @submission.user = user |
|
64 | @submission.language_id = 0 |
|
64 | @submission.language_id = 0 |
|
65 | if (params['file']) and (params['file']!='') |
|
65 | if (params['file']) and (params['file']!='') |
|
66 | @submission.source = params['file'].read |
|
66 | @submission.source = params['file'].read |
|
67 | @submission.source_filename = params['file'].original_filename |
|
67 | @submission.source_filename = params['file'].original_filename |
|
68 | end |
|
68 | end |
|
69 | @submission.submitted_at = Time.new.gmtime |
|
69 | @submission.submitted_at = Time.new.gmtime |
|
70 |
|
70 | ||
|
71 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
71 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
72 | @submission.errors.add(:base,"The contest is over.") |
|
72 | @submission.errors.add(:base,"The contest is over.") |
|
73 | prepare_list_information |
|
73 | prepare_list_information |
|
74 | render :action => 'list' and return |
|
74 | render :action => 'list' and return |
|
75 | end |
|
75 | end |
|
76 |
|
76 | ||
|
77 | if @submission.valid? |
|
77 | if @submission.valid? |
|
78 | if @submission.save == false |
|
78 | if @submission.save == false |
|
79 | flash[:notice] = 'Error saving your submission' |
|
79 | flash[:notice] = 'Error saving your submission' |
|
80 | elsif Task.create(:submission_id => @submission.id, |
|
80 | elsif Task.create(:submission_id => @submission.id, |
|
81 | :status => Task::STATUS_INQUEUE) == false |
|
81 | :status => Task::STATUS_INQUEUE) == false |
|
82 | flash[:notice] = 'Error adding your submission to task queue' |
|
82 | flash[:notice] = 'Error adding your submission to task queue' |
|
83 | end |
|
83 | end |
|
84 | else |
|
84 | else |
|
85 | prepare_list_information |
|
85 | prepare_list_information |
|
86 | render :action => 'list' and return |
|
86 | render :action => 'list' and return |
|
87 | end |
|
87 | end |
|
88 | redirect_to :action => 'list' |
|
88 | redirect_to :action => 'list' |
|
89 | end |
|
89 | end |
|
90 |
|
90 | ||
|
91 | def source |
|
91 | def source |
|
92 | submission = Submission.find(params[:id]) |
|
92 | submission = Submission.find(params[:id]) |
|
93 | if ((submission.user_id == session[:user_id]) and |
|
93 | if ((submission.user_id == session[:user_id]) and |
|
94 | (submission.problem != nil) and |
|
94 | (submission.problem != nil) and |
|
95 | (submission.problem.available)) |
|
95 | (submission.problem.available)) |
|
96 | send_data(submission.source, |
|
96 | send_data(submission.source, |
|
97 | {:filename => submission.download_filename, |
|
97 | {:filename => submission.download_filename, |
|
98 | :type => 'text/plain'}) |
|
98 | :type => 'text/plain'}) |
|
99 | else |
|
99 | else |
|
100 | flash[:notice] = 'Error viewing source' |
|
100 | flash[:notice] = 'Error viewing source' |
|
101 | redirect_to :action => 'list' |
|
101 | redirect_to :action => 'list' |
|
102 | end |
|
102 | end |
|
103 | end |
|
103 | end |
|
104 |
|
104 | ||
|
105 | def compiler_msg |
|
105 | def compiler_msg |
|
106 | @submission = Submission.find(params[:id]) |
|
106 | @submission = Submission.find(params[:id]) |
|
107 | if @submission.user_id == session[:user_id] |
|
107 | if @submission.user_id == session[:user_id] |
|
108 | render :action => 'compiler_msg', :layout => 'empty' |
|
108 | render :action => 'compiler_msg', :layout => 'empty' |
|
109 | else |
|
109 | else |
|
110 | flash[:notice] = 'Error viewing source' |
|
110 | flash[:notice] = 'Error viewing source' |
|
111 | redirect_to :action => 'list' |
|
111 | redirect_to :action => 'list' |
|
112 | end |
|
112 | end |
|
113 | end |
|
113 | end |
|
114 |
|
114 | ||
|
115 | def submission |
|
115 | def submission |
|
116 | @user = User.find(session[:user_id]) |
|
116 | @user = User.find(session[:user_id]) |
|
117 | @problems = @user.available_problems |
|
117 | @problems = @user.available_problems |
|
118 | if params[:id]==nil |
|
118 | if params[:id]==nil |
|
119 | @problem = nil |
|
119 | @problem = nil |
|
120 | @submissions = nil |
|
120 | @submissions = nil |
|
121 | else |
|
121 | else |
|
122 | @problem = Problem.find_by_name(params[:id]) |
|
122 | @problem = Problem.find_by_name(params[:id]) |
|
123 | if not @problem.available |
|
123 | if not @problem.available |
|
124 | redirect_to :action => 'list' |
|
124 | redirect_to :action => 'list' |
|
125 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
125 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
126 | return |
|
126 | return |
|
127 | end |
|
127 | end |
|
128 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
128 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
129 | end |
|
129 | end |
|
130 | end |
|
130 | end |
|
131 |
|
131 | ||
|
132 | def result |
|
132 | def result |
|
133 | if !GraderConfiguration.show_grading_result |
|
133 | if !GraderConfiguration.show_grading_result |
|
134 | redirect_to :action => 'list' and return |
|
134 | redirect_to :action => 'list' and return |
|
135 | end |
|
135 | end |
|
136 | @user = User.find(session[:user_id]) |
|
136 | @user = User.find(session[:user_id]) |
|
137 | @submission = Submission.find(params[:id]) |
|
137 | @submission = Submission.find(params[:id]) |
|
138 | if @submission.user!=@user |
|
138 | if @submission.user!=@user |
|
139 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
139 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
140 | redirect_to :action => 'list' and return |
|
140 | redirect_to :action => 'list' and return |
|
141 | end |
|
141 | end |
|
142 | prepare_grading_result(@submission) |
|
142 | prepare_grading_result(@submission) |
|
143 | end |
|
143 | end |
|
144 |
|
144 | ||
|
145 | def load_output |
|
145 | def load_output |
|
146 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
146 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
147 | redirect_to :action => 'list' and return |
|
147 | redirect_to :action => 'list' and return |
|
148 | end |
|
148 | end |
|
149 | @user = User.find(session[:user_id]) |
|
149 | @user = User.find(session[:user_id]) |
|
150 | @submission = Submission.find(params[:id]) |
|
150 | @submission = Submission.find(params[:id]) |
|
151 | if @submission.user!=@user |
|
151 | if @submission.user!=@user |
|
152 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
152 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
153 | redirect_to :action => 'list' and return |
|
153 | redirect_to :action => 'list' and return |
|
154 | end |
|
154 | end |
|
155 | case_num = params[:num].to_i |
|
155 | case_num = params[:num].to_i |
|
156 | out_filename = output_filename(@user.login, |
|
156 | out_filename = output_filename(@user.login, |
|
157 | @submission.problem.name, |
|
157 | @submission.problem.name, |
|
158 | @submission.id, |
|
158 | @submission.id, |
|
159 | case_num) |
|
159 | case_num) |
|
160 | if !FileTest.exists?(out_filename) |
|
160 | if !FileTest.exists?(out_filename) |
|
161 | flash[:notice] = 'Output not found.' |
|
161 | flash[:notice] = 'Output not found.' |
|
162 | redirect_to :action => 'list' and return |
|
162 | redirect_to :action => 'list' and return |
|
163 | end |
|
163 | end |
|
164 |
|
164 | ||
|
165 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
165 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
166 | response.headers['Content-Type'] = "application/force-download" |
|
166 | response.headers['Content-Type'] = "application/force-download" |
|
167 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
167 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
168 | response.headers["X-Sendfile"] = out_filename |
|
168 | response.headers["X-Sendfile"] = out_filename |
|
169 | response.headers['Content-length'] = File.size(out_filename) |
|
169 | response.headers['Content-length'] = File.size(out_filename) |
|
170 | render :nothing => true |
|
170 | render :nothing => true |
|
171 | else |
|
171 | else |
|
172 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
172 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
173 | end |
|
173 | end |
|
174 | end |
|
174 | end |
|
175 |
|
175 | ||
|
176 | def error |
|
176 | def error |
|
177 | @user = User.find(session[:user_id]) |
|
177 | @user = User.find(session[:user_id]) |
|
178 | end |
|
178 | end |
|
179 |
|
179 | ||
|
180 | # announcement refreshing and hiding methods |
|
180 | # announcement refreshing and hiding methods |
|
181 |
|
181 | ||
|
182 | def announcements |
|
182 | def announcements |
|
183 | if params.has_key? 'recent' |
|
183 | if params.has_key? 'recent' |
|
184 | prepare_announcements(params[:recent]) |
|
184 | prepare_announcements(params[:recent]) |
|
185 | else |
|
185 | else |
|
186 | prepare_announcements |
|
186 | prepare_announcements |
|
187 | end |
|
187 | end |
|
188 | render(:partial => 'announcement', |
|
188 | render(:partial => 'announcement', |
|
189 | :collection => @announcements, |
|
189 | :collection => @announcements, |
|
190 | :locals => {:announcement_effect => true}) |
|
190 | :locals => {:announcement_effect => true}) |
|
191 | end |
|
191 | end |
|
192 |
|
192 | ||
|
193 | def confirm_contest_start |
|
193 | def confirm_contest_start |
|
194 | user = User.find(session[:user_id]) |
|
194 | user = User.find(session[:user_id]) |
|
195 |
- if request.method == |
|
195 | + if request.method == 'POST' |
|
196 | user.update_start_time |
|
196 | user.update_start_time |
|
197 | redirect_to :action => 'list' |
|
197 | redirect_to :action => 'list' |
|
198 | else |
|
198 | else |
|
199 | @contests = user.contests |
|
199 | @contests = user.contests |
|
200 | @user = user |
|
200 | @user = user |
|
201 | end |
|
201 | end |
|
202 | end |
|
202 | end |
|
203 |
|
203 | ||
|
204 | protected |
|
204 | protected |
|
205 |
|
205 | ||
|
206 | def prepare_announcements(recent=nil) |
|
206 | def prepare_announcements(recent=nil) |
|
207 | if GraderConfiguration.show_tasks_to?(@user) |
|
207 | if GraderConfiguration.show_tasks_to?(@user) |
|
208 | @announcements = Announcement.find_published(true) |
|
208 | @announcements = Announcement.find_published(true) |
|
209 | else |
|
209 | else |
|
210 | @announcements = Announcement.find_published |
|
210 | @announcements = Announcement.find_published |
|
211 | end |
|
211 | end |
|
212 | if recent!=nil |
|
212 | if recent!=nil |
|
213 | recent_id = recent.to_i |
|
213 | recent_id = recent.to_i |
|
214 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
214 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
215 | end |
|
215 | end |
|
216 | end |
|
216 | end |
|
217 |
|
217 | ||
|
218 | def prepare_list_information |
|
218 | def prepare_list_information |
|
219 | @user = User.find(session[:user_id]) |
|
219 | @user = User.find(session[:user_id]) |
|
220 | if not GraderConfiguration.multicontests? |
|
220 | if not GraderConfiguration.multicontests? |
|
221 | @problems = @user.available_problems |
|
221 | @problems = @user.available_problems |
|
222 | else |
|
222 | else |
|
223 | @contest_problems = @user.available_problems_group_by_contests |
|
223 | @contest_problems = @user.available_problems_group_by_contests |
|
224 | @problems = @user.available_problems |
|
224 | @problems = @user.available_problems |
|
225 | end |
|
225 | end |
|
226 | @prob_submissions = {} |
|
226 | @prob_submissions = {} |
|
227 | @problems.each do |p| |
|
227 | @problems.each do |p| |
|
228 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
228 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
229 | if sub!=nil |
|
229 | if sub!=nil |
|
230 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
230 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
231 | else |
|
231 | else |
|
232 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
232 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
233 | end |
|
233 | end |
|
234 | end |
|
234 | end |
|
235 | prepare_announcements |
|
235 | prepare_announcements |
|
236 | end |
|
236 | end |
|
237 |
|
237 | ||
|
238 | def check_viewability |
|
238 | def check_viewability |
|
239 | @user = User.find(session[:user_id]) |
|
239 | @user = User.find(session[:user_id]) |
|
240 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
240 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
241 | ((action_name=='submission') or (action_name=='submit')) |
|
241 | ((action_name=='submission') or (action_name=='submit')) |
|
242 | redirect_to :action => 'list' and return |
|
242 | redirect_to :action => 'list' and return |
|
243 | end |
|
243 | end |
|
244 | end |
|
244 | end |
|
245 |
|
245 | ||
|
246 | def prepare_grading_result(submission) |
|
246 | def prepare_grading_result(submission) |
|
247 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
247 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
248 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
248 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
249 | else |
|
249 | else |
|
250 | # guess task info from problem.full_score |
|
250 | # guess task info from problem.full_score |
|
251 | cases = submission.problem.full_score / 10 |
|
251 | cases = submission.problem.full_score / 10 |
|
252 | grading_info = { |
|
252 | grading_info = { |
|
253 | 'testruns' => cases, |
|
253 | 'testruns' => cases, |
|
254 | 'testcases' => cases |
|
254 | 'testcases' => cases |
|
255 | } |
|
255 | } |
|
256 | end |
|
256 | end |
|
257 | @test_runs = [] |
|
257 | @test_runs = [] |
|
258 | if grading_info['testruns'].is_a? Integer |
|
258 | if grading_info['testruns'].is_a? Integer |
|
259 | trun_count = grading_info['testruns'] |
|
259 | trun_count = grading_info['testruns'] |
|
260 | trun_count.times do |i| |
|
260 | trun_count.times do |i| |
|
261 | @test_runs << [ read_grading_result(@user.login, |
|
261 | @test_runs << [ read_grading_result(@user.login, |
|
262 | submission.problem.name, |
|
262 | submission.problem.name, |
|
263 | submission.id, |
|
263 | submission.id, |
|
264 | i+1) ] |
|
264 | i+1) ] |
|
265 | end |
|
265 | end |
|
266 | else |
|
266 | else |
|
267 | grading_info['testruns'].keys.sort.each do |num| |
|
267 | grading_info['testruns'].keys.sort.each do |num| |
|
268 | run = [] |
|
268 | run = [] |
|
269 | testrun = grading_info['testruns'][num] |
|
269 | testrun = grading_info['testruns'][num] |
|
270 | testrun.each do |c| |
|
270 | testrun.each do |c| |
|
271 | run << read_grading_result(@user.login, |
|
271 | run << read_grading_result(@user.login, |
|
272 | submission.problem.name, |
|
272 | submission.problem.name, |
|
273 | submission.id, |
|
273 | submission.id, |
|
274 | c) |
|
274 | c) |
|
275 | end |
|
275 | end |
|
276 | @test_runs << run |
|
276 | @test_runs << run |
|
277 | end |
|
277 | end |
|
278 | end |
|
278 | end |
|
279 | end |
|
279 | end |
|
280 |
|
280 | ||
|
281 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
281 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
282 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
282 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
283 | end |
|
283 | end |
|
284 |
|
284 | ||
|
285 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
285 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
286 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
286 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
287 | return "#{dir}/output.txt" |
|
287 | return "#{dir}/output.txt" |
|
288 | end |
|
288 | end |
|
289 |
|
289 | ||
|
290 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
290 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
291 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
291 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
292 | result_file_name = "#{dir}/result" |
|
292 | result_file_name = "#{dir}/result" |
|
293 | if !FileTest.exists?(result_file_name) |
|
293 | if !FileTest.exists?(result_file_name) |
|
294 | return {:num => case_num, :msg => 'program did not run'} |
|
294 | return {:num => case_num, :msg => 'program did not run'} |
|
295 | else |
|
295 | else |
|
296 | results = File.open(result_file_name).readlines |
|
296 | results = File.open(result_file_name).readlines |
|
297 | run_stat = extract_running_stat(results) |
|
297 | run_stat = extract_running_stat(results) |
|
298 | output_filename = "#{dir}/output.txt" |
|
298 | output_filename = "#{dir}/output.txt" |
|
299 | if FileTest.exists?(output_filename) |
|
299 | if FileTest.exists?(output_filename) |
|
300 | output_file = true |
|
300 | output_file = true |
|
301 | output_size = File.size(output_filename) |
|
301 | output_size = File.size(output_filename) |
|
302 | else |
|
302 | else |
|
303 | output_file = false |
|
303 | output_file = false |
|
304 | output_size = 0 |
|
304 | output_size = 0 |
|
305 | end |
|
305 | end |
|
306 |
|
306 | ||
|
307 | return { |
|
307 | return { |
|
308 | :num => case_num, |
|
308 | :num => case_num, |
|
309 | :msg => results[0], |
|
309 | :msg => results[0], |
|
310 | :run_stat => run_stat, |
|
310 | :run_stat => run_stat, |
|
311 | :output => output_file, |
|
311 | :output => output_file, |
|
312 | :output_size => output_size |
|
312 | :output_size => output_size |
|
313 | } |
|
313 | } |
|
314 | end |
|
314 | end |
|
315 | end |
|
315 | end |
|
316 |
|
316 | ||
|
317 | # copied from grader/script/lib/test_request_helper.rb |
|
317 | # copied from grader/script/lib/test_request_helper.rb |
|
318 | def extract_running_stat(results) |
|
318 | def extract_running_stat(results) |
|
319 | running_stat_line = results[-1] |
|
319 | running_stat_line = results[-1] |
|
320 |
|
320 | ||
|
321 | # extract exit status line |
|
321 | # extract exit status line |
|
322 | run_stat = "" |
|
322 | run_stat = "" |
|
323 | if !(/[Cc]orrect/.match(results[0])) |
|
323 | if !(/[Cc]orrect/.match(results[0])) |
|
324 | run_stat = results[0].chomp |
|
324 | run_stat = results[0].chomp |
|
325 | else |
|
325 | else |
|
326 | run_stat = 'Program exited normally' |
|
326 | run_stat = 'Program exited normally' |
|
327 | end |
|
327 | end |
|
328 |
|
328 | ||
|
329 | logger.info "Stat line: #{running_stat_line}" |
|
329 | logger.info "Stat line: #{running_stat_line}" |
|
330 |
|
330 | ||
|
331 | # extract running time |
|
331 | # extract running time |
|
332 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
332 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
333 | seconds = (res[1].to_f + res[2].to_f) |
|
333 | seconds = (res[1].to_f + res[2].to_f) |
|
334 | time_stat = "Time used: #{seconds} sec." |
|
334 | time_stat = "Time used: #{seconds} sec." |
|
335 | else |
|
335 | else |
|
336 | seconds = nil |
|
336 | seconds = nil |
|
337 | time_stat = "Time used: n/a sec." |
|
337 | time_stat = "Time used: n/a sec." |
|
338 | end |
|
338 | end |
|
339 |
|
339 | ||
|
340 | # extract memory usage |
|
340 | # extract memory usage |
|
341 | if res = /s(.*)m/.match(running_stat_line) |
|
341 | if res = /s(.*)m/.match(running_stat_line) |
|
342 | memory_used = res[1].to_i |
|
342 | memory_used = res[1].to_i |
|
343 | else |
|
343 | else |
|
344 | memory_used = -1 |
|
344 | memory_used = -1 |
|
345 | end |
|
345 | end |
|
346 |
|
346 | ||
|
347 | return { |
|
347 | return { |
|
348 | :msg => "#{run_stat}\n#{time_stat}", |
|
348 | :msg => "#{run_stat}\n#{time_stat}", |
|
349 | :running_time => seconds, |
|
349 | :running_time => seconds, |
|
350 | :exit_status => run_stat, |
|
350 | :exit_status => run_stat, |
|
351 | :memory_usage => memory_used |
|
351 | :memory_usage => memory_used |
|
352 | } |
|
352 | } |
|
353 | end |
|
353 | end |
|
354 |
|
354 | ||
|
355 | def confirm_and_update_start_time |
|
355 | def confirm_and_update_start_time |
|
356 | user = User.find(session[:user_id]) |
|
356 | user = User.find(session[:user_id]) |
|
357 | if (GraderConfiguration.indv_contest_mode? and |
|
357 | if (GraderConfiguration.indv_contest_mode? and |
|
358 | GraderConfiguration['contest.confirm_indv_contest_start'] and |
|
358 | GraderConfiguration['contest.confirm_indv_contest_start'] and |
|
359 | !user.contest_started?) |
|
359 | !user.contest_started?) |
|
360 | redirect_to :action => 'confirm_contest_start' and return |
|
360 | redirect_to :action => 'confirm_contest_start' and return |
|
361 | end |
|
361 | end |
|
362 | if not GraderConfiguration.analysis_mode? |
|
362 | if not GraderConfiguration.analysis_mode? |
|
363 | user.update_start_time |
|
363 | user.update_start_time |
|
364 | end |
|
364 | end |
|
365 | end |
|
365 | end |
|
366 |
|
366 | ||
|
367 | def reject_announcement_refresh_when_logged_out |
|
367 | def reject_announcement_refresh_when_logged_out |
|
368 | if not session[:user_id] |
|
368 | if not session[:user_id] |
|
369 | render :text => 'Access forbidden', :status => 403 |
|
369 | render :text => 'Access forbidden', :status => 403 |
|
370 | end |
|
370 | end |
|
371 |
|
371 | ||
|
372 | if GraderConfiguration.multicontests? |
|
372 | if GraderConfiguration.multicontests? |
|
373 | user = User.find(session[:user_id]) |
|
373 | user = User.find(session[:user_id]) |
|
374 | if user.contest_stat.forced_logout |
|
374 | if user.contest_stat.forced_logout |
|
375 | render :text => 'Access forbidden', :status => 403 |
|
375 | render :text => 'Access forbidden', :status => 403 |
|
376 | end |
|
376 | end |
|
377 | end |
|
377 | end |
|
378 | end |
|
378 | end |
|
379 |
|
379 | ||
|
380 | end |
|
380 | end |
|
381 |
|
381 |
@@ -1,16 +1,16 | |||||
|
1 | = user_title_bar(@user) |
|
1 | = user_title_bar(@user) |
|
2 |
|
2 | ||
|
3 | .announcementbox |
|
3 | .announcementbox |
|
4 | %span{:class => 'title'} |
|
4 | %span{:class => 'title'} |
|
5 | =t 'main.confirm_contest_start.box_title' |
|
5 | =t 'main.confirm_contest_start.box_title' |
|
6 | .announcement |
|
6 | .announcement |
|
7 | %center |
|
7 | %center |
|
8 | =t 'main.confirm_contest_start.contest_list' |
|
8 | =t 'main.confirm_contest_start.contest_list' |
|
9 | - @contests.each do |contest| |
|
9 | - @contests.each do |contest| |
|
10 | = contest.title |
|
10 | = contest.title |
|
11 | %br |
|
11 | %br |
|
12 |
|
12 | ||
|
13 | =t 'main.confirm_contest_start.timer_starts_after_click' |
|
13 | =t 'main.confirm_contest_start.timer_starts_after_click' |
|
14 |
|
14 | ||
|
15 |
- = form_tag :action => 'confirm_contest_start' |
|
15 | + = form_tag :action => 'confirm_contest_start' do |
|
16 | = submit_tag t('main.confirm_contest_start.start_button'), :confirm => t('main.confirm_contest_start.start_button_confirm') |
|
16 | = submit_tag t('main.confirm_contest_start.start_button'), :confirm => t('main.confirm_contest_start.start_button_confirm') |
You need to be logged in to leave comments.
Login now