diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -180,8 +180,13 @@ # actions for Code Jom # def download_input + user = User.find(session[:user_id]) + + if Configuration.time_limit_mode? and user.contest_finished? + redirect_to :action => 'list' and return + end + problem = Problem.find(params[:id]) - user = User.find(session[:user_id]) if user.can_request_new_test_pair_for? problem assignment = user.get_new_test_pair_assignment_for problem assignment.save @@ -202,6 +207,10 @@ user = User.find(session[:user_id]) recent_assignment = user.get_recent_test_pair_assignment_for problem + if Configuration.time_limit_mode? and user.contest_finished? + redirect_to :action => 'list' and return + end + if recent_assignment == nil flash[:notice] = 'You have not requested for any input data for this problem. Please download an input first.' session[:current_problem_id] = problem.id diff --git a/app/views/main/_problem.html.haml b/app/views/main/_problem.html.haml --- a/app/views/main/_problem.html.haml +++ b/app/views/main/_problem.html.haml @@ -1,15 +1,20 @@ .problem-panel{:id => "problem-panel-#{problem.id}", :style => "#{(problem.id != @current_problem_id) ? "display:none" : ""}"} - .problem-form{:id => "problem-form-#{problem.id}"} - - form_tag({ :action => 'download_input', :id => problem.id }, :method => :post) do - %b Input: - %input{:type => "submit", :value => "Download input", :onclick => "CodejomTimeout.updateTimeoutAfterDownloadClick(#{problem.id}); return true;"} - %span{:id => "problem-timing-message-#{problem.id}"} - = "After downloading, you have #{TEST_ASSIGNMENT_EXPIRATION_DURATION/60} minutes to submit." - %div{:id => "problem-submission-form-#{problem.id}"} - - form_tag({ :action => 'submit_solution', :id => problem.id }, :method => :post, :multipart => true) do - %b Submit output: - %input{:type => "file", :name => "file"} - %input{:type => "submit", :value => "Submit solution"} + - if (not Configuration.time_limit_mode?) or (not @user.contest_finished?) + .problem-form{:id => "problem-form-#{problem.id}"} + - form_tag({ :action => 'download_input', :id => problem.id }, :method => :post) do + %b Input: + %input{:type => "submit", :value => "Download input", :onclick => "CodejomTimeout.updateTimeoutAfterDownloadClick(#{problem.id}); return true;"} + %span{:id => "problem-timing-message-#{problem.id}"} + = "After downloading, you have #{TEST_ASSIGNMENT_EXPIRATION_DURATION/60} minutes to submit." + %div{:id => "problem-submission-form-#{problem.id}"} + - form_tag({ :action => 'submit_solution', :id => problem.id }, :method => :post, :multipart => true) do + %b Submit output: + %input{:type => "file", :name => "file"} + %input{:type => "submit", :value => "Submit solution"} + - else + .problem-form + %p + The contest is over, you can view the tasks, but you can no longer submit. .problem-description - if problem.description!=nil diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20100126170609) do +ActiveRecord::Schema.define(:version => 20100129041917) do create_table "announcements", :force => true do |t| t.string "author" @@ -186,8 +186,8 @@ create_table "test_pairs", :force => true do |t| t.integer "problem_id" - t.text "input" - t.text "solution" + t.text "input", :limit => 16777215 + t.text "solution", :limit => 16777215 t.datetime "created_at" t.datetime "updated_at" t.integer "number"