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 @@ -147,10 +147,14 @@ end def import + @allow_test_pair_import = allow_test_pair_import? end def do_import old_problem = Problem.find_by_name(params[:name]) + if !allow_test_pair_import? and params.has_key? :import_to_db + params.delete :import_to_db + end @problem, import_log = Problem.create_from_import_form_params(params, old_problem) @@ -167,6 +171,14 @@ ################################## protected + def allow_test_pair_import? + if defined? ALLOW_TEST_PAIR_IMPORT + return ALLOW_TEST_PAIR_IMPORT + else + return false + end + end + def change_date_added problems = get_problems_from_params year = params[:date_added][:year].to_i diff --git a/app/views/problems/import.html.haml b/app/views/problems/import.html.haml --- a/app/views/problems/import.html.haml +++ b/app/views/problems/import.html.haml @@ -33,11 +33,12 @@ %br/ You may put task description in *.html for raw html and *.md or *.markdown for markdown. - %tr - %td - %td - = check_box_tag 'import_to_db' - Import test data to database (for a test-pair task) + - if @allow_test_pair_import + %tr + %td + %td + = check_box_tag 'import_to_db' + Import test data to database (for a test-pair task) %tr %td Time limit: %td diff --git a/config/environment.rb.SAMPLE b/config/environment.rb.SAMPLE --- a/config/environment.rb.SAMPLE +++ b/config/environment.rb.SAMPLE @@ -90,8 +90,9 @@ # TODO: change this to where results are kept. GRADING_RESULT_DIR = 'RESULT-DIR' -# Uncomment so that configuration is read only once when the server is loaded -# Configuration.enable_caching +# Change this to allow importing testdata into database as test-pairs. +# This is mainly for Code Jom contest. +ALLOW_TEST_PAIR_IMPORT = false # Uncomment so that the system validates user e-mails # VALIDATE_USER_EMAILS = true @@ -99,3 +100,6 @@ # Uncomment so that Apache X-Sendfile is used when delivering files # (e.g., in /tasks/view). # USE_APACHE_XSENDFILE = true + +# Uncomment so that configuration is read only once when the server is loaded +# Configuration.enable_caching