mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
reversed options as well
This commit is contained in:
parent
e73351d0f5
commit
52d31ea0ca
2 changed files with 7 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue