mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
feat: Add parent button to overview page and alter 'School Quality Framework Indicators' section to show parent scales
This commit is contained in:
parent
e5beb46035
commit
e2e162d33b
13 changed files with 157 additions and 88 deletions
|
|
@ -15,5 +15,7 @@ class OverviewController < SqmApplicationController
|
|||
@category_presenters = @page.category_presenters
|
||||
@student_response_rate_presenter = @page.student_response_rate_presenter
|
||||
@teacher_response_rate_presenter = @page.teacher_response_rate_presenter
|
||||
@parent_response_rate_presenter = @page.parent_response_rate_presenter
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -88,4 +88,3 @@ class CategoryPresenter
|
|||
'5': "heart" }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Overview::OverviewPresenter
|
|||
"school-quality-frameworks"
|
||||
end
|
||||
|
||||
def show_response_rates
|
||||
def show_student_response_rates
|
||||
view == "student"
|
||||
end
|
||||
|
||||
|
|
@ -36,11 +36,15 @@ class Overview::OverviewPresenter
|
|||
end
|
||||
|
||||
def student_response_rate_presenter
|
||||
ResponseRatePresenter.new(focus: :student, school: @school, academic_year: @academic_year)
|
||||
StudentResponseRatePresenter.new(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def teacher_response_rate_presenter
|
||||
ResponseRatePresenter.new(focus: :teacher, school: @school, academic_year: @academic_year)
|
||||
TeacherResponseRatePresenter.new(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def parent_response_rate_presenter
|
||||
ParentResponseRatePresenter.new(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
|
|
|
|||
|
|
@ -30,3 +30,4 @@ class Overview::ParentOverviewPresenter < Overview::OverviewPresenter
|
|||
Overview::VarianceChartRowPresenter.new(construct: scale, score:)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
24
app/presenters/parent_response_rate_presenter.rb
Normal file
24
app/presenters/parent_response_rate_presenter.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class ParentResponseRatePresenter < ResponseRatePresenter
|
||||
def initialize(academic_year:, school:)
|
||||
super(academic_year:, school:)
|
||||
@survey_items = SurveyItem.parent_survey_items
|
||||
end
|
||||
|
||||
def actual_count
|
||||
SurveyItemResponse.includes(:parent).where(school:, academic_year:).where.not(parent_id: nil)
|
||||
.select(:parent_id)
|
||||
.distinct
|
||||
.map { |response| response.parent&.number_of_children }
|
||||
.compact.sum
|
||||
end
|
||||
|
||||
def respondents_count
|
||||
return 0 if respondents.nil?
|
||||
|
||||
respondents.total_students
|
||||
end
|
||||
|
||||
def focus
|
||||
"parent"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +1,9 @@
|
|||
class ResponseRatePresenter
|
||||
attr_reader :focus, :academic_year, :school, :survey_items
|
||||
attr_reader :academic_year, :school, :survey_items
|
||||
|
||||
def initialize(focus:, academic_year:, school:)
|
||||
@focus = focus
|
||||
def initialize(academic_year:, school:)
|
||||
@academic_year = academic_year
|
||||
@school = school
|
||||
if focus == :student
|
||||
@survey_items = Measure.all.flat_map do |measure|
|
||||
measure.student_survey_items_with_sufficient_responses(school:, academic_year:)
|
||||
end
|
||||
end
|
||||
@survey_items = SurveyItem.teacher_survey_items if focus == :teacher
|
||||
end
|
||||
|
||||
def date
|
||||
|
|
@ -40,6 +33,10 @@ class ResponseRatePresenter
|
|||
"Percentages based on #{actual_count} out of #{respondents_count.round} #{focus}s completing at least 25% of the survey."
|
||||
end
|
||||
|
||||
def focus
|
||||
raise "please implment method: focus"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cap_at_100(value)
|
||||
|
|
@ -47,30 +44,7 @@ class ResponseRatePresenter
|
|||
end
|
||||
|
||||
def actual_count
|
||||
if focus == :teacher
|
||||
response_count_for_survey_items(survey_items:)
|
||||
else
|
||||
non_early_ed_items = survey_items - SurveyItem.early_education_survey_items
|
||||
non_early_ed_count = response_count_for_survey_items(survey_items: non_early_ed_items)
|
||||
|
||||
early_ed_items = survey_items & SurveyItem.early_education_survey_items
|
||||
early_ed_count = SurveyItemResponse.where(school:, academic_year:,
|
||||
survey_item: early_ed_items)
|
||||
.group(:survey_item)
|
||||
.select(:response_id)
|
||||
.distinct
|
||||
.count
|
||||
.reduce(0) do |largest, row|
|
||||
count = row[1]
|
||||
if count > largest
|
||||
count
|
||||
else
|
||||
largest
|
||||
end
|
||||
end
|
||||
|
||||
non_early_ed_count + early_ed_count
|
||||
end
|
||||
raise "please implement the method: actual_count"
|
||||
end
|
||||
|
||||
def response_count_for_survey_items(survey_items:)
|
||||
|
|
@ -79,11 +53,7 @@ class ResponseRatePresenter
|
|||
end
|
||||
|
||||
def respondents_count
|
||||
return 0 if respondents.nil?
|
||||
|
||||
count = enrollment if focus == :student
|
||||
count = respondents.total_teachers if focus == :teacher
|
||||
count
|
||||
raise "please implement the method: respondents_count"
|
||||
end
|
||||
|
||||
def enrollment
|
||||
|
|
@ -106,3 +76,4 @@ class ResponseRatePresenter
|
|||
respondents.enrollment_by_grade.keys
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
42
app/presenters/student_response_rate_presenter.rb
Normal file
42
app/presenters/student_response_rate_presenter.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
class StudentResponseRatePresenter < ResponseRatePresenter
|
||||
def initialize(academic_year:, school:)
|
||||
super(academic_year:, school:)
|
||||
@survey_items = Measure.all.flat_map do |measure|
|
||||
measure.student_survey_items_with_sufficient_responses(school:, academic_year:)
|
||||
end
|
||||
end
|
||||
|
||||
def actual_count
|
||||
# Early ed surveys are given in batches so they have to be counted separately because we have to account for the same student having a different response id per batch
|
||||
non_early_ed_items = survey_items - SurveyItem.early_education_survey_items
|
||||
non_early_ed_count = response_count_for_survey_items(survey_items: non_early_ed_items)
|
||||
|
||||
early_ed_items = SurveyItem.early_education_survey_items
|
||||
early_ed_count = SurveyItemResponse.where(school:, academic_year:,
|
||||
survey_item: early_ed_items)
|
||||
.group(:survey_item)
|
||||
.select(:response_id)
|
||||
.distinct
|
||||
.count
|
||||
.reduce(0) do |largest, row|
|
||||
count = row[1]
|
||||
if count > largest
|
||||
count
|
||||
else
|
||||
largest
|
||||
end
|
||||
end
|
||||
|
||||
non_early_ed_count + early_ed_count
|
||||
end
|
||||
|
||||
def respondents_count
|
||||
return 0 if respondents.nil?
|
||||
|
||||
enrollment
|
||||
end
|
||||
|
||||
def focus
|
||||
"student"
|
||||
end
|
||||
end
|
||||
20
app/presenters/teacher_response_rate_presenter.rb
Normal file
20
app/presenters/teacher_response_rate_presenter.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class TeacherResponseRatePresenter < ResponseRatePresenter
|
||||
def initialize(academic_year:, school:)
|
||||
super(academic_year:, school:)
|
||||
@survey_items = SurveyItem.teacher_survey_items
|
||||
end
|
||||
|
||||
def actual_count
|
||||
response_count_for_survey_items(survey_items:)
|
||||
end
|
||||
|
||||
def respondents_count
|
||||
return 0 if respondents.nil?
|
||||
|
||||
respondents.total_teachers
|
||||
end
|
||||
|
||||
def focus
|
||||
"teacher"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue