parent
a9b4f97a84
commit
acfdaf5587
@ -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
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module SpedColumn
|
||||||
|
class NotSped < GroupedBarColumnPresenter
|
||||||
|
include Analyze::Graph::Column::SpedColumn::ScoreForSped
|
||||||
|
include Analyze::Graph::Column::SpedColumn::SpedCount
|
||||||
|
|
||||||
|
def label
|
||||||
|
["Not Special", "Education"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def basis
|
||||||
|
"student"
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_irrelevancy_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_insufficient_data_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def sped
|
||||||
|
::Sped.find_by_slug "not-special-education"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module SpedColumn
|
||||||
|
module ScoreForSped
|
||||||
|
def score(year_index)
|
||||||
|
academic_year = academic_years[year_index]
|
||||||
|
meets_student_threshold = sufficient_student_responses?(academic_year:)
|
||||||
|
return Score::NIL_SCORE unless meets_student_threshold
|
||||||
|
|
||||||
|
averages = SurveyItemResponse.averages_for_sped(measure.student_survey_items, school, academic_year,
|
||||||
|
sped)
|
||||||
|
average = bubble_up_averages(averages:).round(2)
|
||||||
|
|
||||||
|
Score.new(average:,
|
||||||
|
meets_teacher_threshold: false,
|
||||||
|
meets_student_threshold:,
|
||||||
|
meets_admin_data_threshold: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def bubble_up_averages(averages:)
|
||||||
|
measure.student_scales.map do |scale|
|
||||||
|
scale.survey_items.map do |survey_item|
|
||||||
|
averages[survey_item]
|
||||||
|
end.remove_blanks.average
|
||||||
|
end.remove_blanks.average
|
||||||
|
end
|
||||||
|
|
||||||
|
def sufficient_student_responses?(academic_year:)
|
||||||
|
return false unless measure.subcategory.response_rate(school:, academic_year:).meets_student_threshold?
|
||||||
|
|
||||||
|
yearly_counts = SurveyItemResponse.where(school:, academic_year:,
|
||||||
|
sped:, survey_item: measure.student_survey_items).group(:sped).select(:response_id).distinct(:response_id).count
|
||||||
|
yearly_counts.any? do |count|
|
||||||
|
count[1] >= 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module SpedColumn
|
||||||
|
class Sped < GroupedBarColumnPresenter
|
||||||
|
include Analyze::Graph::Column::SpedColumn::ScoreForSped
|
||||||
|
include Analyze::Graph::Column::SpedColumn::SpedCount
|
||||||
|
|
||||||
|
def label
|
||||||
|
%w[Special Education]
|
||||||
|
end
|
||||||
|
|
||||||
|
def basis
|
||||||
|
"student"
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_irrelevancy_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_insufficient_data_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def sped
|
||||||
|
::Sped.find_by_slug "special-education"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module SpedColumn
|
||||||
|
module SpedCount
|
||||||
|
def type
|
||||||
|
:student
|
||||||
|
end
|
||||||
|
|
||||||
|
def n_size(year_index)
|
||||||
|
SurveyItemResponse.where(sped:, survey_item: measure.student_survey_items, school:, grade: grades(year_index),
|
||||||
|
academic_year: academic_years[year_index]).select(:response_id).distinct.count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module SpedColumn
|
||||||
|
class Unknown < GroupedBarColumnPresenter
|
||||||
|
include Analyze::Graph::Column::SpedColumn::ScoreForSped
|
||||||
|
include Analyze::Graph::Column::SpedColumn::SpedCount
|
||||||
|
|
||||||
|
def label
|
||||||
|
%w[Unknown]
|
||||||
|
end
|
||||||
|
|
||||||
|
def basis
|
||||||
|
"student"
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_irrelevancy_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_insufficient_data_message?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def sped
|
||||||
|
::Sped.find_by_slug "unknown"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
class StudentsBySped
|
||||||
|
include Analyze::Graph::Column::SpedColumn
|
||||||
|
attr_reader :speds
|
||||||
|
|
||||||
|
def initialize(speds:)
|
||||||
|
@speds = speds
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"Students by SpEd"
|
||||||
|
end
|
||||||
|
|
||||||
|
def slug
|
||||||
|
"students-by-sped"
|
||||||
|
end
|
||||||
|
|
||||||
|
def columns
|
||||||
|
[].tap do |array|
|
||||||
|
speds.each do |sped|
|
||||||
|
array << column_for_sped_code(code: sped.slug)
|
||||||
|
end
|
||||||
|
array << Analyze::Graph::Column::AllStudent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def column_for_sped_code(code:)
|
||||||
|
CFR[code]
|
||||||
|
end
|
||||||
|
|
||||||
|
CFR = {
|
||||||
|
"special-education" => Analyze::Graph::Column::SpedColumn::Sped,
|
||||||
|
"not-special-education" => Analyze::Graph::Column::SpedColumn::NotSped,
|
||||||
|
"unknown" => Analyze::Graph::Column::SpedColumn::Unknown
|
||||||
|
}.freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
module Analyze
|
||||||
|
module Group
|
||||||
|
class Sped
|
||||||
|
def name
|
||||||
|
"SpEd"
|
||||||
|
end
|
||||||
|
|
||||||
|
def slug
|
||||||
|
"sped"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
class CreateSpeds < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table :speds do |t|
|
||||||
|
t.string :designation
|
||||||
|
t.string :slug
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :speds, :designation
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class AddSpedToSurveyItemResponse < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_reference :survey_item_responses, :sped, foreign_key: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in new issue