Description:
let testdata importer set the full score
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r345:d3662f88d75c - - 1 file changed: 11 inserted, 0 deleted

@@ -25,24 +25,25
25 25
26 26 @problem.test_pairs.clear
27 27 if import_test_pairs(dirname)
28 28 test_pair_count = TestPair.count :conditions => "problem_id = #{@problem.id}"
29 29 @log_msg = "Importing test pair successful. (#{test_pair_count} test pairs imported)"
30 30 else
31 31 @log_msg = "Importing test pair failed. (0 test pairs imported)"
32 32 end
33 33 end
34 34
35 35 @log_msg << import_problem_description(dirname)
36 36 @log_msg << import_problem_pdf(dirname)
37 + @log_msg << import_full_score(dirname)
37 38
38 39 return true
39 40 end
40 41
41 42 protected
42 43
43 44 def self.long_ext(filename)
44 45 i = filename.index('.')
45 46 len = filename.length
46 47 return filename.slice(i..len)
47 48 end
48 49
@@ -160,13 +161,23
160 161 File.delete out_filename
161 162 end
162 163
163 164 File.rename(filename, out_filename)
164 165 @problem.description_filename = "#{@problem.name}.pdf"
165 166 @problem.save
166 167 return "\nProblem pdf imported from #{filename}."
167 168 else
168 169 return ""
169 170 end
170 171 end
171 172
173 + #just set the full score to the total number of test case
174 + #it is not perfect but works on most normal use case
175 + def import_full_score(dirname)
176 + in_file = Dir["#{dirname}/*.in"]
177 + full_score =in_file.length * 10
178 + @problem.full_score = full_score
179 + @problem.save
180 + return "\nFull score is set to #{full_score}."
181 + end
182 +
172 183 end
You need to be logged in to leave comments. Login now