mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08: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
6e4700c1f0
commit
6f3634582e
25 changed files with 537 additions and 314 deletions
|
|
@ -54,6 +54,15 @@
|
|||
grid-template-rows: repeat(4, max-content);
|
||||
}
|
||||
|
||||
.school-quality-frameworks-parent {
|
||||
display: grid;
|
||||
row-gap: map-get($spacers, 4);
|
||||
column-gap: map-get($spacers, 5);
|
||||
grid-auto-flow: column;
|
||||
grid-template-columns: 250px 250px 250px;
|
||||
grid-template-rows: repeat(4, max-content);
|
||||
}
|
||||
|
||||
.zone-header {
|
||||
@extend .sub-header-4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class AnalyzeController < SqmApplicationController
|
||||
def index
|
||||
@presenter = Analyze::Presenter.new(params:, school: @school, academic_year: @academic_year)
|
||||
@background ||= BackgroundPresenter.new(num_of_columns: @presenter.graph.columns.count)
|
||||
@background ||= Analyze::BackgroundPresenter.new(num_of_columns: @presenter.graph.columns.count)
|
||||
@academic_year = @presenter.selected_academic_years&.first || AcademicYear.last
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,42 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class OverviewController < SqmApplicationController
|
||||
before_action :check_empty_dataset, only: [:index]
|
||||
helper VarianceHelper
|
||||
|
||||
def index
|
||||
@variance_chart_row_presenters = measures.map(&method(:presenter_for_measure))
|
||||
@category_presenters = categories.map { |category| CategoryPresenter.new(category:) }
|
||||
@student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
|
||||
academic_year: @academic_year)
|
||||
@teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
|
||||
academic_year: @academic_year)
|
||||
end
|
||||
@page = if params[:view] == "student" || params[:view].nil?
|
||||
Overview::OverviewPresenter.new(params:, school: @school, academic_year: @academic_year)
|
||||
else
|
||||
Overview::ParentOverviewPresenter.new(params:, school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
score = measure.score(school: @school, academic_year: @academic_year)
|
||||
|
||||
VarianceChartRowPresenter.new(measure:, score:)
|
||||
end
|
||||
|
||||
def check_empty_dataset
|
||||
@has_empty_dataset = subcategories.none? do |subcategory|
|
||||
response_rate = subcategory.response_rate(school: @school, academic_year: @academic_year)
|
||||
response_rate.meets_student_threshold || response_rate.meets_teacher_threshold
|
||||
end
|
||||
end
|
||||
|
||||
def measures
|
||||
@measures ||= subcategories.flat_map(&:measures)
|
||||
end
|
||||
|
||||
def subcategories
|
||||
@subcategories ||= categories.flat_map(&:subcategories)
|
||||
end
|
||||
|
||||
def categories
|
||||
@categories ||= Category.sorted.includes(%i[measures scales admin_data_items subcategories])
|
||||
@has_empty_dataset = @page.empty_dataset?
|
||||
@variance_chart_row_presenters = @page.variance_chart_row_presenters
|
||||
@category_presenters = @page.category_presenters
|
||||
@student_response_rate_presenter = @page.student_response_rate_presenter
|
||||
@teacher_response_rate_presenter = @page.teacher_response_rate_presenter
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class Scale < ApplicationRecord
|
||||
belongs_to :measure, counter_cache: true
|
||||
has_one :category, through: :measure
|
||||
has_many :survey_items
|
||||
has_many :survey_item_responses, through: :survey_items
|
||||
has_many :admin_data_items
|
||||
|
|
@ -19,6 +20,18 @@ class Scale < ApplicationRecord
|
|||
@score[[school, academic_year]]
|
||||
end
|
||||
|
||||
def parent_score(school:, academic_year:)
|
||||
@parent_score ||= Hash.new do |memo, (school, academic_year)|
|
||||
memo[[school, academic_year]] = begin
|
||||
items = []
|
||||
items << collect_survey_item_average(survey_items.parent_survey_items, school, academic_year)
|
||||
|
||||
items.remove_blanks.average
|
||||
end
|
||||
end
|
||||
@parent_score[[school, academic_year]]
|
||||
end
|
||||
|
||||
scope :teacher_scales, lambda {
|
||||
where("scale_id LIKE 't-%'")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class BackgroundPresenter
|
||||
class Analyze::BackgroundPresenter
|
||||
include AnalyzeHelper
|
||||
attr_reader :num_of_columns
|
||||
|
||||
|
|
@ -45,6 +45,23 @@ class CategoryPresenter
|
|||
end
|
||||
end
|
||||
|
||||
def harvey_scorecard_presenters(school:, academic_year:)
|
||||
@category.subcategories.map do |subcategory|
|
||||
measures = subcategory.measures
|
||||
zones = Zones.new(
|
||||
watch_low_benchmark: measures.map(&:watch_low_benchmark).average,
|
||||
growth_low_benchmark: measures.map(&:growth_low_benchmark).average,
|
||||
approval_low_benchmark: measures.map(&:approval_low_benchmark).average,
|
||||
ideal_low_benchmark: measures.map(&:ideal_low_benchmark).average
|
||||
)
|
||||
|
||||
Overview::ScorecardPresenter.new(construct: subcategory,
|
||||
zones:,
|
||||
score: subcategory.score(school:, academic_year:),
|
||||
id: subcategory.subcategory_id)
|
||||
end
|
||||
end
|
||||
|
||||
def to_model
|
||||
@category
|
||||
end
|
||||
|
|
@ -52,18 +69,18 @@ class CategoryPresenter
|
|||
private
|
||||
|
||||
def colors
|
||||
{ '1': 'blue',
|
||||
'2': 'red',
|
||||
'3': 'black',
|
||||
'4': 'lime',
|
||||
'5': 'teal' }
|
||||
{ '1': "blue",
|
||||
'2': "red",
|
||||
'3': "black",
|
||||
'4': "lime",
|
||||
'5': "teal" }
|
||||
end
|
||||
|
||||
def classes
|
||||
{ '1': 'apple-alt',
|
||||
'2': 'school',
|
||||
'3': 'users-cog',
|
||||
'4': 'graduation-cap',
|
||||
'5': 'heart' }
|
||||
{ '1': "apple-alt",
|
||||
'2': "school",
|
||||
'3': "users-cog",
|
||||
'4': "graduation-cap",
|
||||
'5': "heart" }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class MeasurePresenter
|
|||
@school = school
|
||||
@name = measure.name
|
||||
@description = measure.description
|
||||
@id = measure.measure_id
|
||||
end
|
||||
|
||||
def title
|
||||
|
|
|
|||
58
app/presenters/overview/overview_presenter.rb
Normal file
58
app/presenters/overview/overview_presenter.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
class Overview::OverviewPresenter
|
||||
attr_reader :view, :school, :academic_year
|
||||
|
||||
def initialize(params:, school:, academic_year:)
|
||||
@view = params[:view] || "student"
|
||||
@school = school
|
||||
@academic_year = academic_year
|
||||
end
|
||||
|
||||
def variance_chart_row_presenters
|
||||
measures.map(&method(:presenter_for_measure))
|
||||
end
|
||||
|
||||
def category_presenters
|
||||
categories.map { |category| CategoryPresenter.new(category:) }
|
||||
end
|
||||
|
||||
def measures
|
||||
@measures ||= subcategories.flat_map(&:measures)
|
||||
end
|
||||
|
||||
def subcategories
|
||||
@subcategories ||= categories.flat_map(&:subcategories)
|
||||
end
|
||||
|
||||
def framework_indicator_class
|
||||
"school-quality-frameworks"
|
||||
end
|
||||
|
||||
def show_response_rates
|
||||
view == "student"
|
||||
end
|
||||
|
||||
def categories
|
||||
Category.sorted.includes(%i[measures scales admin_data_items subcategories])
|
||||
end
|
||||
|
||||
def student_response_rate_presenter
|
||||
ResponseRatePresenter.new(focus: :student, school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def teacher_response_rate_presenter
|
||||
ResponseRatePresenter.new(focus: :teacher, school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
score = measure.score(school: @school, academic_year: @academic_year)
|
||||
|
||||
Overview::VarianceChartRowPresenter.new(measure:, score:)
|
||||
end
|
||||
|
||||
def empty_dataset?
|
||||
subcategories.none? do |subcategory|
|
||||
response_rate = subcategory.response_rate(school: @school, academic_year: @academic_year)
|
||||
response_rate.meets_student_threshold || response_rate.meets_teacher_threshold
|
||||
end
|
||||
end
|
||||
end
|
||||
15
app/presenters/overview/parent_overview_presenter.rb
Normal file
15
app/presenters/overview/parent_overview_presenter.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class Overview::ParentOverviewPresenter < Overview::OverviewPresenter
|
||||
def categories
|
||||
Category.sorted.includes(%i[measures scales admin_data_items subcategories]).select do |category|
|
||||
category.survey_items.parent_survey_items.count.positive?
|
||||
end
|
||||
end
|
||||
|
||||
def category_presenters
|
||||
categories.map { |category| ParentCategoryPresenter.new(category:) }
|
||||
end
|
||||
|
||||
def framework_indicator_class
|
||||
"school-quality-frameworks-parent"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SubcategoryCardPresenter
|
||||
attr_reader :name, :subcategory, :category, :subcategory_id
|
||||
class Overview::ScorecardPresenter
|
||||
attr_reader :name, :construct, :category, :id
|
||||
|
||||
def initialize(subcategory:, zones:, score:)
|
||||
@name = subcategory.name
|
||||
@subcategory = subcategory
|
||||
@category = subcategory.category
|
||||
@subcategory_id = subcategory.subcategory_id
|
||||
def initialize(construct:, zones:, score:, id:)
|
||||
@name = construct.name
|
||||
@category = construct.category
|
||||
@id = id
|
||||
@zones = zones
|
||||
@score = score
|
||||
end
|
||||
|
|
@ -25,7 +24,7 @@ class SubcategoryCardPresenter
|
|||
end
|
||||
|
||||
def to_model
|
||||
subcategory
|
||||
construct
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class VarianceChartRowPresenter
|
||||
class Overview::VarianceChartRowPresenter
|
||||
include Comparable
|
||||
|
||||
attr_reader :score, :measure_name, :measure_id, :category
|
||||
|
|
@ -30,7 +30,7 @@ class VarianceChartRowPresenter
|
|||
def x_offset
|
||||
case zone.type
|
||||
when :ideal, :approval
|
||||
'60%'
|
||||
"60%"
|
||||
else
|
||||
"#{((0.6 - bar_width_percentage) * 100).abs.round(2)}%"
|
||||
end
|
||||
|
|
@ -57,9 +57,9 @@ class VarianceChartRowPresenter
|
|||
|
||||
def partial_data_sources
|
||||
[].tap do |sources|
|
||||
sources << 'teacher survey results' if @measure.includes_teacher_survey_items? && !@meets_teacher_threshold
|
||||
sources << 'student survey results' if @measure.includes_student_survey_items? && !@meets_student_threshold
|
||||
sources << 'administrative data' if @measure.includes_admin_data_items?
|
||||
sources << "teacher survey results" if @measure.includes_teacher_survey_items? && !@meets_teacher_threshold
|
||||
sources << "student survey results" if @measure.includes_student_survey_items? && !@meets_student_threshold
|
||||
sources << "administrative data" if @measure.includes_admin_data_items?
|
||||
end
|
||||
end
|
||||
|
||||
18
app/presenters/parent_category_presenter.rb
Normal file
18
app/presenters/parent_category_presenter.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class ParentCategoryPresenter < CategoryPresenter
|
||||
def harvey_scorecard_presenters(school:, academic_year:)
|
||||
@category.scales.parent_scales.map do |scale|
|
||||
measure = scale.measure
|
||||
zones = Zones.new(
|
||||
watch_low_benchmark: measure.watch_low_benchmark,
|
||||
growth_low_benchmark: measure.growth_low_benchmark,
|
||||
approval_low_benchmark: measure.approval_low_benchmark,
|
||||
ideal_low_benchmark: measure.ideal_low_benchmark
|
||||
)
|
||||
|
||||
Overview::ScorecardPresenter.new(construct: scale,
|
||||
zones:,
|
||||
score: scale.parent_score(school:, academic_year:),
|
||||
id: scale.scale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ParentScalePresenter < MeasurePresenter
|
||||
attr_reader :scale, :academic_year, :school, :name, :description
|
||||
class ParentScalePresenter
|
||||
attr_reader :scale, :academic_year, :school, :name, :description, :id
|
||||
|
||||
def initialize(scale:, academic_year:, school:)
|
||||
@scale = scale
|
||||
|
|
@ -9,6 +9,7 @@ class ParentScalePresenter < MeasurePresenter
|
|||
@school = school
|
||||
@name = scale.name
|
||||
@description = scale.description
|
||||
@id = scale.scale_id
|
||||
end
|
||||
|
||||
def title
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@ class SubcategoryPresenter
|
|||
GaugePresenter.new(zones:, score: average_score)
|
||||
end
|
||||
|
||||
def subcategory_card_presenter
|
||||
SubcategoryCardPresenter.new(subcategory: @subcategory, zones:, score: average_score)
|
||||
end
|
||||
|
||||
def average_score
|
||||
@average_score ||= @subcategory.score(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
|
|
|||
7
app/views/overview/_harvey_scorecard.html.erb
Normal file
7
app/views/overview/_harvey_scorecard.html.erb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<div class="subcategory-card__benchmark-item">
|
||||
<svg class="subcategory-card__circle" width="24" height="24" xmlns="http://www.w3.org/2000/svg" <%= "data-bs-toggle=popover" if harvey_scorecard.insufficient_data? %> data-bs-placement="top" data-bs-content="This subcategory is not displayed due to limited availability of school data and/or low survey response rates.">
|
||||
<use class="harvey-ball harvey-ball--<%= harvey_scorecard.color %>" xlink:href="#<%= harvey_scorecard.harvey_ball_icon %>"></use>
|
||||
</svg>
|
||||
|
||||
<%= link_to(harvey_scorecard.name, district_school_category_path( @district, @school, harvey_scorecard.category, {year: @academic_year.range, anchor: "#{harvey_scorecard.id}"})) %>
|
||||
</div>
|
||||
|
|
@ -1,22 +1,24 @@
|
|||
<div class="mt-5 school-quality-frameworks">
|
||||
<% category_presenters.each do |category_presenter| %>
|
||||
<div class="text-center">
|
||||
<i class="<%= category_presenter.icon_class %> <%= category_presenter.icon_color_class %> fa-2x"></i>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<h3 class="sub-header-3">
|
||||
<%= link_to [@district, @school, category_presenter, { year: @academic_year.range }] do %>
|
||||
<%= category_presenter.name %>
|
||||
<% end %>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<p class="body-small text-center m-0"><%= category_presenter.short_description %></p>
|
||||
|
||||
<div class="subcategory-card">
|
||||
<div class="subcategory-card__benchmark-list">
|
||||
<%= render partial: 'subcategory_card', collection: category_presenter.subcategories(academic_year: @academic_year, school: @school).map(&:subcategory_card_presenter) %>
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="mt-5 <%= @page.framework_indicator_class %>">
|
||||
<% category_presenters.each do |category_presenter| %>
|
||||
<div class="text-center">
|
||||
<i class="<%= category_presenter.icon_class %> <%= category_presenter.icon_color_class %> fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="text-center">
|
||||
<h3 class="sub-header-3">
|
||||
<%= link_to [@district, @school, category_presenter, { year: @academic_year.range }] do %>
|
||||
<%= category_presenter.name %>
|
||||
<% end %>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<p class="body-small text-center m-0"><%= category_presenter.short_description %></p>
|
||||
|
||||
<div class="subcategory-card">
|
||||
<div class="subcategory-card__benchmark-list">
|
||||
<%= render partial: 'harvey_scorecard', collection: category_presenter.harvey_scorecard_presenters(school: @school, academic_year: @academic_year) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
|
||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-primary" for="btnradio1">Students & Teachers</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btnradio2">Parents</label>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
|
||||
<%= link_to(district_school_overview_index_path(@district, @school, year: @academic_year.range, view: "student")) do %>
|
||||
<input type="radio" class="btn-check" name="student_and_teacher_btn" id="student_and_teacher_btn" autocomplete="off" <%= @page.view == "student" ? "checked" : "" %> >
|
||||
<label class="btn btn-outline-primary" for="student_and_teacher_btn">Students & Teachers</label>
|
||||
<% end %>
|
||||
<%= link_to(district_school_overview_index_path(@district, @school, year: @academic_year.range, view: "parent")) do %>
|
||||
<input type="radio" class="btn-check" name="parent_btn" id="parent_btn" autocomplete="off" <%= @page.view == "parent" ? "checked" : "" %> >
|
||||
<label class="btn btn-outline-primary" for="parent_btn">Parents</label>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
<div class="subcategory-card__benchmark-item">
|
||||
<svg class="subcategory-card__circle" width="24" height="24" xmlns="http://www.w3.org/2000/svg" <%= "data-bs-toggle=popover" if subcategory_card.insufficient_data? %> data-bs-placement="top" data-bs-content="This subcategory is not displayed due to limited availability of school data and/or low survey response rates.">
|
||||
<use class="harvey-ball harvey-ball--<%= subcategory_card.color %>" xlink:href="#<%= subcategory_card.harvey_ball_icon %>"></use>
|
||||
</svg>
|
||||
|
||||
<%= link_to(subcategory_card.name, district_school_category_path( @district, @school, subcategory_card.category, {year: @academic_year.range, anchor: "#{subcategory_card.subcategory_id}"})) %>
|
||||
</div>
|
||||
|
|
@ -18,10 +18,12 @@
|
|||
</div>
|
||||
<%= render partial: "quality_framework_indicators", locals: { category_presenters: @category_presenters } %>
|
||||
|
||||
<% if @page.show_response_rates %>
|
||||
<div class="overall-response-rate-row">
|
||||
<%= render partial: "response_rate", locals: {response_rate_presenter: @student_response_rate_presenter} %>
|
||||
<%= render partial: "response_rate", locals: {response_rate_presenter: @teacher_response_rate_presenter} %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="card">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue