Description:
[web] test request stops at 30 min before end, auto refresh grader process status git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@258 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r128:f40baf68cc55 - - 4 files changed: 20 inserted, 3 deleted

@@ -17,31 +17,38
17 end
17 end
18
18
19 def submit
19 def submit
20 @user = User.find(session[:user_id])
20 @user = User.find(session[:user_id])
21
21
22 @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request])
22 @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request])
23
23
24 if @submitted_test_request.errors.length != 0
24 if @submitted_test_request.errors.length != 0
25 prepare_index_information
25 prepare_index_information
26 render :action => 'index' and return
26 render :action => 'index' and return
27 end
27 end
28
28
29 - if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and
29 + if Configuration[SYSTEM_MODE_CONF_KEY]=='contest'
30 - @user.site!=nil and @user.site.finished?
30 + if @user.site!=nil and @user.site.finished?
31 @submitted_test_request.errors.add_to_base('Contest is over.')
31 @submitted_test_request.errors.add_to_base('Contest is over.')
32 prepare_index_information
32 prepare_index_information
33 render :action => 'index' and return
33 render :action => 'index' and return
34 end
34 end
35
35
36 + if !Configuration.allow_test_request(@user)
37 + prepare_index_information
38 + flash[:notice] = 'Test request is not allowed during the last 30 minutes'
39 + redirect_to :action => 'index' and return
40 + end
41 + end
42 +
36 if @submitted_test_request.save
43 if @submitted_test_request.save
37 redirect_to :action => 'index'
44 redirect_to :action => 'index'
38 else
45 else
39 prepare_index_information
46 prepare_index_information
40 render :action => 'index'
47 render :action => 'index'
41 end
48 end
42 end
49 end
43
50
44 def read
51 def read
45 user = User.find(session[:user_id])
52 user = User.find(session[:user_id])
46 begin
53 begin
47 test_request = TestRequest.find(params[:id])
54 test_request = TestRequest.find(params[:id])
@@ -38,24 +38,33
38 end
38 end
39 return true
39 return true
40 end
40 end
41
41
42 def self.show_tasks_to?(user)
42 def self.show_tasks_to?(user)
43 mode = get(SYSTEM_MODE_CONF_KEY)
43 mode = get(SYSTEM_MODE_CONF_KEY)
44 if (mode=='contest')
44 if (mode=='contest')
45 return false if (user.site!=nil) and (user.site.started==false)
45 return false if (user.site!=nil) and (user.site.started==false)
46 end
46 end
47 return true
47 return true
48 end
48 end
49
49
50 + def self.allow_test_request(user)
51 + mode = get(SYSTEM_MODE_CONF_KEY)
52 + if (mode=='contest')
53 + return false if (user.site!=nil) and ((user.site.started==false) or
54 + (user.site.time_left < 30.minutes))
55 + end
56 + return false if mode=='analysis'
57 + return true
58 + end
50
59
51 protected
60 protected
52 def self.read_config
61 def self.read_config
53 @@configurations = {}
62 @@configurations = {}
54 Configuration.find(:all).each do |conf|
63 Configuration.find(:all).each do |conf|
55 key = conf.key
64 key = conf.key
56 val = conf.value
65 val = conf.value
57 case conf.value_type
66 case conf.value_type
58 when 'string'
67 when 'string'
59 @@configurations[key] = val
68 @@configurations[key] = val
60
69
61 when 'integer'
70 when 'integer'
@@ -1,14 +1,15
1 - content_for :head do
1 - content_for :head do
2 = stylesheet_link_tag 'graders'
2 = stylesheet_link_tag 'graders'
3 + <meta http-equiv ="refresh" content="10"/>
3
4
4 %h2 (Under Experiments)
5 %h2 (Under Experiments)
5
6
6 - form_for :clear, nil, :url => {:action => 'clear_all'} do |f|
7 - form_for :clear, nil, :url => {:action => 'clear_all'} do |f|
7 = submit_tag 'Clear all data'
8 = submit_tag 'Clear all data'
8
9
9 Last task:
10 Last task:
10 = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task'
11 = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task'
11
12
12 %br/
13 %br/
13
14
14 Last test_request:
15 Last test_request:
@@ -26,25 +26,25
26 for(i=0; i<old_len; i++)
26 for(i=0; i<old_len; i++)
27 submissionSelect.remove(0);
27 submissionSelect.remove(0);
28 for(i=count; i>=1; i--) {
28 for(i=count; i>=1; i--) {
29 try {
29 try {
30 submissionSelect.add(new Option(""+i,""+i,false,false),null);
30 submissionSelect.add(new Option(""+i,""+i,false,false),null);
31 } catch(ex) {
31 } catch(ex) {
32 submissionSelect.add(new Option(""+i,""+i,false,false));
32 submissionSelect.add(new Option(""+i,""+i,false,false));
33 }
33 }
34 }
34 }
35 }
35 }
36 </script>
36 </script>
37
37
38 - <% if Configuration.show_submitbox_to?(@user) %>
38 + <% if Configuration.show_submitbox_to?(@user) and Configuration.allow_test_request(@user) %>
39 <div class="submitbox">
39 <div class="submitbox">
40 <%= error_messages_for 'submitted_test_request' %>
40 <%= error_messages_for 'submitted_test_request' %>
41 <% form_for :test_request, nil,
41 <% form_for :test_request, nil,
42 :url => { :action => 'submit'},
42 :url => { :action => 'submit'},
43 :html => { :multipart => true } do |f| %>
43 :html => { :multipart => true } do |f| %>
44 <table>
44 <table>
45 <tr>
45 <tr>
46 <td>Task:</td>
46 <td>Task:</td>
47 <td>
47 <td>
48 <%= select(:test_request,
48 <%= select(:test_request,
49 :problem_id,
49 :problem_id,
50 @problems.collect {|p| [p.name, p.id]}, {},
50 @problems.collect {|p| [p.name, p.id]}, {},
You need to be logged in to leave comments. Login now