feat: Add parent button to overview page and alter 'School Quality Framework Indicators' section to show parent scales
parent
55aba4b2ba
commit
d0340c8a52
@ -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
|
||||
|
||||
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])
|
||||
@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
|
||||
|
||||
@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
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
class BackgroundPresenter
|
||||
class Analyze::BackgroundPresenter
|
||||
include AnalyzeHelper
|
||||
attr_reader :num_of_columns
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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>
|
||||
<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 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>
|
||||
<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="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>
|
||||
</div>
|
||||
<% end %>
|
||||
<% 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>
|
||||
@ -0,0 +1,89 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Overview::ScorecardPresenter do
|
||||
let(:zones) do
|
||||
Zones.new(
|
||||
watch_low_benchmark: 1.5,
|
||||
growth_low_benchmark: 2.5,
|
||||
approval_low_benchmark: 3.5,
|
||||
ideal_low_benchmark: 4.5
|
||||
)
|
||||
end
|
||||
|
||||
let(:subcategory_card_presenter) do
|
||||
subcategory = Subcategory.new(name: "A subcategory")
|
||||
Overview::ScorecardPresenter.new(construct: subcategory, zones:, score:, id: subcategory.subcategory_id)
|
||||
end
|
||||
|
||||
context "when the given score is in the Warning zone for the given scale" do
|
||||
let(:score) { 1 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "warning-harvey-ball"
|
||||
end
|
||||
|
||||
it "returns the color class of the zone" do
|
||||
expect(subcategory_card_presenter.color).to eq "warning"
|
||||
end
|
||||
end
|
||||
|
||||
context "when the given score is in the Watch zone for the given scale" do
|
||||
let(:score) { 2 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "watch-harvey-ball"
|
||||
end
|
||||
|
||||
it "returns the color class of the zone" do
|
||||
expect(subcategory_card_presenter.color).to eq "watch"
|
||||
end
|
||||
end
|
||||
|
||||
context "when the given score is in the Growth zone for the given scale" do
|
||||
let(:score) { 3 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "growth-harvey-ball"
|
||||
end
|
||||
|
||||
it "returns the color class of the zone" do
|
||||
expect(subcategory_card_presenter.color).to eq "growth"
|
||||
end
|
||||
end
|
||||
|
||||
context "when the given score is in the Approval zone for the given scale" do
|
||||
let(:score) { 4 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "approval-harvey-ball"
|
||||
end
|
||||
|
||||
it "returns the color class of the zone" do
|
||||
expect(subcategory_card_presenter.color).to eq "approval"
|
||||
end
|
||||
end
|
||||
|
||||
context "when the given score is in the Ideal zone for the given scale" do
|
||||
let(:score) { 5 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "ideal-harvey-ball"
|
||||
end
|
||||
|
||||
it "returns the color class of the zone" do
|
||||
expect(subcategory_card_presenter.color).to eq "ideal"
|
||||
end
|
||||
end
|
||||
|
||||
context "when the given score is invalid for the given scale" do
|
||||
let(:score) { 0 }
|
||||
|
||||
it "returns the icon that represents the zone" do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq "insufficient_data-harvey-ball"
|
||||
end
|
||||
|
||||
it "reports that there is insufficient data" do
|
||||
expect(subcategory_card_presenter.insufficient_data?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,86 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe SubcategoryCardPresenter do
|
||||
let(:zones) do
|
||||
Zones.new(
|
||||
watch_low_benchmark: 1.5,
|
||||
growth_low_benchmark: 2.5,
|
||||
approval_low_benchmark: 3.5,
|
||||
ideal_low_benchmark: 4.5
|
||||
)
|
||||
end
|
||||
|
||||
let(:subcategory_card_presenter) { SubcategoryCardPresenter.new(subcategory: Subcategory.new(name: 'A subcategory'), zones:, score:) }
|
||||
|
||||
context 'when the given score is in the Warning zone for the given scale' do
|
||||
let(:score) { 1 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'warning-harvey-ball'
|
||||
end
|
||||
|
||||
it 'returns the color class of the zone' do
|
||||
expect(subcategory_card_presenter.color).to eq 'warning'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given score is in the Watch zone for the given scale' do
|
||||
let(:score) { 2 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'watch-harvey-ball'
|
||||
end
|
||||
|
||||
it 'returns the color class of the zone' do
|
||||
expect(subcategory_card_presenter.color).to eq 'watch'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given score is in the Growth zone for the given scale' do
|
||||
let(:score) { 3 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'growth-harvey-ball'
|
||||
end
|
||||
|
||||
it 'returns the color class of the zone' do
|
||||
expect(subcategory_card_presenter.color).to eq 'growth'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given score is in the Approval zone for the given scale' do
|
||||
let(:score) { 4 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'approval-harvey-ball'
|
||||
end
|
||||
|
||||
it 'returns the color class of the zone' do
|
||||
expect(subcategory_card_presenter.color).to eq 'approval'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given score is in the Ideal zone for the given scale' do
|
||||
let(:score) { 5 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'ideal-harvey-ball'
|
||||
end
|
||||
|
||||
it 'returns the color class of the zone' do
|
||||
expect(subcategory_card_presenter.color).to eq 'ideal'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given score is invalid for the given scale' do
|
||||
let(:score) { 0 }
|
||||
|
||||
it 'returns the icon that represents the zone' do
|
||||
expect(subcategory_card_presenter.harvey_ball_icon).to eq 'insufficient_data-harvey-ball'
|
||||
end
|
||||
|
||||
it 'reports that there is insufficient data' do
|
||||
expect(subcategory_card_presenter.insufficient_data?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue