# HG changeset patch # User jittat # Date 2008-05-09 08:29:26 # Node ID f40baf68cc551052dc2271efbd4faf615d6e48c9 # Parent 9f136d243b9c6533bcb4383d77ec650d20480d26 [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 diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -26,11 +26,18 @@ render :action => 'index' and return end - if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and - @user.site!=nil and @user.site.finished? - @submitted_test_request.errors.add_to_base('Contest is over.') - prepare_index_information - render :action => 'index' and return + if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' + if @user.site!=nil and @user.site.finished? + @submitted_test_request.errors.add_to_base('Contest is over.') + prepare_index_information + render :action => 'index' and return + end + + if !Configuration.allow_test_request(@user) + prepare_index_information + flash[:notice] = 'Test request is not allowed during the last 30 minutes' + redirect_to :action => 'index' and return + end end if @submitted_test_request.save diff --git a/app/models/configuration.rb b/app/models/configuration.rb --- a/app/models/configuration.rb +++ b/app/models/configuration.rb @@ -46,7 +46,16 @@ end return true end - + + def self.allow_test_request(user) + mode = get(SYSTEM_MODE_CONF_KEY) + if (mode=='contest') + return false if (user.site!=nil) and ((user.site.started==false) or + (user.site.time_left < 30.minutes)) + end + return false if mode=='analysis' + return true + end protected def self.read_config diff --git a/app/views/graders/list.html.haml b/app/views/graders/list.html.haml --- a/app/views/graders/list.html.haml +++ b/app/views/graders/list.html.haml @@ -1,5 +1,6 @@ - content_for :head do = stylesheet_link_tag 'graders' + %h2 (Under Experiments) diff --git a/app/views/test/index.html.erb b/app/views/test/index.html.erb --- a/app/views/test/index.html.erb +++ b/app/views/test/index.html.erb @@ -35,7 +35,7 @@ } -<% if Configuration.show_submitbox_to?(@user) %> +<% if Configuration.show_submitbox_to?(@user) and Configuration.allow_test_request(@user) %>
<%= error_messages_for 'submitted_test_request' %> <% form_for :test_request, nil,