Description:
sends whole submission to result collecter in submission reporter, instead of just user and problem
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r123:57e6d251108e - - 2 files changed: 6 inserted, 5 deleted
@@ -120,37 +120,39 | |||
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | return options |
|
123 | 123 | end |
|
124 | 124 | |
|
125 | 125 | class ResultCollector |
|
126 | 126 | def initialize |
|
127 | 127 | @results = {} |
|
128 | 128 | @problems = {} |
|
129 | 129 | @users = {} |
|
130 | 130 | end |
|
131 | 131 | |
|
132 |
- def after_save_hook( |
|
|
132 | + def after_save_hook(submission, grading_result) | |
|
133 | 133 | end |
|
134 | 134 | |
|
135 |
- def save( |
|
|
135 | + def save(submission, grading_result) | |
|
136 | + user = submission.user | |
|
137 | + problem = submission.problem | |
|
136 | 138 | if not @problems.has_key? problem.id |
|
137 | 139 | @problems[problem.id] = problem |
|
138 | 140 | end |
|
139 | 141 | if not @users.has_key? user.id |
|
140 | 142 | @users[user.id] = user |
|
141 | 143 | end |
|
142 | 144 | @results[[user.id, problem.id]] = grading_result |
|
143 | 145 | |
|
144 |
- after_save_hook( |
|
|
146 | + after_save_hook(submission, grading_result) | |
|
145 | 147 | end |
|
146 | 148 | |
|
147 | 149 | def print_report_by_user |
|
148 | 150 | puts "---------------------" |
|
149 | 151 | puts " REPORT" |
|
150 | 152 | puts "---------------------" |
|
151 | 153 | |
|
152 | 154 | print "login,email" |
|
153 | 155 | @problems.each_value do |problem| |
|
154 | 156 | print ",#{problem.name}" |
|
155 | 157 | end |
|
156 | 158 | print "\n" |
@@ -33,26 +33,25 | |||
|
33 | 33 | |
|
34 | 34 | class SubmissionReporter |
|
35 | 35 | def initialize(options={}) |
|
36 | 36 | options = {:dry_run => false, :result_collector => nil}.merge(options) |
|
37 | 37 | @config = Grader::Configuration.get_instance |
|
38 | 38 | @dry_run = options[:dry_run] |
|
39 | 39 | @result_collector = options[:result_collector] |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | 42 | def report(sub,test_result_dir) |
|
43 | 43 | result = read_result(test_result_dir) |
|
44 | 44 | if @result_collector |
|
45 |
- @result_collector.save(sub |
|
|
46 | - sub.problem, | |
|
45 | + @result_collector.save(sub, | |
|
47 | 46 | result) |
|
48 | 47 | end |
|
49 | 48 | save_result(sub,result) |
|
50 | 49 | end |
|
51 | 50 | |
|
52 | 51 | def report_error(sub,msg) |
|
53 | 52 | save_result(sub,{:points => 0, |
|
54 | 53 | :comment => "Grading error: #{msg}" }) |
|
55 | 54 | end |
|
56 | 55 | |
|
57 | 56 | protected |
|
58 | 57 | def read_result(test_result_dir) |
You need to be logged in to leave comments.
Login now