mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Fix regression where we accidentally list the questions for measure 1B-i
This commit is contained in:
parent
ea09fa06b7
commit
fc853c4fbc
4 changed files with 121 additions and 32 deletions
|
|
@ -25,6 +25,8 @@ class TeacherSurveyPresenter < DataItemPresenter
|
|||
end
|
||||
|
||||
def descriptions_and_availability
|
||||
return [DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true)] if @measure_id == '1B-i'
|
||||
|
||||
survey_items.map do |survey_item|
|
||||
DataAvailability.new(survey_item.survey_item_id, survey_item.prompt, true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ FactoryBot.define do
|
|||
scale_id { "s-#{rand}" }
|
||||
end
|
||||
factory :admin_scale do
|
||||
scale_id { 'a-{rand' }
|
||||
scale_id { "a-#{rand}" }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,46 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe AdminDataPresenter do
|
||||
let(:school) { School.find_by_slug 'milford-high-school' }
|
||||
let(:academic_year) { AcademicYear.find_by_range '2021-22' }
|
||||
let(:measure_1A_i) { Measure.find_by_measure_id '1A-i' }
|
||||
let(:measure_1A_iii) { Measure.find_by_measure_id '1A-iii' }
|
||||
let(:school) { create(:school) }
|
||||
let(:academic_year) { create(:academic_year) }
|
||||
|
||||
let(:measure_1A_i) { create(:measure, measure_id: '1A-i') }
|
||||
let(:scale_1) { create(:admin_scale, measure: measure_1A_i) }
|
||||
let(:admin_data_item_1) do
|
||||
create(:admin_data_item, admin_data_item_id: 'a-exp-i1', scale: scale_1,
|
||||
description: 'Percentage teachers with 5+ years of experience')
|
||||
end
|
||||
let(:admin_data_item_2) do
|
||||
create(:admin_data_item, admin_data_item_id: 'a-exp-i2', scale: scale_1,
|
||||
description: 'Percentage teachers National Board certified')
|
||||
end
|
||||
let(:admin_data_item_3) do
|
||||
create(:admin_data_item, admin_data_item_id: 'a-exp-i3', scale: scale_1,
|
||||
description: 'Percentage teachers teaching in area of licensure')
|
||||
end
|
||||
|
||||
let(:measure_1A_iii) { create(:measure, measure_id: '1B-i') }
|
||||
let(:scale_2) { create(:admin_scale, measure: measure_1A_iii) }
|
||||
let(:admin_data_item_4) do
|
||||
create(:admin_data_item, admin_data_item_id: 'a-pcom-i1', scale: scale_2,
|
||||
description: 'Percent teacher returning (excluding retirement)')
|
||||
end
|
||||
let(:admin_data_item_5) do
|
||||
create(:admin_data_item, admin_data_item_id: 'a-pcom-i2', scale: scale_2,
|
||||
description: 'Percent teachers with 10+ days absent')
|
||||
end
|
||||
|
||||
before :each do
|
||||
scale_1
|
||||
scale_2
|
||||
admin_data_item_1
|
||||
admin_data_item_2
|
||||
admin_data_item_3
|
||||
admin_data_item_4
|
||||
admin_data_item_5
|
||||
end
|
||||
|
||||
describe '#item_description' do
|
||||
before :each do
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context 'When the presenter is based on measure 1A-1' do
|
||||
it 'returns a list of survey prompts for teacher survey items' do
|
||||
expect(AdminDataPresenter.new(measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items,
|
||||
|
|
@ -47,13 +74,6 @@ describe AdminDataPresenter do
|
|||
end
|
||||
|
||||
describe '#descriptions_and_availibility' do
|
||||
before :each do
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
context 'when there are any matching values for admin data items' do
|
||||
before do
|
||||
admin_data_item = measure_1A_i.admin_data_items.first
|
||||
|
|
@ -72,6 +92,17 @@ describe AdminDataPresenter do
|
|||
end
|
||||
end
|
||||
context 'when there are NO matching values for admin data items' do
|
||||
it 'returns a list of admin data items and whether there is a matching value' do
|
||||
expect(
|
||||
AdminDataPresenter.new(
|
||||
measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, has_sufficient_data: true, school:, academic_year:
|
||||
).descriptions_and_availability
|
||||
).to eq [
|
||||
DataAvailability.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', false),
|
||||
DataAvailability.new('a-exp-i2', 'Percentage teachers National Board certified', false),
|
||||
DataAvailability.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false)
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,20 +1,38 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe TeacherSurveyPresenter do
|
||||
let(:school) { School.first }
|
||||
let(:academic_year) { AcademicYear.first }
|
||||
let(:measure_1A_i) { Measure.find_by_measure_id '1A-i' }
|
||||
let(:measure_1B_i) { Measure.find_by_measure_id '1B-i' }
|
||||
let(:school) { nil }
|
||||
let(:academic_year) { nil }
|
||||
let(:measure_1A_i) { create(:measure, measure_id: '1A-i') }
|
||||
let(:scale_1) { create(:teacher_scale, measure: measure_1A_i) }
|
||||
let(:survey_item_1) do
|
||||
create(:teacher_survey_item, survey_item_id: 't-1', scale: scale_1,
|
||||
prompt: 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?')
|
||||
end
|
||||
let(:survey_item_2) do
|
||||
create(:teacher_survey_item, survey_item_id: 't-2', scale: scale_1,
|
||||
prompt: 'How prepared are you for teaching the topics that you are expected to teach in your assignment?')
|
||||
end
|
||||
let(:survey_item_3) do
|
||||
create(:teacher_survey_item, survey_item_id: 't-3', scale: scale_1,
|
||||
prompt: 'How confident are you in working with the student body at your school?')
|
||||
end
|
||||
let(:measure_1B_i) { create(:measure, measure_id: '1B-i') }
|
||||
let(:scale_2) { create(:teacher_scale, measure: measure_1B_i) }
|
||||
let(:survey_item_4) do
|
||||
create(:teacher_survey_item, scale: scale_2,
|
||||
prompt: 'Some prompt that will not be shown. Instead it will say items will be available upon request to MCIEA')
|
||||
end
|
||||
before do
|
||||
scale_1
|
||||
scale_2
|
||||
survey_item_1
|
||||
survey_item_2
|
||||
survey_item_3
|
||||
survey_item_4
|
||||
end
|
||||
|
||||
describe '#item_description' do
|
||||
before :each do
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context 'When the presenter is based on measure 1A-1' do
|
||||
it 'returns a list of survey prompts for teacher survey items' do
|
||||
expect(TeacherSurveyPresenter.new(measure_id: measure_1A_i.measure_id, survey_items: measure_1A_i.teacher_survey_items,
|
||||
|
|
@ -35,4 +53,42 @@ describe TeacherSurveyPresenter do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#descriptions_and_availability' do
|
||||
context 'When the presenter is NOT based on measure 1B-i' do
|
||||
it 'returns a list containing the survey item properties' do
|
||||
expect(
|
||||
TeacherSurveyPresenter.new(
|
||||
measure_id: measure_1A_i.measure_id,
|
||||
survey_items: measure_1A_i.teacher_survey_items,
|
||||
has_sufficient_data: true,
|
||||
school:,
|
||||
academic_year:
|
||||
).descriptions_and_availability
|
||||
).to eq [
|
||||
DataAvailability.new('t-1',
|
||||
'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', true),
|
||||
DataAvailability.new('t-2',
|
||||
'How prepared are you for teaching the topics that you are expected to teach in your assignment?', true),
|
||||
DataAvailability.new('t-3',
|
||||
'How confident are you in working with the student body at your school?', true)
|
||||
]
|
||||
end
|
||||
end
|
||||
context 'When the presenter is based on measure 1B-i' do
|
||||
it 'returns a message hiding the actual prompts. Instead it presents a message telling the user they can ask for more information' do
|
||||
expect(
|
||||
TeacherSurveyPresenter.new(
|
||||
measure_id: measure_1B_i.measure_id,
|
||||
survey_items: measure_1B_i.teacher_survey_items,
|
||||
has_sufficient_data: true,
|
||||
school:,
|
||||
academic_year:
|
||||
).descriptions_and_availability
|
||||
).to eq [
|
||||
DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true)
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue