mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
Fix response rates for small schools by accounting for expected minimum counts of responses less than 10
This commit is contained in:
parent
b5be86d74d
commit
3c30808a5e
2 changed files with 7 additions and 3 deletions
|
|
@ -28,11 +28,14 @@ class StudentResponseRateCalculator < ResponseRateCalculator
|
|||
end
|
||||
|
||||
def survey_items_with_sufficient_responses(grade:)
|
||||
threshold = 10
|
||||
quarter_of_grade = enrollment_by_grade[grade] / 4
|
||||
threshold = threshold > quarter_of_grade ? quarter_of_grade : threshold
|
||||
SurveyItem.joins('inner join survey_item_responses on survey_item_responses.survey_item_id = survey_items.id')
|
||||
.student_survey_items
|
||||
.where("survey_item_responses.school": school, "survey_item_responses.academic_year": academic_year, "survey_item_responses.grade": grade, "survey_item_responses.survey_item_id": subcategory.survey_items.student_survey_items)
|
||||
.group('survey_items.id')
|
||||
.having('count(*) >= 10')
|
||||
.having("count(*) >= #{threshold}")
|
||||
.count
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue