diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 28ce9c447..9c83bc3e3 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -9,10 +9,14 @@ class PollsController < ApplicationController end def show - questions = @poll.questions.sort_for_list.for_render + @answerable_questions = @poll.questions.answerable_by(current_user).for_render.sort_for_list + @non_answerable_questions = @poll.questions.where.not(id: @answerable_questions.map(&:id)).for_render.sort_for_list - @answerable_questions = questions.answerable_by(current_user) - @non_answerable_questions = questions.where.not(id: @answerable_questions.pluck(:id)) + @answers_by_question_id = {} + poll_partial_results = Poll::PartialResult.by_question(@poll.question_ids).by_author(current_user.try(:id)) + poll_partial_results.each do |result| + @answers_by_question_id[result.question_id] = result.answer + end end end diff --git a/app/views/poll/questions/_answers.html.erb b/app/views/poll/questions/_answers.html.erb new file mode 100644 index 000000000..94eed7045 --- /dev/null +++ b/app/views/poll/questions/_answers.html.erb @@ -0,0 +1,23 @@ +