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 | importer = TestdataImporter.new(problem) |
|
41 | importer = TestdataImporter.new(problem) |
|
42 |
|
42 | ||
|
43 | if not importer.import_from_file(import_params[:file], |
|
43 | if not importer.import_from_file(import_params[:file], |
|
44 | import_params[:time_limit], |
|
44 | import_params[:time_limit], |
|
45 | import_params[:memory_limit], |
|
45 | import_params[:memory_limit], |
|
|
46 | + import_params[:checker_name], | ||
|
46 | import_to_db) |
|
47 | import_to_db) |
|
47 | problem.errors.add_to_base('Import error.') |
|
48 | problem.errors.add_to_base('Import error.') |
|
48 | end |
|
49 | end |
|
49 |
|
50 | ||
|
50 | return problem, importer.log_msg |
|
51 | return problem, importer.log_msg |
|
51 | end |
|
52 | end |
@@ -87,12 +88,17 | |||||
|
87 | end |
|
88 | end |
|
88 |
|
89 | ||
|
89 | if params[:file]==nil or params[:file]=='' |
|
90 | if params[:file]==nil or params[:file]=='' |
|
90 | problem.errors.add_to_base('No testdata file.') |
|
91 | problem.errors.add_to_base('No testdata file.') |
|
91 | end |
|
92 | end |
|
92 |
|
93 | ||
|
|
94 | + checker_name = 'text' | ||
|
|
95 | + if ['text','float'].include? params[:checker] | ||
|
|
96 | + checker_name = params[:checker] | ||
|
|
97 | + end | ||
|
|
98 | + | ||
|
93 | file = params[:file] |
|
99 | file = params[:file] |
|
94 |
|
100 | ||
|
95 | if !problem.errors.empty? |
|
101 | if !problem.errors.empty? |
|
96 | return nil, problem |
|
102 | return nil, problem |
|
97 | end |
|
103 | end |
|
98 |
|
104 | ||
@@ -103,12 +109,13 | |||||
|
103 | problem.full_name = params[:name] |
|
109 | problem.full_name = params[:name] |
|
104 | end |
|
110 | end |
|
105 |
|
111 | ||
|
106 | return [{ |
|
112 | return [{ |
|
107 | :time_limit => time_limit, |
|
113 | :time_limit => time_limit, |
|
108 | :memory_limit => memory_limit, |
|
114 | :memory_limit => memory_limit, |
|
109 | - :file => file |
|
115 | + :file => file, |
|
|
116 | + :checker_name => checker_name | ||
|
110 | }, |
|
117 | }, |
|
111 | problem] |
|
118 | problem] |
|
112 | end |
|
119 | end |
|
113 |
|
120 | ||
|
114 | end |
|
121 | end |
@@ -29,12 +29,25 | |||||
|
29 | In .zip, .tgz, tar.gz, .tar format. |
|
29 | In .zip, .tgz, tar.gz, .tar format. |
|
30 | It should includes inputs (e.g., 1.in, 2a.in, 2b.in) |
|
30 | It should includes inputs (e.g., 1.in, 2a.in, 2b.in) |
|
31 | and solutions (e.g., 1.sol, 2a.sol, 2b.sol). |
|
31 | and solutions (e.g., 1.sol, 2a.sol, 2b.sol). |
|
32 | %br/ |
|
32 | %br/ |
|
33 | You may put task description in *.html for raw html |
|
33 | You may put task description in *.html for raw html |
|
34 | and *.md or *.markdown for markdown. |
|
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 | - if @allow_test_pair_import |
|
48 | - if @allow_test_pair_import |
|
36 | %tr |
|
49 | %tr |
|
37 | %td |
|
50 | %td |
|
38 | %td |
|
51 | %td |
|
39 | = check_box_tag 'import_to_db' |
|
52 | = check_box_tag 'import_to_db' |
|
40 | Import test data to database (for a test-pair task) |
|
53 | Import test data to database (for a test-pair task) |
@@ -47,12 +47,12 | |||||
|
47 | " -t #{time_limit} -m #{memory_limit}" |
|
47 | " -t #{time_limit} -m #{memory_limit}" |
|
48 |
|
48 | ||
|
49 | output = `#{cmd}` |
|
49 | output = `#{cmd}` |
|
50 |
|
50 | ||
|
51 | Dir.chdir(cur_dir) |
|
51 | Dir.chdir(cur_dir) |
|
52 |
|
52 | ||
|
53 | - return output |
|
53 | + return "import CMD: #{cmd}\n" + output |
|
54 | end |
|
54 | end |
|
55 | return '' |
|
55 | return '' |
|
56 | end |
|
56 | end |
|
57 |
|
57 | ||
|
58 | end |
|
58 | end |
@@ -8,21 +8,23 | |||||
|
8 | @problem = problem |
|
8 | @problem = problem |
|
9 | end |
|
9 | end |
|
10 |
|
10 | ||
|
11 | def import_from_file(tempfile, |
|
11 | def import_from_file(tempfile, |
|
12 | time_limit, |
|
12 | time_limit, |
|
13 | memory_limit, |
|
13 | memory_limit, |
|
|
14 | + checker_name='text', | ||
|
14 | import_to_db=false) |
|
15 | import_to_db=false) |
|
15 |
|
16 | ||
|
16 | dirname = extract(tempfile) |
|
17 | dirname = extract(tempfile) |
|
17 | return false if not dirname |
|
18 | return false if not dirname |
|
18 | if not import_to_db |
|
19 | if not import_to_db |
|
19 | @log_msg = GraderScript.call_import_problem(@problem.name, |
|
20 | @log_msg = GraderScript.call_import_problem(@problem.name, |
|
20 | dirname, |
|
21 | dirname, |
|
21 | time_limit, |
|
22 | time_limit, |
|
22 |
- memory_limit |
|
23 | + memory_limit, |
|
|
24 | + checker_name) | ||
|
23 | else |
|
25 | else |
|
24 | # Import test data to test pairs. |
|
26 | # Import test data to test pairs. |
|
25 |
|
27 | ||
|
26 | @problem.test_pairs.clear |
|
28 | @problem.test_pairs.clear |
|
27 | if import_test_pairs(dirname) |
|
29 | if import_test_pairs(dirname) |
|
28 | test_pair_count = TestPair.count :conditions => "problem_id = #{@problem.id}" |
|
30 | test_pair_count = TestPair.count :conditions => "problem_id = #{@problem.id}" |
You need to be logged in to leave comments.
Login now