Description:
fixed single contest bug, reported by K. Siththa
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r292:35efcd905ebb - - 1 file changed: 1 inserted, 1 deleted
@@ -155,97 +155,97 | |||
|
155 | 155 | redirect_to :action => 'list' and return |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | 158 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
159 | 159 | response.headers['Content-Type'] = "application/force-download" |
|
160 | 160 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
161 | 161 | response.headers["X-Sendfile"] = out_filename |
|
162 | 162 | response.headers['Content-length'] = File.size(out_filename) |
|
163 | 163 | render :nothing => true |
|
164 | 164 | else |
|
165 | 165 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
166 | 166 | end |
|
167 | 167 | end |
|
168 | 168 | |
|
169 | 169 | def error |
|
170 | 170 | @user = User.find(session[:user_id]) |
|
171 | 171 | end |
|
172 | 172 | |
|
173 | 173 | # announcement refreshing and hiding methods |
|
174 | 174 | |
|
175 | 175 | def announcements |
|
176 | 176 | if params.has_key? 'recent' |
|
177 | 177 | prepare_announcements(params[:recent]) |
|
178 | 178 | else |
|
179 | 179 | prepare_announcements |
|
180 | 180 | end |
|
181 | 181 | render(:partial => 'announcement', |
|
182 | 182 | :collection => @announcements, |
|
183 | 183 | :locals => {:announcement_effect => true}) |
|
184 | 184 | end |
|
185 | 185 | |
|
186 | 186 | protected |
|
187 | 187 | |
|
188 | 188 | def prepare_announcements(recent=nil) |
|
189 | 189 | if Configuration.show_tasks_to?(@user) |
|
190 | 190 | @announcements = Announcement.find_published(true) |
|
191 | 191 | else |
|
192 | 192 | @announcements = Announcement.find_published |
|
193 | 193 | end |
|
194 | 194 | if recent!=nil |
|
195 | 195 | recent_id = recent.to_i |
|
196 | 196 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
197 | 197 | end |
|
198 | 198 | end |
|
199 | 199 | |
|
200 | 200 | def prepare_list_information |
|
201 | 201 | @user = User.find(session[:user_id]) |
|
202 | 202 | if not Configuration.multicontests? |
|
203 | - @problems = problem_list_for_user(@user) | |
|
203 | + @problems = @user.available_problems | |
|
204 | 204 | else |
|
205 | 205 | @contest_problems = @user.available_problems_group_by_contests |
|
206 | 206 | @problems = @user.available_problems |
|
207 | 207 | end |
|
208 | 208 | @prob_submissions = {} |
|
209 | 209 | @problems.each do |p| |
|
210 | 210 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
211 | 211 | if sub!=nil |
|
212 | 212 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
213 | 213 | else |
|
214 | 214 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
215 | 215 | end |
|
216 | 216 | end |
|
217 | 217 | prepare_announcements |
|
218 | 218 | end |
|
219 | 219 | |
|
220 | 220 | def check_viewability |
|
221 | 221 | @user = User.find(session[:user_id]) |
|
222 | 222 | if (!Configuration.show_tasks_to?(@user)) and |
|
223 | 223 | ((action_name=='submission') or (action_name=='submit')) |
|
224 | 224 | redirect_to :action => 'list' and return |
|
225 | 225 | end |
|
226 | 226 | end |
|
227 | 227 | |
|
228 | 228 | def prepare_grading_result(submission) |
|
229 | 229 | if Configuration.task_grading_info.has_key? submission.problem.name |
|
230 | 230 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
231 | 231 | else |
|
232 | 232 | # guess task info from problem.full_score |
|
233 | 233 | cases = submission.problem.full_score / 10 |
|
234 | 234 | grading_info = { |
|
235 | 235 | 'testruns' => cases, |
|
236 | 236 | 'testcases' => cases |
|
237 | 237 | } |
|
238 | 238 | end |
|
239 | 239 | @test_runs = [] |
|
240 | 240 | if grading_info['testruns'].is_a? Integer |
|
241 | 241 | trun_count = grading_info['testruns'] |
|
242 | 242 | trun_count.times do |i| |
|
243 | 243 | @test_runs << [ read_grading_result(@user.login, |
|
244 | 244 | submission.problem.name, |
|
245 | 245 | submission.id, |
|
246 | 246 | i+1) ] |
|
247 | 247 | end |
|
248 | 248 | else |
|
249 | 249 | grading_info['testruns'].keys.sort.each do |num| |
|
250 | 250 | run = [] |
|
251 | 251 | testrun = grading_info['testruns'][num] |
You need to be logged in to leave comments.
Login now