reversed options as well

pull/1/head
Jared Cosulich 8 years ago
parent e73351d0f5
commit 52d31ea0ca

@ -32,8 +32,13 @@ class Question < ApplicationRecord
[option1, option2, option3, option4, option5]
end
def options_with_reverse
return options.reverse if reverse?
options
end
def option_index(answer)
options.map(&:downcase).map(&:strip).index(answer.downcase.strip)
options_with_reverse.map(&:downcase).map(&:strip).index(answer.downcase.strip)
end
def aggregated_responses_for_school(school)

@ -1,7 +1,7 @@
- histogram = data.responses.map(&:answer_index_with_reverse).group_by { |a| a.to_s }
%table.answers
%tbody
- data.question.options.each_with_index do |option, index|
- data.question.options_with_reverse.each_with_index do |option, index|
%tr.answer
- group = histogram[(index + 1).to_s]
- width = (100 * (group.blank? ? 0 : group.length)) / histogram.values.flatten.length

Loading…
Cancel
Save