Description:
add selectable checker (for now, only 'text' and 'float') in the problem import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r402:7f3e18dca393 - - 4 files changed: 25 inserted, 3 deleted
@@ -40,12 +40,13 | |||
|
40 | 40 | |
|
41 | 41 | importer = TestdataImporter.new(problem) |
|
42 | 42 | |
|
43 | 43 | if not importer.import_from_file(import_params[:file], |
|
44 | 44 | import_params[:time_limit], |
|
45 | 45 | import_params[:memory_limit], |
|
46 | + import_params[:checker_name], | |
|
46 | 47 | import_to_db) |
|
47 | 48 | problem.errors.add_to_base('Import error.') |
|
48 | 49 | end |
|
49 | 50 | |
|
50 | 51 | return problem, importer.log_msg |
|
51 | 52 | end |
@@ -87,12 +88,17 | |||
|
87 | 88 | end |
|
88 | 89 | |
|
89 | 90 | if params[:file]==nil or params[:file]=='' |
|
90 | 91 | problem.errors.add_to_base('No testdata file.') |
|
91 | 92 | end |
|
92 | 93 | |
|
94 | + checker_name = 'text' | |
|
95 | + if ['text','float'].include? params[:checker] | |
|
96 | + checker_name = params[:checker] | |
|
97 | + end | |
|
98 | + | |
|
93 | 99 | file = params[:file] |
|
94 | 100 | |
|
95 | 101 | if !problem.errors.empty? |
|
96 | 102 | return nil, problem |
|
97 | 103 | end |
|
98 | 104 | |
@@ -103,12 +109,13 | |||
|
103 | 109 | problem.full_name = params[:name] |
|
104 | 110 | end |
|
105 | 111 | |
|
106 | 112 | return [{ |
|
107 | 113 | :time_limit => time_limit, |
|
108 | 114 | :memory_limit => memory_limit, |
|
109 | - :file => file | |
|
115 | + :file => file, | |
|
116 | + :checker_name => checker_name | |
|
110 | 117 | }, |
|
111 | 118 | problem] |
|
112 | 119 | end |
|
113 | 120 | |
|
114 | 121 | end |
@@ -29,12 +29,25 | |||
|
29 | 29 | In .zip, .tgz, tar.gz, .tar format. |
|
30 | 30 | It should includes inputs (e.g., 1.in, 2a.in, 2b.in) |
|
31 | 31 | and solutions (e.g., 1.sol, 2a.sol, 2b.sol). |
|
32 | 32 | %br/ |
|
33 | 33 | You may put task description in *.html for raw html |
|
34 | 34 | and *.md or *.markdown for markdown. |
|
35 | + %br/ | |
|
36 | + You may also put a pdf file for the task description | |
|
37 | + %tr | |
|
38 | + %td Checker: | |
|
39 | + %td= select_tag 'checker', options_for_select([['Text checker','text'],['Float checker','float']], 'text') | |
|
40 | + %tr | |
|
41 | + %td | |
|
42 | + %td | |
|
43 | + %span{:class => 'help'} | |
|
44 | + "Text" checker checks if the text (including numbers) is the same, ignoring any whitespace | |
|
45 | + %br/ | |
|
46 | + "Float" checker checks if all numbers is within EPSILON error using formula |a-b| < EPSILON * max(|a|,|b|) | |
|
47 | + | |
|
35 | 48 | - if @allow_test_pair_import |
|
36 | 49 | %tr |
|
37 | 50 | %td |
|
38 | 51 | %td |
|
39 | 52 | = check_box_tag 'import_to_db' |
|
40 | 53 | Import test data to database (for a test-pair task) |
@@ -47,12 +47,12 | |||
|
47 | 47 | " -t #{time_limit} -m #{memory_limit}" |
|
48 | 48 | |
|
49 | 49 | output = `#{cmd}` |
|
50 | 50 | |
|
51 | 51 | Dir.chdir(cur_dir) |
|
52 | 52 | |
|
53 | - return output | |
|
53 | + return "import CMD: #{cmd}\n" + output | |
|
54 | 54 | end |
|
55 | 55 | return '' |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | end |
@@ -8,21 +8,23 | |||
|
8 | 8 | @problem = problem |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | def import_from_file(tempfile, |
|
12 | 12 | time_limit, |
|
13 | 13 | memory_limit, |
|
14 | + checker_name='text', | |
|
14 | 15 | import_to_db=false) |
|
15 | 16 | |
|
16 | 17 | dirname = extract(tempfile) |
|
17 | 18 | return false if not dirname |
|
18 | 19 | if not import_to_db |
|
19 | 20 | @log_msg = GraderScript.call_import_problem(@problem.name, |
|
20 | 21 | dirname, |
|
21 | 22 | time_limit, |
|
22 |
- memory_limit |
|
|
23 | + memory_limit, | |
|
24 | + checker_name) | |
|
23 | 25 | else |
|
24 | 26 | # Import test data to test pairs. |
|
25 | 27 | |
|
26 | 28 | @problem.test_pairs.clear |
|
27 | 29 | if import_test_pairs(dirname) |
|
28 | 30 | test_pair_count = TestPair.count :conditions => "problem_id = #{@problem.id}" |
You need to be logged in to leave comments.
Login now