Module: Course::LessonPlanConcern

Extended by:
ActiveSupport::Concern
Included in:
Course
Defined in:
app/models/concerns/course/lesson_plan_concern.rb

Instance Method Summary collapse

Instance Method Details

#grouped_lesson_plan_items_with_milestonesHash{Course::LessonPlan::Milestone,nil=>Array<Course::LessonPlanItem>}

Groups lesson plan items by their milestone.

This combines the lesson plan milestones with the items, grouping them by milestone.

There may be a special key, +nil+ for items which do not come under a milestone.

Returns:

  • (Hash{Course::LessonPlan::Milestone,nil=>Array<Course::LessonPlanItem>})

    The items grouped by key, with a nil key indicating items not belonging to any milestone.


13
14
15
16
17
18
# File 'app/models/concerns/course/lesson_plan_concern.rb', line 13

def grouped_lesson_plan_items_with_milestones
  milestones = lesson_plan_milestones.order(start_at: :asc).to_a
  items = lesson_plan_items.order(start_at: :asc).includes(:actable).to_a

  group_lesson_plan_items_with_milestones(milestones, items)
end