mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
chore: rename counts_by_grade to enrollment_by_grade for clarity
This commit is contained in:
parent
a75373f6f2
commit
ea079e927b
8 changed files with 14 additions and 14 deletions
|
|
@ -31,7 +31,7 @@ module Report
|
|||
|
||||
row = [response_rate, subcategory, school, academic_year]
|
||||
|
||||
all_grades = respondents.counts_by_grade.keys
|
||||
all_grades = respondents.enrollment_by_grade.keys
|
||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||
mutex.synchronize do
|
||||
data << [school.district.name,
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ class Respondent < ApplicationRecord
|
|||
|
||||
validates :school, uniqueness: { scope: :academic_year }
|
||||
|
||||
def counts_by_grade
|
||||
@counts_by_grade ||= {}.tap do |row|
|
||||
def enrollment_by_grade
|
||||
@enrollment_by_grade ||= {}.tap do |row|
|
||||
attributes = %i[pk k one two three four five six seven eight nine ten eleven twelve]
|
||||
grades = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
attributes.zip(grades).each do |attribute, grade|
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ class School < ApplicationRecord
|
|||
end
|
||||
|
||||
def grades(academic_year:)
|
||||
Respondent.find_by(school: self, academic_year:)&.counts_by_grade&.keys || (-1..12).to_a
|
||||
Respondent.find_by(school: self, academic_year:)&.enrollment_by_grade&.keys || (-1..12).to_a
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ class StudentResponseRateCalculator < ResponseRateCalculator
|
|||
end
|
||||
|
||||
def enrollment_by_grade
|
||||
@enrollment_by_grade ||= respondents.counts_by_grade
|
||||
@enrollment_by_grade ||= respondents.enrollment_by_grade
|
||||
end
|
||||
|
||||
def total_enrollment
|
||||
respondents.counts_by_grade.sum
|
||||
respondents.enrollment_by_grade.sum
|
||||
end
|
||||
|
||||
def survey_items_have_sufficient_responses?
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ module Analyze
|
|||
end
|
||||
|
||||
def grades(year_index)
|
||||
Respondent.find_by(school:, academic_year: academic_years[year_index]).counts_by_grade.keys
|
||||
Respondent.find_by(school:, academic_year: academic_years[year_index]).enrollment_by_grade.keys
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ResponseRatePresenter
|
|||
.pluck(:grade)
|
||||
.reject(&:nil?)
|
||||
.map do |grade|
|
||||
respondents.counts_by_grade[grade]
|
||||
respondents.enrollment_by_grade[grade]
|
||||
end.sum.to_f
|
||||
end
|
||||
|
||||
|
|
@ -95,6 +95,6 @@ class ResponseRatePresenter
|
|||
end
|
||||
|
||||
def grades
|
||||
respondents.counts_by_grade.keys
|
||||
respondents.enrollment_by_grade.keys
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -264,8 +264,8 @@ class SurveyItemValues
|
|||
return true if respondent_type == :teacher
|
||||
|
||||
respondents = Respondent.where(school:, academic_year:).first
|
||||
if respondents.present? && respondents.counts_by_grade[grade].present?
|
||||
enrollment = respondents.counts_by_grade[grade]
|
||||
if respondents.present? && respondents.enrollment_by_grade[grade].present?
|
||||
enrollment = respondents.enrollment_by_grade[grade]
|
||||
end
|
||||
return false if enrollment.nil?
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ RSpec.describe Respondent, type: :model do
|
|||
context 'when the student respondents include one or more counts for the number of respondents' do
|
||||
it 'returns a hash with only the grades that have a non-zero count of students' do
|
||||
expect(single_grade_of_respondents.one).to eq(10)
|
||||
expect(single_grade_of_respondents.counts_by_grade).to eq({ 1 => 10 })
|
||||
expect(two_grades_of_respondents.counts_by_grade).to eq({ -1 => 10, 0 => 5 })
|
||||
expect(three_grades_of_respondents.counts_by_grade).to eq({ 1 => 10, 2 => 5, 12 => 6 })
|
||||
expect(single_grade_of_respondents.enrollment_by_grade).to eq({ 1 => 10 })
|
||||
expect(two_grades_of_respondents.enrollment_by_grade).to eq({ -1 => 10, 0 => 5 })
|
||||
expect(three_grades_of_respondents.enrollment_by_grade).to eq({ 1 => 10, 2 => 5, 12 => 6 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue