Class: Survey::Survey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/survey/survey.rb

Instance Method Summary collapse

Instance Method Details

#available_for_participant?(participant) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'app/models/survey/survey.rb', line 38

def available_for_participant?(participant)
  current_number_of_attempts =
    self.attempts.for_participant(participant).size
  upper_bound = self.attempts_number
  not(current_number_of_attempts >= upper_bound and upper_bound != 0)
end

#correct_optionsObject

returns all the correct options for current surveys



29
30
31
# File 'app/models/survey/survey.rb', line 29

def correct_options
  Survey::Question.where(:section_id => self.sections.collect(&:id)).map { |question| question.correct_options }.flatten
end

#descriptionObject



49
50
51
# File 'app/models/survey/survey.rb', line 49

def description
  I18n.locale == I18n.default_locale ? super : locale_description.blank? ? super : locale_description
end

#incorrect_optionsObject

returns all the incorrect options for current surveys



34
35
36
# File 'app/models/survey/survey.rb', line 34

def incorrect_options
  Survey::Question.where(:section_id => self.sections.collect(&:id)).map { |question| question.incorrect_options }.flatten
end

#nameObject



45
46
47
# File 'app/models/survey/survey.rb', line 45

def name
  I18n.locale == I18n.default_locale ? super : locale_name.blank? ? super : locale_name
end