Show More
Commit Description:
handle the case when problem id or submission id is null. Grader will simply skip such request. Add more report on console (for command line grading)...
Commit Description:
handle the case when problem id or submission id is null. Grader will simply skip such request. Add more report on console (for command line grading)
(mercurial grafted from d233105d3965c5368c9b33125f390e39b25f910e)
References:
File last commit:
Show/Diff file:
Action:
lib/runner.rb
| 62 lines
| 1.6 KiB
| text/x-ruby
| RubyLexer
|
|
r23 | # | ||
# A runner drives the engine into various tasks. | ||||
# | ||||
module Grader | ||||
class Runner | ||||
def initialize(engine, grader_process=nil) | ||||
@engine = engine | ||||
@grader_process = grader_process | ||||
end | ||||
def grade_oldest_task | ||||
task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) | ||||
if task!=nil | ||||
@grader_process.report_active(task) if @grader_process!=nil | ||||
submission = Submission.find(task.submission_id) | ||||
@engine.grade(submission) | ||||
task.status_complete! | ||||
|
r59 | @grader_process.report_inactive(task) if @grader_process!=nil | ||
|
r23 | end | ||
return task | ||||
end | ||||
|
r93 | def grade_problem(problem, options={}) | ||
|
r23 | users = User.find(:all) | ||
users.each do |u| | ||||
puts "user: #{u.login}" | ||||
|
r93 | if options[:user_conditions]!=nil | ||
con_proc = options[:user_conditions] | ||||
next if not con_proc.call(u) | ||||
end | ||||
|
r68 | last_sub = Submission.find_last_by_user_and_problem(u.id,problem.id) | ||
|
r23 | if last_sub!=nil | ||
@engine.grade(last_sub) | ||||
end | ||||
end | ||||
end | ||||
|
r61 | def grade_submission(submission) | ||
puts "Submission: #{submission.id} by #{submission.user.full_name}" | ||||
@engine.grade(submission) | ||||
end | ||||
|
r23 | def grade_oldest_test_request | ||
test_request = TestRequest.get_inqueue_and_change_status(Task::STATUS_GRADING) | ||||
if test_request!=nil | ||||
@grader_process.report_active(test_request) if @grader_process!=nil | ||||
@engine.grade(test_request) | ||||
test_request.status_complete! | ||||
|
r59 | @grader_process.report_inactive(test_request) if @grader_process!=nil | ||
|
r23 | end | ||
return test_request | ||||
end | ||||
end | ||||
end | ||||