Class: Decidim::Surveys::Survey

Inherits:
ApplicationRecord show all
Includes:
HasFeature
Defined in:
decidim-surveys/app/models/decidim/surveys/survey.rb

Overview

The data store for a Survey in the Decidim::Surveys component.

Instance Method Summary collapse

Instance Method Details

#answered_by?(user) ⇒ Boolean

Public: returns whether the survey is answered by the user or not.

Returns:

  • (Boolean)


20
21
22
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 20

def answered_by?(user)
  answers.where(user: user).count == questions.length
end

#questions_editable?Boolean

Public: returns whether the survey questions can be modified or not.

Returns:

  • (Boolean)


15
16
17
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 15

def questions_editable?
  answers.empty?
end