Sha256: 89b355a9de7261e566006e7be3d7d71a74c4f7eaded4619005e712ed9c3e38bc

Contents?: true

Size: 1.16 KB

Versions: 27

Compression:

Stored size: 1.16 KB

Contents

class Problem < QueriableChallenge
  include WithExpectations,
          WithEditor,
          Solvable

  markdown_on :corollary

  validate :ensure_evaluation_criteria

  name_model_as Exercise

  def setup_query_assignment!(assignment)
  end

  def save_query_results!(assignment)
  end

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

  def expectations
    own_expectations + guide_expectations
  end

  def custom_expectations
    "#{own_custom_expectations}\n#{guide_custom_expectations}"
  end

  def guide_expectations
    guide.expectations
  end

  def guide_custom_expectations
    guide.custom_expectations
  end

  def evaluation_criteria?
    manual_evaluation? || expectations? || test.present?
  end

  def expectations?
    own_expectations.present? || own_custom_expectations.present?
  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

27 entries across 27 versions & 2 rubygems

Version Path
mumuki-domain-8.1.2 app/models/exercise/problem.rb
mumuki-domain-8.1.1 app/models/exercise/problem.rb
mumuki-domain-8.1.0 app/models/exercise/problem.rb
mumuki-domain-8.0.0 app/models/exercise/problem.rb
mumuki-domain-7.12.2 app/models/exercise/problem.rb
mumuki-domain-7.12.1 app/models/exercise/problem.rb
mumuki-domain-7.12.0 app/models/exercise/problem.rb
mumuki-domain-7.11.1 app/models/exercise/problem.rb
mumuki-laboratory-7.11.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-c92f2a7212e2/app/models/exercise/problem.rb
mumuki-laboratory-7.11.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-2e15c3330133/app/models/exercise/problem.rb
mumuki-domain-7.11.0 app/models/exercise/problem.rb
mumuki-domain-7.10.1 app/models/exercise/problem.rb
mumuki-domain-7.10.0 app/models/exercise/problem.rb
mumuki-laboratory-7.9.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-7082a83493eb/app/models/exercise/problem.rb
mumuki-domain-7.9.2 app/models/exercise/problem.rb
mumuki-laboratory-7.9.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-b162dc91aa77/app/models/exercise/problem.rb
mumuki-domain-7.9.1 app/models/exercise/problem.rb
mumuki-laboratory-7.9.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-520f859ca8af/app/models/exercise/problem.rb
mumuki-domain-7.9.0 app/models/exercise/problem.rb
mumuki-domain-7.7.3 app/models/exercise/problem.rb