Module: Extensions::ActsAsHelpers::ActiveRecord::Base::ClassMethods

Defined in:
lib/extensions/acts_as_helpers/active_record/base.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_experience_points_recordObject

Decorator for items that give course_users EXP Points


5
6
7
8
# File 'lib/extensions/acts_as_helpers/active_record/base.rb', line 5

def acts_as_experience_points_record
  acts_as :experience_points_record, class_name: Course::ExperiencePointsRecord.name
  include ExperiencePointsInstanceMethods
end

#acts_as_lesson_plan_item(has_todo: false) ⇒ Object

Decorator for abstractions with concrete occurrences for student activities with a start and end date, with the option to: (i) Award course_users with EXP Points, and/or (ii) Appear as a todo item for each course_user once it is published

Todo acts as reminders for sutdents to act on. Todos are also automatically created when the lesson_plan_item transits from draft to non-draft, and destroyed in the reverse case (see Course::LessonPlan::ItemTodoConcern).

To declare that an actable model has todos:

  • Define has_todo as true when calling acts_as_lesson_plan_item
  • Define hooks to update todo's workflow_state (see Course::LessonPlan::Todo)
  • For additional logic on whether a user can start an item, overwrite #can_user_start? in the actable model.
  • Implement two view partials for the actable model for display in the course landing page. 1) todo#Extensions::ActsAsHelpers::ActiveRecord::Base::ClassMethods.actableactable.classactable.class.nametitle.html.slim -> Title and any links if required. 2) _todo#Extensions::ActsAsHelpers::ActiveRecord::Base::ClassMethods.actableactable.classactable.class.name_button.html.slim -> Action button for todo.

26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/extensions/acts_as_helpers/active_record/base.rb', line 26

def acts_as_lesson_plan_item(has_todo: false)
  acts_as :lesson_plan_item, class_name: Course::LessonPlan::Item.name

  class << self
    attr_accessor :has_todo
  end
  self.has_todo = has_todo ? true : false

  scope :active, -> { joins(:lesson_plan_item).merge(Course::LessonPlan::Item.currently_active) }

  extend LessonPlanItemClassMethods
  include LessonPlanItemInstanceMethods
end