From b6b88da3288a5f7bec4655851ad0071a6f19a677 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Tue, 28 Feb 2023 19:08:11 -0800 Subject: [PATCH] Add all pillars --- app/controllers/gps_controller.rb | 2 +- app/models/report/gps.rb | 26 +++++++++++++++++++------- app/models/report/pillar.rb | 7 +++---- spec/models/pillar_spec.rb | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/controllers/gps_controller.rb b/app/controllers/gps_controller.rb index 986ee4a6..622ff226 100644 --- a/app/controllers/gps_controller.rb +++ b/app/controllers/gps_controller.rb @@ -2,7 +2,7 @@ class GpsController < ActionController::Base def index respond_to do |format| format.html - format.csv { send_data Report::Gps.to_csv } + format.csv { send_data Report::Gps.to_csv, disposition: 'attachment', filename: "gps_#{Date.today}.csv" } end end end diff --git a/app/models/report/gps.rb b/app/models/report/gps.rb index ef8be041..a95e4ec4 100644 --- a/app/models/report/gps.rb +++ b/app/models/report/gps.rb @@ -1,7 +1,7 @@ module Report class Gps def self.to_csv - headers = ['School', 'Pillar', 'Indicator', 'Period', 'HALS Category', 'Measures', 'Score', 'Zone'] + headers = ['School', 'Pillar', 'Indicator', 'Period', 'HALS Category', 'Ref.', 'Score', 'Zone'] attributes = %w[school_name pillar indicator period category measure_ids score zone] pillars = generate_pillars CSV.generate(headers: true) do |csv| @@ -16,17 +16,29 @@ module Report schools = School.all academic_years = AcademicYear.order(range: :desc).first(2) periods = %w[Current Previous] - indicator_1 = 'Teaching' - measures_1 = [Measure.find_by_measure_id('1A-iii'), Measure.find_by_measure_id('1B-ii')] [].tap do |pillars| - schools.each do |school| - academic_years.zip(periods).each do |academic_year, period| - pillars << Pillar.new(school:, measures: measures_1, indicator: indicator_1, period:, - academic_year:) + academic_years.zip(periods).each do |academic_year, period| + schools.each do |school| + INDICATORS.each do |indicator, measures| + pillars << Pillar.new(school:, measures:, indicator:, period:, academic_year:) + end end end end end + + INDICATORS = + { "Teaching Environment": [Measure.find_by_measure_id('1A-iii'), Measure.find_by_measure_id('1B-ii')], + "Safety": Subcategory.find_by_subcategory_id('2A').measures, + "Relationships": Subcategory.find_by_subcategory_id('2B').measures, + "Academic Orientation": Subcategory.find_by_subcategory_id('2C').measures, + "Facilities & Personnel": Subcategory.find_by_subcategory_id('3A').measures, + "Family-School Relationships": [Measure.find_by_measure_id('3C-i')], + "Community Involvement & External Partners": [Measure.find_by_measure_id('3C-ii')], + "Perception of Performance": Subcategory.find_by_subcategory_id('4A').measures, + "Student Commitment To Learning": Subcategory.find_by_subcategory_id('4B').measures, + "Critical Thinking": Subcategory.find_by_subcategory_id('4C').measures, + "College & Career Readiness": Subcategory.find_by_subcategory_id('4D').measures } end end diff --git a/app/models/report/pillar.rb b/app/models/report/pillar.rb index 1d6d1448..1335625f 100644 --- a/app/models/report/pillar.rb +++ b/app/models/report/pillar.rb @@ -15,7 +15,7 @@ module Report end def pillar - pillars[indicator.to_sym] + PILLARS[indicator.to_sym] end def score @@ -38,12 +38,12 @@ module Report approval_low_benchmark:, ideal_low_benchmark:) - zones.zone_for_score(score).type.to_s + zones.zone_for_score(score).type.to_s.capitalize end private - def pillars + PILLARS = { "Teaching Environment": 'Operational Efficiency', "Safety": 'Safe and Welcoming Environment', "Relationships": 'Safe and Welcoming Environment', @@ -55,7 +55,6 @@ module Report "Student Commitment To Learning": 'Academics and Student Achievement', "Critical Thinking": 'Academics and Student Achievement', "College & Career Readiness": 'Academics and Student Achievement' } - end def watch_low_benchmark measures.map do |measure| diff --git a/spec/models/pillar_spec.rb b/spec/models/pillar_spec.rb index 3424b2d9..5c45f06c 100644 --- a/spec/models/pillar_spec.rb +++ b/spec/models/pillar_spec.rb @@ -70,7 +70,7 @@ RSpec.describe Report::Pillar, type: :model do pillar = Report::Pillar.new(school:, measures:, indicator: 'The Teaching Environment', period: 'Current', academic_year: academic_year_1) expect(pillar.score).to eq 4.5 - expect(pillar.zone).to eq 'approval' + expect(pillar.zone).to eq 'Approval' end end end