Class: Course::QuestionAssessment

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

Instance Method Summary collapse

Instance Method Details

#display_titlestring

Prefixes a question number in front of the title

Returns:

  • (string)

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

def display_title
  question_number = I18n.t('activerecord.course/assessment/question.question_number',
                           index: assessment.question_assessments.index(self) + 1)

  return question_number if question.title.blank?
  I18n.t('activerecord.course/assessment/question.question_with_title',
         question_number: question_number, title: question.title)
end

#initialize_duplicate(duplicator, other) ⇒ Object


22
23
24
25
# File 'app/models/course/question_assessment.rb', line 22

def initialize_duplicate(duplicator, other)
  self.weight = other.weight
  self.question = duplicator.duplicate(other.question.actable).acting_as
end