Description:
Fixed Individual Contest confirmation
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r371:6d2e9920049d - - 2 files changed: 2 inserted, 2 deleted

@@ -99,193 +99,193
99 99 else
100 100 flash[:notice] = 'Error viewing source'
101 101 redirect_to :action => 'list'
102 102 end
103 103 end
104 104
105 105 def compiler_msg
106 106 @submission = Submission.find(params[:id])
107 107 if @submission.user_id == session[:user_id]
108 108 render :action => 'compiler_msg', :layout => 'empty'
109 109 else
110 110 flash[:notice] = 'Error viewing source'
111 111 redirect_to :action => 'list'
112 112 end
113 113 end
114 114
115 115 def submission
116 116 @user = User.find(session[:user_id])
117 117 @problems = @user.available_problems
118 118 if params[:id]==nil
119 119 @problem = nil
120 120 @submissions = nil
121 121 else
122 122 @problem = Problem.find_by_name(params[:id])
123 123 if not @problem.available
124 124 redirect_to :action => 'list'
125 125 flash[:notice] = 'Error: submissions for that problem are not viewable.'
126 126 return
127 127 end
128 128 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
129 129 end
130 130 end
131 131
132 132 def result
133 133 if !GraderConfiguration.show_grading_result
134 134 redirect_to :action => 'list' and return
135 135 end
136 136 @user = User.find(session[:user_id])
137 137 @submission = Submission.find(params[:id])
138 138 if @submission.user!=@user
139 139 flash[:notice] = 'You are not allowed to view result of other users.'
140 140 redirect_to :action => 'list' and return
141 141 end
142 142 prepare_grading_result(@submission)
143 143 end
144 144
145 145 def load_output
146 146 if !GraderConfiguration.show_grading_result or params[:num]==nil
147 147 redirect_to :action => 'list' and return
148 148 end
149 149 @user = User.find(session[:user_id])
150 150 @submission = Submission.find(params[:id])
151 151 if @submission.user!=@user
152 152 flash[:notice] = 'You are not allowed to view result of other users.'
153 153 redirect_to :action => 'list' and return
154 154 end
155 155 case_num = params[:num].to_i
156 156 out_filename = output_filename(@user.login,
157 157 @submission.problem.name,
158 158 @submission.id,
159 159 case_num)
160 160 if !FileTest.exists?(out_filename)
161 161 flash[:notice] = 'Output not found.'
162 162 redirect_to :action => 'list' and return
163 163 end
164 164
165 165 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
166 166 response.headers['Content-Type'] = "application/force-download"
167 167 response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\""
168 168 response.headers["X-Sendfile"] = out_filename
169 169 response.headers['Content-length'] = File.size(out_filename)
170 170 render :nothing => true
171 171 else
172 172 send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain"
173 173 end
174 174 end
175 175
176 176 def error
177 177 @user = User.find(session[:user_id])
178 178 end
179 179
180 180 # announcement refreshing and hiding methods
181 181
182 182 def announcements
183 183 if params.has_key? 'recent'
184 184 prepare_announcements(params[:recent])
185 185 else
186 186 prepare_announcements
187 187 end
188 188 render(:partial => 'announcement',
189 189 :collection => @announcements,
190 190 :locals => {:announcement_effect => true})
191 191 end
192 192
193 193 def confirm_contest_start
194 194 user = User.find(session[:user_id])
195 - if request.method == :post
195 + if request.method == 'POST'
196 196 user.update_start_time
197 197 redirect_to :action => 'list'
198 198 else
199 199 @contests = user.contests
200 200 @user = user
201 201 end
202 202 end
203 203
204 204 protected
205 205
206 206 def prepare_announcements(recent=nil)
207 207 if GraderConfiguration.show_tasks_to?(@user)
208 208 @announcements = Announcement.find_published(true)
209 209 else
210 210 @announcements = Announcement.find_published
211 211 end
212 212 if recent!=nil
213 213 recent_id = recent.to_i
214 214 @announcements = @announcements.find_all { |a| a.id > recent_id }
215 215 end
216 216 end
217 217
218 218 def prepare_list_information
219 219 @user = User.find(session[:user_id])
220 220 if not GraderConfiguration.multicontests?
221 221 @problems = @user.available_problems
222 222 else
223 223 @contest_problems = @user.available_problems_group_by_contests
224 224 @problems = @user.available_problems
225 225 end
226 226 @prob_submissions = {}
227 227 @problems.each do |p|
228 228 sub = Submission.find_last_by_user_and_problem(@user.id,p.id)
229 229 if sub!=nil
230 230 @prob_submissions[p.id] = { :count => sub.number, :submission => sub }
231 231 else
232 232 @prob_submissions[p.id] = { :count => 0, :submission => nil }
233 233 end
234 234 end
235 235 prepare_announcements
236 236 end
237 237
238 238 def check_viewability
239 239 @user = User.find(session[:user_id])
240 240 if (!GraderConfiguration.show_tasks_to?(@user)) and
241 241 ((action_name=='submission') or (action_name=='submit'))
242 242 redirect_to :action => 'list' and return
243 243 end
244 244 end
245 245
246 246 def prepare_grading_result(submission)
247 247 if GraderConfiguration.task_grading_info.has_key? submission.problem.name
248 248 grading_info = GraderConfiguration.task_grading_info[submission.problem.name]
249 249 else
250 250 # guess task info from problem.full_score
251 251 cases = submission.problem.full_score / 10
252 252 grading_info = {
253 253 'testruns' => cases,
254 254 'testcases' => cases
255 255 }
256 256 end
257 257 @test_runs = []
258 258 if grading_info['testruns'].is_a? Integer
259 259 trun_count = grading_info['testruns']
260 260 trun_count.times do |i|
261 261 @test_runs << [ read_grading_result(@user.login,
262 262 submission.problem.name,
263 263 submission.id,
264 264 i+1) ]
265 265 end
266 266 else
267 267 grading_info['testruns'].keys.sort.each do |num|
268 268 run = []
269 269 testrun = grading_info['testruns'][num]
270 270 testrun.each do |c|
271 271 run << read_grading_result(@user.login,
272 272 submission.problem.name,
273 273 submission.id,
274 274 c)
275 275 end
276 276 @test_runs << run
277 277 end
278 278 end
279 279 end
280 280
281 281 def grading_result_dir(user_name, problem_name, submission_id, case_num)
282 282 return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}"
283 283 end
284 284
285 285 def output_filename(user_name, problem_name, submission_id, case_num)
286 286 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
287 287 return "#{dir}/output.txt"
288 288 end
289 289
290 290 def read_grading_result(user_name, problem_name, submission_id, case_num)
291 291 dir = grading_result_dir(user_name,problem_name, submission_id, case_num)
@@ -1,16 +1,16
1 1 = user_title_bar(@user)
2 2
3 3 .announcementbox
4 4 %span{:class => 'title'}
5 5 =t 'main.confirm_contest_start.box_title'
6 6 .announcement
7 7 %center
8 8 =t 'main.confirm_contest_start.contest_list'
9 9 - @contests.each do |contest|
10 10 = contest.title
11 11 %br
12 12
13 13 =t 'main.confirm_contest_start.timer_starts_after_click'
14 14
15 - = form_tag :action => 'confirm_contest_start', :method => 'post' do
15 + = form_tag :action => 'confirm_contest_start' do
16 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