Sha256: 83ca35db98fdb462a61657b50e2534e99269e752e598859ddd24610019b2cef2

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

class Problem < QueriableChallenge
  include WithExpectations,
          WithEditor,
          Solvable

  markdown_on :corollary

  validate :ensure_evaluation_criteria

  name_model_as Exercise

  def save_query_submission!(_assignment, _submission)
  end

  def save_query_results!(assignment)
  end

  def reset!
    super
    self.test = nil
    self.expectations = []
  end

  alias_method :own_expectations, :expectations
  alias_method :own_custom_expectations, :custom_expectations

  def expectations
    own_expectations + guide.expectations
  end

  def custom_expectations
    "#{own_custom_expectations}\n#{guide.custom_expectations}"
  end

  def evaluation_criteria?
    manual_evaluation? || automated_evaluation?
  end

  def mixed_evaluation?
    manual_evaluation? && automated_evaluation?
  end

  def automated_evaluation?
    expectations? || test.present?
  end

  def expectations?
    own_expectations.present? || own_custom_expectations.present?
  end

  def evaluation_class
    if mixed_evaluation?
      Mumuki::Domain::Evaluation::Mixed
    elsif manual_evaluation?
      Mumuki::Domain::Evaluation::Manual
    else
      Mumuki::Domain::Evaluation::Automated
    end
  end

  # Sets the layout. This method accepts input_kids as a synonym of input_primary
  # for historical reasons
  def layout=(layout)
    self[:layout] = layout.like?(:input_kids) ? :input_primary : layout
  end

  private

  def ensure_evaluation_criteria
    errors.add :base, :evaluation_criteria_required unless evaluation_criteria?
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/exercise/problem.rb
mumuki-domain-9.22.1 app/models/exercise/problem.rb
mumuki-domain-9.22.0 app/models/exercise/problem.rb
mumuki-domain-9.21.0 app/models/exercise/problem.rb
mumuki-domain-9.20.0 app/models/exercise/problem.rb
mumuki-domain-9.19.0 app/models/exercise/problem.rb
mumuki-domain-9.18.0 app/models/exercise/problem.rb
mumuki-domain-9.17.0 app/models/exercise/problem.rb
mumuki-domain-9.16.0 app/models/exercise/problem.rb
mumuki-domain-9.15.0 app/models/exercise/problem.rb
mumuki-domain-9.14.1 app/models/exercise/problem.rb
mumuki-domain-9.14.0 app/models/exercise/problem.rb
mumuki-domain-9.13.1 app/models/exercise/problem.rb
mumuki-domain-9.13.0 app/models/exercise/problem.rb
mumuki-domain-9.12.0 app/models/exercise/problem.rb
mumuki-domain-9.11.0 app/models/exercise/problem.rb
mumuki-domain-9.10.0 app/models/exercise/problem.rb
mumuki-domain-9.9.0 app/models/exercise/problem.rb