Class: Course::Settings::LessonPlanItems

Inherits:
PanComponent
  • Object
show all
Defined in:
app/models/course/settings/lesson_plan_items.rb

Overview

This model facilitates displaying and setting of lesson plan item settings.

To add lesson plan item settings to a course component, ensure that these two methods are defined on the component's setting model (see ControllerComponentHost::Settings::ClassMethods#settings_class):

Lesson Plan Item settings are stored with the individual course components as all such items e.g. Surveys and Videos, act as lesson plan items.

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Course::Settings::PanComponent

Instance Method Details

#actable_hashHash{String => Array or nil}

Gets a hash of actable type names for lesson plan items of enabled components mapped to data that will be passed to actable's model scope for further processing.


57
58
59
60
61
# File 'app/models/course/settings/lesson_plan_items.rb', line 57

def actable_hash
  lesson_plan_item_actable_names.map do |actable_name|
    actable_hash_data(actable_name)
  end.compact.to_h
end

#lesson_plan_item_settingsArray<Hash>

Consolidates lesson plan item settings from each course component. Each setting item should be a hash in the format similar to the this example: The setting item hash format might have to change when other components need item settings.

{
  component: :course_assessments_component, # Component key
  category_title: 'Category title',         # For display
  enabled: true,                # The user's setting, otherwise, the default setting
  tab_title: 'Quests',          # For display
  options: { category_id: 5, tab_id: 145 },  # Other info for the setting
}

31
32
33
# File 'app/models/course/settings/lesson_plan_items.rb', line 31

def lesson_plan_item_settings
  consolidate_settings_from_components(:lesson_plan_item_settings)
end

#update(attributes) ⇒ Boolean

Updates a single lesson plan item setting. It delegates the updating to the appropriate settings model. The attributes hash is expected to have the following shape:

{
  'component' => 'course_assessments_component', # Component key
  'enabled' => false,                  # The new setting
  'options' => { 'category_id' => 5 }, # [Optional] Other info for the setting
}

49
50
51
# File 'app/models/course/settings/lesson_plan_items.rb', line 49

def update(attributes)
  update_setting_in_component(:update_lesson_plan_item_setting, attributes)
end