mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-10 07:50:33 -07:00
to survey table. We no longer check or keep track of the survey type. Instead we look in the database to see if a survey item has at least 10 responses. If it does, that survey item was presented to the respondent and we count it, and all responses when calculating the response rate. Remove response rate timestamp from caching logic because we no longer add the response rate to the database. All response rates are calculated on the fly Update three_b_two scraper to use teacher only numbers swap over to using https://profiles.doe.mass.edu/statereport/gradesubjectstaffing.aspx as the source of staffing information
37 lines
1.1 KiB
Ruby
37 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class TeacherResponseRateCalculator < ResponseRateCalculator
|
|
def survey_item_count
|
|
@survey_item_count ||= @subcategory.measures.map do |measure|
|
|
measure.teacher_survey_items.reject do |survey_item|
|
|
survey_item.survey_item_responses.where(school:, academic_year:).none?
|
|
end.count
|
|
end.sum
|
|
end
|
|
|
|
def survey_items_have_sufficient_responses?
|
|
survey_item_count.positive?
|
|
end
|
|
|
|
def response_count
|
|
@response_count ||= @subcategory.measures.map do |measure|
|
|
measure.teacher_survey_items.map do |survey_item|
|
|
survey_item.survey_item_responses.where(school:,
|
|
academic_year:).exclude_boston.count
|
|
end.sum
|
|
end.sum
|
|
end
|
|
|
|
def total_possible_responses
|
|
@total_possible_responses ||= begin
|
|
total_responses = Respondent.where(school:, academic_year:).first
|
|
return 0 unless total_responses.present?
|
|
|
|
total_responses.total_teachers
|
|
end
|
|
end
|
|
|
|
def raw_response_rate
|
|
(average_responses_per_survey_item / total_possible_responses.to_f * 100).round
|
|
end
|
|
end
|