Sha256: 50a14a963e7f6f148e6cda6c788d712b00e0a8b9488a912796cff13b5bbf6c42
Contents?: true
Size: 836 Bytes
Versions: 9
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true module Decidim module Forms # The data store for a Questionnaire in the Decidim::Forms component. class Questionnaire < Forms::ApplicationRecord belongs_to :questionnaire_for, polymorphic: true has_many :questions, -> { order(:position) }, class_name: "Question", foreign_key: "decidim_questionnaire_id", dependent: :destroy has_many :answers, class_name: "Answer", foreign_key: "decidim_questionnaire_id", dependent: :destroy # Public: returns whether the questionnaire questions can be modified or not. def questions_editable? answers.empty? end # Public: returns whether the questionnaire is answered by the user or not. def answered_by?(user) answers.where(user: user).any? if questions.present? end end end end
Version data entries
9 entries across 9 versions & 1 rubygems