Sha256: aee47f783b115d2f6650dd8e0ff88b319f470e909ff906fe213d48ac48a9287f

Contents?: true

Size: 744 Bytes

Versions: 18

Compression:

Stored size: 744 Bytes

Contents

require 'securerandom'

class Submission
  include ActiveModel::Model

  required :try_evaluate!

  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.update! results
  end

  def notify_results!(results, assignment)
    assignment.notify!
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mumuki-laboratory-5.3.0 app/models/submission/submission.rb
mumuki-laboratory-5.2.1 app/models/submission/submission.rb
mumuki-laboratory-5.2.0 app/models/submission/submission.rb
mumuki-laboratory-5.1.1 app/models/submission/submission.rb
mumuki-laboratory-5.1.0 app/models/submission/submission.rb
mumuki-laboratory-5.0.12 app/models/submission/submission.rb
mumuki-laboratory-5.0.11 app/models/submission/submission.rb
mumuki-laboratory-5.0.10 app/models/submission/submission.rb
mumuki-laboratory-5.0.9 app/models/submission/submission.rb
mumuki-laboratory-5.0.8 app/models/submission/submission.rb
mumuki-laboratory-5.0.7 app/models/submission/submission.rb
mumuki-laboratory-5.0.6 app/models/submission/submission.rb
mumuki-laboratory-5.0.5 app/models/submission/submission.rb
mumuki-laboratory-5.0.4 app/models/submission/submission.rb
mumuki-laboratory-5.0.3 app/models/submission/submission.rb
mumuki-laboratory-5.0.2 app/models/submission/submission.rb
mumuki-laboratory-5.0.1 app/models/submission/submission.rb
mumuki-laboratory-5.0.0 app/models/submission/submission.rb