mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
feat: add parent survey gauges
This commit is contained in:
parent
695f8b69a2
commit
c85ddddd8d
12 changed files with 305 additions and 9 deletions
24
app/presenters/parent_measure_presenter.rb
Normal file
24
app/presenters/parent_measure_presenter.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ParentMeasurePresenter < MeasurePresenter
|
||||
def measure_id
|
||||
"#{measure.measure_id} (Parent)"
|
||||
end
|
||||
|
||||
def score_for_measure
|
||||
@measure.parent_score(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def data_item_presenters
|
||||
[].tap do |array|
|
||||
array << parent_survey_presenter if measure.parent_survey_items.any?
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parent_survey_presenter
|
||||
ParentSurveyPresenter.new(measure_id: measure.measure_id, survey_items: measure.parent_survey_items,
|
||||
has_sufficient_data: true, school:, academic_year:)
|
||||
end
|
||||
end
|
||||
26
app/presenters/parent_survey_presenter.rb
Normal file
26
app/presenters/parent_survey_presenter.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ParentSurveyPresenter < DataItemPresenter
|
||||
attr_reader :survey_items
|
||||
|
||||
def initialize(measure_id:, survey_items:, has_sufficient_data:, school:, academic_year:)
|
||||
super(measure_id:, has_sufficient_data:, school:, academic_year:)
|
||||
@survey_items = survey_items
|
||||
end
|
||||
|
||||
def title
|
||||
"Parent survey"
|
||||
end
|
||||
|
||||
def id
|
||||
"parent-survey-items-#{measure_id}"
|
||||
end
|
||||
|
||||
def reason_for_insufficiency
|
||||
"low response rate"
|
||||
end
|
||||
|
||||
def descriptions_and_availability
|
||||
survey_items.map(&:description)
|
||||
end
|
||||
end
|
||||
|
|
@ -43,12 +43,22 @@ class SubcategoryPresenter
|
|||
|
||||
def measure_presenters
|
||||
@subcategory.measures.sort_by(&:measure_id).map do |measure|
|
||||
MeasurePresenter.new(measure:, academic_year: @academic_year, school: @school)
|
||||
end
|
||||
out = [MeasurePresenter.new(measure:, academic_year: @academic_year, school: @school)]
|
||||
if parent_gauges_have_displayable_score?(measure:)
|
||||
out << ParentMeasurePresenter.new(measure:, academic_year: @academic_year,
|
||||
school: @school)
|
||||
end
|
||||
out
|
||||
end.flatten
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parent_gauges_have_displayable_score?(measure:)
|
||||
measure.includes_parent_survey_items? && measure.parent_score(school: @school,
|
||||
academic_year: @academic_year).average.positive?
|
||||
end
|
||||
|
||||
def admin_data_values_count
|
||||
@subcategory.measures.map do |measure|
|
||||
measure.scales.map do |scale|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue