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

r574:6250748f34ac - - 1 file changed: 1 inserted, 1 deleted

@@ -194,97 +194,97
194 194 return site.time_left
195 195 elsif GraderConfiguration.indv_contest_mode?
196 196 time_limit = GraderConfiguration.contest_time_limit
197 197 if time_limit == nil
198 198 return nil
199 199 end
200 200 if contest_stat==nil or contest_stat.started_at==nil
201 201 return (Time.now.gmtime + time_limit) - Time.now.gmtime
202 202 else
203 203 finish_time = contest_stat.started_at + time_limit
204 204 current_time = Time.now.gmtime
205 205 if current_time > finish_time
206 206 return 0
207 207 else
208 208 return finish_time - current_time
209 209 end
210 210 end
211 211 else
212 212 return nil
213 213 end
214 214 end
215 215
216 216 def contest_finished?
217 217 if GraderConfiguration.contest_mode?
218 218 return false if site==nil
219 219 return site.finished?
220 220 elsif GraderConfiguration.indv_contest_mode?
221 221 return false if self.contest_stat(true)==nil
222 222 return contest_time_left == 0
223 223 else
224 224 return false
225 225 end
226 226 end
227 227
228 228 def contest_started?
229 229 if GraderConfiguration.indv_contest_mode?
230 230 stat = self.contest_stat
231 231 return ((stat != nil) and (stat.started_at != nil))
232 232 elsif GraderConfiguration.contest_mode?
233 233 return true if site==nil
234 234 return site.started
235 235 else
236 236 return true
237 237 end
238 238 end
239 239
240 240 def update_start_time
241 241 stat = self.contest_stat
242 - if stat == nil or stat.started_at == nil
242 + if (stat.nil?) or (stat.started_at.nil?)
243 243 stat ||= UserContestStat.new(:user => self)
244 244 stat.started_at = Time.now.gmtime
245 245 stat.save
246 246 end
247 247 end
248 248
249 249 def problem_in_user_contests?(problem)
250 250 problem_contests = problem.contests.all
251 251
252 252 if problem_contests.length == 0 # this is public contest
253 253 return true
254 254 end
255 255
256 256 contests.each do |contest|
257 257 if problem_contests.find {|c| c.id == contest.id }
258 258 return true
259 259 end
260 260 end
261 261 return false
262 262 end
263 263
264 264 def available_problems_group_by_contests
265 265 contest_problems = []
266 266 pin = {}
267 267 contests.enabled.each do |contest|
268 268 available_problems = contest.problems.available
269 269 contest_problems << {
270 270 :contest => contest,
271 271 :problems => available_problems
272 272 }
273 273 available_problems.each {|p| pin[p.id] = true}
274 274 end
275 275 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
276 276 contest_problems << {
277 277 :contest => nil,
278 278 :problems => other_avaiable_problems
279 279 }
280 280 return contest_problems
281 281 end
282 282
283 283 def available_problems
284 284 if not GraderConfiguration.multicontests?
285 285 return Problem.find_available_problems
286 286 else
287 287 contest_problems = []
288 288 pin = {}
289 289 contests.enabled.each do |contest|
290 290 contest.problems.available.each do |problem|
You need to be logged in to leave comments. Login now