Switch from valid_answers to question_answers usage for Poll Questions
This commit is contained in:
@@ -15,7 +15,6 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
|
||||
|
||||
def new
|
||||
@polls = Poll.all
|
||||
@question.valid_answers = I18n.t('poll_questions.default_valid_answers')
|
||||
proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present?
|
||||
@question.copy_attributes_from_proposal(proposal)
|
||||
end
|
||||
@@ -56,7 +55,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
|
||||
private
|
||||
|
||||
def question_params
|
||||
params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url)
|
||||
params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :video_url)
|
||||
end
|
||||
|
||||
def search_params
|
||||
|
||||
@@ -51,7 +51,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
results.each_pair do |answer_index, count|
|
||||
next if count.blank?
|
||||
answer = question.valid_answers[answer_index.to_i]
|
||||
answer = question.question_answers.where(given_order: answer_index.to_i + 1).first.title
|
||||
go_back_to_new if question.blank?
|
||||
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% question.valid_answers.each_with_index do |answer, i| %>
|
||||
<% question.question_answers.each_with_index do |answer, i| %>
|
||||
<% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %>
|
||||
<tr id="question_<%= question.id %>_<%= i %>_result">
|
||||
<td><%= answer %></td>
|
||||
<td class="text-center"><%= by_answer[answer].present? ? by_answer[answer].sum(&:amount) : 0 %></td>
|
||||
<td><%= answer.title %></td>
|
||||
<td class="text-center"><%= by_answer[answer.title].present? ? by_answer[answer.title].sum(&:amount) : 0 %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% question.valid_answers.each_with_index do |answer, i| %>
|
||||
<% question.question_answers.each_with_index do |answer, i| %>
|
||||
<% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %>
|
||||
<tr id="question_<%= question.id %>_<%= i %>_result">
|
||||
<td><%= answer %></td>
|
||||
<td><%= by_answer[answer].present? ? by_answer[answer].first.amount : 0 %></td>
|
||||
<td><%= answer.title %></td>
|
||||
<td><%= by_answer[answer.title].present? ? by_answer[answer.title].first.amount : 0 %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
<div class="small-12 column">
|
||||
<h3><%= question.title %></h3>
|
||||
</div>
|
||||
<% question.valid_answers.each_with_index do |answer, i| %>
|
||||
<% question.question_answers.each_with_index do |answer, i| %>
|
||||
<div class="small-12 medium-6 large-3 column end">
|
||||
<label><%= answer %></label>
|
||||
<label><%= answer.title %></label>
|
||||
<%= text_field_tag "questions[#{question.id}][#{i}]", answer_result_value(question.id, i), placeholder: "0" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -156,7 +156,6 @@ en:
|
||||
description: "Description"
|
||||
poll/question:
|
||||
title: "Question"
|
||||
valid_answers: "Posibles answers"
|
||||
summary: "Summary"
|
||||
description: "Description"
|
||||
external_url: "Link to additional documentation"
|
||||
|
||||
@@ -500,7 +500,6 @@ en:
|
||||
videos: "External video"
|
||||
poll_questions:
|
||||
create_question: "Create question"
|
||||
default_valid_answers: "Yes, No"
|
||||
show:
|
||||
vote_answer: "Vote %{answer}"
|
||||
voted: "You have voted %{answer}"
|
||||
|
||||
@@ -150,7 +150,6 @@ es:
|
||||
description: "Descripción"
|
||||
poll/question:
|
||||
title: "Pregunta"
|
||||
valid_answers: "Posibles respuestas"
|
||||
summary: "Resumen"
|
||||
description: "Descripción"
|
||||
external_url: "Enlace a documentación adicional"
|
||||
|
||||
@@ -500,7 +500,6 @@ es:
|
||||
videos: "Vídeo externo"
|
||||
poll_questions:
|
||||
create_question: "Crear pregunta para votación"
|
||||
default_valid_answers: "Sí, No"
|
||||
show:
|
||||
vote_answer: "Votar %{answer}"
|
||||
voted: "Has votado %{answer}"
|
||||
|
||||
Reference in New Issue
Block a user