Description:
fixed codejom stutus update to ignore disabled problems
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r246:180b30450ef3 - - 1 file changed: 2 inserted, 2 deleted

@@ -1,13 +1,13
1 - # -*- coding: undecided -*-
1 + # -*- coding: utf-8 -*-
2 require 'digest/sha1'
2 require 'digest/sha1'
3
3
4 class User < ActiveRecord::Base
4 class User < ActiveRecord::Base
5
5
6 has_and_belongs_to_many :roles
6 has_and_belongs_to_many :roles
7
7
8 has_many :test_requests, :order => "submitted_at DESC"
8 has_many :test_requests, :order => "submitted_at DESC"
9
9
10 has_many :messages,
10 has_many :messages,
11 :class_name => "Message",
11 :class_name => "Message",
12 :foreign_key => "sender_id",
12 :foreign_key => "sender_id",
13 :order => 'created_at DESC'
13 :order => 'created_at DESC'
@@ -225,25 +225,25
225 if Configuration.contest_mode?
225 if Configuration.contest_mode?
226 return true if site==nil
226 return true if site==nil
227 return site.started
227 return site.started
228 else
228 else
229 return true
229 return true
230 end
230 end
231 end
231 end
232
232
233 # For Code Jom
233 # For Code Jom
234 def update_codejom_status
234 def update_codejom_status
235 status = codejom_status || CodejomStatus.new(:user => self)
235 status = codejom_status || CodejomStatus.new(:user => self)
236 problem_count = Problem.available_problem_count
236 problem_count = Problem.available_problem_count
237 - status.num_problems_passed = (self.submission_statuses.find_all {|s| s.passed}).length
237 + status.num_problems_passed = (self.submission_statuses.find_all {|s| s.passed and s.problem.available }).length
238 status.alive = (problem_count - (status.num_problems_passed)) <= CODEJOM_MAX_ALIVE_LEVEL
238 status.alive = (problem_count - (status.num_problems_passed)) <= CODEJOM_MAX_ALIVE_LEVEL
239 status.save
239 status.save
240 end
240 end
241
241
242 def codejom_level
242 def codejom_level
243 problem_count = Problem.available_problem_count
243 problem_count = Problem.available_problem_count
244 if codejom_status!=nil
244 if codejom_status!=nil
245 return problem_count - codejom_status.num_problems_passed
245 return problem_count - codejom_status.num_problems_passed
246 else
246 else
247 return problem_count
247 return problem_count
248 end
248 end
249 end
249 end
You need to be logged in to leave comments. Login now