feat: add special education disaggregation

This commit is contained in:
rebuilt 2023-10-05 14:51:36 -07:00
parent c582126d2a
commit 48e795fcfb
27 changed files with 399 additions and 62 deletions

7
app/models/sped.rb Normal file
View file

@ -0,0 +1,7 @@
class Sped < ApplicationRecord
scope :by_designation, -> { all.map { |sped| [sped.designation, sped] }.to_h }
include FriendlyId
friendly_id :designation, use: [:slugged]
end

View file

@ -11,6 +11,7 @@ class SurveyItemResponse < ActiveRecord::Base
belongs_to :gender
belongs_to :income
belongs_to :ell
belongs_to :sped
has_one :measure, through: :survey_item
@ -38,6 +39,11 @@ class SurveyItemResponse < ActiveRecord::Base
academic_year:, ell:, grade: school.grades(academic_year:)).group(:survey_item).having("count(*) >= 10").average(:likert_score)
}
scope :averages_for_sped, lambda { |survey_items, school, academic_year, sped|
SurveyItemResponse.where(survey_item: survey_items, school:,
academic_year:, sped:, grade: school.grades(academic_year:)).group(:survey_item).having("count(*) >= 10").average(:likert_score)
}
scope :averages_for_race, lambda { |school, academic_year, race|
SurveyItemResponse.joins("JOIN student_races on survey_item_responses.student_id = student_races.student_id JOIN students on students.id = student_races.student_id").where(
school:, academic_year:, grade: school.grades(academic_year:)