Description:
my fault, fixing auto full score to properly handle subtask case
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r346:d02b70f6c474 - - 1 file changed: 7 inserted, 2 deleted

@@ -128,56 +128,61
128 128 filename = html_files[0]
129 129 description.markdowned = false
130 130 else
131 131 filename = markdown_files[0]
132 132 description.markdowned = true
133 133 end
134 134
135 135 description.body = open(filename).read
136 136 description.save
137 137 @problem.description = description
138 138 @problem.save
139 139 return "\nProblem description imported from #{filename}."
140 140 else
141 141 return ''
142 142 end
143 143 end
144 144
145 145 def import_problem_pdf(dirname)
146 146 pdf_files = Dir["#{dirname}/*.pdf"]
147 147 puts "CHECKING... #{dirname}"
148 148 if pdf_files.length != 0
149 149 puts "HAS PDF FILE"
150 150 filename = pdf_files[0]
151 151
152 152 @problem.save if not @problem.id
153 153 out_dirname = "#{Problem.download_file_basedir}/#{@problem.id}"
154 154 if not FileTest.exists? out_dirname
155 155 Dir.mkdir out_dirname
156 156 end
157 157
158 158 out_filename = "#{out_dirname}/#{@problem.name}.pdf"
159 159
160 160 if FileTest.exists? out_filename
161 161 File.delete out_filename
162 162 end
163 163
164 164 File.rename(filename, out_filename)
165 165 @problem.description_filename = "#{@problem.name}.pdf"
166 166 @problem.save
167 167 return "\nProblem pdf imported from #{filename}."
168 168 else
169 169 return ""
170 170 end
171 171 end
172 172
173 173 #just set the full score to the total number of test case
174 174 #it is not perfect but works on most normal use case
175 175 def import_full_score(dirname)
176 - in_file = Dir["#{dirname}/*.in"]
177 - full_score =in_file.length * 10
176 + num = 0
177 + loop do
178 + num += 1
179 + in_file = Dir["#{dirname}/#{num}*.in"]
180 + break if in_file.length == 0
181 + end
182 + full_score = (num - 1) * 10
178 183 @problem.full_score = full_score
179 184 @problem.save
180 185 return "\nFull score is set to #{full_score}."
181 186 end
182 187
183 188 end
You need to be logged in to leave comments. Login now