Rename DataAvailability to Summary

mciea-main
rebuilt 3 years ago
parent 09963c3323
commit 0ed6cbe6b4

@ -1,4 +0,0 @@
# frozen_string_literal: true
class DataAvailability < Struct.new(:id, :description, :available?)
end

@ -0,0 +1,4 @@
# frozen_string_literal: true
class Summary < Struct.new(:id, :description, :available?)
end

@ -29,6 +29,6 @@ class SurveyItem < ActiveRecord::Base
} }
def description def description
DataAvailability.new(survey_item_id, prompt, true) Summary.new(survey_item_id, prompt, true)
end end
end end

@ -24,7 +24,7 @@ class AdminDataPresenter < DataItemPresenter
def descriptions_and_availability def descriptions_and_availability
@admin_data_items.map do |admin_data_item| @admin_data_items.map do |admin_data_item|
DataAvailability.new(admin_data_item.admin_data_item_id, admin_data_item.description, Summary.new(admin_data_item.admin_data_item_id, admin_data_item.description,
admin_data_item.admin_data_values.where(school:, academic_year:).count > 0) admin_data_item.admin_data_values.where(school:, academic_year:).count > 0)
end end
end end

@ -27,10 +27,13 @@ class TeacherSurveyPresenter < DataItemPresenter
end end
def descriptions_and_availability def descriptions_and_availability
return [DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true)] if @measure_id == '1B-i' if @measure_id == '1B-i'
return [Summary.new('1B-i', 'Items available upon request to MCIEA',
true)]
end
survey_items.map do |survey_item| survey_items.map do |survey_item|
DataAvailability.new(survey_item.survey_item_id, survey_item.prompt, true) Summary.new(survey_item.survey_item_id, survey_item.prompt, true)
end end
end end
end end

@ -85,9 +85,9 @@ describe AdminDataPresenter do
measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, has_sufficient_data: true, school:, academic_year: 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 ).descriptions_and_availability
).to eq [ ).to eq [
DataAvailability.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', true), Summary.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', true),
DataAvailability.new('a-exp-i2', 'Percentage teachers National Board certified', false), Summary.new('a-exp-i2', 'Percentage teachers National Board certified', false),
DataAvailability.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false) Summary.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false)
] ]
end end
end end
@ -98,9 +98,9 @@ describe AdminDataPresenter do
measure_id: measure_1A_i.measure_id, admin_data_items: measure_1A_i.admin_data_items, has_sufficient_data: true, school:, academic_year: 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 ).descriptions_and_availability
).to eq [ ).to eq [
DataAvailability.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', false), Summary.new('a-exp-i1', 'Percentage teachers with 5+ years of experience', false),
DataAvailability.new('a-exp-i2', 'Percentage teachers National Board certified', false), Summary.new('a-exp-i2', 'Percentage teachers National Board certified', false),
DataAvailability.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false) Summary.new('a-exp-i3', 'Percentage teachers teaching in area of licensure', false)
] ]
end end
end end

@ -0,0 +1,49 @@
require 'rails_helper'
describe StudentSurveyPresenter do
let(:school) { nil }
let(:academic_year) { nil }
let(:measure_1A_i) { create(:measure, measure_id: '1A-i') }
let(:scale_1) { create(:student_scale, measure: measure_1A_i) }
let(:survey_item_1) do
create(:student_survey_item, survey_item_id: 's-sbel-q1', scale: scale_1,
prompt: 'I am happy when I am in class.')
end
let(:survey_item_2) do
create(:student_survey_item, survey_item_id: 's-sbel-q2', scale: scale_1,
prompt: 'My teacher gives me help when I need it.')
end
let(:survey_item_3) do
create(:student_survey_item, survey_item_id: 's-sbel-es1', scale: scale_1,
prompt: 'This prompt should not show up')
end
let(:measure_1B_i) { create(:measure, measure_id: '1B-i') }
before do
scale_1
survey_item_1
survey_item_2
survey_item_3
end
describe '#descriptions_and_availability' do
context 'When there is a survey item with a blank prompt' do
it 'returns a list containing the survey item properties excluding survey items with blank prompts' do
result = StudentSurveyPresenter.new(
measure_id: measure_1A_i.measure_id,
survey_items: measure_1A_i.student_survey_items,
has_sufficient_data: true,
school:,
academic_year:
).descriptions_and_availability
expect(
result
).to eq [
Summary.new('s-sbel-q1',
'I am happy when I am in class.', true),
Summary.new('s-sbel-q2',
'My teacher gives me help when I need it.', true)
]
end
end
end
end

@ -66,11 +66,11 @@ describe TeacherSurveyPresenter do
academic_year: academic_year:
).descriptions_and_availability ).descriptions_and_availability
).to eq [ ).to eq [
DataAvailability.new('t-1', Summary.new('t-1',
'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', true), 'Given your preparation for teaching how comfortable are you teaching at the grade-level you have been assigned?', true),
DataAvailability.new('t-2', Summary.new('t-2',
'How prepared are you for teaching the topics that you are expected to teach in your assignment?', true), 'How prepared are you for teaching the topics that you are expected to teach in your assignment?', true),
DataAvailability.new('t-3', Summary.new('t-3',
'How confident are you in working with the student body at your school?', true) 'How confident are you in working with the student body at your school?', true)
] ]
end end
@ -86,7 +86,7 @@ describe TeacherSurveyPresenter do
academic_year: academic_year:
).descriptions_and_availability ).descriptions_and_availability
).to eq [ ).to eq [
DataAvailability.new('1B-i', 'Items available upon request to MCIEA.', true) Summary.new('1B-i', 'Items available upon request to MCIEA', true)
] ]
end end
end end

Loading…
Cancel
Save