|
|
|
@ -1,42 +1,55 @@
|
|
|
|
require 'rails_helper'
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
|
|
describe GroupedBarColumnPresenter do
|
|
|
|
describe GroupedBarColumnPresenter do
|
|
|
|
let(:watch_low_benchmark) { 2.9 }
|
|
|
|
let(:school) { create(:school) }
|
|
|
|
let(:growth_low_benchmark) { 3.1 }
|
|
|
|
let(:academic_year) { create(:academic_year) }
|
|
|
|
let(:approval_low_benchmark) { 3.6 }
|
|
|
|
let(:watch_low_benchmark) { 2 }
|
|
|
|
let(:ideal_low_benchmark) { 3.8 }
|
|
|
|
let(:growth_low_benchmark) { 3 }
|
|
|
|
|
|
|
|
let(:approval_low_benchmark) { 4 }
|
|
|
|
let(:measure_with_student_survey_items) do
|
|
|
|
let(:ideal_low_benchmark) { 4.5 }
|
|
|
|
measure = create(
|
|
|
|
|
|
|
|
:measure,
|
|
|
|
let(:measure_with_student_survey_items) { create(:measure, name: 'Student measure') }
|
|
|
|
name: 'Some Title'
|
|
|
|
let(:scale_with_student_survey_item) { create(:student_scale, measure: measure_with_student_survey_items) }
|
|
|
|
)
|
|
|
|
let(:student_survey_item) do
|
|
|
|
scale = create(:scale, measure:)
|
|
|
|
create(:student_survey_item, scale: scale_with_student_survey_item,
|
|
|
|
|
|
|
|
|
|
|
|
create(:student_survey_item, scale:,
|
|
|
|
|
|
|
|
watch_low_benchmark:,
|
|
|
|
watch_low_benchmark:,
|
|
|
|
growth_low_benchmark:,
|
|
|
|
growth_low_benchmark:,
|
|
|
|
approval_low_benchmark:,
|
|
|
|
approval_low_benchmark:,
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
|
|
|
|
|
|
|
|
measure
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let(:measure_with_teacher_survey_items) do
|
|
|
|
let(:measure_with_teacher_survey_items) { create(:measure, name: 'Teacher measure') }
|
|
|
|
measure = create(
|
|
|
|
let(:scale_with_teacher_survey_item) { create(:teacher_scale, measure: measure_with_teacher_survey_items) }
|
|
|
|
:measure,
|
|
|
|
let(:teacher_survey_item) do
|
|
|
|
name: 'Some Title'
|
|
|
|
create(:teacher_survey_item, scale: scale_with_teacher_survey_item,
|
|
|
|
)
|
|
|
|
|
|
|
|
scale = create(:scale, measure:)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create(:teacher_survey_item, scale:,
|
|
|
|
|
|
|
|
watch_low_benchmark:,
|
|
|
|
watch_low_benchmark:,
|
|
|
|
growth_low_benchmark:,
|
|
|
|
growth_low_benchmark:,
|
|
|
|
approval_low_benchmark:,
|
|
|
|
approval_low_benchmark:,
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
measure
|
|
|
|
let(:measure_composed_of_student_and_teacher_items) { create(:measure, name: 'Student and teacher measure') }
|
|
|
|
|
|
|
|
let(:student_scale_for_composite_measure) do
|
|
|
|
|
|
|
|
create(:student_scale, measure: measure_composed_of_student_and_teacher_items)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:student_survey_item_for_composite_measure) do
|
|
|
|
|
|
|
|
create(:student_survey_item, scale: student_scale_for_composite_measure,
|
|
|
|
|
|
|
|
watch_low_benchmark:,
|
|
|
|
|
|
|
|
growth_low_benchmark:,
|
|
|
|
|
|
|
|
approval_low_benchmark:,
|
|
|
|
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:teacher_scale_for_composite_measure) do
|
|
|
|
|
|
|
|
create(:teacher_scale, measure: measure_composed_of_teacher_and_teacher_items)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:teacher_survey_item_for_composite_measure) do
|
|
|
|
|
|
|
|
create(:teacher_survey_item, scale: teacher_scale_for_composite_measure,
|
|
|
|
|
|
|
|
watch_low_benchmark:,
|
|
|
|
|
|
|
|
growth_low_benchmark:,
|
|
|
|
|
|
|
|
approval_low_benchmark:,
|
|
|
|
|
|
|
|
ideal_low_benchmark:)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let(:measure_without_admin_data_items) do
|
|
|
|
let(:measure_without_admin_data_items) do
|
|
|
|
create(
|
|
|
|
create(
|
|
|
|
:measure,
|
|
|
|
:measure,
|
|
|
|
@ -45,22 +58,39 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let(:student_presenter) do
|
|
|
|
let(:student_presenter) do
|
|
|
|
GroupedBarColumnPresenter.new measure: measure_with_student_survey_items, score:, position: 1, type: :student
|
|
|
|
StudentGroupedBarColumnPresenter.new measure: measure_with_student_survey_items, school:, academic_year:,
|
|
|
|
|
|
|
|
position: 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let(:teacher_presenter) do
|
|
|
|
let(:teacher_presenter) do
|
|
|
|
GroupedBarColumnPresenter.new measure: measure_with_teacher_survey_items, score:, position: 1, type: :teacher
|
|
|
|
TeacherGroupedBarColumnPresenter.new measure: measure_with_teacher_survey_items, school:, academic_year:,
|
|
|
|
|
|
|
|
position: 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:all_data_presenter) do
|
|
|
|
|
|
|
|
GroupedBarColumnPresenter.new measure: measure_composed_of_student_and_teacher_items, school:, academic_year:,
|
|
|
|
|
|
|
|
position: 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:respondent, school:, academic_year:, total_students: 1, total_teachers: 1)
|
|
|
|
|
|
|
|
create(:survey, form: :normal, school:, academic_year:)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
shared_examples_for 'measure_name' do
|
|
|
|
shared_examples_for 'measure_name' do
|
|
|
|
it 'returns the measure name' do
|
|
|
|
it 'returns the measure name' do
|
|
|
|
expect(student_presenter.measure_name).to eq 'Some Title'
|
|
|
|
expect(student_presenter.measure_name).to eq 'Student measure'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when a measure is based on student survey items' do
|
|
|
|
context 'when a measure is based on student survey items' do
|
|
|
|
context 'when the score is in the Ideal zone' do
|
|
|
|
context 'when the score is in the Ideal zone' do
|
|
|
|
let(:score) { Score.new(4.4, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 5)
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 4)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,16 +99,19 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns a bar width equal to the approval zone width plus the proportionate ideal zone width' do
|
|
|
|
it 'returns a bar width equal to the approval zone width plus the proportionate ideal zone width' do
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(25.5)
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(17)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns a y_offset equal to the ' do
|
|
|
|
it 'returns a y_offset equal to the ' do
|
|
|
|
expect(student_presenter.y_offset).to be_within(0.01).of(8.5)
|
|
|
|
expect(student_presenter.y_offset).to be_within(0.01).of(17)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when the score is in the Approval zone' do
|
|
|
|
context 'when the score is in the Approval zone' do
|
|
|
|
let(:score) { Score.new(3.7, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 4)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
|
|
|
|
|
|
|
|
@ -87,16 +120,19 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns a bar width equal to the proportionate approval zone width' do
|
|
|
|
it 'returns a bar width equal to the proportionate approval zone width' do
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(8.5)
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns an x-offset of 60%' do
|
|
|
|
it 'returns an x-offset of 60%' do
|
|
|
|
expect(student_presenter.y_offset).to be_within(0.01).of(25.5)
|
|
|
|
expect(student_presenter.y_offset).to be_within(0.01).of(34)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when the score is in the Growth zone' do
|
|
|
|
context 'when the score is in the Growth zone' do
|
|
|
|
let(:score) { Score.new(3.2, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 3)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
|
|
|
|
|
|
|
|
@ -105,7 +141,7 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns a bar width equal to the proportionate growth zone width' do
|
|
|
|
it 'returns a bar width equal to the proportionate growth zone width' do
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(13.59)
|
|
|
|
expect(student_presenter.bar_height_percentage).to be_within(0.01).of(17)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'in order to achieve the visual effect' do
|
|
|
|
context 'in order to achieve the visual effect' do
|
|
|
|
@ -116,7 +152,10 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when the score is in the Watch zone' do
|
|
|
|
context 'when the score is in the Watch zone' do
|
|
|
|
let(:score) { Score.new(2.9, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 2)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,7 +175,10 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when the score is in the Warning zone' do
|
|
|
|
context 'when the score is in the Warning zone' do
|
|
|
|
let(:score) { Score.new(1.0, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:, likert_score: 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
it_behaves_like 'measure_name'
|
|
|
|
|
|
|
|
|
|
|
|
@ -156,53 +198,36 @@ describe GroupedBarColumnPresenter do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'when there are insufficient responses to calculate a score' do
|
|
|
|
context 'when there are insufficient responses to calculate a score' do
|
|
|
|
let(:score) { Score.new(nil, true, false) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
expect(student_presenter.show_insufficient_data_message?).to eq true
|
|
|
|
expect(student_presenter.show_insufficient_data_message?).to eq true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when there are enough responses to calculate a score' do
|
|
|
|
context 'when there are enough responses to calculate a score' do
|
|
|
|
let(:score) { Score.new(nil, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:)
|
|
|
|
|
|
|
|
end
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
expect(student_presenter.show_insufficient_data_message?).to eq false
|
|
|
|
expect(student_presenter.show_insufficient_data_message?).to eq false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when the presenter type is student but the measure is not based on student surveys' do
|
|
|
|
|
|
|
|
let(:score) { Score.new(nil, false, false) }
|
|
|
|
|
|
|
|
let(:student_presenter) do
|
|
|
|
|
|
|
|
GroupedBarColumnPresenter.new measure: measure_without_admin_data_items, score:, position: 1, type: :student
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'indecates it should show the irrelevancy message' do
|
|
|
|
|
|
|
|
expect(student_presenter.show_irrelevancy_message?).to be true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'when the measure is based on teacher survey items' do
|
|
|
|
context 'when the measure is based on teacher survey items' do
|
|
|
|
context 'when there are insufficient responses to calculate a score' do
|
|
|
|
context 'when there are insufficient responses to calculate a score' do
|
|
|
|
let(:score) { Score.new(nil, false, true) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
expect(teacher_presenter.show_insufficient_data_message?).to eq true
|
|
|
|
expect(teacher_presenter.show_insufficient_data_message?).to eq true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when there are enough responses to calculate a score' do
|
|
|
|
context 'when there are enough responses to calculate a score' do
|
|
|
|
let(:score) { Score.new(nil, true, true) }
|
|
|
|
before do
|
|
|
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item, school:,
|
|
|
|
|
|
|
|
academic_year:)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
it 'indicates it should show the insufficient data message' do
|
|
|
|
expect(teacher_presenter.show_insufficient_data_message?).to eq false
|
|
|
|
expect(teacher_presenter.show_insufficient_data_message?).to eq false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when the presenter type is teacher but the measure is not based on teacher surveys' do
|
|
|
|
|
|
|
|
let(:score) { Score.new(nil, false, false) }
|
|
|
|
|
|
|
|
let(:teacher_presenter) do
|
|
|
|
|
|
|
|
GroupedBarColumnPresenter.new measure: measure_without_admin_data_items, score:, position: 1, type: :teacher
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'indecates it should show the irrelevancy message' do
|
|
|
|
|
|
|
|
expect(teacher_presenter.show_irrelevancy_message?).to be true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|