Show More
Commit Description:
add dump submission & octave
Commit Description:
add dump submission & octave
References:
File last commit:
Show/Diff file:
Action:
lib/runner.rb
| 74 lines
| 2.3 KiB
| text/x-ruby
| RubyLexer
|
|
r23 | # | ||
# A runner drives the engine into various tasks. | ||||
r256 | # | |||
|
r23 | |||
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 | ||||
r256 | ||||
|
r23 | 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 | ||||
r254 | # grade a specified problem for the latest submission of each user | |||
# optionally, on all submission when options[:all_sub] is set | ||||
# optionally, only submission that has error (use when the problem itself has some problem) | ||||
|
r93 | def grade_problem(problem, options={}) | ||
r240 | user_index = 0 | |||
user_count = User.count | ||||
r163 | User.find_each do |u| | |||
r240 | puts "user: #{u.login} (#{user_index}/#{user_count})" | |||
user_index += 1 | ||||
|
r93 | if options[:user_conditions]!=nil | ||
con_proc = options[:user_conditions] | ||||
next if not con_proc.call(u) | ||||
end | ||||
r163 | if options[:all_sub] | |||
Submission.where(user_id: u.id,problem_id: problem.id).find_each do |sub| | ||||
r240 | next if options[:only_err] and sub.grader_comment != 'error during grading' | |||
r163 | @engine.grade(sub) | |||
end | ||||
else | ||||
last_sub = Submission.find_last_by_user_and_problem(u.id,problem.id) | ||||
if last_sub!=nil | ||||
r240 | @engine.grade(last_sub) unless options[:only_err] and last_sub.grader_comment != 'error during grading' | |||
r163 | end | |||
|
r23 | end | ||
end | ||||
end | ||||
|
r61 | def grade_submission(submission) | ||
r256 | puts "RUNNER: grade submission: #{submission.id} by #{submission.try(:user).try(:full_name)}" | |||
|
r61 | @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 | ||||
r256 | ||||
|
r23 | @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 | ||||