diff --git a/app/models/measure.rb b/app/models/measure.rb
index 3fc0d4c8..5d19e42f 100644
--- a/app/models/measure.rb
+++ b/app/models/measure.rb
@@ -173,6 +173,10 @@ class Measure < ActiveRecord::Base
approval_low_benchmark:, ideal_low_benchmark:).zone_for_score(score.average)
end
+ def construct_id
+ measure_id
+ end
+
private
def any_admin_data_collected?(school:, academic_year:)
diff --git a/app/models/scale.rb b/app/models/scale.rb
index bb2bc2d9..b53a68cc 100644
--- a/app/models/scale.rb
+++ b/app/models/scale.rb
@@ -42,6 +42,38 @@ class Scale < ApplicationRecord
where("scale_id LIKE 'p-%'")
}
+ def watch_low_benchmark
+ survey_items.first.watch_low_benchmark
+ end
+
+ def growth_low_benchmark
+ survey_items.first.growth_low_benchmark
+ end
+
+ def approval_low_benchmark
+ survey_items.first.approval_low_benchmark
+ end
+
+ def ideal_low_benchmark
+ survey_items.first.ideal_low_benchmark
+ end
+
+ def includes_teacher_survey_items?
+ survey_items.teacher_survey_items.length.positive?
+ end
+
+ def includes_student_survey_items?
+ survey_items.student_survey_items.length.positive?
+ end
+
+ def includes_admin_data_items?
+ admin_data_items.length.positive?
+ end
+
+ def construct_id
+ scale_id
+ end
+
private
def collect_survey_item_average(survey_items, school, academic_year)
diff --git a/app/presenters/overview/overview_presenter.rb b/app/presenters/overview/overview_presenter.rb
index 31ca5cf6..94fae8b9 100644
--- a/app/presenters/overview/overview_presenter.rb
+++ b/app/presenters/overview/overview_presenter.rb
@@ -46,7 +46,7 @@ class Overview::OverviewPresenter
def presenter_for_measure(measure)
score = measure.score(school: @school, academic_year: @academic_year)
- Overview::VarianceChartRowPresenter.new(measure:, score:)
+ Overview::VarianceChartRowPresenter.new(construct: measure, score:)
end
def empty_dataset?
diff --git a/app/presenters/overview/parent_overview_presenter.rb b/app/presenters/overview/parent_overview_presenter.rb
index bfd68aba..46dfa898 100644
--- a/app/presenters/overview/parent_overview_presenter.rb
+++ b/app/presenters/overview/parent_overview_presenter.rb
@@ -12,4 +12,21 @@ class Overview::ParentOverviewPresenter < Overview::OverviewPresenter
def framework_indicator_class
"school-quality-frameworks-parent"
end
+
+ def variance_chart_row_presenters
+ scales.map(&method(:presenter_for_scale))
+ end
+
+ def scales
+ measures.flat_map { |measure| measure.scales.parent_scales }
+ end
+
+ private
+
+ def presenter_for_scale(scale)
+ score = scale.parent_score(school: @school, academic_year: @academic_year)
+ score = Score.new(average: score, meets_teacher_threshold: true, meets_student_threshold: true)
+
+ Overview::VarianceChartRowPresenter.new(construct: scale, score:)
+ end
end
diff --git a/app/presenters/overview/variance_chart_row_presenter.rb b/app/presenters/overview/variance_chart_row_presenter.rb
index 4f74c497..043b1903 100644
--- a/app/presenters/overview/variance_chart_row_presenter.rb
+++ b/app/presenters/overview/variance_chart_row_presenter.rb
@@ -3,16 +3,16 @@
class Overview::VarianceChartRowPresenter
include Comparable
- attr_reader :score, :measure_name, :measure_id, :category
+ attr_reader :score, :construct_name, :construct_id, :category
- def initialize(measure:, score:)
- @measure = measure
+ def initialize(construct:, score:)
+ @construct = construct
@score = score.average
@meets_teacher_threshold = score.meets_teacher_threshold?
@meets_student_threshold = score.meets_student_threshold?
- @measure_name = @measure.name
- @measure_id = @measure.measure_id
- @category = @measure.subcategory.category
+ @construct_name = @construct.name
+ @construct_id = @construct.construct_id
+ @category = @construct.category
end
def sufficient_data?
@@ -106,11 +106,12 @@ class Overview::VarianceChartRowPresenter
def zone
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
+ watch_low_benchmark: @construct.watch_low_benchmark,
+ growth_low_benchmark: @construct.growth_low_benchmark,
+ approval_low_benchmark: @construct.approval_low_benchmark,
+ ideal_low_benchmark: @construct.ideal_low_benchmark
)
zones.zone_for_score(@score)
end
end
+
diff --git a/app/views/overview/_variance_chart.html.erb b/app/views/overview/_variance_chart.html.erb
index 5bed58ec..67c5872f 100644
--- a/app/views/overview/_variance_chart.html.erb
+++ b/app/views/overview/_variance_chart.html.erb
@@ -4,7 +4,7 @@
<% if displayed_presenters.none? %>
Note: No measures can be displayed due to limited availability of school data and/or low survey response rates.
<% elsif not_displayed_presenters.present? %>
-Note: The following measures are not displayed due to limited availability of school data and/or low survey response rates: <%= not_displayed_presenters.map(&:measure_name).join('; ') %>.
+Note: The following measures are not displayed due to limited availability of school data and/or low survey response rates: <%= not_displayed_presenters.map(&:construct_name).join('; ') %>.
<% end %>
xmlns="http://www.w3.org/2000/svg">
@@ -90,7 +90,7 @@
width="550"
height="200">
- <%= link_to(presenter.measure_name, district_school_category_path( @district, @school, presenter.category, {year: @academic_year.range, anchor: "#{presenter.measure_id}"}), class: "measure-row-label") %>
+ <%= link_to(presenter.construct_name, district_school_category_path( @district, @school, presenter.category, {year: @academic_year.range, anchor: "#{presenter.construct_id}"}), class: "measure-row-label") %>
<% end %>
@@ -120,7 +120,7 @@
y="<%= index * measure_row_height + (measure_row_height - measure_row_bar_height) / 2 %>"
width="<%= presenter.bar_width %>"
height="<%= measure_row_bar_height %>"
- data-for-measure-id="<%= presenter.measure_id %>"
+ data-for-measure-id="<%= presenter.construct_id %>"
stroke="none"
/>
<% end %>
diff --git a/spec/presenters/variance_chart_row_presenter_spec.rb b/spec/presenters/variance_chart_row_presenter_spec.rb
index 7620948b..1c2148c7 100644
--- a/spec/presenters/variance_chart_row_presenter_spec.rb
+++ b/spec/presenters/variance_chart_row_presenter_spec.rb
@@ -30,12 +30,12 @@ describe Overview::VarianceChartRowPresenter do
end
let(:presenter) do
- Overview::VarianceChartRowPresenter.new measure:, score:
+ Overview::VarianceChartRowPresenter.new construct: measure, score:
end
shared_examples_for "measure_name" do
it "returns the measure name" do
- expect(presenter.measure_name).to eq "Some Title"
+ expect(presenter.construct_name).to eq "Some Title"
end
end
@@ -139,7 +139,7 @@ describe Overview::VarianceChartRowPresenter do
let(:score) { Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false) }
it "it does not show a partial data indicator" do
- presenter_without_admin_data = Overview::VarianceChartRowPresenter.new(measure: measure_without_admin_data_items,
+ presenter_without_admin_data = Overview::VarianceChartRowPresenter.new(construct: measure_without_admin_data_items,
score:)
expect(presenter_without_admin_data.show_partial_data_indicator?).to be false
end
@@ -163,7 +163,7 @@ describe Overview::VarianceChartRowPresenter do
growth_low_benchmark:,
approval_low_benchmark:,
ideal_low_benchmark:)
- admin_data_presenter = Overview::VarianceChartRowPresenter.new measure: measure_with_admin_data,
+ admin_data_presenter = Overview::VarianceChartRowPresenter.new construct: measure_with_admin_data,
score: Score.new(
average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true
)
@@ -236,11 +236,11 @@ describe Overview::VarianceChartRowPresenter do
growth_low_benchmark:,
approval_low_benchmark:,
ideal_low_benchmark:)
- approval_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ approval_presenter = Overview::VarianceChartRowPresenter.new construct: measure,
score: Score.new(
average: 3.7, meets_teacher_threshold: true, meets_student_threshold: true
)
- ideal_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ ideal_presenter = Overview::VarianceChartRowPresenter.new construct: measure,
score: Score.new(
average: 4.4, meets_teacher_threshold: true, meets_student_threshold: true
)
@@ -249,11 +249,11 @@ describe Overview::VarianceChartRowPresenter do
end
it "selects a warning bar below a ideal bar" do
- warning_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ warning_presenter = Overview::VarianceChartRowPresenter.new construct: measure,
score: Score.new(
average: 1.0, meets_teacher_threshold: true, meets_student_threshold: true
)
- ideal_presenter = Overview::VarianceChartRowPresenter.new measure:,
+ ideal_presenter = Overview::VarianceChartRowPresenter.new construct: measure,
score: Score.new(
average: 5.0, meets_teacher_threshold: true, meets_student_threshold: true
)
diff --git a/spec/views/overview/index.html.erb_spec.rb b/spec/views/overview/index.html.erb_spec.rb
index 4784a1c4..dc4b87c1 100644
--- a/spec/views/overview/index.html.erb_spec.rb
+++ b/spec/views/overview/index.html.erb_spec.rb
@@ -50,16 +50,16 @@ describe "overview/index" do
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
[
- Overview::VarianceChartRowPresenter.new(measure:,
+ Overview::VarianceChartRowPresenter.new(construct: measure,
score: Score.new(average: rand))
]
end
context "when some presenters have a nil score" do
let(:variance_chart_row_presenters) do
[
- Overview::VarianceChartRowPresenter.new(measure: support_for_teaching, score: Score.new),
- Overview::VarianceChartRowPresenter.new(measure: effective_leadership, score: Score.new(average: rand)),
- Overview::VarianceChartRowPresenter.new(measure: professional_qualifications, score: Score.new)
+ Overview::VarianceChartRowPresenter.new(construct: support_for_teaching, score: Score.new),
+ Overview::VarianceChartRowPresenter.new(construct: effective_leadership, score: Score.new(average: rand)),
+ Overview::VarianceChartRowPresenter.new(construct: professional_qualifications, score: Score.new)
]
end
diff --git a/spec/views/overview/variance_chart.html.erb_spec.rb b/spec/views/overview/variance_chart.html.erb_spec.rb
index a1547fa6..9b1c646f 100644
--- a/spec/views/overview/variance_chart.html.erb_spec.rb
+++ b/spec/views/overview/variance_chart.html.erb_spec.rb
@@ -27,8 +27,8 @@ describe "overview/_variance_chart.html.erb" do
before :each do
presenters = [
- Overview::VarianceChartRowPresenter.new(measure: lower_scoring_measure, score: Score.new(average: 1)),
- Overview::VarianceChartRowPresenter.new(measure: higher_scoring_measure, score: Score.new(average: 5))
+ Overview::VarianceChartRowPresenter.new(construct: lower_scoring_measure, score: Score.new(average: 1)),
+ Overview::VarianceChartRowPresenter.new(construct: higher_scoring_measure, score: Score.new(average: 5))
]
render partial: "variance_chart", locals: { presenters: }
@@ -53,8 +53,9 @@ describe "overview/_variance_chart.html.erb" do
measure_lacking_score = create(:measure)
another_measure_lacking_score = create(:measure)
presenters = [
- Overview::VarianceChartRowPresenter.new(measure: measure_lacking_score, score: Score.new(average: nil)),
- Overview::VarianceChartRowPresenter.new(measure: another_measure_lacking_score, score: Score.new(average: nil))
+ Overview::VarianceChartRowPresenter.new(construct: measure_lacking_score, score: Score.new(average: nil)),
+ Overview::VarianceChartRowPresenter.new(construct: another_measure_lacking_score,
+ score: Score.new(average: nil))
]
render partial: "variance_chart", locals: { presenters: }