|
|
|
|
@ -9,6 +9,8 @@ class SchoolCategory < ApplicationRecord
|
|
|
|
|
scope :for, -> (school, category) { where(school: school).where(category: category) }
|
|
|
|
|
scope :for_parent_category, -> (school, category=nil) { where(school: school).joins(:category).merge(Category.for_parent(category)) }
|
|
|
|
|
|
|
|
|
|
scope :valid, -> { where("answer_index_total > 0 or zscore is not null") }
|
|
|
|
|
|
|
|
|
|
def answer_index_average
|
|
|
|
|
answer_index_total.to_f / response_count.to_f
|
|
|
|
|
end
|
|
|
|
|
@ -32,8 +34,8 @@ class SchoolCategory < ApplicationRecord
|
|
|
|
|
_aggregated_responses = aggregated_responses
|
|
|
|
|
|
|
|
|
|
child_school_categories = category.child_categories.collect do |cc|
|
|
|
|
|
SchoolCategory.for(school, cc)
|
|
|
|
|
end.flatten
|
|
|
|
|
SchoolCategory.for(school, cc).valid
|
|
|
|
|
end.flatten.compact
|
|
|
|
|
|
|
|
|
|
new_zscore = zscore
|
|
|
|
|
if new_zscore.nil?
|
|
|
|
|
|