Description:
added problem description import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r211:3a4974a6747f - - 3 files changed: 35 inserted, 3 deleted
@@ -22,8 +22,17 | |||||
|
22 | %span{:class => 'help'} Leave blank to use the same value as the name above. |
|
22 | %span{:class => 'help'} Leave blank to use the same value as the name above. |
|
23 | %tr |
|
23 | %tr |
|
24 | %td Testdata file: |
|
24 | %td Testdata file: |
|
|
25 | + %td= file_field_tag 'file' | ||
|
|
26 | + %tr | ||
|
25 | %td |
|
27 | %td |
|
26 | - = file_field_tag 'file' |
|
28 | + %td |
|
|
29 | + %span{:class => 'help'} | ||
|
|
30 | + In .zip, .tgz, tar.gz, .tar format. | ||
|
|
31 | + It should includes inputs (e.g., 1.in, 2a.in, 2b.in) | ||
|
|
32 | + and solutions (e.g., 1.sol, 2a.sol, 2b.sol). | ||
|
|
33 | + %br/ | ||
|
|
34 | + You may put task description in *.html for raw html | ||
|
|
35 | + and *.md or *.markdown for markdown. | ||
|
27 | %tr |
|
36 | %tr |
|
28 | %td |
|
37 | %td |
|
29 | %td |
|
38 | %td |
@@ -11,9 +11,7 | |||||
|
11 | <% if problem.description.markdowned %> |
|
11 | <% if problem.description.markdowned %> |
|
12 | <%= markdown(problem.description.body) %> |
|
12 | <%= markdown(problem.description.body) %> |
|
13 | <% else %> |
|
13 | <% else %> |
|
14 | - <pre> |
|
||
|
15 | <%= problem.description.body %> |
|
14 | <%= problem.description.body %> |
|
16 | - </pre> |
|
||
|
17 | <% end %> |
|
15 | <% end %> |
|
18 | <% else %> |
|
16 | <% else %> |
|
19 | (not available) |
|
17 | (not available) |
@@ -31,6 +31,9 | |||||
|
31 | @log_msg = "Importing test pair failed. (0 test pairs imported)" |
|
31 | @log_msg = "Importing test pair failed. (0 test pairs imported)" |
|
32 | end |
|
32 | end |
|
33 | end |
|
33 | end |
|
|
34 | + | ||
|
|
35 | + @log_msg << import_problem_description(dirname) | ||
|
|
36 | + | ||
|
34 | return true |
|
37 | return true |
|
35 | end |
|
38 | end |
|
36 |
|
39 | ||
@@ -106,4 +109,26 | |||||
|
106 | return test_num > 1 |
|
109 | return test_num > 1 |
|
107 | end |
|
110 | end |
|
108 |
|
111 | ||
|
|
112 | + def import_problem_description(dirname) | ||
|
|
113 | + html_files = Dir["#{dirname}/*.html"] | ||
|
|
114 | + markdown_files = Dir["#{dirname}/*.md"] + Dir["#{dirname}/*.markdown"] | ||
|
|
115 | + if (html_files.length != 0) or (markdown_files.length != 0) | ||
|
|
116 | + description = @problem.description || Description.new | ||
|
|
117 | + | ||
|
|
118 | + if html_files.length != 0 | ||
|
|
119 | + filename = html_files[0] | ||
|
|
120 | + description.markdowned = false | ||
|
|
121 | + else | ||
|
|
122 | + filename = markdown_files[0] | ||
|
|
123 | + description.markdowned = true | ||
|
109 | end |
|
124 | end |
|
|
125 | + | ||
|
|
126 | + description.body = open(filename).read | ||
|
|
127 | + description.save | ||
|
|
128 | + @problem.description = description | ||
|
|
129 | + @problem.save | ||
|
|
130 | + return "\nProblem description imported from #{filename}." | ||
|
|
131 | + end | ||
|
|
132 | + end | ||
|
|
133 | + | ||
|
|
134 | + end |
You need to be logged in to leave comments.
Login now