Description:
contest ends after user is dead, added status xml for visualization
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r262:9f069571bd87 - - 4 files changed: 33 inserted, 7 deleted
@@ -0,0 +1,17 | |||||
|
|
1 | + <?xml version="1.0"?> | ||
|
|
2 | + <codejom> | ||
|
|
3 | + <% @dead_users.each do |user| %> | ||
|
|
4 | + <node> | ||
|
|
5 | + <name><%= user.login %></name> | ||
|
|
6 | + <depth>100</depth> | ||
|
|
7 | + </node> | ||
|
|
8 | + <% end %> | ||
|
|
9 | + <% @levels.each do |level| %> | ||
|
|
10 | + <% @level_users[level].each do |user| %> | ||
|
|
11 | + <node> | ||
|
|
12 | + <name><%= user.login %></name> | ||
|
|
13 | + <depth><%= level %></depth> | ||
|
|
14 | + </node> | ||
|
|
15 | + <% end %> | ||
|
|
16 | + <% end %> | ||
|
|
17 | + </codejom> |
@@ -3,36 +3,31 | |||||
|
3 | def index |
|
3 | def index |
|
4 | if not SHOW_CONTEST_STATUS |
|
4 | if not SHOW_CONTEST_STATUS |
|
5 | render :status => 403 and return |
|
5 | render :status => 403 and return |
|
6 | end |
|
6 | end |
|
7 |
|
7 | ||
|
8 | problem_count = Problem.available_problem_count |
|
8 | problem_count = Problem.available_problem_count |
|
9 |
|
9 | ||
|
10 | @dead_users = [] |
|
10 | @dead_users = [] |
|
11 | @level_users = {} |
|
11 | @level_users = {} |
|
12 | @levels = (0..CODEJOM_MAX_ALIVE_LEVEL) |
|
12 | @levels = (0..CODEJOM_MAX_ALIVE_LEVEL) |
|
13 | @levels.each { |l| @level_users[l] = [] } |
|
13 | @levels.each { |l| @level_users[l] = [] } |
|
14 | User.find(:all).find_all{|user| not user.admin? }.each do |user| |
|
14 | User.find(:all).find_all{|user| not user.admin? }.each do |user| |
|
15 | - if user.codejom_status==nil |
|
||
|
16 |
|
|
15 | user.update_codejom_status |
|
17 |
|
|
16 | user.codejom_status(true) # reload |
|
18 | - end |
|
||
|
19 |
|
17 | ||
|
20 | if not user.codejom_status.alive |
|
18 | if not user.codejom_status.alive |
|
21 | @dead_users << user |
|
19 | @dead_users << user |
|
22 | else |
|
20 | else |
|
23 | @level_users[user.codejom_level] << user |
|
21 | @level_users[user.codejom_level] << user |
|
24 | end |
|
22 | end |
|
25 | end |
|
23 | end |
|
26 |
|
24 | ||
|
27 | respond_to do |format| |
|
25 | respond_to do |format| |
|
28 | format.html |
|
26 | format.html |
|
29 | format.xml do |
|
27 | format.xml do |
|
30 | - render :xml => { |
|
28 | + render :template => 'statuses/index.xml.erb' |
|
31 | - :levels => @level_users, |
|
||
|
32 | - :dead_users => @dead_users |
|
||
|
33 | - } |
|
||
|
34 | end |
|
29 | end |
|
35 | end |
|
30 | end |
|
36 | end |
|
31 | end |
|
37 |
|
32 | ||
|
38 | end |
|
33 | end |
@@ -69,30 +69,38 | |||||
|
69 | nil |
|
69 | nil |
|
70 | end |
|
70 | end |
|
71 | end |
|
71 | end |
|
72 |
|
72 | ||
|
73 | def user_title_bar(user) |
|
73 | def user_title_bar(user) |
|
74 | header = '' |
|
74 | header = '' |
|
75 | time_left = '' |
|
75 | time_left = '' |
|
76 |
|
76 | ||
|
77 | # |
|
77 | # |
|
78 | # if the contest is over |
|
78 | # if the contest is over |
|
79 | if Configuration.time_limit_mode? |
|
79 | if Configuration.time_limit_mode? |
|
80 | if user.contest_finished? |
|
80 | if user.contest_finished? |
|
|
81 | + if (user.codejom_status) and (not user.codejom_status.alive) | ||
|
|
82 | + header = <<CONTEST_OVER | ||
|
|
83 | + <tr><td colspan="2" align="center"> | ||
|
|
84 | + <span class="contest-over-msg">BYE-BYE. YOU ARE DEAD</span> | ||
|
|
85 | + </td></tr> | ||
|
|
86 | + CONTEST_OVER | ||
|
|
87 | + else | ||
|
81 | header = <<CONTEST_OVER |
|
88 | header = <<CONTEST_OVER |
|
82 | <tr><td colspan="2" align="center"> |
|
89 | <tr><td colspan="2" align="center"> |
|
83 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
90 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
84 | </td></tr> |
|
91 | </td></tr> |
|
85 | CONTEST_OVER |
|
92 | CONTEST_OVER |
|
86 | end |
|
93 | end |
|
|
94 | + end | ||
|
87 | if !user.contest_started? |
|
95 | if !user.contest_started? |
|
88 | time_left = " " + (t 'title_bar.contest_not_started') |
|
96 | time_left = " " + (t 'title_bar.contest_not_started') |
|
89 | else |
|
97 | else |
|
90 | time_left = " " + (t 'title_bar.remaining_time') + |
|
98 | time_left = " " + (t 'title_bar.remaining_time') + |
|
91 | " #{format_short_duration(user.contest_time_left)}" |
|
99 | " #{format_short_duration(user.contest_time_left)}" |
|
92 | end |
|
100 | end |
|
93 | end |
|
101 | end |
|
94 |
|
102 | ||
|
95 | # |
|
103 | # |
|
96 | # if the contest is in the anaysis mode |
|
104 | # if the contest is in the anaysis mode |
|
97 | if Configuration.analysis_mode? |
|
105 | if Configuration.analysis_mode? |
|
98 | header = <<ANALYSISMODE |
|
106 | header = <<ANALYSISMODE |
@@ -200,25 +200,31 | |||||
|
200 | else |
|
200 | else |
|
201 | return finish_time - current_time |
|
201 | return finish_time - current_time |
|
202 | end |
|
202 | end |
|
203 | end |
|
203 | end |
|
204 | else |
|
204 | else |
|
205 | return nil |
|
205 | return nil |
|
206 | end |
|
206 | end |
|
207 | end |
|
207 | end |
|
208 |
|
208 | ||
|
209 | def contest_finished? |
|
209 | def contest_finished? |
|
210 | if Configuration.contest_mode? |
|
210 | if Configuration.contest_mode? |
|
211 | return false if site==nil |
|
211 | return false if site==nil |
|
212 |
- |
|
212 | + if site.finished? |
|
|
213 | + return true | ||
|
|
214 | + elsif codejom_status!=nil | ||
|
|
215 | + return (not codejom_status.alive) | ||
|
|
216 | + else | ||
|
|
217 | + return false | ||
|
|
218 | + end | ||
|
213 | elsif Configuration.indv_contest_mode? |
|
219 | elsif Configuration.indv_contest_mode? |
|
214 | time_limit = Configuration.contest_time_limit |
|
220 | time_limit = Configuration.contest_time_limit |
|
215 |
|
221 | ||
|
216 | return false if contest_stat==nil |
|
222 | return false if contest_stat==nil |
|
217 |
|
223 | ||
|
218 | return contest_time_left == 0 |
|
224 | return contest_time_left == 0 |
|
219 | else |
|
225 | else |
|
220 | return false |
|
226 | return false |
|
221 | end |
|
227 | end |
|
222 | end |
|
228 | end |
|
223 |
|
229 | ||
|
224 | def contest_started? |
|
230 | def contest_started? |
You need to be logged in to leave comments.
Login now