add disaggregation glossary

This commit is contained in:
Nelson Jovel 2024-05-14 15:25:00 -07:00
parent 63b4c4762a
commit ea2feb138b
9 changed files with 160 additions and 104 deletions

View file

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe SurveyItemValues, type: :model do
let(:headers) do
["StartDate", "EndDate", "Status", "IPAddress", "Progress", "Duration (in seconds)", "Finished", "RecordedDate",
"ResponseId", "RecipientLastName", "RecipientFirstName", "RecipientEmail", "ExternalReference", "LocationLatitude", "LocationLongitude", "DistributionChannel", "UserLanguage", "District", "School- Lee", "School- Maynard", "LASID", "Grade", "s-emsa-q1", "s-emsa-q2", "s-emsa-q3", "s-tint-q1", "s-tint-q2", "s-tint-q3", "s-tint-q4", "s-tint-q5", "s-acpr-q1", "s-acpr-q2", "s-acpr-q3", "s-acpr-q4", "s-cure-q1", "s-cure-q2", "s-cure-q3", "s-cure-q4", "s-sten-q1", "s-sten-q2", "s-sten-q3", "s-sper-q1", "s-sper-q2", "s-sper-q3", "s-sper-q4", "s-civp-q1", "s-civp-q2", "s-civp-q3", "s-civp-q4", "s-grmi-q1", "s-grmi-q2", "s-grmi-q3", "s-grmi-q4", "s-appa-q1", "s-appa-q2", "s-appa-q3", "s-peff-q1", "s-peff-q2", "s-peff-q3", "s-peff-q4", "s-peff-q5", "s-peff-q6", "s-sbel-q1", "s-sbel-q2", "s-sbel-q3", "s-sbel-q4", "s-sbel-q5", "s-phys-q1", "s-phys-q2", "s-phys-q3", "s-phys-q4", "s-vale-q1", "s-vale-q2", "s-vale-q3", "s-vale-q4", "s-acst-q1", "s-acst-q2", "s-acst-q3", "s-sust-q1", "s-sust-q2", "s-grit-q1", "s-grit-q2", "s-grit-q3", "s-grit-q4", "s-expa-q1", "s-poaf-q1", "s-poaf-q2", "s-poaf-q3", "s-poaf-q4", "s-tint-q1-1", "s-tint-q2-1", "s-tint-q3-1", "s-tint-q4-1", "s-tint-q5-1", "s-acpr-q1-1", "s-acpr-q2-1", "s-acpr-q3-1", "s-acpr-q4-1", "s-peff-q1-1", "s-peff-q2-1", "s-peff-q3-1", "s-peff-q4-1", "s-peff-q5-1", "s-peff-q6-1", "Gender", "Race"]
"ResponseId", "RecipientLastName", "RecipientFirstName", "RecipientEmail", "ExternalReference", "LocationLatitude", "LocationLongitude", "DistributionChannel", "UserLanguage", "District", "School- Lee", "School- Maynard", "LASID", "Grade", "s-emsa-q1", "s-emsa-q2", "s-emsa-q3", "s-tint-q1", "s-tint-q2", "s-tint-q3", "s-tint-q4", "s-tint-q5", "s-acpr-q1", "s-acpr-q2", "s-acpr-q3", "s-acpr-q4", "s-cure-q1", "s-cure-q2", "s-cure-q3", "s-cure-q4", "s-sten-q1", "s-sten-q2", "s-sten-q3", "s-sper-q1", "s-sper-q2", "s-sper-q3", "s-sper-q4", "s-civp-q1", "s-civp-q2", "s-civp-q3", "s-civp-q4", "s-grmi-q1", "s-grmi-q2", "s-grmi-q3", "s-grmi-q4", "s-appa-q1", "s-appa-q2", "s-appa-q3", "s-peff-q1", "s-peff-q2", "s-peff-q3", "s-peff-q4", "s-peff-q5", "s-peff-q6", "s-sbel-q1", "s-sbel-q2", "s-sbel-q3", "s-sbel-q4", "s-sbel-q5", "s-phys-q1", "s-phys-q2", "s-phys-q3", "s-phys-q4", "s-vale-q1", "s-vale-q2", "s-vale-q3", "s-vale-q4", "s-acst-q1", "s-acst-q2", "s-acst-q3", "s-sust-q1", "s-sust-q2", "s-grit-q1", "s-grit-q2", "s-grit-q3", "s-grit-q4", "s-expa-q1", "s-poaf-q1", "s-poaf-q2", "s-poaf-q3", "s-poaf-q4", "s-tint-q1-1", "s-tint-q2-1", "s-tint-q3-1", "s-tint-q4-1", "s-tint-q5-1", "s-acpr-q1-1", "s-acpr-q2-1", "s-acpr-q3-1", "s-acpr-q4-1", "s-peff-q1-1", "s-peff-q2-1", "s-peff-q3-1", "s-peff-q4-1", "s-peff-q5-1", "s-peff-q6-1", "Gender", "Race"]
end
let(:genders) do
create(:gender, qualtrics_code: 1)
@ -27,6 +27,10 @@ RSpec.describe SurveyItemValues, type: :model do
Race.by_qualtrics_code
end
let(:demographic_filepath) do
Rails.root.join("spec", "fixtures", "demographic_glossary.csv")
end
let(:survey_items) { [] }
let(:district) { create(:district, name: "Attleboro") }
let(:attleboro) do
@ -48,12 +52,12 @@ RSpec.describe SurveyItemValues, type: :model do
let(:standard_survey_items) do
survey_item_ids = %w[s-peff-q1 s-peff-q2 s-peff-q3 s-peff-q4 s-peff-q5 s-peff-q6 s-phys-q1 s-phys-q2 s-phys-q3 s-phys-q4
s-emsa-q1 s-emsa-q2 s-emsa-q3 s-sbel-q1 s-sbel-q2 s-sbel-q3 s-sbel-q4 s-sbel-q5 s-tint-q1 s-tint-q2
s-tint-q3 s-tint-q4 s-tint-q5 s-vale-q1 s-vale-q2 s-vale-q3 s-vale-q4 s-acpr-q1 s-acpr-q2 s-acpr-q3
s-acpr-q4 s-sust-q1 s-sust-q2 s-cure-q1 s-cure-q2 s-cure-q3 s-cure-q4 s-sten-q1 s-sten-q2 s-sten-q3
s-sper-q1 s-sper-q2 s-sper-q3 s-sper-q4 s-civp-q1 s-civp-q2 s-civp-q3 s-civp-q4 s-grit-q1 s-grit-q2
s-grit-q3 s-grit-q4 s-grmi-q1 s-grmi-q2 s-grmi-q3 s-grmi-q4 s-expa-q1 s-appa-q1 s-appa-q2 s-appa-q3
s-acst-q1 s-acst-q2 s-acst-q3 s-poaf-q1 s-poaf-q2 s-poaf-q3 s-poaf-q4]
s-emsa-q1 s-emsa-q2 s-emsa-q3 s-sbel-q1 s-sbel-q2 s-sbel-q3 s-sbel-q4 s-sbel-q5 s-tint-q1 s-tint-q2
s-tint-q3 s-tint-q4 s-tint-q5 s-vale-q1 s-vale-q2 s-vale-q3 s-vale-q4 s-acpr-q1 s-acpr-q2 s-acpr-q3
s-acpr-q4 s-sust-q1 s-sust-q2 s-cure-q1 s-cure-q2 s-cure-q3 s-cure-q4 s-sten-q1 s-sten-q2 s-sten-q3
s-sper-q1 s-sper-q2 s-sper-q3 s-sper-q4 s-civp-q1 s-civp-q2 s-civp-q3 s-civp-q4 s-grit-q1 s-grit-q2
s-grit-q3 s-grit-q4 s-grmi-q1 s-grmi-q2 s-grmi-q3 s-grmi-q4 s-expa-q1 s-appa-q1 s-appa-q2 s-appa-q3
s-acst-q1 s-acst-q2 s-acst-q3 s-poaf-q1 s-poaf-q2 s-poaf-q3 s-poaf-q4]
survey_item_ids.map do |survey_item_id|
create(:survey_item, survey_item_id:)
end
@ -62,12 +66,12 @@ RSpec.describe SurveyItemValues, type: :model do
let(:short_form_survey_items) do
survey_item_ids = %w[s-peff-q1 s-peff-q2 s-peff-q3 s-peff-q4 s-peff-q5 s-peff-q6 s-phys-q1 s-phys-q2 s-phys-q3 s-phys-q4
s-emsa-q1 s-emsa-q2 s-emsa-q3 s-sbel-q1 s-sbel-q2 s-sbel-q3 s-sbel-q4 s-sbel-q5 s-tint-q1 s-tint-q2
s-tint-q3 s-tint-q4 s-tint-q5 s-vale-q1 s-vale-q2 s-vale-q3 s-vale-q4 s-acpr-q1 s-acpr-q2 s-acpr-q3
s-acpr-q4 s-sust-q1 s-sust-q2 s-cure-q1 s-cure-q2 s-cure-q3 s-cure-q4 s-sten-q1 s-sten-q2 s-sten-q3
s-sper-q1 s-sper-q2 s-sper-q3 s-sper-q4 s-civp-q1 s-civp-q2 s-civp-q3 s-civp-q4 s-grit-q1 s-grit-q2
s-grit-q3 s-grit-q4 s-grmi-q1 s-grmi-q2 s-grmi-q3 s-grmi-q4 s-expa-q1 s-appa-q1 s-appa-q2 s-appa-q3
s-acst-q1 s-acst-q2 s-acst-q3 s-poaf-q1 s-poaf-q2 s-poaf-q3 s-poaf-q4 s-phys-q1 s-phys-q2 s-phys-q3]
s-emsa-q1 s-emsa-q2 s-emsa-q3 s-sbel-q1 s-sbel-q2 s-sbel-q3 s-sbel-q4 s-sbel-q5 s-tint-q1 s-tint-q2
s-tint-q3 s-tint-q4 s-tint-q5 s-vale-q1 s-vale-q2 s-vale-q3 s-vale-q4 s-acpr-q1 s-acpr-q2 s-acpr-q3
s-acpr-q4 s-sust-q1 s-sust-q2 s-cure-q1 s-cure-q2 s-cure-q3 s-cure-q4 s-sten-q1 s-sten-q2 s-sten-q3
s-sper-q1 s-sper-q2 s-sper-q3 s-sper-q4 s-civp-q1 s-civp-q2 s-civp-q3 s-civp-q4 s-grit-q1 s-grit-q2
s-grit-q3 s-grit-q4 s-grmi-q1 s-grmi-q2 s-grmi-q3 s-grmi-q4 s-expa-q1 s-appa-q1 s-appa-q2 s-appa-q3
s-acst-q1 s-acst-q2 s-acst-q3 s-poaf-q1 s-poaf-q2 s-poaf-q3 s-poaf-q4 s-phys-q1 s-phys-q2 s-phys-q3]
survey_item_ids.map do |survey_item_id|
create(:survey_item, survey_item_id:, on_short_form: true)
end
@ -76,12 +80,12 @@ RSpec.describe SurveyItemValues, type: :model do
let(:early_education_survey_items) do
survey_item_ids = %w[s-peff-es1 s-peff-es2 s-peff-es3 s-peff-es4 s-peff-es5 s-peff-es6 s-phys-es1 s-phys-es2 s-phys-es3 s-phys-es4
s-emsa-es1 s-emsa-es2 s-emsa-es3 s-sbel-es1 s-sbel-es2 s-sbel-es3 s-sbel-es4 s-sbel-es5 s-tint-es1 s-tint-es2
s-tint-es3 s-tint-es4 s-tint-es5 s-vale-es1 s-vale-es2 s-vale-es3 s-vale-es4 s-acpr-es1 s-acpr-es2 s-acpr-es3
s-acpr-es4 s-sust-es1 s-sust-es2 s-cure-es1 s-cure-es2 s-cure-es3 s-cure-es4 s-sten-es1 s-sten-es2 s-sten-es3
s-sper-es1 s-sper-es2 s-sper-es3 s-sper-es4 s-civp-es1 s-civp-es2 s-civp-es3 s-civp-es4 s-grit-es1 s-grit-es2
s-grit-es3 s-grit-es4 s-grmi-es1 s-grmi-es2 s-grmi-es3 s-grmi-es4 s-expa-es1 s-appa-es1 s-appa-es2 s-appa-es3
s-acst-es1 s-acst-es2 s-acst-es3 s-poaf-es1 s-poaf-es2 s-poaf-es3 s-poaf-es4 s-phys-es1 s-phys-es2 s-phys-es3]
s-emsa-es1 s-emsa-es2 s-emsa-es3 s-sbel-es1 s-sbel-es2 s-sbel-es3 s-sbel-es4 s-sbel-es5 s-tint-es1 s-tint-es2
s-tint-es3 s-tint-es4 s-tint-es5 s-vale-es1 s-vale-es2 s-vale-es3 s-vale-es4 s-acpr-es1 s-acpr-es2 s-acpr-es3
s-acpr-es4 s-sust-es1 s-sust-es2 s-cure-es1 s-cure-es2 s-cure-es3 s-cure-es4 s-sten-es1 s-sten-es2 s-sten-es3
s-sper-es1 s-sper-es2 s-sper-es3 s-sper-es4 s-civp-es1 s-civp-es2 s-civp-es3 s-civp-es4 s-grit-es1 s-grit-es2
s-grit-es3 s-grit-es4 s-grmi-es1 s-grmi-es2 s-grmi-es3 s-grmi-es4 s-expa-es1 s-appa-es1 s-appa-es2 s-appa-es3
s-acst-es1 s-acst-es2 s-acst-es3 s-poaf-es1 s-poaf-es2 s-poaf-es3 s-poaf-es4 s-phys-es1 s-phys-es2 s-phys-es3]
survey_item_ids.map do |survey_item_id|
create(:survey_item, survey_item_id:)
end
@ -90,12 +94,12 @@ RSpec.describe SurveyItemValues, type: :model do
let(:teacher_survey_items) do
survey_item_ids = %w[t-prep-q1 t-prep-q2 t-prep-q3 t-ieff-q1 t-ieff-q2 t-ieff-q3 t-ieff-q4 t-pcom-q1 t-pcom-q2 t-pcom-q3
t-pcom-q4 t-pcom-q5 t-inle-q1 t-inle-q2 t-inle-q3 t-prtr-q1 t-prtr-q2 t-prtr-q3 t-coll-q1 t-coll-q2
t-coll-q3 t-qupd-q1 t-qupd-q2 t-qupd-q3 t-qupd-q4 t-pvic-q1 t-pvic-q2 t-pvic-q3 t-psup-q1 t-psup-q2
t-psup-q3 t-psup-q4 t-acch-q1 t-acch-q2 t-acch-q3 t-reso-q1 t-reso-q2 t-reso-q3 t-reso-q4 t-reso-q5
t-sust-q1 t-sust-q2 t-sust-q3 t-sust-q4 t-curv-q1 t-curv-q2 t-curv-q3 t-curv-q4 t-cure-q1 t-cure-q2
t-cure-q3 t-cure-q4 t-peng-q1 t-peng-q2 t-peng-q3 t-peng-q4 t-ceng-q1 t-ceng-q2 t-ceng-q3 t-ceng-q4
t-sach-q1 t-sach-q2 t-sach-q3 t-psol-q1 t-psol-q2 t-psol-q3 t-expa-q2 t-expa-q3 t-phya-q2 t-phya-q3]
t-pcom-q4 t-pcom-q5 t-inle-q1 t-inle-q2 t-inle-q3 t-prtr-q1 t-prtr-q2 t-prtr-q3 t-coll-q1 t-coll-q2
t-coll-q3 t-qupd-q1 t-qupd-q2 t-qupd-q3 t-qupd-q4 t-pvic-q1 t-pvic-q2 t-pvic-q3 t-psup-q1 t-psup-q2
t-psup-q3 t-psup-q4 t-acch-q1 t-acch-q2 t-acch-q3 t-reso-q1 t-reso-q2 t-reso-q3 t-reso-q4 t-reso-q5
t-sust-q1 t-sust-q2 t-sust-q3 t-sust-q4 t-curv-q1 t-curv-q2 t-curv-q3 t-curv-q4 t-cure-q1 t-cure-q2
t-cure-q3 t-cure-q4 t-peng-q1 t-peng-q2 t-peng-q3 t-peng-q4 t-ceng-q1 t-ceng-q2 t-ceng-q3 t-ceng-q4
t-sach-q1 t-sach-q2 t-sach-q3 t-psol-q1 t-psol-q2 t-psol-q3 t-expa-q2 t-expa-q3 t-phya-q2 t-phya-q3]
survey_item_ids.map do |survey_item_id|
create(:survey_item, survey_item_id:)
@ -541,6 +545,15 @@ RSpec.describe SurveyItemValues, type: :model do
ay_2022_23
end
it "validates the code matches the expectations defined in the demographic_glossary" do
list = read(demographic_filepath, "ELL Value", "ELL Type")
list.each do |target, result|
compare("Raw ELL", target, result, :ell)
end
end
it 'translates "LEP Student 1st Year" or "LEP Student Not 1st Year" into ELL' do
headers = ["Raw ELL"]
row = { "Raw ELL" => "LEP Student 1st Year" }
@ -586,23 +599,11 @@ RSpec.describe SurveyItemValues, type: :model do
expect(values.ell).to eq "Not ELL"
end
it 'tranlsates NAs and blanks into "Not ELL"' do
it 'tranlsates blanks into "Not ELL"' do
headers = ["Raw ELL"]
row = { "Raw ELL" => "" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
expect(values.ell).to eq "Not ELL"
row = { "Raw ELL" => "NA" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
expect(values.ell).to eq "Not ELL"
row = { "Raw ELL" => "#NA" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
expect(values.ell).to eq "Not ELL"
row = { "Raw ELL" => "#N/A" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
expect(values.ell).to eq "Not ELL"
end
# NOTE: This will halt test runs too
@ -621,6 +622,15 @@ RSpec.describe SurveyItemValues, type: :model do
ay_2022_23
end
it "validates the code matches the expectations defined in the demographic_glossary" do
list = read(demographic_filepath, "Sped Value", "Sped Type")
list.each do |target, result|
compare("Raw Sped", target, result, :sped)
end
end
it 'translates "active" into "Special Education"' do
headers = ["Raw SpEd"]
row = { "Raw SpEd" => "active" }
@ -670,15 +680,15 @@ RSpec.describe SurveyItemValues, type: :model do
expect(values.sped).to eq "Not Special Education"
end
it 'translates NA into "Not Special Education"' do
it 'translates NA into "Unknown"' do
headers = ["Raw SpEd"]
row = { "Raw SpEd" => "NA" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
expect(values.sped).to eq "Not Special Education"
expect(values.sped).to eq "Unknown"
row = { "Raw SpEd" => "#NA" }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
expect(values.sped).to eq "Not Special Education"
expect(values.sped).to eq "Unknown"
end
# NOTE: This will halt test runs too
@ -695,33 +705,33 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns true" do
headers = standard_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "240", "Gender" => "Male" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
headers = teacher_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "300" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
headers = short_form_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "100" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
# When duration is blank or N/A or NA, we don't have enough information to kick out the row as invalid so we keep it in
headers = short_form_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
headers = short_form_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "N/A" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
headers = short_form_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "NA" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq true
end
end
@ -730,16 +740,16 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns false" do
headers = standard_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "239" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq false
headers = teacher_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "299" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq false
headers = short_form_survey_items
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "99" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_duration?).to eq false
end
end
@ -749,8 +759,8 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns the number of questions answered" do
headers = standard_survey_items
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-phys-q3" => 1, "s-phys-q4" => 1 }
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-phys-q3" => 1, "s-phys-q4" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
expect(values.progress).to eq 10
end
@ -761,12 +771,12 @@ RSpec.describe SurveyItemValues, type: :model do
it "when there are 17 or more standard survey items valid_progress returns true" do
headers = standard_survey_items
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-phys-q3" => 1, "s-phys-q4" => 1, "s-emsa-q1" => 1, "s-emsa-q2" => 1,
"s-emsa-q3" => 1, "s-sbel-q1" => 1, "s-sbel-q2" => 1, "s-sbel-q3" => 1,
"s-sbel-q4" => 1 }
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-phys-q3" => 1, "s-phys-q4" => 1, "s-emsa-q1" => 1, "s-emsa-q2" => 1,
"s-emsa-q3" => 1, "s-sbel-q1" => 1, "s-sbel-q2" => 1, "s-sbel-q3" => 1,
"s-sbel-q4" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 17
expect(values.valid_progress?).to eq true
end
@ -781,7 +791,7 @@ RSpec.describe SurveyItemValues, type: :model do
"t-psup-q3" => 1, "t-psup-q4" => 1, "t-acch-q1" => 1, "t-acch-q2" => 1
}
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 12
expect(values.valid_progress?).to eq true
end
@ -789,9 +799,9 @@ RSpec.describe SurveyItemValues, type: :model do
it "when there are 5 or more short form survey items valid_progress returns true" do
headers = short_form_survey_items
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
"s-sbel-q4" => 1 }
"s-sbel-q4" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 5
expect(values.valid_progress?).to eq true
end
@ -799,9 +809,9 @@ RSpec.describe SurveyItemValues, type: :model do
it "when there are 5 or more early education survey items valid_progress returns true" do
headers = early_education_survey_items
row = { "s-peff-es1" => 1, "s-peff-es2" => 1, "s-peff-es3" => 1, "s-peff-es4" => 1,
"s-peff-es5" => 1 }
"s-peff-es5" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 5
expect(values.valid_progress?).to eq true
end
@ -811,10 +821,10 @@ RSpec.describe SurveyItemValues, type: :model do
it "when there are fewer than 11 standard survey items valid_progress returns true" do
headers = standard_survey_items
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-emsa-q3" => 1, "s-sbel-q1" => 1 }
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
"s-emsa-q3" => 1, "s-sbel-q1" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 10
expect(values.valid_progress?).to eq false
end
@ -829,7 +839,7 @@ RSpec.describe SurveyItemValues, type: :model do
"t-psup-q3" => 1, "t-psup-q4" => 1, "t-acch-q1" => 1
}
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 11
expect(values.valid_progress?).to eq false
end
@ -838,7 +848,7 @@ RSpec.describe SurveyItemValues, type: :model do
headers = short_form_survey_items
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 4
expect(values.valid_progress?).to eq false
end
@ -847,7 +857,7 @@ RSpec.describe SurveyItemValues, type: :model do
headers = early_education_survey_items
row = { "s-peff-es1" => 1, "s-peff-es2" => 1, "s-peff-es3" => 1, "s-peff-es4" => 1 }
values = SurveyItemValues.new(row:, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.progress).to eq 4
expect(values.valid_progress?).to eq false
end
@ -863,14 +873,14 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns true for students" do
headers = %w[s-sbel-q5 s-phys-q2 grade RecordedDate DeseID]
values = SurveyItemValues.new(row: { "grade" => "9", "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_grade?).to eq true
end
it "returns true for teachers" do
headers = %w[t-sbel-q5 t-phys-q2 grade RecordedDate DeseID]
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
expect(values.valid_grade?).to eq true
end
end
@ -883,7 +893,7 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns false" do
headers = %w[s-sbel-q5 s-phys-q2 grade RecordedDate DeseID]
values = SurveyItemValues.new(row: { "grade" => "2", "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools: School.by_dese_id)
schools: School.by_dese_id)
expect(values.valid_grade?).to eq false
end
end
@ -894,13 +904,13 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns true for student questions" do
headers = %w[s-sbel-q5 s-phys-q1 s-phys-q2 RecordedDate]
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "s-sbel-q5" => "1", "s-phys-q1" => "", "s-phys-q2" => "5" }, headers:, survey_items:,
schools: School.by_dese_id)
schools: School.by_dese_id)
expect(values.valid_sd?).to eq true
end
it "returns true for teacher questions" do
headers = %w[t-sbel-q5 t-phys-q2]
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "t-sbel-q5" => "1", "t-phys-q2" => "5" }, headers:, survey_items:,
schools: School.by_dese_id)
schools: School.by_dese_id)
expect(values.valid_sd?).to eq true
end
end
@ -909,13 +919,13 @@ RSpec.describe SurveyItemValues, type: :model do
it "returns false for student questions" do
headers = %w[s-sbel-q5 s-phys-q1 s-phys-q2 RecordedDate]
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "s-sbel-q5" => "1", "s-phys-q2" => "1" }, headers:, survey_items:,
schools: School.by_dese_id)
schools: School.by_dese_id)
expect(values.valid_sd?).to eq false
end
it "returns false for teacher questions" do
headers = %w[t-sbel-q5 t-phys-q1 t-phys-q2 RecordedDate]
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "t-sbel-q5" => "1", "t-phys-q2" => "1" }, headers:, survey_items:,
schools: School.by_dese_id)
schools: School.by_dese_id)
expect(values.valid_sd?).to eq false
end
end
@ -930,7 +940,7 @@ RSpec.describe SurveyItemValues, type: :model do
it "parses the date correctly when the date is in standard date format for google sheets: 'MM/DD/YYYY HH:MM:SS'" do
recorded_date = "1/10/2022 14:21:45"
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
ay_21_22 = AcademicYear.find_by_range "2021-22"
expect(values.academic_year).to eq ay_21_22
end
@ -938,7 +948,7 @@ RSpec.describe SurveyItemValues, type: :model do
it "parses the date correctly when the date is in iso standard 8601 'YYYY-MM-DDTHH:MM:SS'" do
recorded_date = "2022-1-10T14:21:45"
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
ay_21_22 = AcademicYear.find_by_range "2021-22"
expect(values.academic_year).to eq ay_21_22
end
@ -946,9 +956,29 @@ RSpec.describe SurveyItemValues, type: :model do
it "parses the date correctly when the date is in the format of: 'YYYY-MM-DD HH:MM:SS'" do
recorded_date = "2022-01-10 14:21:45"
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
schools:, academic_years:)
schools:, academic_years:)
ay_21_22 = AcademicYear.find_by_range "2021-22"
expect(values.academic_year).to eq ay_21_22
end
end
end
def compare(header, target, result, model)
headers = [header]
row = { header => target}
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
expect(values.send(model)).to eq result
end
def read(filepath, value_header, type_header)
map = {}
CSV.parse(File.read(filepath), headers: true) do |row|
value = row[value_header]&.strip
type = row[type_header]&.strip
next if value.blank?
next if type.blank?
next if value.downcase == "[blanks]"
map[value] = type
end
map
end

View file

@ -344,11 +344,13 @@ def assigns_ell_to_responses
"student_survey_response_3" => not_ell,
"student_survey_response_4" => yes_ell,
"student_survey_response_5" => yes_ell,
"student_survey_response_6" => not_ell,
"student_survey_response_7" => not_ell }
"student_survey_response_6" => unknown_ell,
"student_survey_response_7" => unknown_ell }
results.each do |key, value|
ell = SurveyItemResponse.find_by_response_id(key).ell
puts key
puts value
expect(ell).to eq value
end
end