Persist assessments in the testrun model

This commit is contained in:
Maximilian Grundke
2016-03-09 14:49:44 +01:00
parent 0b349489b4
commit 087b2bdf93
2 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,9 @@ module SubmissionScoring
future = Concurrent::Future.execute do future = Concurrent::Future.execute do
assessor = Assessor.new(execution_environment: submission.execution_environment) assessor = Assessor.new(execution_environment: submission.execution_environment)
output = execute_test_file(file, submission) output = execute_test_file(file, submission)
output.merge!(assessor.assess(output)) assessment = assessor.assess(output)
Testrun.new(submission: submission, file: file, passed: assessment[:passed] == assessment[:count], output: output[:stderr]).save
output.merge!(assessment)
output.merge!(filename: file.name_with_extension, message: feedback_message(file, output[:score]), weight: file.weight) output.merge!(filename: file.name_with_extension, message: feedback_message(file, output[:score]), weight: file.weight)
end end
future.value future.value
@ -27,9 +29,9 @@ module SubmissionScoring
def score_submission(submission) def score_submission(submission)
outputs = collect_test_results(submission) outputs = collect_test_results(submission)
score = 0.0 score = 0.0
if not (outputs.nil? || outputs.empty?) unless outputs.nil? || outputs.empty?
outputs.each do |output| outputs.each do |output|
if not output.nil? unless output.nil?
score += output[:score] * output[:weight] score += output[:score] * output[:weight]
end end
end end

View File

@ -1,4 +1,4 @@
class Testrun < ActiveRecord::Base class Testrun < ActiveRecord::Base
belongs_to :file belongs_to :file, class_name: 'CodeOcean::File'
belongs_to :submission belongs_to :submission
end end