- <% @available_academic_years.each do | year | %>
+ <% @available_academic_years.each_with_index do | year, index | %>
data-action="click->analyze#refresh">
-
+
<% end %>
diff --git a/spec/presenters/grouped_bar_column_presenter_spec.rb b/spec/presenters/grouped_bar_column_presenter_spec.rb
index de690588..23d02572 100644
--- a/spec/presenters/grouped_bar_column_presenter_spec.rb
+++ b/spec/presenters/grouped_bar_column_presenter_spec.rb
@@ -1,8 +1,12 @@
require 'rails_helper'
+include AnalyzeHelper
describe GroupedBarColumnPresenter do
let(:school) { create(:school) }
- let(:academic_year) { create(:academic_year) }
+ let(:academic_year) { create(:academic_year, range: '1900-01') }
+ let(:another_academic_year) { create(:academic_year, range: '2000-01') }
+ let(:academic_years) { [academic_year, another_academic_year] }
+ let(:year_index) { academic_years.find_index(academic_year) }
let(:watch_low_benchmark) { 2 }
let(:growth_low_benchmark) { 3 }
let(:approval_low_benchmark) { 4 }
@@ -58,18 +62,18 @@ describe GroupedBarColumnPresenter do
end
let(:student_presenter) do
- StudentGroupedBarColumnPresenter.new measure: measure_with_student_survey_items, school:, academic_year:,
- position: 1
+ StudentGroupedBarColumnPresenter.new measure: measure_with_student_survey_items, school:, academic_years:,
+ position: 0
end
let(:teacher_presenter) do
- TeacherGroupedBarColumnPresenter.new measure: measure_with_teacher_survey_items, school:, academic_year:,
- position: 1
+ TeacherGroupedBarColumnPresenter.new measure: measure_with_teacher_survey_items, school:, academic_years:,
+ position: 0
end
let(:all_data_presenter) do
- GroupedBarColumnPresenter.new measure: measure_composed_of_student_and_teacher_items, school:, academic_year:,
- position: 1
+ GroupedBarColumnPresenter.new measure: measure_composed_of_student_and_teacher_items, school:, academic_years:,
+ position: 0
end
before do
@@ -83,132 +87,198 @@ describe GroupedBarColumnPresenter do
end
end
- context 'when a measure is based on student survey items' do
- context 'when the score is in the Ideal zone' do
+ shared_examples_for 'column_midpoint' do
+ it 'return an x position centered in the width of the column' do
+ expect(student_presenter.column_midpoint).to eq 29
+ end
+ end
+
+ shared_examples_for 'bar_color' do
+ it 'returns the correct color' do
+ expect(student_presenter.bars[year_index].color).to eq colors[year_index]
+ end
+ end
+
+ shared_examples_for 'y_offset' do
+ it 'bar will be based on the approval low benchmark boundary' do
+ expect(student_presenter.bars[year_index].y_offset).to be_within(0.01).of(34)
+ end
+ end
+
+ context 'for a grouped column presenter with both student and teacher responses' do
+ context 'with a single year'
+ before do
+ create(:survey_item_response, survey_item: student_survey_item_for_composite_measure, school:,
+ academic_year:, likert_score: 4)
+ create(:survey_item_response, survey_item: student_survey_item_for_composite_measure, school:,
+ academic_year:, likert_score: 5)
+ end
+
+ it 'returns a score that is an average of the likert scores ' do
+ expect(all_data_presenter.score(0).average).to eq 4.5
+ expect(all_data_presenter.score(1).average).to eq nil
+ expect(all_data_presenter.academic_years[0].range).to be academic_year.range
+ expect(all_data_presenter.academic_years[1].range).to be another_academic_year.range
+ end
+ context 'when more than one year exists' do
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)
+ create(:survey_item_response, survey_item: student_survey_item_for_composite_measure, school:,
+ academic_year: another_academic_year, likert_score: 5)
+ create(:survey_item_response, survey_item: student_survey_item_for_composite_measure, school:,
+ academic_year: another_academic_year, likert_score: 3)
+ end
+ it 'returns independent scores for each year of data' do
+ expect(all_data_presenter.score(0).average).to eq 4.5
+ expect(all_data_presenter.score(1).average).to eq 4
end
+ end
+ end
+ context 'when a measure is based on student survey items' do
+ before do
+ year_index = academic_years.find_index(academic_year)
+ end
+
+ context 'when there is insufficient data to show a score' do
it_behaves_like 'measure_name'
+ it_behaves_like 'column_midpoint'
- it 'returns the correct color' do
- expect(student_presenter.bar_color).to eq 'fill-ideal'
+ it 'returns an emtpy set of bars' do
+ expect(student_presenter.bars).to eq []
end
- 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(17)
+ it 'returns an emty score' do
+ expect(student_presenter.score(year_index).average).to eq nil
end
- it 'returns a y_offset equal to the ' do
- expect(student_presenter.y_offset).to be_within(0.01).of(17)
+ it 'shows the irrelevancy message ' do
+ expect(student_presenter.show_irrelevancy_message?).to eq true
+ end
+
+ it 'shows the insufficient data message' do
+ expect(student_presenter.show_insufficient_data_message?).to eq true
end
end
- context 'when the score is in the Approval zone' do
+ context 'when the score is in the Ideal zone' do
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 'column_midpoint'
+ it_behaves_like 'bar_color'
- it 'returns the correct color' do
- expect(student_presenter.bar_color).to eq 'fill-approval'
+ it 'returns a bar width equal to the approval zone width plus the proportionate ideal zone width' do
+ expect(student_presenter.bars[year_index].bar_height_percentage).to be_within(0.01).of(17)
end
- 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(0)
+ it 'returns a y_offset equal to the ' do
+ expect(student_presenter.bars[0].y_offset).to be_within(0.01).of(17)
end
- it 'returns an x-offset of 60%' do
- expect(student_presenter.y_offset).to be_within(0.01).of(34)
+ it 'returns a text representation of the type of survey the bars are based on' do
+ expect(student_presenter.basis).to eq 'student'
end
- end
- context 'when the score is in the Growth zone' do
- before do
- create(:survey_item_response, survey_item: student_survey_item, school:,
- academic_year:, likert_score: 3)
+ it 'returns only bars that have a numeric score' do
+ expect(student_presenter.bars.count).to be 1
end
- it_behaves_like 'measure_name'
+ it 'returns an explanatory bar label' do
+ expect(student_presenter.label).to eq 'All Students'
+ end
- it 'returns the correct color' do
- expect(student_presenter.bar_color).to eq 'fill-growth'
+ it 'does not show a message that the data source is irrelevant for this measure' do
+ expect(student_presenter.show_irrelevancy_message?).to be false
end
- 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(17)
+ it 'does not show a message about insufficient responses' do
+ expect(student_presenter.show_insufficient_data_message?).to be false
end
- context 'in order to achieve the visual effect' do
- it 'returns an x-offset equal to 60% minus the bar width' do
- expect(student_presenter.y_offset).to eq 34
+ context 'when there is more than one years worth of data to show' do
+ before do
+ create(:survey_item_response, survey_item: student_survey_item, school:,
+ academic_year: another_academic_year, likert_score: 3)
+ create(:survey_item_response, survey_item: student_survey_item, school:,
+ academic_year: another_academic_year, likert_score: 4)
+ end
+
+ it 'returns only bars that have a numeric score' do
+ expect(student_presenter.bars.count).to be 2
end
end
end
- context 'when the score is in the Watch zone' do
+ context 'when the score is in the Approval zone' do
before do
create(:survey_item_response, survey_item: student_survey_item, school:,
- academic_year:, likert_score: 2)
+ academic_year:, likert_score: 4)
end
it_behaves_like 'measure_name'
+ it_behaves_like 'column_midpoint'
+ it_behaves_like 'bar_color'
+ it_behaves_like 'y_offset'
- it 'returns the correct color' do
- expect(student_presenter.bar_color).to eq 'fill-watch'
- end
-
- it 'returns a bar width equal to the proportionate watch zone width plus the growth zone width' do
- expect(student_presenter.bar_height_percentage).to eq 34
- end
+ context 'and the score is right at the approval low benchmark' do
+ it 'bar will have a height of 0' do
+ expect(student_presenter.bars[year_index].bar_height_percentage).to be_within(0.01).of(0)
+ end
- context 'in order to achieve the visual effect' do
- it 'returns an x-offset equal to 60% minus the bar width' do
- expect(student_presenter.y_offset).to eq 34
+ it 'bar will be based on the approval low benchmark boundary' do
+ expect(student_presenter.bars[year_index].y_offset).to be_within(0.01).of(34)
end
end
end
-
- context 'when the score is in the Warning zone' do
+ context 'when the score is in the Growth zone' do
before do
create(:survey_item_response, survey_item: student_survey_item, school:,
- academic_year:, likert_score: 1)
+ academic_year:, likert_score: 3)
end
it_behaves_like 'measure_name'
+ it_behaves_like 'column_midpoint'
+ it_behaves_like 'bar_color'
+ it_behaves_like 'y_offset'
- it 'returns the correct color' do
- expect(student_presenter.bar_color).to eq 'fill-warning'
+ it 'returns a bar width equal to the proportionate growth zone width' do
+ expect(student_presenter.bars[year_index].bar_height_percentage).to be_within(0.01).of(17)
end
+ end
- it 'returns a bar width equal to the proportionate warning zone width plus the watch & growth zone widths' do
- expect(student_presenter.bar_height_percentage).to eq 51
+ context 'when the score is in the Watch zone' do
+ before do
+ create(:survey_item_response, survey_item: student_survey_item, school:,
+ academic_year:, likert_score: 2)
end
- context 'in order to achieve the visual effect' do
- it 'returns an y-offset equal to 60% minus the bar width' do
- expect(student_presenter.y_offset).to eq 34
- end
- end
- end
+ it_behaves_like 'measure_name'
+ it_behaves_like 'column_midpoint'
+ it_behaves_like 'bar_color'
+ it_behaves_like 'y_offset'
- context 'when there are insufficient responses to calculate a score' do
- it 'indicates it should show the insufficient data message' do
- expect(student_presenter.show_insufficient_data_message?).to eq true
+ it 'returns a bar width equal to the proportionate watch zone width plus the growth zone width' do
+ expect(student_presenter.bars[year_index].bar_height_percentage).to eq 34
end
end
- context 'when there are enough responses to calculate a score' do
+ context 'when the score is in the Warning zone' do
before do
create(:survey_item_response, survey_item: student_survey_item, school:,
- academic_year:)
+ academic_year:, likert_score: 1)
end
- it 'indicates it should show the insufficient data message' do
- expect(student_presenter.show_insufficient_data_message?).to eq false
+
+ it_behaves_like 'measure_name'
+ it_behaves_like 'column_midpoint'
+ it_behaves_like 'bar_color'
+ it_behaves_like 'y_offset'
+
+ it 'returns a bar width equal to the proportionate warning zone width plus the watch & growth zone widths' do
+ expect(student_presenter.bars[year_index].bar_height_percentage).to eq 51
end
end
end
diff --git a/spec/views/analyze/index.html.erb_spec.rb b/spec/views/analyze/index.html.erb_spec.rb
index 6d5a1902..8b37c00c 100644
--- a/spec/views/analyze/index.html.erb_spec.rb
+++ b/spec/views/analyze/index.html.erb_spec.rb
@@ -78,10 +78,15 @@ describe 'analyze/index' do
# end
it 'displays a set of grouped bars for each presenter' do
+ displayed_variance_columns = subject.css('.grouped-bar-column')
+ expect(displayed_variance_columns.count).to eq 9
+
displayed_variance_rows = subject.css('[data-for-measure-id]')
- expect(displayed_variance_rows.count).to eq 9
expect(displayed_variance_rows.first.attribute('data-for-measure-id').value).to eq '1A-I'
+ # displayed_variance_rows = subject.css('data-for-academic-year')
+ # expect(displayed_variance_rows.count).to eq 9
+
displayed_variance_labels = subject.css('[data-grouped-bar-label]')
expect(displayed_variance_labels.count).to eq 9
expect(displayed_variance_labels.first.inner_text).to include 'All Students'