diff --git a/app/models/category.rb b/app/models/category.rb index d23e637c..d8e90310 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -34,4 +34,13 @@ class Category < ApplicationRecord ].index(root_identifier) || 0 end + def zone_widths + return nil if zones.nil? + split_zones = zones.split(",") + + w = split_zones.each_with_index.map do |zone, index| + (zone.to_f - (index == 0 ? 0 : split_zones[index - 1]).to_f).round(2) + end + end + end diff --git a/app/views/school_categories/_indicator.html.haml b/app/views/school_categories/_indicator.html.haml index 8299fb7b..37b938d4 100644 --- a/app/views/school_categories/_indicator.html.haml +++ b/app/views/school_categories/_indicator.html.haml @@ -1,5 +1,3 @@ -- num_likerts = 5 - - likert = info.answer_index_average - zscore = info.zscore.present? ? info.zscore + 3 : nil - if zscore.present? @@ -8,21 +6,24 @@ - return if likert.nan? +- num_likerts = 5 - average_offset = (likert/num_likerts) * 100 -- approval_zone = [[76, 90], [77, 91], [71, 85], [73, 86], [73, 86], []][info.category.root_index] +- default_approval_zone = [[76, 90], [77, 91], [71, 85], [73, 86], [73, 86], []][info.category.root_index] + +- zone_descriptions = ['Warning Zone: Schools that fall in this range are five or more years away from reaching community-wide targets. Consequently, this zone, as established by teachers, principals, parents, and district administrators, indicates that a school is in significant need of improvement. If the school is not in the Warning Zone in other areas, it may be a relatively successful school overall. Still, it must immediately develop a plan for addressing its shortcomings.', 'Watch Zone: Schools falling in this range are three or four years away from reaching community-wide targets. This zone, established by teachers, principals, parents, and district administrators, is not an ideal place for schools to be. But it does not mean that the school is failing. Instead, it means that the school needs to place particular emphasis on improving its work in this area.', 'Growth Zone: Schools falling in this range earned scores just below "acceptable." Yet these schools are close enough to the Approval Zone that they might reasonably reach it within two years. As established by teachers, principals, parents, and district administrators, this zone is an acceptable place for schools to be if they have the leadership, focus, and resources to improve their work in a particular area.', 'Approval Zone: Schools falling in this range earned scores between "acceptable" and "ideal." This zone, established by teachers, principals, parents, and district administrators, is the target that all schools should be striving to hit. Scoring in this range does not mean that a school is perfect; but it does mean that it is meeting or exceeding community-wide expectations in a particular category.', 'This area represents a set of outcomes so close to perfect that they are unlikely to be realized in any school.'] -- if approval_zone.present? - - zone_widths = [0] - - zone_widths << approval_zone[0] - (15 + 15) - - zone_widths << 15 - - zone_widths << 15 - - zone_widths << approval_zone[1] - approval_zone[0] - - zone_widths << 100 - approval_zone[1] - - zones = ['Warning Zone: Schools that fall in this range are five or more years away from reaching community-wide targets. Consequently, this zone, as established by teachers, principals, parents, and district administrators, indicates that a school is in significant need of improvement. If the school is not in the Warning Zone in other areas, it may be a relatively successful school overall. Still, it must immediately develop a plan for addressing its shortcomings.', 'Watch Zone: Schools falling in this range are three or four years away from reaching community-wide targets. This zone, established by teachers, principals, parents, and district administrators, is not an ideal place for schools to be. But it does not mean that the school is failing. Instead, it means that the school needs to place particular emphasis on improving its work in this area.', 'Growth Zone: Schools falling in this range earned scores just below "acceptable." Yet these schools are close enough to the Approval Zone that they might reasonably reach it within two years. As established by teachers, principals, parents, and district administrators, this zone is an acceptable place for schools to be if they have the leadership, focus, and resources to improve their work in a particular area.', 'Approval Zone: Schools falling in this range earned scores between "acceptable" and "ideal." This zone, established by teachers, principals, parents, and district administrators, is the target that all schools should be striving to hit. Scoring in this range does not mean that a school is perfect; but it does mean that it is meeting or exceeding community-wide expectations in a particular category.', 'This area represents a set of outcomes so close to perfect that they are unlikely to be realized in any school.'] -- else - - zone_widths = [0, 100] - - zones = ['There is not yet any national data to compare to for this measure.'] +- if (zone_widths = info.category.zone_widths).nil? + - if default_approval_zone.present? + - zone_widths = [default_approval_zone[0] - (15 + 15)] + - zone_widths << 15 + - zone_widths << 15 + - zone_widths << default_approval_zone[1] - default_approval_zone[0] + - zone_widths << 100 - default_approval_zone[1] + - zone_widths = zone_widths.map { |z| z / 20.0 } + - else + - zone_widths = [5] + - zone_descriptions = ['There is not yet any national data to compare to for this measure.'] - buffer = 0.25 - this_school_zone = "This school scored in the range between #{(likert - buffer).round(2)} and #{(likert + buffer).round(2)}.\n\nMouse over each color to read a description of each zone." @@ -31,9 +32,9 @@ .indicator-circle .indicator-zones{style: "margin-left: #{local_assigns[:small] ? ((average_offset - 5) * -10) : 0}%"} - zone_total = 0 - - zones.each_with_index do |zone, index| - %div{class: "zone#{index}", style: "width: #{zone_widths[index+1]}%", title: "#{zone}\n\nThis zone: #{(zone_total/20.0).round(2)} - #{((zone_total + zone_widths[index+1])/20.0).round(2)}\nThis school: #{(likert - buffer).round(2)} - #{(likert + buffer).round(2)}"} - - zone_total += zone_widths[index + 1] + - zone_descriptions.each_with_index do |zone, index| + %div{class: "zone#{index}", style: "width: #{zone_widths[index]*20}%", title: "#{zone}\n\nThis zone: #{(zone_total).round(2)} - #{((zone_total + zone_widths[index])).round(2)}\nThis school: #{(likert - buffer).round(2)} - #{(likert + buffer).round(2)}"} + - zone_total += zone_widths[index] - if local_assigns[:small] -# .average{title: this_school_zone} diff --git a/data/Benchmarks2016-2017.csv b/data/Benchmarks2016-2017.csv new file mode 100644 index 00000000..33d7805f --- /dev/null +++ b/data/Benchmarks2016-2017.csv @@ -0,0 +1 @@ +,Subcategory,Improvement Step,Warning High,Watch Low,Watch High,Growth Low,Growth High,Approval Low,Approval High,Ideal Low 1A-i,Professional Qualifications,0.49,2.06,2.07,2.56,2.57,3.05,3.06,4.2,4.21 1A-ii,Effective Practices,0.54,1.89,1.9,2.43,2.44,2.97,2.98,4.17,4.18 1B-i,Professional Community,0.58,2.04,2.05,2.63,2.64,3.21,3.22,4.2,4.21 1B-ii,Support For Teaching Development And Growth,0.52,1.76,1.77,2.29,2.3,2.81,2.82,3.93,3.94 1B-iii,Effective Leadership,0.55,1.92,1.93,2.48,2.49,3.02,3.03,4.01,4.02 2A-i,Student Physical Safety,0.48,2.51,2.52,2.99,3,3.47,3.48,3.54,3.55 2A-ii,Student Emotional Safety,0.48,2.23,2.24,2.72,2.73,3.2,3.21,3.51,3.52 2B-i,Sense of Belonging,0.49,1.75,1.76,2.25,2.26,2.74,2.75,4.07,4.08 2B-ii,Student/Teacher Relationships,0.49,1.62,1.63,2.12,2.13,2.62,2.63,4.02,4.03 2C-i,Valuing of Learning,0.43,2.16,2.17,2.6,2.61,3.03,3.04,4.09,4.1 2C-ii,Academic Challenge,0.5,2.21,2.22,2.72,2.73,3.21,3.22,4.03,4.04 3A-i,Physical Spaces and Materials,0.5,1.68,1.69,2.19,2.2,2.69,2.7,3.71,3.72 3A-ii,Content Specialists and Support Staff,0.49,2.06,2.07,2.57,2.58,3.06,3.07,3.77,3.78 3B-i,Curricular Strength and Variety,0.45,1.96,1.97,2.42,2.43,2.87,2.88,4.14,4.15 3B-ii,Cultural Responsiveness,0.43,1.92,1.93,2.35,2.36,2.78,2.79,4.08,4.09 3B-iii,Co-Curricular Resources,,,,,,,,, 3C-i,Family/School Relationships,0.47,1.58,1.59,2.07,2.08,2.54,2.55,3.75,3.76 3C-ii,Community Involvement and External Partners,0.53,1.8,1.81,2.33,2.34,2.86,2.87,3.95,3.96 4A-i,Performance Growth,,,,,,,,, 4A-ii,Overall performance,,,,,,,,, 4B-i,Engagement in School,0.55,1.6,1.61,2.15,2.16,2.7,2.71,3.81,3.82 4B-ii,Degree completion,,,,,,,,, 4C-i,Problem Solving Emphasis,0.53,1.63,1.64,2.17,2.18,2.7,2.71,3.77,3.78 4C-ii,Problem Solving Skills,,,,,,,,, 4D-i,College-Going and Persistence,,,,,,,,, 4D-ii,Career Preparation and Placement,,,,,,,,, 5A-i,Appreciation for Diversity,0.55,1.86,1.87,2.42,2.43,2.97,2.98,3.89,3.9 5A-ii,Civic Participation,0.5,1.97,1.98,2.47,2.48,2.97,2.98,3.86,3.87 5B-i,Perseverance and Determination,0.45,1.93,1.94,2.39,2.4,2.84,2.85,3.96,3.97 5B-ii,Growth Mindset,0.47,1.73,1.74,2.22,2.23,2.69,2.7,3.59,3.6 5C-i,Participation in Creative and Performing Arts,0.53,1.25,1.26,1.79,1.8,2.32,2.33,3.77,3.78 5C-ii,Valuing Creative and Performing Arts,0.54,1.35,1.36,1.9,1.91,2.43,2.44,3.93,3.94 5D-i,Social and Emotional Health,0.48,1.7,1.71,2.18,2.19,2.66,2.67,3.81,3.82 5D-ii,Physical Health,0.53,1.77,1.78,2.3,2.31,2.83,2.84,3.88,3.89 \ No newline at end of file diff --git a/db/migrate/20180128015651_add_zones_to_category.rb b/db/migrate/20180128015651_add_zones_to_category.rb new file mode 100644 index 00000000..14cb7942 --- /dev/null +++ b/db/migrate/20180128015651_add_zones_to_category.rb @@ -0,0 +1,5 @@ +class AddZonesToCategory < ActiveRecord::Migration[5.0] + def change + add_column :categories, :zones, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 99289e89..25e7e142 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180120150542) do +ActiveRecord::Schema.define(version: 20180128015651) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20180120150542) do t.string "slug" t.float "benchmark" t.string "benchmark_description" + t.string "zones" t.index ["slug"], name: "index_categories_on_slug", unique: true, using: :btree end diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index d6b771cd..add550a2 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -256,13 +256,10 @@ namespace :data do csv = CSV.parse(csv_string, :headers => true) puts("LOADING NONLIKERT CSV: #{csv.length} ROWS") - t = Time.new - school_category_id = -1 csv.each_with_index do |row, index| base = Category category_ids = row["Category"].split("-") category_ids.each do |category_id| - puts("#{category_id} -> #{base.find_by_external_id(category_id).try(:name)}") base = base.find_by_external_id(category_id).child_categories end @@ -284,7 +281,6 @@ namespace :data do nonlikert: row["NL_Value"], zscore: [row["Z-Score"].to_f,2].min ) - school_category_id = school_category.id end ENV.delete('BULK_PROCESS') @@ -292,6 +288,37 @@ namespace :data do sync_school_category_aggregates end + desc 'Load in nonlikert values for each school' + task load_custom_zones: :environment do + ENV['BULK_PROCESS'] = 'true' + + csv_string = File.read(File.expand_path("../../../data/Benchmarks2016-2017.csv", __FILE__)) + csv = CSV.parse(csv_string, :headers => true) + + csv.each_with_index do |row, index| + next if row["Warning High"].blank? + + category = Category.find_by_name(row["Subcategory"]) + + if category.nil? + puts "Unable to find category #{row["Subcategory"]}" + next + end + + custom_zones = [ + row["Warning High"], + row["Watch High"], + row["Growth High"], + row["Approval High"], + 5 + ] + + puts "#{category.name} -> #{custom_zones.join(",")}" + + category.update(zones: custom_zones.join(",")) + end + end + def sync_school_category_aggregates School.all.each do |school| Category.all.each do |category|