Sha256: 3efaa9b2f2d359dbd5259915db9573fe8a4f15f5b233d39a168c036b049c35ad

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 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

  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? || 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

12 entries across 12 versions & 1 rubygems

Version Path
mumuki-domain-9.0.5 app/models/exercise/problem.rb
mumuki-domain-9.0.4 app/models/exercise/problem.rb
mumuki-domain-9.0.3 app/models/exercise/problem.rb
mumuki-domain-9.0.2 app/models/exercise/problem.rb
mumuki-domain-9.0.0 app/models/exercise/problem.rb
mumuki-domain-8.6.1 app/models/exercise/problem.rb
mumuki-domain-8.6.0 app/models/exercise/problem.rb
mumuki-domain-8.5.0 app/models/exercise/problem.rb
mumuki-domain-8.4.0 app/models/exercise/problem.rb
mumuki-domain-8.3.1 app/models/exercise/problem.rb
mumuki-domain-8.2.0 app/models/exercise/problem.rb
mumuki-domain-8.1.3 app/models/exercise/problem.rb