diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -43,6 +43,7 @@ if not importer.import_from_file(import_params[:file], import_params[:time_limit], import_params[:memory_limit], + import_params[:checker_name], import_to_db) problem.errors.add_to_base('Import error.') end @@ -90,6 +91,11 @@ problem.errors.add_to_base('No testdata file.') end + checker_name = 'text' + if ['text','float'].include? params[:checker] + checker_name = params[:checker] + end + file = params[:file] if !problem.errors.empty? @@ -106,7 +112,8 @@ return [{ :time_limit => time_limit, :memory_limit => memory_limit, - :file => file + :file => file, + :checker_name => checker_name }, problem] end 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 @@ -32,6 +32,19 @@ %br/ You may put task description in *.html for raw html and *.md or *.markdown for markdown. + %br/ + You may also put a pdf file for the task description + %tr + %td Checker: + %td= select_tag 'checker', options_for_select([['Text checker','text'],['Float checker','float']], 'text') + %tr + %td + %td + %span{:class => 'help'} + "Text" checker checks if the text (including numbers) is the same, ignoring any whitespace + %br/ + "Float" checker checks if all numbers is within EPSILON error using formula |a-b| < EPSILON * max(|a|,|b|) + - if @allow_test_pair_import %tr %td diff --git a/lib/grader_script.rb b/lib/grader_script.rb --- a/lib/grader_script.rb +++ b/lib/grader_script.rb @@ -50,7 +50,7 @@ Dir.chdir(cur_dir) - return output + return "import CMD: #{cmd}\n" + output end return '' end diff --git a/lib/testdata_importer.rb b/lib/testdata_importer.rb --- a/lib/testdata_importer.rb +++ b/lib/testdata_importer.rb @@ -11,6 +11,7 @@ def import_from_file(tempfile, time_limit, memory_limit, + checker_name='text', import_to_db=false) dirname = extract(tempfile) @@ -19,7 +20,8 @@ @log_msg = GraderScript.call_import_problem(@problem.name, dirname, time_limit, - memory_limit) + memory_limit, + checker_name) else # Import test data to test pairs.