diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -156,6 +156,14 @@ render :action => 'import' and return end + old_problem = Problem.find_by_name(@problem.name) + if old_problem!=nil + old_problem.full_name = @problem.full_name + @problem = old_problem + + flash[:notice] = "The test data has been replaced for problem #{@problem.name}" + end + @problem.save @log = import_log end 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 @@ -101,7 +101,7 @@ end @test_requests = [] @user.test_requests.each do |ts| - if ts.problem.available + if ts.problem and ts.problem.available @test_requests << ts end end diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -3,8 +3,9 @@ belongs_to :description validates_presence_of :name + validates_format_of :name, :with => /^\w+$/ validates_presence_of :full_name - + def self.find_available_problems find(:all, :conditions => {:available => true}, :order => "date_added DESC") end 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 @@ -4,6 +4,9 @@ %h1 Grader information += link_to '[Refresh]', :action => 'list' +%br/ + .submitbox .item Grader control: diff --git a/lib/testdata_importer.rb b/lib/testdata_importer.rb --- a/lib/testdata_importer.rb +++ b/lib/testdata_importer.rb @@ -42,7 +42,7 @@ elsif ext=='.tar' cmd = "tar -xvf #{testdata_filename} -C #{extract_dir}" elsif ext=='.zip' - cmd = "unzip #{testdata_filename} -d #{extract_dir}" + cmd = "unzip -o #{testdata_filename} -d #{extract_dir}" else return nil end