Description:
[web] confirm when start contest, downloading task description through apache
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@260 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r130:f343b8fb7d21 - - 3 files changed: 12 inserted, 4 deleted
@@ -8,12 +8,22 | |||||
|
8 |
|
8 | ||
|
9 | def list |
|
9 | def list |
|
10 | @problems = Problem.find_available_problems |
|
10 | @problems = Problem.find_available_problems |
|
11 | @user = User.find(session[:user_id]) |
|
11 | @user = User.find(session[:user_id]) |
|
12 | end |
|
12 | end |
|
13 |
|
13 | ||
|
|
14 | + def view | ||
|
|
15 | + file_name = "#{RAILS_ROOT}/data/tasks/#{params[:file]}" | ||
|
|
16 | + if !FileTest.exists?(file_name) | ||
|
|
17 | + redirect_to :action => 'index' and return | ||
|
|
18 | + end | ||
|
|
19 | + # ask Apache to send the file | ||
|
|
20 | + response.headers['X-Sendfile'] = file_name | ||
|
|
21 | + render :nothing => true | ||
|
|
22 | + end | ||
|
|
23 | + | ||
|
14 | protected |
|
24 | protected |
|
15 |
|
25 | ||
|
16 | def check_viewability |
|
26 | def check_viewability |
|
17 | user = User.find(session[:user_id]) |
|
27 | user = User.find(session[:user_id]) |
|
18 | if user==nil or !Configuration.show_tasks_to?(user) |
|
28 | if user==nil or !Configuration.show_tasks_to?(user) |
|
19 | redirect_to :controller => 'main', :action => 'list' |
|
29 | redirect_to :controller => 'main', :action => 'list' |
@@ -52,13 +52,13 | |||||
|
52 | if (mode=='contest') |
|
52 | if (mode=='contest') |
|
53 | return false if (user.site!=nil) and ((user.site.started!=true) or (user.site.time_left < 30.minutes)) |
|
53 | return false if (user.site!=nil) and ((user.site.started!=true) or (user.site.time_left < 30.minutes)) |
|
54 | end |
|
54 | end |
|
55 | return false if mode=='analysis' |
|
55 | return false if mode=='analysis' |
|
56 | return true |
|
56 | return true |
|
57 | end |
|
57 | end |
|
58 | - |
|
58 | + |
|
59 | protected |
|
59 | protected |
|
60 | def self.read_config |
|
60 | def self.read_config |
|
61 | @@configurations = {} |
|
61 | @@configurations = {} |
|
62 | Configuration.find(:all).each do |conf| |
|
62 | Configuration.find(:all).each do |conf| |
|
63 | key = conf.key |
|
63 | key = conf.key |
|
64 | val = conf.value |
|
64 | val = conf.value |
@@ -14,9 +14,7 | |||||
|
14 | - form_tag :action => 'start' do |
|
14 | - form_tag :action => 'start' do |
|
15 | When you're ready, you can click the button below to start the contest. |
|
15 | When you're ready, you can click the button below to start the contest. |
|
16 | %br/ |
|
16 | %br/ |
|
17 | Please make sure that the contestants are ready. |
|
17 | Please make sure that the contestants are ready. |
|
18 | After the contest is started, it <b>cannot</b> be paused or stopped. |
|
18 | After the contest is started, it <b>cannot</b> be paused or stopped. |
|
19 | %br/ |
|
19 | %br/ |
|
20 | - = submit_tag 'Start the Contest.' |
|
20 | + = submit_tag 'Start the Contest.', :onclick => "return confirm('Are you sure?');" |
|
21 | - |
|
||
|
22 | - |
|
You need to be logged in to leave comments.
Login now