add first pillar

This commit is contained in:
rebuilt 2023-02-28 17:50:21 -08:00
parent c0332955f3
commit 8128af200b
11 changed files with 252 additions and 0 deletions

32
app/models/report/gps.rb Normal file
View file

@ -0,0 +1,32 @@
module Report
class Gps
def self.to_csv
headers = ['School', 'Pillar', 'Indicator', 'Period', 'HALS Category', 'Measures', 'Score', 'Zone']
attributes = %w[school_name pillar indicator period category measure_ids score zone]
pillars = generate_pillars
CSV.generate(headers: true) do |csv|
csv << headers
pillars.each do |gps|
csv << attributes.map { |attr| gps.send(attr) }
end
end
end
def self.generate_pillars
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:)
end
end
end
end
end
end

View file

@ -0,0 +1,84 @@
module Report
class Pillar
attr_reader :period, :measures, :indicator, :school, :academic_year
def initialize(school:, period:, measures:, indicator:, academic_year:)
@school = school
@measures = measures
@indicator = indicator
@period = period
@academic_year = academic_year
end
def school_name
school.name
end
def pillar
pillars[indicator.to_sym]
end
def score
measures.map do |measure|
measure.score(school:, academic_year:).average
end.flatten.compact.average
end
def category
measures.first.category.name
end
def measure_ids
measures.map(&:measure_id).join(' & ')
end
def zone
zones = Zones.new(watch_low_benchmark:,
growth_low_benchmark:,
approval_low_benchmark:,
ideal_low_benchmark:)
zones.zone_for_score(score).type.to_s
end
private
def pillars
{ "Teaching Environment": 'Operational Efficiency',
"Safety": 'Safe and Welcoming Environment',
"Relationships": 'Safe and Welcoming Environment',
"Academic Orientation": 'Safe and Welcoming Environment',
"Facilities & Personnel": 'Operational Efficiency',
"Family-School Relationships": 'Family and Community Engagement',
"Community Involvement & External Partners": 'Family and Community Engagement',
"Perception of Performance": 'Academics and Student Achievement',
"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|
measure.watch_low_benchmark
end.average
end
def growth_low_benchmark
measures.map do |measure|
measure.growth_low_benchmark
end.average
end
def approval_low_benchmark
measures.map do |measure|
measure.approval_low_benchmark
end.average
end
def ideal_low_benchmark
measures.map do |measure|
measure.ideal_low_benchmark
end.average
end
end
end