Sha256: 972f54f11b604adda20ed5b8c3d1508f9b67884b80691c51a1e80e6286d2d232
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
require 'securerandom' class Submission include ActiveModel::Model required :try_evaluate! ATTRIBUTES = [:solution, :status, :result, :expectation_results, :feedback, :test_results, :submission_id, :queries, :query_results, :manual_evaluation_comment] attr_accessor *ATTRIBUTES def self.from_attributes(*args) new ATTRIBUTES.zip(args).to_h end def self.mapping_attributes ATTRIBUTES end def run!(assignment, evaluation) save_submission! assignment results = evaluation.evaluate! assignment, self save_results! results, assignment notify_results! results, assignment results end def evaluate!(assignment) try_evaluate! assignment rescue => e {status: :errored, result: e.message} end def id @id ||= SecureRandom.hex(8) end private def save_submission!(assignment) assignment.content = content assignment.save! end def save_results!(results, assignment) assignment.assign_attributes results assignment.increment_attemps! assignment.save! results end def notify_results!(results, assignment) assignment.notify! end end
Version data entries
4 entries across 4 versions & 1 rubygems