diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 257290a8..8405f751 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -14,7 +14,7 @@ class CategoriesController < ApplicationController district = @school.district authenticate(district.name.downcase, "#{district.name.downcase}!") @school_category = SchoolCategory.for(@school, @category).first - @child_school_categories = SchoolCategory.for_parent_category(@school, @category) + @child_school_categories = SchoolCategory.for_parent_category(@school, @category).valid @questions = @category.questions end diff --git a/app/models/school_category.rb b/app/models/school_category.rb index 91137019..b7ecd763 100644 --- a/app/models/school_category.rb +++ b/app/models/school_category.rb @@ -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? diff --git a/app/views/school_categories/_indicator.html.haml b/app/views/school_categories/_indicator.html.haml index 734124fd..8299fb7b 100644 --- a/app/views/school_categories/_indicator.html.haml +++ b/app/views/school_categories/_indicator.html.haml @@ -6,6 +6,8 @@ - likert = info.answer_index_average.nan? ? zscore : (info.answer_index_average + zscore) / 2 - likert = likert.round(1) +- return if likert.nan? + - average_offset = (likert/num_likerts) * 100 - approval_zone = [[76, 90], [77, 91], [71, 85], [73, 86], [73, 86], []][info.category.root_index]