Class: Problem

Inherits:
QueriableChallenge show all
Includes:
Solvable, WithEditor, WithExpectations
Defined in:
app/models/exercise/problem.rb

Constant Summary

Constants inherited from Exercise

Exercise::BASIC_RESOURCE_FIELDS, Exercise::RANDOMIZED_FIELDS

Instance Method Summary collapse

Methods included from WithExpectations

#ensure_expectations_format, #expectations=, #expectations_yaml, #expectations_yaml=, #own_custom_expectations, #own_expectations

Methods included from WithEditor

#choice?, #editor_with_defaults?, #pretty_choices

Methods included from Solvable

#run_tests!, #solution_for, #submit_solution!

Methods included from Queriable

#run_query!, #submit_query!

Methods inherited from Challenge

#extra

Methods included from WithLayout

#input_kids?

Methods inherited from Exercise

#choice?, #choice_index_for, #choice_values, #console?, #custom?, #description_context, #description_task, #ensure_type!, #files_for, find_transparently!, #friendly, #guide_done_for?, #import_from_resource_h!, #inspection_keywords, #limited?, locate!, #messages_path_for, #messages_url_for, #new_solution, #pending_siblings_for, #previous, #reclassify!, #results_hidden?, #search_tags, #settings, #sibling_at, #splitted_description, #structural_parent, #submission_for, #to_expanded_resource_h, #to_resource_h, #transparent_id, #transparent_params, #try_submit_solution!, #used_in?

Methods included from SiblingsNavigation

#navigable_name, #next_for, #restart, #siblings

Methods included from ParentNavigation

#leave, #navigable_name, #navigable_parent, #navigation_end?

Methods included from Submittable

#find_assignment_and_submit!, #submit!

Methods included from Questionable

#submit_question!

Methods included from WithAssignments

#assignment_for, #find_assignment_for, #has_messages_for?, #messages_for, #status_for

Methods included from FriendlyName

#friendly_name, #to_param

Methods included from Assistable

#assist_with, #assistant

Methods included from WithRandomizations

#randomizer, #seed, #seed_with!

Methods included from WithDiscussions

#discuss!, #new_discussion_for, #submission_for, #try_solve_discussions

Methods included from WithDescription

#description_teaser

Methods inherited from ApplicationRecord

aggregate_of, all_except, defaults, #delete, #destroy!, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, #update_and_notify!, update_or_create!, whitelist_attributes

Instance Method Details

#custom_expectationsObject



28
29
30
# File 'app/models/exercise/problem.rb', line 28

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

#evaluation_criteria?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/models/exercise/problem.rb', line 40

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

#expectationsObject



24
25
26
# File 'app/models/exercise/problem.rb', line 24

def expectations
  own_expectations + guide_expectations
end

#expectations?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/exercise/problem.rb', line 44

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

#guide_custom_expectationsObject



36
37
38
# File 'app/models/exercise/problem.rb', line 36

def guide_custom_expectations
  guide.custom_expectations
end

#guide_expectationsObject



32
33
34
# File 'app/models/exercise/problem.rb', line 32

def guide_expectations
  guide.expectations
end

#layout=(layout) ⇒ Object

Sets the layout. This method accepts input_kids as a synonym of input_primary for historical reasons



50
51
52
# File 'app/models/exercise/problem.rb', line 50

def layout=(layout)
  self[:layout] = layout.like?(:input_kids) ? :input_primary : layout
end

#reset!Object



18
19
20
21
22
# File 'app/models/exercise/problem.rb', line 18

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

#save_query_results!(assignment) ⇒ Object



15
16
# File 'app/models/exercise/problem.rb', line 15

def save_query_results!(assignment)
end

#setup_query_assignment!(assignment) ⇒ Object



12
13
# File 'app/models/exercise/problem.rb', line 12

def setup_query_assignment!(assignment)
end