Class: Course::Assessment::Tab

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

Instance Method Summary collapse

Instance Method Details

#initialize_duplicate(duplicator, other) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/course/assessment/tab.rb', line 21

def initialize_duplicate(duplicator, other)
  self.category = if duplicator.duplicated?(other.category)
                    duplicator.duplicate(other.category)
                  else
                    duplicator.options[:destination_course].assessment_categories.first
                  end
  assessments <<
    other.assessments.select { |assessment| duplicator.duplicated?(assessment) }.map do |assessment|
      duplicator.duplicate(assessment).tap do |duplicate_assessment|
        duplicate_assessment.folder.parent = category.folder
      end
    end
end

#other_tabs_remaining?Boolean

Returns a boolean value indicating if there are other tabs besides this one remaining in its category.


17
18
19
# File 'app/models/course/assessment/tab.rb', line 17

def other_tabs_remaining?
  category.tabs.count > 1
end