From d655ab74306d5382a180dae70aaec15b675df467 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Sat, 24 Feb 2018 11:01:45 -0500 Subject: [PATCH] use zscore for all averages --- app/models/school_category.rb | 7 +++++-- app/views/school_categories/_indicator.html.haml | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/school_category.rb b/app/models/school_category.rb index 0dca8370..6592bc8f 100644 --- a/app/models/school_category.rb +++ b/app/models/school_category.rb @@ -26,7 +26,10 @@ class SchoolCategory < ApplicationRecord return { attempt_count: attempt_data.attempt_count || 0, response_count: attempt_data.response_count || 0, - answer_index_total: attempt_data.answer_index_total || 0 + answer_index_total: attempt_data.answer_index_total || 0, + zscore: attempt_data.answer_index_total.nil? ? + zscore : + attempt_data.answer_index_total.to_f / attempt_data.response_count.to_f - 3.to_f } end @@ -54,7 +57,7 @@ class SchoolCategory < ApplicationRecord answer_index_total: _aggregated_responses[:answer_index_total] + child_school_categories.inject(0) { |total, csc| total + csc.answer_index_total }, - zscore: average_zscore.present? ? average_zscore : zscore + zscore: average_zscore.present? ? average_zscore : _aggregated_responses[:zscore] } end diff --git a/app/views/school_categories/_indicator.html.haml b/app/views/school_categories/_indicator.html.haml index 37b938d4..deead51d 100644 --- a/app/views/school_categories/_indicator.html.haml +++ b/app/views/school_categories/_indicator.html.haml @@ -1,7 +1,6 @@ - likert = info.answer_index_average - zscore = info.zscore.present? ? info.zscore + 3 : nil -- if zscore.present? - - likert = info.answer_index_average.nan? ? zscore : (info.answer_index_average + zscore) / 2 +- likert = zscore if zscore.present? - likert = likert.round(1) - return if likert.nan?