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
@@ -108,61 +108,63 | |||||
|
108 | end |
|
108 | end |
|
109 |
|
109 | ||
|
110 | options[:dry_run] = (ARGV.delete('--dry') != nil) |
|
110 | options[:dry_run] = (ARGV.delete('--dry') != nil) |
|
111 | if options[:dry_run] and (not ['prob','contest','autonew'].include? options[:mode]) |
|
111 | if options[:dry_run] and (not ['prob','contest','autonew'].include? options[:mode]) |
|
112 | puts "Dry run currently works only for 'prob' or 'contest' modes." |
|
112 | puts "Dry run currently works only for 'prob' or 'contest' modes." |
|
113 | exit(0) |
|
113 | exit(0) |
|
114 | end |
|
114 | end |
|
115 |
|
115 | ||
|
116 | options[:report] = (ARGV.delete('--report') != nil) |
|
116 | options[:report] = (ARGV.delete('--report') != nil) |
|
117 | if options[:report] and (not ['prob','contest','autonew'].include? options[:mode]) |
|
117 | if options[:report] and (not ['prob','contest','autonew'].include? options[:mode]) |
|
118 | puts "Report currently works only for 'prob' or 'contest' modes." |
|
118 | puts "Report currently works only for 'prob' or 'contest' modes." |
|
119 | exit(0) |
|
119 | exit(0) |
|
120 | end |
|
120 | end |
|
121 |
|
121 | ||
|
122 | return options |
|
122 | return options |
|
123 | end |
|
123 | end |
|
124 |
|
124 | ||
|
125 | class ResultCollector |
|
125 | class ResultCollector |
|
126 | def initialize |
|
126 | def initialize |
|
127 | @results = {} |
|
127 | @results = {} |
|
128 | @problems = {} |
|
128 | @problems = {} |
|
129 | @users = {} |
|
129 | @users = {} |
|
130 | end |
|
130 | end |
|
131 |
|
131 | ||
|
132 |
- def after_save_hook( |
|
132 | + def after_save_hook(submission, grading_result) |
|
133 | end |
|
133 | end |
|
134 |
|
134 | ||
|
135 |
- def save( |
|
135 | + def save(submission, grading_result) |
|
|
136 | + user = submission.user | ||
|
|
137 | + problem = submission.problem | ||
|
136 | if not @problems.has_key? problem.id |
|
138 | if not @problems.has_key? problem.id |
|
137 | @problems[problem.id] = problem |
|
139 | @problems[problem.id] = problem |
|
138 | end |
|
140 | end |
|
139 | if not @users.has_key? user.id |
|
141 | if not @users.has_key? user.id |
|
140 | @users[user.id] = user |
|
142 | @users[user.id] = user |
|
141 | end |
|
143 | end |
|
142 | @results[[user.id, problem.id]] = grading_result |
|
144 | @results[[user.id, problem.id]] = grading_result |
|
143 |
|
145 | ||
|
144 |
- after_save_hook( |
|
146 | + after_save_hook(submission, grading_result) |
|
145 | end |
|
147 | end |
|
146 |
|
148 | ||
|
147 | def print_report_by_user |
|
149 | def print_report_by_user |
|
148 | puts "---------------------" |
|
150 | puts "---------------------" |
|
149 | puts " REPORT" |
|
151 | puts " REPORT" |
|
150 | puts "---------------------" |
|
152 | puts "---------------------" |
|
151 |
|
153 | ||
|
152 | print "login,email" |
|
154 | print "login,email" |
|
153 | @problems.each_value do |problem| |
|
155 | @problems.each_value do |problem| |
|
154 | print ",#{problem.name}" |
|
156 | print ",#{problem.name}" |
|
155 | end |
|
157 | end |
|
156 | print "\n" |
|
158 | print "\n" |
|
157 |
|
159 | ||
|
158 | @users.each_value do |user| |
|
160 | @users.each_value do |user| |
|
159 | print "#{user.login},#{user.email}" |
|
161 | print "#{user.login},#{user.email}" |
|
160 | @problems.each_value do |problem| |
|
162 | @problems.each_value do |problem| |
|
161 | if @results.has_key? [user.id, problem.id] |
|
163 | if @results.has_key? [user.id, problem.id] |
|
162 | print ",#{@results[[user.id,problem.id]][:points]}" |
|
164 | print ",#{@results[[user.id,problem.id]][:points]}" |
|
163 | else |
|
165 | else |
|
164 | print "," |
|
166 | print "," |
|
165 | end |
|
167 | end |
|
166 | end |
|
168 | end |
|
167 | print "\n" |
|
169 | print "\n" |
|
168 | end |
|
170 | end |
@@ -21,50 +21,49 | |||||
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | def save_source(submission,source_name) |
|
23 | def save_source(submission,source_name) |
|
24 | dir = self.produce_grading_room(submission) |
|
24 | dir = self.produce_grading_room(submission) |
|
25 | f = File.open("#{dir}/#{source_name}","w") |
|
25 | f = File.open("#{dir}/#{source_name}","w") |
|
26 | f.write(submission.source) |
|
26 | f.write(submission.source) |
|
27 | f.close |
|
27 | f.close |
|
28 | end |
|
28 | end |
|
29 |
|
29 | ||
|
30 | def clean_up(submission) |
|
30 | def clean_up(submission) |
|
31 | end |
|
31 | end |
|
32 | end |
|
32 | end |
|
33 |
|
33 | ||
|
34 | class SubmissionReporter |
|
34 | class SubmissionReporter |
|
35 | def initialize(options={}) |
|
35 | def initialize(options={}) |
|
36 | options = {:dry_run => false, :result_collector => nil}.merge(options) |
|
36 | options = {:dry_run => false, :result_collector => nil}.merge(options) |
|
37 | @config = Grader::Configuration.get_instance |
|
37 | @config = Grader::Configuration.get_instance |
|
38 | @dry_run = options[:dry_run] |
|
38 | @dry_run = options[:dry_run] |
|
39 | @result_collector = options[:result_collector] |
|
39 | @result_collector = options[:result_collector] |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | def report(sub,test_result_dir) |
|
42 | def report(sub,test_result_dir) |
|
43 | result = read_result(test_result_dir) |
|
43 | result = read_result(test_result_dir) |
|
44 | if @result_collector |
|
44 | if @result_collector |
|
45 |
- @result_collector.save(sub |
|
45 | + @result_collector.save(sub, |
|
46 | - sub.problem, |
|
||
|
47 | result) |
|
46 | result) |
|
48 | end |
|
47 | end |
|
49 | save_result(sub,result) |
|
48 | save_result(sub,result) |
|
50 | end |
|
49 | end |
|
51 |
|
50 | ||
|
52 | def report_error(sub,msg) |
|
51 | def report_error(sub,msg) |
|
53 | save_result(sub,{:points => 0, |
|
52 | save_result(sub,{:points => 0, |
|
54 | :comment => "Grading error: #{msg}" }) |
|
53 | :comment => "Grading error: #{msg}" }) |
|
55 | end |
|
54 | end |
|
56 |
|
55 | ||
|
57 | protected |
|
56 | protected |
|
58 | def read_result(test_result_dir) |
|
57 | def read_result(test_result_dir) |
|
59 | cmp_msg_fname = "#{test_result_dir}/compiler_message" |
|
58 | cmp_msg_fname = "#{test_result_dir}/compiler_message" |
|
60 | if FileTest.exist?(cmp_msg_fname) |
|
59 | if FileTest.exist?(cmp_msg_fname) |
|
61 | cmp_file = File.open(cmp_msg_fname) |
|
60 | cmp_file = File.open(cmp_msg_fname) |
|
62 | cmp_msg = cmp_file.read |
|
61 | cmp_msg = cmp_file.read |
|
63 | cmp_file.close |
|
62 | cmp_file.close |
|
64 | else |
|
63 | else |
|
65 | cmp_msg = "" |
|
64 | cmp_msg = "" |
|
66 | end |
|
65 | end |
|
67 |
|
66 | ||
|
68 | result_fname = "#{test_result_dir}/result" |
|
67 | result_fname = "#{test_result_dir}/result" |
|
69 | comment_fname = "#{test_result_dir}/comment" |
|
68 | comment_fname = "#{test_result_dir}/comment" |
|
70 | if FileTest.exist?(result_fname) |
|
69 | if FileTest.exist?(result_fname) |
You need to be logged in to leave comments.
Login now