diff --git a/app/presenters/measure_graph_row_presenter.rb b/app/presenters/measure_graph_row_presenter.rb index ba984aee..e33baebf 100644 --- a/app/presenters/measure_graph_row_presenter.rb +++ b/app/presenters/measure_graph_row_presenter.rb @@ -30,12 +30,19 @@ class MeasureGraphRowPresenter end end - def <=>(other_presenter) - if x_offset.to_f == other_presenter.x_offset.to_f - return bar_width.to_f <=> other_presenter.bar_width.to_f + def order + case zone.type + when :ideal, :approval + bar_width_percentage + when :warning, :watch, :growth + -bar_width_percentage + when :no_zone + -100 end + end - x_offset.to_f <=> other_presenter.x_offset.to_f + def <=>(other_presenter) + order <=> other_presenter.order end private @@ -56,8 +63,10 @@ class MeasureGraphRowPresenter (1 - percentage) * GROWTH_ZONE_WIDTH_PERCENTAGE when :watch (1 - percentage) * WATCH_ZONE_WIDTH_PERCENTAGE + GROWTH_ZONE_WIDTH_PERCENTAGE - else + when :warning (1 - percentage) * WARNING_ZONE_WIDTH_PERCENTAGE + WATCH_ZONE_WIDTH_PERCENTAGE + GROWTH_ZONE_WIDTH_PERCENTAGE + else + 0.0 end end diff --git a/app/presenters/scale.rb b/app/presenters/scale.rb index c520e7ef..5707d582 100644 --- a/app/presenters/scale.rb +++ b/app/presenters/scale.rb @@ -4,6 +4,7 @@ class Scale @growth_low_benchmark = growth_low_benchmark @approval_low_benchmark = approval_low_benchmark @ideal_low_benchmark = ideal_low_benchmark + @warning_low_benchmark = 1 end Zone = Struct.new(:low_benchmark, :high_benchmark, :type) @@ -28,6 +29,10 @@ class Scale Zone.new(@ideal_low_benchmark, 5.0, :ideal) end + def no_zone + Zone.new(0,@warning_low_benchmark,:no_zone) + end + def zone_for_score(score) case score when ideal_zone.low_benchmark..ideal_zone.high_benchmark @@ -38,8 +43,10 @@ class Scale growth_zone when watch_zone.low_benchmark..watch_zone.high_benchmark watch_zone - else + when 1..warning_zone.high_benchmark warning_zone + else + no_zone end end end diff --git a/spec/features/school_dashboard_feature_spec.rb b/spec/features/school_dashboard_feature_spec.rb index 937a59c1..128f65a6 100644 --- a/spec/features/school_dashboard_feature_spec.rb +++ b/spec/features/school_dashboard_feature_spec.rb @@ -13,6 +13,7 @@ feature 'School dashboard', type: feature do let(:measure_1A_i) { Measure.find_by_measure_id('1A-i') } let(:measure_2A_i) { Measure.find_by_measure_id('2A-i') } let(:measure_4C_i) { Measure.find_by_measure_id('4C-i') } + let(:measure_with_no_survey_responses) { Measure.find_by_measure_id('3A-i') } let(:survey_item_1_for_measure_1A_i) { SurveyItem.create measure: measure_1A_i, survey_item_id: rand.to_s } let(:survey_item_2_for_measure_1A_i) { SurveyItem.create measure: measure_1A_i, survey_item_id: rand.to_s } @@ -80,6 +81,17 @@ feature 'School dashboard', type: feature do expect(problem_solving_emphasis_row['width']).to eq '50.0%' expect(problem_solving_emphasis_row['x']).to eq '0.0%' + measure_row_bar_with_no_responses = measure_row_bars.find { |item| item['data-for-measure-id'] == '3A-i' } + + # puts measure_with_no_survey_responses.id + # puts measure_with_no_survey_responses.measure_id + # survey_item_responses = SurveyItemResponse.for_measure(measure_with_no_survey_responses) + # responses_count = SurveyItemResponse.count + + # expect(responses_count).to eq survey_item_responses.count + # expect(survey_item_responses.count).to eq 0 + expect(measure_row_bar_with_no_responses['width']).to eq '0.0%' + page.assert_selector('.measure-row-bar', count: Measure.count) professional_qualifications_row_index = measure_row_bars.find_index { |item| item['data-for-measure-id'] == '1A-i' } student_physical_safety_row_index = measure_row_bars.find_index { |item| item['data-for-measure-id'] == '2A-i' } @@ -91,7 +103,8 @@ feature 'School dashboard', type: feature do expect(page).to have_text('Teachers & Leadership') expect(page).to have_text('Approval') - end + + end # visit photos_path # assert_selector 'h1', text: 'Photos'