Sha256: 80e41a9eaab102bd04aec2fc8912f3a0fc495302b7225c13f2b48c4f4f1398ca
Contents?: true
Size: 787 Bytes
Versions: 43
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true module Decidim module Surveys # The data store for a Survey in the Decidim::Surveys component. class Survey < Surveys::ApplicationRecord include Decidim::HasFeature feature_manifest_name "surveys" has_many :questions, -> { order(:position) }, class_name: "SurveyQuestion", foreign_key: "decidim_survey_id" has_many :answers, class_name: "SurveyAnswer", foreign_key: "decidim_survey_id" # Public: returns whether the survey questions can be modified or not. def questions_editable? answers.empty? end # Public: returns whether the survey is answered by the user or not. def answered_by?(user) answers.where(user: user).count == questions.length end end end end
Version data entries
43 entries across 43 versions & 2 rubygems