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