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