Class: Course::Assessment::Skill

Inherits:
ApplicationRecord show all
Defined in:
app/models/course/assessment/skill.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.order_by_title(direction = :asc) ⇒ Object

Orders the skills alphabetically by title.


11
# File 'app/models/course/assessment/skill.rb', line 11

scope :order_by_title, ->(direction = :asc) { order(title: direction) }

Instance Method Details

#initialize_duplicate(duplicator, other) ⇒ Object


13
14
15
16
17
18
19
# File 'app/models/course/assessment/skill.rb', line 13

def initialize_duplicate(duplicator, other)
  self.course = duplicator.options[:destination_course]
  self.skill_branch = duplicator.duplicated?(other.skill_branch) ? duplicator.duplicate(other.skill_branch) : nil
  questions << other.questions.map(&:actable).
               select { |question| duplicator.duplicated?(question) }.
               map { |question| duplicator.duplicate(question).acting_as }
end