Description:
shows contest start confirmation for indv contest
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r302:77a5c6e76df3 - - 4 files changed: 45 inserted, 4 deleted
@@ -0,0 +1,12 | |||||
|
|
1 | + = user_title_bar(@user) | ||
|
|
2 | + | ||
|
|
3 | + %center | ||
|
|
4 | + You will participate in contest: | ||
|
|
5 | + - @contests.each do |contest| | ||
|
|
6 | + = contest.title | ||
|
|
7 | + %br | ||
|
|
8 | + | ||
|
|
9 | + The timer will start after you click the start button. | ||
|
|
10 | + | ||
|
|
11 | + - form_tag :action => 'confirm_contest_start', :method => 'post' do | ||
|
|
12 | + = submit_tag 'Start!', :confirm => 'Are you sure?' |
@@ -3,11 +3,15 | |||||
|
3 | before_filter :authenticate, :except => [:index, :login] |
|
3 | before_filter :authenticate, :except => [:index, :login] |
|
4 | before_filter :check_viewability, :except => [:index, :login] |
|
4 | before_filter :check_viewability, :except => [:index, :login] |
|
5 |
|
5 | ||
|
6 |
- append_before_filter :update |
|
6 | + append_before_filter :confirm_and_update_start_time, |
|
|
7 | + :except => [:index, | ||
|
|
8 | + :login, | ||
|
|
9 | + :confirm_contest_start] | ||
|
7 |
|
10 | ||
|
8 | # to prevent log in box to be shown when user logged out of the |
|
11 | # to prevent log in box to be shown when user logged out of the |
|
9 | # system only in some tab |
|
12 | # system only in some tab |
|
10 |
- prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
13 | + prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
|
14 | + :only => [:announcements] | ||
|
11 |
|
15 | ||
|
12 | # COMMENTED OUT: filter in each action instead |
|
16 | # COMMENTED OUT: filter in each action instead |
|
13 | # before_filter :verify_time_limit, :only => [:submit] |
|
17 | # before_filter :verify_time_limit, :only => [:submit] |
@@ -183,6 +187,17 | |||||
|
183 | :locals => {:announcement_effect => true}) |
|
187 | :locals => {:announcement_effect => true}) |
|
184 | end |
|
188 | end |
|
185 |
|
189 | ||
|
|
190 | + def confirm_contest_start | ||
|
|
191 | + user = User.find(session[:user_id]) | ||
|
|
192 | + if request.method == :post | ||
|
|
193 | + user.update_start_time | ||
|
|
194 | + redirect_to :action => 'list' | ||
|
|
195 | + else | ||
|
|
196 | + @contests = user.contests | ||
|
|
197 | + @user = user | ||
|
|
198 | + end | ||
|
|
199 | + end | ||
|
|
200 | + | ||
|
186 | protected |
|
201 | protected |
|
187 |
|
202 | ||
|
188 | def prepare_announcements(recent=nil) |
|
203 | def prepare_announcements(recent=nil) |
@@ -334,8 +349,13 | |||||
|
334 | } |
|
349 | } |
|
335 | end |
|
350 | end |
|
336 |
|
351 | ||
|
337 |
- def update |
|
352 | + def confirm_and_update_start_time |
|
338 | user = User.find(session[:user_id]) |
|
353 | user = User.find(session[:user_id]) |
|
|
354 | + if (Configuration.indv_contest_mode? and | ||
|
|
355 | + Configuration['contest.confirm_indv_contest_start'] and | ||
|
|
356 | + !user.contest_started?) | ||
|
|
357 | + redirect_to :action => 'confirm_contest_start' and return | ||
|
|
358 | + end | ||
|
339 | user.update_start_time |
|
359 | user.update_start_time |
|
340 | end |
|
360 | end |
|
341 |
|
361 |
@@ -172,7 +172,10 | |||||
|
172 | end |
|
172 | end |
|
173 |
|
173 | ||
|
174 | def contest_started? |
|
174 | def contest_started? |
|
175 | - if Configuration.contest_mode? |
|
175 | + if Configuration.indv_contest_mode? |
|
|
176 | + stat = self.contest_stat | ||
|
|
177 | + return ((stat != nil) and (stat.started_at != nil)) | ||
|
|
178 | + elsif Configuration.contest_mode? | ||
|
176 | return true if site==nil |
|
179 | return true if site==nil |
|
177 | return site.started |
|
180 | return site.started |
|
178 | else |
|
181 | else |
@@ -101,6 +101,12 | |||||
|
101 | :key => 'system.multicontests', |
|
101 | :key => 'system.multicontests', |
|
102 | :value_type => 'boolean', |
|
102 | :value_type => 'boolean', |
|
103 | :default_value => 'false' |
|
103 | :default_value => 'false' |
|
|
104 | + }, | ||
|
|
105 | + | ||
|
|
106 | + { | ||
|
|
107 | + :key => 'contest.confirm_indv_contest_start', | ||
|
|
108 | + :value_type => 'boolean', | ||
|
|
109 | + :default_value => 'false' | ||
|
104 | } |
|
110 | } |
|
105 | ] |
|
111 | ] |
|
106 |
|
112 |
You need to be logged in to leave comments.
Login now