use zscore for all averages

pull/1/head
Jared Cosulich 8 years ago
parent 52026544bd
commit d655ab7430

@ -26,7 +26,10 @@ class SchoolCategory < ApplicationRecord
return { return {
attempt_count: attempt_data.attempt_count || 0, attempt_count: attempt_data.attempt_count || 0,
response_count: attempt_data.response_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 end
@ -54,7 +57,7 @@ class SchoolCategory < ApplicationRecord
answer_index_total: answer_index_total:
_aggregated_responses[:answer_index_total] + _aggregated_responses[:answer_index_total] +
child_school_categories.inject(0) { |total, csc| total + csc.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 end

@ -1,7 +1,6 @@
- likert = info.answer_index_average - likert = info.answer_index_average
- zscore = info.zscore.present? ? info.zscore + 3 : nil - zscore = info.zscore.present? ? info.zscore + 3 : nil
- if zscore.present? - likert = zscore if zscore.present?
- likert = info.answer_index_average.nan? ? zscore : (info.answer_index_average + zscore) / 2
- likert = likert.round(1) - likert = likert.round(1)
- return if likert.nan? - return if likert.nan?

Loading…
Cancel
Save