Refactor GroupedBarColumnPresenter to accept a configuration so that a

column can by given on the fly (dependency injection). Show Parent
graphs on analyze page.
This commit is contained in:
rebuilt 2025-02-20 13:01:47 -08:00
parent 86b0ac9bbf
commit b9ba8abf73
83 changed files with 762 additions and 1925 deletions

View file

@ -0,0 +1,64 @@
# frozen_string_literal: true
module Analyze
module Graph
module Column
class Sped < ColumnBase
attr_reader :sped
def initialize(sped:)
@sped = sped
end
def label
["#{sped.designation}"]
end
def basis
"student surveys"
end
def show_irrelevancy_message?(measure:)
false
end
def show_insufficient_data_message?(measure:, school:, academic_years:)
false
end
def type
:student
end
def n_size(measure:, school:, academic_year:)
SurveyItemResponse.where(sped:, survey_item: measure.student_survey_items, school:, grade: grades(school:, academic_year:),
academic_year:).select(:response_id).distinct.count
end
def score(measure:, school:, academic_year:)
meets_student_threshold = sufficient_student_responses?(measure:, school:, 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(measure:, averages:).round(2)
Score.new(average:,
meets_teacher_threshold: false,
meets_student_threshold:,
meets_admin_data_threshold: false)
end
def sufficient_student_responses?(measure:, school:, 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