Description:
sends whole submission to result collecter in submission reporter, instead of just user and problem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r123:57e6d251108e - - 2 files changed: 6 inserted, 5 deleted

@@ -1,336 +1,338
1 #!/usr/bin/ruby
1 #!/usr/bin/ruby
2
2
3 def stop_grader(id)
3 def stop_grader(id)
4 if id==:all
4 if id==:all
5 File.open(File.dirname(__FILE__) + "/stop.all",'w').close
5 File.open(File.dirname(__FILE__) + "/stop.all",'w').close
6 else
6 else
7 File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close
7 File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close
8 end
8 end
9 end
9 end
10
10
11 def check_stopfile
11 def check_stopfile
12 FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or
12 FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or
13 FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
13 FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
14 end
14 end
15
15
16 def clear_stopfile
16 def clear_stopfile
17 if FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
17 if FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
18 File.delete(File.dirname(__FILE__) + "/stop.#{Process.pid}")
18 File.delete(File.dirname(__FILE__) + "/stop.#{Process.pid}")
19 end
19 end
20 end
20 end
21
21
22 def config
22 def config
23 Grader::Configuration.get_instance
23 Grader::Configuration.get_instance
24 end
24 end
25
25
26 def log_file_name
26 def log_file_name
27 if !File.exists?(config.log_dir)
27 if !File.exists?(config.log_dir)
28 raise "Log directory does not exist: #{config.log_dir}"
28 raise "Log directory does not exist: #{config.log_dir}"
29 end
29 end
30 config.log_dir +
30 config.log_dir +
31 "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}"
31 "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}"
32 end
32 end
33
33
34 def log(str)
34 def log(str)
35 if config.talkative
35 if config.talkative
36 puts str
36 puts str
37 end
37 end
38 if config.logging
38 if config.logging
39 fp = File.open(log_file_name,"a")
39 fp = File.open(log_file_name,"a")
40 fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}")
40 fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}")
41 fp.close
41 fp.close
42 end
42 end
43 end
43 end
44
44
45 def display_manual
45 def display_manual
46 puts <<USAGE
46 puts <<USAGE
47 Grader.
47 Grader.
48 using: (1) grader
48 using: (1) grader
49 (2) grader environment [mode]
49 (2) grader environment [mode]
50 (3) grader stop [all|pids-list]
50 (3) grader stop [all|pids-list]
51 (4) grader --help
51 (4) grader --help
52 (1) call grader with environment = 'exam', mode = 'queue'
52 (1) call grader with environment = 'exam', mode = 'queue'
53 (2) possible modes are: 'queue', 'test_request', 'prob', 'sub', 'contest', and 'autonew'
53 (2) possible modes are: 'queue', 'test_request', 'prob', 'sub', 'contest', and 'autonew'
54 (3) create stop-file to stop running grader in queue mode
54 (3) create stop-file to stop running grader in queue mode
55 (4) You are here.
55 (4) You are here.
56 USAGE
56 USAGE
57 end
57 end
58
58
59 def process_options_and_stop_file
59 def process_options_and_stop_file
60 # The list of options are:
60 # The list of options are:
61 # - stop [all|process ids]
61 # - stop [all|process ids]
62 # -
62 # -
63
63
64 # Process 'help' option
64 # Process 'help' option
65 if (ARGV.length==1) and (/help/.match(ARGV[0]))
65 if (ARGV.length==1) and (/help/.match(ARGV[0]))
66 display_manual
66 display_manual
67 exit(0)
67 exit(0)
68 end
68 end
69
69
70 # Process 'stop' option.
70 # Process 'stop' option.
71 if (ARGV.length >= 1) and (ARGV[0]=='stop')
71 if (ARGV.length >= 1) and (ARGV[0]=='stop')
72 if ARGV.length==1
72 if ARGV.length==1
73 puts "you should specify pid-list or 'all'"
73 puts "you should specify pid-list or 'all'"
74 display_manual
74 display_manual
75 elsif (ARGV.length==2) and (ARGV[1]=='all')
75 elsif (ARGV.length==2) and (ARGV[1]=='all')
76 stop_grader(:all)
76 stop_grader(:all)
77 puts "A global stop file ('stop.all') created."
77 puts "A global stop file ('stop.all') created."
78 puts "You should remove it manually later."
78 puts "You should remove it manually later."
79 else
79 else
80 (1..ARGV.length-1).each do |i|
80 (1..ARGV.length-1).each do |i|
81 stop_grader(ARGV[i])
81 stop_grader(ARGV[i])
82 end
82 end
83 puts "stop file(s) created"
83 puts "stop file(s) created"
84 end
84 end
85 exit(0)
85 exit(0)
86 end
86 end
87
87
88 # Check stop file.
88 # Check stop file.
89 if check_stopfile
89 if check_stopfile
90 puts "Stop file exists. Terminated."
90 puts "Stop file exists. Terminated."
91 clear_stopfile
91 clear_stopfile
92 exit(0)
92 exit(0)
93 end
93 end
94
94
95 #default options
95 #default options
96 options = {
96 options = {
97 :mode => 'queue',
97 :mode => 'queue',
98 :environment => 'exam',
98 :environment => 'exam',
99 :dry_run => false,
99 :dry_run => false,
100 }
100 }
101
101
102 # Process mode and environment option
102 # Process mode and environment option
103 if ARGV.length >= 1
103 if ARGV.length >= 1
104 options[:environment] = ARGV.shift
104 options[:environment] = ARGV.shift
105 if ARGV.length >=1
105 if ARGV.length >=1
106 options[:mode] = ARGV.shift
106 options[:mode] = ARGV.shift
107 end
107 end
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(user, problem, grading_result)
132 + def after_save_hook(submission, grading_result)
133 end
133 end
134
134
135 - def save(user, problem, grading_result)
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(user, problem, grading_result)
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
169 end
171 end
170 end
172 end
171
173
172 def grader_general_loop(engine, grader_proc, options)
174 def grader_general_loop(engine, grader_proc, options)
173 runner = Grader::Runner.new(engine, grader_proc)
175 runner = Grader::Runner.new(engine, grader_proc)
174 while true
176 while true
175
177
176 if check_stopfile # created by calling grader stop
178 if check_stopfile # created by calling grader stop
177 clear_stopfile
179 clear_stopfile
178 log "stopped (with stop file)"
180 log "stopped (with stop file)"
179 break
181 break
180 end
182 end
181
183
182 task = yield(runner)
184 task = yield(runner)
183
185
184 if task==nil
186 if task==nil
185 sleep(1)
187 sleep(1)
186 end
188 end
187 end
189 end
188 end
190 end
189
191
190 def grader_queue_loop(grader_proc, options)
192 def grader_queue_loop(grader_proc, options)
191 log "Grader: queue"
193 log "Grader: queue"
192 engine = Grader::Engine.new
194 engine = Grader::Engine.new
193 grader_general_loop(engine, grader_proc, options) do |runner|
195 grader_general_loop(engine, grader_proc, options) do |runner|
194 runner.grade_oldest_task
196 runner.grade_oldest_task
195 end
197 end
196 end
198 end
197
199
198 def grader_test_request_loop(grader_proc, options)
200 def grader_test_request_loop(grader_proc, options)
199 log "Grader: test_request"
201 log "Grader: test_request"
200 engine = Grader::Engine.new(:room_maker => Grader::TestRequestRoomMaker.new,
202 engine = Grader::Engine.new(:room_maker => Grader::TestRequestRoomMaker.new,
201 :reporter => Grader::TestRequestReporter.new)
203 :reporter => Grader::TestRequestReporter.new)
202 grader_general_loop(engine, grader_proc, options) do |runner|
204 grader_general_loop(engine, grader_proc, options) do |runner|
203 runner.grade_oldest_test_request
205 runner.grade_oldest_test_request
204 end
206 end
205 end
207 end
206
208
207 def grader_autonew_loop(grader_proc, options)
209 def grader_autonew_loop(grader_proc, options)
208 log "Grader: autonew"
210 log "Grader: autonew"
209
211
210 if options[:report]
212 if options[:report]
211 result_collector = ResultCollector.new
213 result_collector = ResultCollector.new
212 else
214 else
213 result_collector = nil
215 result_collector = nil
214 end
216 end
215
217
216 if options[:dry_run]
218 if options[:dry_run]
217 puts "Running in dry mode"
219 puts "Running in dry mode"
218 end
220 end
219
221
220 prob_reporter = Grader::SubmissionReporter.new(:dry_run => options[:dry_run],
222 prob_reporter = Grader::SubmissionReporter.new(:dry_run => options[:dry_run],
221 :result_collector => result_collector)
223 :result_collector => result_collector)
222
224
223 engine = Grader::Engine.new(:reporter => prob_reporter)
225 engine = Grader::Engine.new(:reporter => prob_reporter)
224 runner = Grader::Runner.new(engine, grader_proc)
226 runner = Grader::Runner.new(engine, grader_proc)
225
227
226 grader_proc.report_active if grader_proc!=nil
228 grader_proc.report_active if grader_proc!=nil
227
229
228 latest_submitted_at = nil
230 latest_submitted_at = nil
229 graded_submission_ids = {}
231 graded_submission_ids = {}
230
232
231 while true
233 while true
232
234
233 if check_stopfile # created by calling grader stop
235 if check_stopfile # created by calling grader stop
234 clear_stopfile
236 clear_stopfile
235 log "stopped (with stop file)"
237 log "stopped (with stop file)"
236 break
238 break
237 end
239 end
238
240
239 if latest_submitted_at==nil
241 if latest_submitted_at==nil
240 submissions = Submission.all
242 submissions = Submission.all
241 else
243 else
242 submissions = Submission.all(:conditions => ["submitted_at >= :latest",
244 submissions = Submission.all(:conditions => ["submitted_at >= :latest",
243 {:latest => latest_submitted_at}])
245 {:latest => latest_submitted_at}])
244 end
246 end
245
247
246 graded_any = false
248 graded_any = false
247
249
248 if submissions.length != 0
250 if submissions.length != 0
249 submissions.each do |submission|
251 submissions.each do |submission|
250 if ! graded_submission_ids[submission.id]
252 if ! graded_submission_ids[submission.id]
251 runner.grade_submission(submission)
253 runner.grade_submission(submission)
252 graded_submission_ids[submission.id] = true
254 graded_submission_ids[submission.id] = true
253 if (!latest_submitted_at or
255 if (!latest_submitted_at or
254 latest_submitted_at < submission.submitted_at)
256 latest_submitted_at < submission.submitted_at)
255 latest_submitted_at = submission.submitted_at
257 latest_submitted_at = submission.submitted_at
256 end
258 end
257 puts "graded: #{submission.id}"
259 puts "graded: #{submission.id}"
258 puts "latest: #{latest_submitted_at}"
260 puts "latest: #{latest_submitted_at}"
259 graded_any = true
261 graded_any = true
260 end
262 end
261 end
263 end
262 end
264 end
263
265
264 if ! graded_any
266 if ! graded_any
265 sleep(1)
267 sleep(1)
266 end
268 end
267 end
269 end
268 end
270 end
269
271
270 def grader_grade_problems(grader_proc, options)
272 def grader_grade_problems(grader_proc, options)
271 if options[:report]
273 if options[:report]
272 result_collector = ResultCollector.new
274 result_collector = ResultCollector.new
273 else
275 else
274 result_collector = nil
276 result_collector = nil
275 end
277 end
276
278
277 if options[:dry_run]
279 if options[:dry_run]
278 puts "Running in dry mode"
280 puts "Running in dry mode"
279 end
281 end
280
282
281 prob_reporter = Grader::SubmissionReporter.new(:dry_run => options[:dry_run],
283 prob_reporter = Grader::SubmissionReporter.new(:dry_run => options[:dry_run],
282 :result_collector => result_collector)
284 :result_collector => result_collector)
283 engine = Grader::Engine.new(:reporter => prob_reporter)
285 engine = Grader::Engine.new(:reporter => prob_reporter)
284 runner = Grader::Runner.new(engine, grader_proc)
286 runner = Grader::Runner.new(engine, grader_proc)
285
287
286 grader_proc.report_active if grader_proc!=nil
288 grader_proc.report_active if grader_proc!=nil
287
289
288 ARGV.each do |prob_name|
290 ARGV.each do |prob_name|
289 prob = Problem.find_by_name(prob_name)
291 prob = Problem.find_by_name(prob_name)
290 if prob==nil
292 if prob==nil
291 puts "cannot find problem: #{prob_name}"
293 puts "cannot find problem: #{prob_name}"
292 else
294 else
293 runner.grade_problem(prob)
295 runner.grade_problem(prob)
294 end
296 end
295 end
297 end
296
298
297 if options[:report]
299 if options[:report]
298 result_collector.print_report_by_user
300 result_collector.print_report_by_user
299 end
301 end
300 end
302 end
301
303
302 def grader_grade_contests(grader_proc, options)
304 def grader_grade_contests(grader_proc, options)
303 # always use dry run when grading during contest
305 # always use dry run when grading during contest
304 dry_run = options[:dry_run] = true
306 dry_run = options[:dry_run] = true
305
307
306 contest_name = ARGV.shift
308 contest_name = ARGV.shift
307
309
308 contest = Contest.find_by_name(contest_name)
310 contest = Contest.find_by_name(contest_name)
309 if contest==nil
311 if contest==nil
310 puts "cannot find contest: #{contest_name}"
312 puts "cannot find contest: #{contest_name}"
311 exit(0)
313 exit(0)
312 end
314 end
313
315
314 if options[:report]
316 if options[:report]
315 result_collector = ResultCollector.new
317 result_collector = ResultCollector.new
316 else
318 else
317 result_collector = nil
319 result_collector = nil
318 end
320 end
319
321
320 if options[:dry_run]
322 if options[:dry_run]
321 puts "Running in dry mode"
323 puts "Running in dry mode"
322 end
324 end
323
325
324 prob_reporter = Grader::SubmissionReporter.new(:dry_run => dry_run,
326 prob_reporter = Grader::SubmissionReporter.new(:dry_run => dry_run,
325 :result_collector => result_collector)
327 :result_collector => result_collector)
326 engine = Grader::Engine.new(:reporter => prob_reporter)
328 engine = Grader::Engine.new(:reporter => prob_reporter)
327 runner = Grader::Runner.new(engine, grader_proc)
329 runner = Grader::Runner.new(engine, grader_proc)
328
330
329 grader_proc.report_active if grader_proc!=nil
331 grader_proc.report_active if grader_proc!=nil
330
332
331 contest.problems.each do |problem|
333 contest.problems.each do |problem|
332 puts "Grading: #{problem.name}"
334 puts "Grading: #{problem.name}"
333 runner.grade_problem(problem,
335 runner.grade_problem(problem,
334 :user_conditions => lambda do |u|
336 :user_conditions => lambda do |u|
335 u.contest_finished? and
337 u.contest_finished? and
336 u.contest_ids.include?(contest.id)
338 u.contest_ids.include?(contest.id)
@@ -1,135 +1,134
1 module Grader
1 module Grader
2
2
3 class SubmissionRoomMaker
3 class SubmissionRoomMaker
4 def initialize
4 def initialize
5 @config = Grader::Configuration.get_instance
5 @config = Grader::Configuration.get_instance
6 end
6 end
7
7
8 def produce_grading_room(submission)
8 def produce_grading_room(submission)
9 user = submission.user
9 user = submission.user
10 problem = submission.problem
10 problem = submission.problem
11 grading_room = "#{@config.user_result_dir}/" +
11 grading_room = "#{@config.user_result_dir}/" +
12 "#{user.login}/#{problem.name}/#{submission.id}"
12 "#{user.login}/#{problem.name}/#{submission.id}"
13
13
14 FileUtils.mkdir_p(grading_room)
14 FileUtils.mkdir_p(grading_room)
15 grading_room
15 grading_room
16 end
16 end
17
17
18 def find_problem_home(submission)
18 def find_problem_home(submission)
19 problem = submission.problem
19 problem = submission.problem
20 "#{@config.problems_dir}/#{problem.name}"
20 "#{@config.problems_dir}/#{problem.name}"
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.user,
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)
71 comment = ""
70 comment = ""
72 begin
71 begin
73 result_file = File.open(result_fname)
72 result_file = File.open(result_fname)
74 result = result_file.readline.to_i
73 result = result_file.readline.to_i
75 result_file.close
74 result_file.close
76 rescue
75 rescue
77 result = 0
76 result = 0
78 comment = "error reading result file."
77 comment = "error reading result file."
79 end
78 end
80
79
81 begin
80 begin
82 comment_file = File.open(comment_fname)
81 comment_file = File.open(comment_fname)
83 comment += comment_file.readline.chomp
82 comment += comment_file.readline.chomp
84 comment_file.close
83 comment_file.close
85 rescue
84 rescue
86 comment += ""
85 comment += ""
87 end
86 end
88
87
89 return {:points => result,
88 return {:points => result,
90 :comment => comment,
89 :comment => comment,
91 :cmp_msg => cmp_msg}
90 :cmp_msg => cmp_msg}
92 else
91 else
93 if FileTest.exist?("#{test_result_dir}/a.out")
92 if FileTest.exist?("#{test_result_dir}/a.out")
94 return {:points => 0,
93 return {:points => 0,
95 :comment => 'error during grading',
94 :comment => 'error during grading',
96 :cmp_msg => cmp_msg}
95 :cmp_msg => cmp_msg}
97 else
96 else
98 return {:points => 0,
97 return {:points => 0,
99 :comment => 'compilation error',
98 :comment => 'compilation error',
100 :cmp_msg => cmp_msg}
99 :cmp_msg => cmp_msg}
101 end
100 end
102 end
101 end
103 end
102 end
104
103
105 def save_result(submission,result)
104 def save_result(submission,result)
106 problem = submission.problem
105 problem = submission.problem
107 submission.graded_at = Time.now.gmtime
106 submission.graded_at = Time.now.gmtime
108 points = result[:points]
107 points = result[:points]
109 submission.points = points
108 submission.points = points
110 comment = @config.report_comment(result[:comment])
109 comment = @config.report_comment(result[:comment])
111
110
112 #
111 #
113 # TODO: FIX THIS MESSAGE
112 # TODO: FIX THIS MESSAGE
114 #
113 #
115 if problem == nil
114 if problem == nil
116 submission.grader_comment = 'PASSED: ' + comment + '(problem is nil)'
115 submission.grader_comment = 'PASSED: ' + comment + '(problem is nil)'
117 elsif points == problem.full_score
116 elsif points == problem.full_score
118 #submission.grader_comment = 'PASSED: ' + comment
117 #submission.grader_comment = 'PASSED: ' + comment
119 submission.grader_comment = comment
118 submission.grader_comment = comment
120 elsif result[:comment].chomp =~ /^[\[\]P]+$/
119 elsif result[:comment].chomp =~ /^[\[\]P]+$/
121 submission.grader_comment = 'PASSED: ' + comment + '(inconsistent score)'
120 submission.grader_comment = 'PASSED: ' + comment + '(inconsistent score)'
122 else
121 else
123 #submission.grader_comment = 'FAILED: ' + comment
122 #submission.grader_comment = 'FAILED: ' + comment
124 submission.grader_comment = comment
123 submission.grader_comment = comment
125 end
124 end
126 submission.compiler_message = result[:cmp_msg] or ''
125 submission.compiler_message = result[:cmp_msg] or ''
127
126
128 if not @dry_run
127 if not @dry_run
129 submission.save
128 submission.save
130 end
129 end
131 end
130 end
132
131
133 end
132 end
134
133
135 end
134 end
You need to be logged in to leave comments. Login now