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,25 +1,25
1 - # -*- coding: undecided -*-
1 + # -*- coding: utf-8 -*-
2 2 require 'digest/sha1'
3 3
4 4 class User < ActiveRecord::Base
5 5
6 6 has_and_belongs_to_many :roles
7 7
8 8 has_many :test_requests, :order => "submitted_at DESC"
9 9
10 10 has_many :messages,
11 11 :class_name => "Message",
12 12 :foreign_key => "sender_id",
13 13 :order => 'created_at DESC'
14 14
15 15 has_many :replied_messages,
16 16 :class_name => "Message",
17 17 :foreign_key => "receiver_id",
18 18 :order => 'created_at DESC'
19 19
20 20 has_many :test_pair_assignments, :dependent => :delete_all
21 21 has_many :submission_statuses
22 22
23 23 has_one :contest_stat, :class_name => "UserContestStat"
24 24
25 25 belongs_to :site
@@ -213,49 +213,49
213 213 elsif Configuration.indv_contest_mode?
214 214 time_limit = Configuration.contest_time_limit
215 215
216 216 return false if contest_stat==nil
217 217
218 218 return contest_time_left == 0
219 219 else
220 220 return false
221 221 end
222 222 end
223 223
224 224 def contest_started?
225 225 if Configuration.contest_mode?
226 226 return true if site==nil
227 227 return site.started
228 228 else
229 229 return true
230 230 end
231 231 end
232 232
233 233 # For Code Jom
234 234 def update_codejom_status
235 235 status = codejom_status || CodejomStatus.new(:user => self)
236 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 238 status.alive = (problem_count - (status.num_problems_passed)) <= CODEJOM_MAX_ALIVE_LEVEL
239 239 status.save
240 240 end
241 241
242 242 def codejom_level
243 243 problem_count = Problem.available_problem_count
244 244 if codejom_status!=nil
245 245 return problem_count - codejom_status.num_problems_passed
246 246 else
247 247 return problem_count
248 248 end
249 249 end
250 250
251 251 protected
252 252 def encrypt_new_password
253 253 return if password.blank?
254 254 self.salt = (10+rand(90)).to_s
255 255 self.hashed_password = User.encrypt(self.password,self.salt)
256 256 end
257 257
258 258 def assign_default_site
259 259 # have to catch error when migrating (because self.site is not available).
260 260 begin
261 261 if self.site==nil
You need to be logged in to leave comments. Login now