Description:
fixed import error when no problem descriptions provided
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r235:41d234115580 - - 1 file changed: 2 inserted, 0 deleted

@@ -107,28 +107,30
107 test_num += 1
107 test_num += 1
108 end
108 end
109 return test_num > 1
109 return test_num > 1
110 end
110 end
111
111
112 def import_problem_description(dirname)
112 def import_problem_description(dirname)
113 html_files = Dir["#{dirname}/*.html"]
113 html_files = Dir["#{dirname}/*.html"]
114 markdown_files = Dir["#{dirname}/*.md"] + Dir["#{dirname}/*.markdown"]
114 markdown_files = Dir["#{dirname}/*.md"] + Dir["#{dirname}/*.markdown"]
115 if (html_files.length != 0) or (markdown_files.length != 0)
115 if (html_files.length != 0) or (markdown_files.length != 0)
116 description = @problem.description || Description.new
116 description = @problem.description || Description.new
117
117
118 if html_files.length != 0
118 if html_files.length != 0
119 filename = html_files[0]
119 filename = html_files[0]
120 description.markdowned = false
120 description.markdowned = false
121 else
121 else
122 filename = markdown_files[0]
122 filename = markdown_files[0]
123 description.markdowned = true
123 description.markdowned = true
124 end
124 end
125
125
126 description.body = open(filename).read
126 description.body = open(filename).read
127 description.save
127 description.save
128 @problem.description = description
128 @problem.description = description
129 @problem.save
129 @problem.save
130 return "\nProblem description imported from #{filename}."
130 return "\nProblem description imported from #{filename}."
131 + else
132 + return ''
131 end
133 end
132 end
134 end
133
135
134 end
136 end
You need to be logged in to leave comments. Login now