Sha256: 569b3f899f51c18ac950f8c203c82a6389f411ff4c54cfdd70aa5611817b1d31

Contents?: true

Size: 849 Bytes

Versions: 19

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # A class used to collect user answers for a questionnaire
    class QuestionnaireUserAnswers < Rectify::Query
      # Syntactic sugar to initialize the class and return the queried objects.
      #
      # questionnaire - a Questionnaire object
      def self.for(questionnaire)
        new(questionnaire).query
      end

      # Initializes the class.
      #
      # questionnaire = a Questionnaire object
      def initialize(questionnaire)
        @questionnaire = questionnaire
      end

      # Finds and group answers by user for each questionnaire's question.
      def query
        answers = Answer.joins(:question).where(questionnaire: @questionnaire)

        answers.sort_by { |answer| answer.question.position }.group_by(&:user).values
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-meetings-0.26.10 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.9 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.8 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.7 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.5 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.4 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.3 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.2 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.1 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.0 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.0.rc2 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.26.0.rc1 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.2 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.1 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.0 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.0.rc4 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.0.rc3 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.0.rc2 app/queries/decidim/meetings/questionnaire_user_answers.rb
decidim-meetings-0.25.0.rc1 app/queries/decidim/meetings/questionnaire_user_answers.rb