Class: AskIt::Survey

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

Instance Method Summary collapse

Instance Method Details

#avaliable_for_participant?(participant) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
# File 'app/models/ask_it/survey.rb', line 41

def avaliable_for_participant?(participant)
  current_number_of_attempts =
    attempts.for_participant(participant).size
  upper_bound = attempts_number
  !(current_number_of_attempts >= upper_bound && upper_bound != 0)
end

#correct_optionsObject

returns all the correct options for current surveys



32
33
34
# File 'app/models/ask_it/survey.rb', line 32

def correct_options
  AskIt::Question.where(section_id: section_ids).map(&:correct_options).flatten
end

#descriptionObject



56
57
58
59
60
61
62
# File 'app/models/ask_it/survey.rb', line 56

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

#incorrect_optionsObject

returns all the incorrect options for current surveys



37
38
39
# File 'app/models/ask_it/survey.rb', line 37

def incorrect_options
  AskIt::Question.where(section_id: sections.collect(&:id)).map(&:incorrect_options).flatten
end

#nameObject



48
49
50
51
52
53
54
# File 'app/models/ask_it/survey.rb', line 48

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