Add Overall Response Rate

This commit is contained in:
rebuilt 2023-05-16 13:19:29 -07:00 committed by Gabe Farrell
parent 435bc4a5be
commit a71ebbc4e4
19 changed files with 585 additions and 244 deletions

View file

@ -1,42 +1,42 @@
require "rails_helper"
require 'rails_helper'
include VarianceHelper
describe "overview/index" do
describe 'overview/index' do
subject { Nokogiri::HTML(rendered) }
let(:support_for_teaching) do
measure = create(:measure, name: "Support For Teaching Development & Growth", measure_id: "1")
measure = create(:measure, name: 'Support For Teaching Development & Growth', measure_id: '1')
scale = create(:scale, measure:)
create(:student_survey_item,
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
measure
end
let(:effective_leadership) do
measure = create(:measure, name: "Effective Leadership", measure_id: "2")
measure = create(:measure, name: 'Effective Leadership', measure_id: '2')
scale = create(:scale, measure:)
create(:teacher_survey_item,
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
measure
end
let(:professional_qualifications) do
measure = create(:measure, name: "Professional Qualifications", measure_id: "3")
measure = create(:measure, name: 'Professional Qualifications', measure_id: '3')
scale = create(:scale, measure:)
create(:admin_data_item,
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
measure
end
@ -47,14 +47,19 @@ describe "overview/index" do
assign :academic_years, [@academic_year]
@district = create(:district)
@school = create(:school)
@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)
Respondent.create!(school: @school, academic_year: @academic_year, total_students: 40, total_teachers: 40)
ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year,
student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true)
render
end
context "when some presenters have a nil score" do
context 'when some presenters have a nil score' do
let(:variance_chart_row_presenters) do
[
VarianceChartRowPresenter.new(measure: support_for_teaching, score: Score.new),
@ -63,49 +68,49 @@ describe "overview/index" do
]
end
it "displays a note detailing which measures have insufficient responses for the given school & academic year" do
it 'displays a note detailing which measures have insufficient responses for the given school & academic year' do
expect(rendered).to match %r{Note: The following measures are not displayed due to limited availability of school data and/or low survey response rates: Support For Teaching Development & Growth; Professional Qualifications.}
end
it "displays a variance row and label only those presenters for which the score is not nil" do
displayed_variance_rows = subject.css("[data-for-measure-id]")
it 'displays a variance row and label only those presenters for which the score is not nil' do
displayed_variance_rows = subject.css('[data-for-measure-id]')
expect(displayed_variance_rows.count).to eq 1
expect(displayed_variance_rows.first.attribute("data-for-measure-id").value).to eq "2"
expect(displayed_variance_rows.first.attribute('data-for-measure-id').value).to eq '2'
displayed_variance_labels = subject.css("[data-variance-row-label]")
displayed_variance_labels = subject.css('[data-variance-row-label]')
expect(displayed_variance_labels.count).to eq 1
expect(displayed_variance_labels.first.inner_text).to include "Effective Leadership"
expect(displayed_variance_labels.first.inner_text).to include 'Effective Leadership'
end
end
context "when all the presenters have a non-nil score" do
context 'when all the presenters have a non-nil score' do
let(:variance_chart_row_presenters) do
measure = create(:measure, name: "Display Me", measure_id: "display-me")
measure = create(:measure, name: 'Display Me', measure_id: 'display-me')
scale = create(:scale, measure:)
create(:student_survey_item,
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
scale:,
watch_low_benchmark: 1.5,
growth_low_benchmark: 2.5,
approval_low_benchmark: 3.5,
ideal_low_benchmark: 4.5)
[
VarianceChartRowPresenter.new(measure:,
score: Score.new(average: rand))
score: Score.new(average: rand))
]
end
it "does not display a note detailing which measures have insufficient responses for the given school & academic year" do
it 'does not display a note detailing which measures have insufficient responses for the given school & academic year' do
expect(rendered).not_to match %r{Note: The following measures are not displayed due to limited availability of school data and/or low survey response rates}
end
it "displays a variance row for each presenter" do
displayed_variance_rows = subject.css("[data-for-measure-id]")
it 'displays a variance row for each presenter' do
displayed_variance_rows = subject.css('[data-for-measure-id]')
expect(displayed_variance_rows.count).to eq 1
expect(displayed_variance_rows.first.attribute("data-for-measure-id").value).to eq "display-me"
expect(displayed_variance_rows.first.attribute('data-for-measure-id').value).to eq 'display-me'
displayed_variance_labels = subject.css("[data-variance-row-label]")
displayed_variance_labels = subject.css('[data-variance-row-label]')
expect(displayed_variance_labels.count).to eq 1
expect(displayed_variance_labels.first.inner_text).to include "Display Me"
expect(displayed_variance_labels.first.inner_text).to include 'Display Me'
end
end
end