Description:
Fixed Individual Contest confirmation
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r371:6d2e9920049d - - 2 files changed: 2 inserted, 2 deleted
@@ -147,97 +147,97 | |||||
|
147 | redirect_to :action => 'list' and return |
|
147 | redirect_to :action => 'list' and return |
|
148 | end |
|
148 | end |
|
149 | @user = User.find(session[:user_id]) |
|
149 | @user = User.find(session[:user_id]) |
|
150 | @submission = Submission.find(params[:id]) |
|
150 | @submission = Submission.find(params[:id]) |
|
151 | if @submission.user!=@user |
|
151 | if @submission.user!=@user |
|
152 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
152 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
153 | redirect_to :action => 'list' and return |
|
153 | redirect_to :action => 'list' and return |
|
154 | end |
|
154 | end |
|
155 | case_num = params[:num].to_i |
|
155 | case_num = params[:num].to_i |
|
156 | out_filename = output_filename(@user.login, |
|
156 | out_filename = output_filename(@user.login, |
|
157 | @submission.problem.name, |
|
157 | @submission.problem.name, |
|
158 | @submission.id, |
|
158 | @submission.id, |
|
159 | case_num) |
|
159 | case_num) |
|
160 | if !FileTest.exists?(out_filename) |
|
160 | if !FileTest.exists?(out_filename) |
|
161 | flash[:notice] = 'Output not found.' |
|
161 | flash[:notice] = 'Output not found.' |
|
162 | redirect_to :action => 'list' and return |
|
162 | redirect_to :action => 'list' and return |
|
163 | end |
|
163 | end |
|
164 |
|
164 | ||
|
165 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
165 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
166 | response.headers['Content-Type'] = "application/force-download" |
|
166 | response.headers['Content-Type'] = "application/force-download" |
|
167 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
167 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
168 | response.headers["X-Sendfile"] = out_filename |
|
168 | response.headers["X-Sendfile"] = out_filename |
|
169 | response.headers['Content-length'] = File.size(out_filename) |
|
169 | response.headers['Content-length'] = File.size(out_filename) |
|
170 | render :nothing => true |
|
170 | render :nothing => true |
|
171 | else |
|
171 | else |
|
172 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
172 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
173 | end |
|
173 | end |
|
174 | end |
|
174 | end |
|
175 |
|
175 | ||
|
176 | def error |
|
176 | def error |
|
177 | @user = User.find(session[:user_id]) |
|
177 | @user = User.find(session[:user_id]) |
|
178 | end |
|
178 | end |
|
179 |
|
179 | ||
|
180 | # announcement refreshing and hiding methods |
|
180 | # announcement refreshing and hiding methods |
|
181 |
|
181 | ||
|
182 | def announcements |
|
182 | def announcements |
|
183 | if params.has_key? 'recent' |
|
183 | if params.has_key? 'recent' |
|
184 | prepare_announcements(params[:recent]) |
|
184 | prepare_announcements(params[:recent]) |
|
185 | else |
|
185 | else |
|
186 | prepare_announcements |
|
186 | prepare_announcements |
|
187 | end |
|
187 | end |
|
188 | render(:partial => 'announcement', |
|
188 | render(:partial => 'announcement', |
|
189 | :collection => @announcements, |
|
189 | :collection => @announcements, |
|
190 | :locals => {:announcement_effect => true}) |
|
190 | :locals => {:announcement_effect => true}) |
|
191 | end |
|
191 | end |
|
192 |
|
192 | ||
|
193 | def confirm_contest_start |
|
193 | def confirm_contest_start |
|
194 | user = User.find(session[:user_id]) |
|
194 | user = User.find(session[:user_id]) |
|
195 |
- if request.method == |
|
195 | + if request.method == 'POST' |
|
196 | user.update_start_time |
|
196 | user.update_start_time |
|
197 | redirect_to :action => 'list' |
|
197 | redirect_to :action => 'list' |
|
198 | else |
|
198 | else |
|
199 | @contests = user.contests |
|
199 | @contests = user.contests |
|
200 | @user = user |
|
200 | @user = user |
|
201 | end |
|
201 | end |
|
202 | end |
|
202 | end |
|
203 |
|
203 | ||
|
204 | protected |
|
204 | protected |
|
205 |
|
205 | ||
|
206 | def prepare_announcements(recent=nil) |
|
206 | def prepare_announcements(recent=nil) |
|
207 | if GraderConfiguration.show_tasks_to?(@user) |
|
207 | if GraderConfiguration.show_tasks_to?(@user) |
|
208 | @announcements = Announcement.find_published(true) |
|
208 | @announcements = Announcement.find_published(true) |
|
209 | else |
|
209 | else |
|
210 | @announcements = Announcement.find_published |
|
210 | @announcements = Announcement.find_published |
|
211 | end |
|
211 | end |
|
212 | if recent!=nil |
|
212 | if recent!=nil |
|
213 | recent_id = recent.to_i |
|
213 | recent_id = recent.to_i |
|
214 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
214 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
215 | end |
|
215 | end |
|
216 | end |
|
216 | end |
|
217 |
|
217 | ||
|
218 | def prepare_list_information |
|
218 | def prepare_list_information |
|
219 | @user = User.find(session[:user_id]) |
|
219 | @user = User.find(session[:user_id]) |
|
220 | if not GraderConfiguration.multicontests? |
|
220 | if not GraderConfiguration.multicontests? |
|
221 | @problems = @user.available_problems |
|
221 | @problems = @user.available_problems |
|
222 | else |
|
222 | else |
|
223 | @contest_problems = @user.available_problems_group_by_contests |
|
223 | @contest_problems = @user.available_problems_group_by_contests |
|
224 | @problems = @user.available_problems |
|
224 | @problems = @user.available_problems |
|
225 | end |
|
225 | end |
|
226 | @prob_submissions = {} |
|
226 | @prob_submissions = {} |
|
227 | @problems.each do |p| |
|
227 | @problems.each do |p| |
|
228 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
228 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
229 | if sub!=nil |
|
229 | if sub!=nil |
|
230 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
230 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
231 | else |
|
231 | else |
|
232 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
232 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
233 | end |
|
233 | end |
|
234 | end |
|
234 | end |
|
235 | prepare_announcements |
|
235 | prepare_announcements |
|
236 | end |
|
236 | end |
|
237 |
|
237 | ||
|
238 | def check_viewability |
|
238 | def check_viewability |
|
239 | @user = User.find(session[:user_id]) |
|
239 | @user = User.find(session[:user_id]) |
|
240 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
240 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
241 | ((action_name=='submission') or (action_name=='submit')) |
|
241 | ((action_name=='submission') or (action_name=='submit')) |
|
242 | redirect_to :action => 'list' and return |
|
242 | redirect_to :action => 'list' and return |
|
243 | end |
|
243 | end |
@@ -1,16 +1,16 | |||||
|
1 | = user_title_bar(@user) |
|
1 | = user_title_bar(@user) |
|
2 |
|
2 | ||
|
3 | .announcementbox |
|
3 | .announcementbox |
|
4 | %span{:class => 'title'} |
|
4 | %span{:class => 'title'} |
|
5 | =t 'main.confirm_contest_start.box_title' |
|
5 | =t 'main.confirm_contest_start.box_title' |
|
6 | .announcement |
|
6 | .announcement |
|
7 | %center |
|
7 | %center |
|
8 | =t 'main.confirm_contest_start.contest_list' |
|
8 | =t 'main.confirm_contest_start.contest_list' |
|
9 | - @contests.each do |contest| |
|
9 | - @contests.each do |contest| |
|
10 | = contest.title |
|
10 | = contest.title |
|
11 | %br |
|
11 | %br |
|
12 |
|
12 | ||
|
13 | =t 'main.confirm_contest_start.timer_starts_after_click' |
|
13 | =t 'main.confirm_contest_start.timer_starts_after_click' |
|
14 |
|
14 | ||
|
15 |
- = form_tag :action => 'confirm_contest_start' |
|
15 | + = form_tag :action => 'confirm_contest_start' do |
|
16 | = submit_tag t('main.confirm_contest_start.start_button'), :confirm => t('main.confirm_contest_start.start_button_confirm') |
|
16 | = submit_tag t('main.confirm_contest_start.start_button'), :confirm => t('main.confirm_contest_start.start_button_confirm') |
You need to be logged in to leave comments.
Login now