Description:
added options not to hide passed problems
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r260:a6455c18d017 - - 2 files changed: 6 inserted, 2 deleted

@@ -270,125 +270,128
270 270 flash[:notice] = 'Correct solution.'
271 271 user.update_codejom_status
272 272 else
273 273 session[:current_problem_id] = problem.id
274 274 flash[:notice] = 'Incorrect solution.'
275 275 end
276 276 redirect_to :action => 'list'
277 277 end
278 278
279 279 def problems
280 280 prepare_list_information
281 281 @page_reload_when_view_problem = true
282 282 render :partial => 'problem_title', :collection => @problems, :as => :problem
283 283 end
284 284
285 285 def splash
286 286 render :text => '<div class="notice">Most recent task:</span>'
287 287 end
288 288
289 289 protected
290 290
291 291 def prepare_announcements(recent=nil)
292 292 if Configuration.show_tasks_to?(@user)
293 293 @announcements = Announcement.find_published(true)
294 294 else
295 295 @announcements = Announcement.find_published
296 296 end
297 297 if recent!=nil
298 298 recent_id = recent.to_i
299 299 @announcements = @announcements.find_all { |a| a.id > recent_id }
300 300 end
301 301 end
302 302
303 303 def prepare_timeout_information(problems)
304 304 @submission_timeouts = {}
305 305 problems.each do |problem|
306 306 assignment = @user.get_recent_test_pair_assignment_for(problem)
307 307 if assignment == nil
308 308 timeout = nil
309 309 else
310 310 if (assignment.expired?) or (assignment.submitted)
311 311 timeout = 0
312 312 else
313 313 timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
314 314 end
315 315 end
316 316 @submission_timeouts[problem.id] = timeout
317 317 end
318 - @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
319 318 end
320 319
321 320 def prepare_list_information
322 321 @user = User.find(session[:user_id])
323 322
324 323 all_problems = Problem.find_available_problems
325 324
326 325 passed = {}
327 326 sub_count = {}
328 327 @user.submission_statuses.each do |status|
329 328 if status.passed
330 329 passed[status.problem_id] = true
331 330 end
332 331 sub_count[status.problem_id] = status.submission_count
333 332 end
334 333
335 334 if session.has_key? :current_problem_id
336 335 @current_problem_id = session[:current_problem_id]
337 336 session.delete(:current_problem_id)
338 337 else
339 338 if params.has_key? :id
340 339 @current_problem_id = params[:id].to_i
341 340 else
342 341 @current_problem_id = nil
343 342 end
344 343 end
345 344
346 - @problems = all_problems.reject { |problem| passed.has_key? problem.id }
345 + if (not defined? HIDE_PASSED_TASKS) or HIDE_PASSED_TASKS
346 + @problems = all_problems.reject { |problem| passed.has_key? problem.id }
347 + else
348 + @problems = all_problems
349 + end
347 350
348 351 prepare_timeout_information(@problems)
349 352
350 353 @prob_submissions = Array.new
351 354 @problems.each do |p|
352 355 if sub_count.has_key? p.id
353 356 @prob_submissions << { :count => sub_count[p.id] }
354 357 else
355 358 @prob_submissions << { :count => 0 }
356 359 end
357 360 end
358 361 prepare_announcements
359 362 end
360 363
361 364 def check_viewability
362 365 @user = User.find(session[:user_id])
363 366 if (!Configuration.show_tasks_to?(@user)) and
364 367 ((action_name=='submission') or (action_name=='submit'))
365 368 redirect_to :action => 'list' and return
366 369 end
367 370 end
368 371
369 372 def prepare_grading_result(submission)
370 373 if Configuration.task_grading_info.has_key? submission.problem.name
371 374 grading_info = Configuration.task_grading_info[submission.problem.name]
372 375 else
373 376 # guess task info from problem.full_score
374 377 cases = submission.problem.full_score / 10
375 378 grading_info = {
376 379 'testruns' => cases,
377 380 'testcases' => cases
378 381 }
379 382 end
380 383 @test_runs = []
381 384 if grading_info['testruns'].is_a? Integer
382 385 trun_count = grading_info['testruns']
383 386 trun_count.times do |i|
384 387 @test_runs << [ read_grading_result(@user.login,
385 388 submission.problem.name,
386 389 submission.id,
387 390 i+1) ]
388 391 end
389 392 else
390 393 grading_info['testruns'].keys.sort.each do |num|
391 394 run = []
392 395 testrun = grading_info['testruns'][num]
393 396 testrun.each do |c|
394 397 run << read_grading_result(@user.login,
@@ -64,48 +64,49
64 64 # inflect.plural /^(ox)$/i, '\1en'
65 65 # inflect.singular /^(ox)en/i, '\1'
66 66 # inflect.irregular 'person', 'people'
67 67 # inflect.uncountable %w( fish sheep )
68 68 # end
69 69
70 70 # Add new mime types for use in respond_to blocks:
71 71 # Mime::Type.register "text/richtext", :rtf
72 72 # Mime::Type.register "application/x-mobile", :mobile
73 73
74 74 # Include your application configuration below
75 75
76 76 # If you want to manage graders through web interface, set the path to
77 77 # the grader directory below. This dir is where raw, ev, ev-exam,
78 78 # scripts reside. All grader scripts will be in
79 79 # #{GRADER_ROOT_DIR}/scripts.
80 80 GRADER_ROOT_DIR = ''
81 81
82 82 # These are where inputs and outputs of test requests are stored
83 83 TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input'
84 84 TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output'
85 85
86 86 # To use ANALYSIS MODE, provide the testcases/testruns breakdown,
87 87 # and the directory of the grading result (usually in judge's dir).
88 88 TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml'
89 89
90 90 # TODO: change this to where results are kept.
91 91 GRADING_RESULT_DIR = 'RESULT-DIR'
92 92
93 93 # Change this to allow importing testdata into database as test-pairs.
94 94 # This is mainly for Code Jom contest.
95 95 ALLOW_TEST_PAIR_IMPORT = false
96 96
97 97 # Uncomment so that the system validates user e-mails
98 98 # VALIDATE_USER_EMAILS = true
99 99
100 100 # Uncomment so that Apache X-Sendfile is used when delivering files
101 101 # (e.g., in /tasks/view).
102 102 # USE_APACHE_XSENDFILE = true
103 103
104 104 # Uncomment so that configuration is read only once when the server is loaded
105 105 # Configuration.enable_caching
106 106
107 107 # OPTIONS FOR CODE JOM
108 108 # --------------------
109 109 CODEJOM_MAX_ALIVE_LEVEL = 10
110 110 TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute
111 111 SHOW_CONTEST_STATUS = false
112 + HIDE_PASSED_TASKS = true No newline at end of file
You need to be logged in to leave comments. Login now