Description:
added contest mode
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r93:bdd89e00b68d - - 2 files changed: 54 inserted, 6 deleted
@@ -114,7 +114,7 | |||
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | options[:report] = (ARGV.delete('--report') != nil) |
|
117 |
- if options[:report] and (not options[:mode] |
|
|
117 | + if options[:report] and (not ['prob','contest'].include? options[:mode]) | |
|
118 | 118 | puts "Report currently works only for 'prob' mode." |
|
119 | 119 | exit(0) |
|
120 | 120 | end |
@@ -249,10 +249,13 | |||
|
249 | 249 | result_collector = nil |
|
250 | 250 | end |
|
251 | 251 | |
|
252 | - engine = (Grader::Engine. | |
|
253 | - new(:reporter => | |
|
254 | - Grader::SubmissionReporter.new(:dry_run => dry_run, | |
|
255 | - :result_collector => result_collector))) | |
|
252 | + if options[:dry_run] | |
|
253 | + puts "Running in dry mode" | |
|
254 | + end | |
|
255 | + | |
|
256 | + prob_reporter = Grader::SubmissionReporter.new(:dry_run => dry_run, | |
|
257 | + :result_collector => result_collector) | |
|
258 | + engine = Grader::Engine.new(:reporter => prob_reporter) | |
|
256 | 259 | runner = Grader::Runner.new(engine, grader_proc) |
|
257 | 260 | |
|
258 | 261 | grader_proc.report_active if grader_proc!=nil |
@@ -270,6 +273,45 | |||
|
270 | 273 | result_collector.print_report_by_user |
|
271 | 274 | end |
|
272 | 275 | |
|
276 | + when "contest" | |
|
277 | + # always use dry run when grading during contest | |
|
278 | + contest_name = ARGV.shift | |
|
279 | + | |
|
280 | + options[:dry_run] = true | |
|
281 | + | |
|
282 | + contest = Contest.find_by_name(contest_name) | |
|
283 | + if contest==nil | |
|
284 | + puts "cannot find contest: #{contest_name}" | |
|
285 | + exit(0) | |
|
286 | + end | |
|
287 | + | |
|
288 | + if options[:report] | |
|
289 | + result_collector = ResultCollector.new | |
|
290 | + else | |
|
291 | + result_collector = nil | |
|
292 | + end | |
|
293 | + | |
|
294 | + if options[:dry_run] | |
|
295 | + puts "Running in dry mode" | |
|
296 | + end | |
|
297 | + | |
|
298 | + prob_reporter = Grader::SubmissionReporter.new(:dry_run => dry_run, | |
|
299 | + :result_collector => result_collector) | |
|
300 | + engine = Grader::Engine.new(:reporter => prob_reporter) | |
|
301 | + runner = Grader::Runner.new(engine, grader_proc) | |
|
302 | + | |
|
303 | + grader_proc.report_active if grader_proc!=nil | |
|
304 | + | |
|
305 | + contest.problems.each do |problem| | |
|
306 | + puts "Grading: #{problem.name}" | |
|
307 | + runner.grade_problem(problem, | |
|
308 | + :user_conditions => lambda {|u| u.contest_finished?}) | |
|
309 | + end | |
|
310 | + | |
|
311 | + if options[:report] | |
|
312 | + result_collector.print_report_by_user | |
|
313 | + end | |
|
314 | + | |
|
273 | 315 | when "sub" |
|
274 | 316 | engine = Grader::Engine.new |
|
275 | 317 | runner = Grader::Runner.new(engine, grader_proc) |
@@ -290,6 +332,8 | |||
|
290 | 332 | end |
|
291 | 333 | end |
|
292 | 334 | |
|
335 | + | |
|
336 | + | |
|
293 | 337 | else |
|
294 | 338 | display_manual |
|
295 | 339 | exit(0) |
@@ -24,10 +24,14 | |||
|
24 | 24 | return task |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | - def grade_problem(problem) | |
|
27 | + def grade_problem(problem, options={}) | |
|
28 | 28 | users = User.find(:all) |
|
29 | 29 | users.each do |u| |
|
30 | 30 | puts "user: #{u.login}" |
|
31 | + if options[:user_conditions]!=nil | |
|
32 | + con_proc = options[:user_conditions] | |
|
33 | + next if not con_proc.call(u) | |
|
34 | + end | |
|
31 | 35 | last_sub = Submission.find_last_by_user_and_problem(u.id,problem.id) |
|
32 | 36 | if last_sub!=nil |
|
33 | 37 | @engine.grade(last_sub) |
You need to be logged in to leave comments.
Login now