mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
chore: refactor analyze page
This commit is contained in:
parent
ccb04511bf
commit
3b3bb52523
15 changed files with 99 additions and 96 deletions
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Analyze::Graph::Column::GenderColumn::Unknown, type: :model do
|
||||
let(:school) { create(:school) }
|
||||
|
|
@ -9,65 +9,65 @@ RSpec.describe Analyze::Graph::Column::GenderColumn::Unknown, type: :model do
|
|||
let(:number_of_columns) { 1 }
|
||||
let(:gender) { create(:gender, qualtrics_code: 99) }
|
||||
|
||||
let(:subcategory) { create(:subcategory, subcategory_id: '1A') }
|
||||
let(:measure) { create(:measure, measure_id: '1A-iii', subcategory:) }
|
||||
let(:subcategory) { create(:subcategory, subcategory_id: "1A") }
|
||||
let(:measure) { create(:measure, measure_id: "1A-iii", subcategory:) }
|
||||
let(:scale) { create(:student_scale, measure:) }
|
||||
let(:survey_item) { create(:student_survey_item, scale:) }
|
||||
let(:teacher_scale) { create(:teacher_scale, measure:) }
|
||||
let(:teacher_survey_item) { create(:teacher_survey_item, scale:) }
|
||||
|
||||
context 'when no teacher responses exist' do
|
||||
context 'when there are insufficient unknown students' do
|
||||
it 'reports a score of 3 when the average is 3' do
|
||||
context "when no teacher responses exist" do
|
||||
context "when there are insufficient unknown students" do
|
||||
it "reports a score of 3 when the average is 3" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).score(0).average).to eq(nil)
|
||||
number_of_columns:).score(academic_year).average).to eq(nil)
|
||||
end
|
||||
it 'reports insufficient data' do
|
||||
it "reports insufficient data" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).sufficient_student_responses?(academic_year:)).to eq(false)
|
||||
end
|
||||
end
|
||||
context 'when there are sufficient unknown students' do
|
||||
context "when there are sufficient unknown students" do
|
||||
before :each do
|
||||
create_list(:survey_item_response, 10, school:, academic_year:, gender:, survey_item:)
|
||||
end
|
||||
it 'reports a score of 3 when the average is 3' do
|
||||
it "reports a score of 3 when the average is 3" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).score(0).average).to eq(3)
|
||||
number_of_columns:).score(academic_year).average).to eq(3)
|
||||
end
|
||||
|
||||
it 'reports sufficient data' do
|
||||
it "reports sufficient data" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).sufficient_student_responses?(academic_year:)).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when teacher responses exist' do
|
||||
context "when teacher responses exist" do
|
||||
before :each do
|
||||
create_list(:survey_item_response, 10, school:, academic_year:, survey_item: teacher_survey_item, likert_score: 5)
|
||||
end
|
||||
|
||||
context 'when there are insufficient unknown students' do
|
||||
it 'reports a score of 3 when the average is 3' do
|
||||
context "when there are insufficient unknown students" do
|
||||
it "reports a score of 3 when the average is 3" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).score(0).average).to eq(nil)
|
||||
number_of_columns:).score(academic_year).average).to eq(nil)
|
||||
end
|
||||
it 'reports insufficient data' do
|
||||
it "reports insufficient data" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).sufficient_student_responses?(academic_year:)).to eq(false)
|
||||
end
|
||||
end
|
||||
context 'when there are sufficient unknown students' do
|
||||
context "when there are sufficient unknown students" do
|
||||
before :each do
|
||||
create_list(:survey_item_response, 10, school:, academic_year:, gender:, survey_item:)
|
||||
end
|
||||
it 'reports a score of 3 when the average is 3' do
|
||||
it "reports a score of 3 when the average is 3" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).score(0).average).to eq(3)
|
||||
number_of_columns:).score(academic_year).average).to eq(3)
|
||||
end
|
||||
|
||||
it 'reports sufficient data' do
|
||||
it "reports sufficient data" do
|
||||
expect(Analyze::Graph::Column::GenderColumn::Unknown.new(school:, academic_years:, position:, measure:,
|
||||
number_of_columns:).sufficient_student_responses?(academic_year:)).to eq(true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ describe GroupedBarColumnPresenter do
|
|||
end
|
||||
|
||||
let(:all_data_presenter) do
|
||||
GroupedBarColumnPresenter.new measure: measure_composed_of_student_and_teacher_items, school:, academic_years:,
|
||||
position: 0, number_of_columns: 3
|
||||
Analyze::Graph::Column::AllData.new measure: measure_composed_of_student_and_teacher_items, school:, academic_years:,
|
||||
position: 0, number_of_columns: 3
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
@ -120,8 +120,8 @@ describe GroupedBarColumnPresenter do
|
|||
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.score(academic_year).average).to eq 4.5
|
||||
expect(all_data_presenter.score(another_academic_year).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
|
||||
|
|
@ -133,8 +133,8 @@ describe GroupedBarColumnPresenter do
|
|||
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
|
||||
expect(all_data_presenter.score(academic_year).average).to eq 4.5
|
||||
expect(all_data_presenter.score(another_academic_year).average).to eq 4
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -144,12 +144,8 @@ describe GroupedBarColumnPresenter do
|
|||
it_behaves_like "measure_name"
|
||||
it_behaves_like "column_midpoint"
|
||||
|
||||
it "returns an emtpy set of bars" do
|
||||
expect(student_presenter.bars).to eq []
|
||||
end
|
||||
|
||||
it "returns an emty score" do
|
||||
expect(student_presenter.score(year_index).average).to eq nil
|
||||
expect(student_presenter.score(academic_year).average).to eq nil
|
||||
end
|
||||
|
||||
it "shows the irrelevancy message " do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue