mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
WIP: create backend for socio-economic-status
This commit is contained in:
parent
61c5b0b087
commit
a258b32b39
23 changed files with 346 additions and 23 deletions
32
app/models/benefit.rb
Normal file
32
app/models/benefit.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class Benefit < ApplicationRecord
|
||||
scope :by_designation, -> { all.map { |benefits| [benefits.designation, benefits] }.to_h }
|
||||
|
||||
def self.to_designation(benefits)
|
||||
return "Unknown" if benefits.blank? or benefits.nil?
|
||||
|
||||
case benefits
|
||||
in /^1$/i
|
||||
"Yes"
|
||||
in /^2$/i
|
||||
"No"
|
||||
in /^3$/i
|
||||
"Unknown"
|
||||
in /^99$|^100$/i
|
||||
"Unknown"
|
||||
else
|
||||
puts "************************************"
|
||||
puts "******** ERROR **********"
|
||||
puts ""
|
||||
puts "Error parsing Income column. '#{benefits}' is not a known value. Halting execution"
|
||||
puts ""
|
||||
puts "************************************"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def points
|
||||
return 1 if designation == "Yes"
|
||||
|
||||
0
|
||||
end
|
||||
end
|
||||
45
app/models/education.rb
Normal file
45
app/models/education.rb
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
class Education < ApplicationRecord
|
||||
scope :by_designation, -> { all.map { |education| [education.designation, education] }.to_h }
|
||||
|
||||
def self.to_designation(education)
|
||||
return "Unknown" if education.blank? or education.nil?
|
||||
|
||||
case education
|
||||
in /^1$/i
|
||||
"No formal schooling completed"
|
||||
in /^2$/i
|
||||
"Some formal schooling"
|
||||
in /^3$/i
|
||||
"High school diploma or GED"
|
||||
in /^4$/i
|
||||
"Associates Degree"
|
||||
in /^5$/i
|
||||
"Bachelors Degree"
|
||||
in /^6$/i
|
||||
"Masters Degree"
|
||||
in /^7$/i
|
||||
"Professional Degree"
|
||||
in /^8$/i
|
||||
"Doctorate Degree"
|
||||
in /^99$|^100$/i
|
||||
"Unknown"
|
||||
else
|
||||
puts "************************************"
|
||||
puts "******** ERROR **********"
|
||||
puts ""
|
||||
puts "Error parsing Income column. '#{education}' is not a known value. Halting execution"
|
||||
puts ""
|
||||
puts "************************************"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def points
|
||||
higher_level_education = ["Associates Degree", "Bachelors Degree", "Masters Degree", "Professional Degree", "Doctorate Degree"]
|
||||
if higher_level_education.include?(designation)
|
||||
1
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
39
app/models/employment.rb
Normal file
39
app/models/employment.rb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
class Employment < ApplicationRecord
|
||||
scope :by_designation, -> { all.map { |employment| [employment.designation, employment] }.to_h }
|
||||
|
||||
def self.to_designation(employment)
|
||||
return "Unknown" if employment.blank? or employment.nil?
|
||||
|
||||
case employment
|
||||
in /^1$/i
|
||||
"Two adults with full-time employment"
|
||||
in /^2$/i
|
||||
"One adult with full-time employment"
|
||||
in /^3$/i
|
||||
"Two adults with part-time employment"
|
||||
in /^4$/i
|
||||
"One adult with part-time employment"
|
||||
in /^5$/i
|
||||
"No full-time or part-time employment"
|
||||
in /^99$|^100$/i
|
||||
"Unknown"
|
||||
else
|
||||
puts "************************************"
|
||||
puts "******** ERROR **********"
|
||||
puts ""
|
||||
puts "Error parsing Income column. '#{employment}' is not a known value. Halting execution"
|
||||
puts ""
|
||||
puts "************************************"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def points
|
||||
higher_level_employment = ["Two adults with full-time employment", "One adult with full-time employment"]
|
||||
if higher_level_employment.include?(designation)
|
||||
1
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
class Parent < ApplicationRecord
|
||||
belongs_to :housing, optional: true
|
||||
belongs_to :education, optional: true
|
||||
belongs_to :benefit, optional: true
|
||||
|
||||
has_many :parent_languages
|
||||
has_and_belongs_to_many :languages, join_table: :parent_languages
|
||||
has_and_belongs_to_many :races, join_table: :parent_races
|
||||
has_and_belongs_to_many :genders, join_table: :parent_genders
|
||||
has_and_belongs_to_many :employments, join_table: :parent_employments
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ module Report
|
|||
row << academic_year.range
|
||||
survey_items.each do |survey_item_id|
|
||||
survey_item = survey_items_by_id[survey_item_id]
|
||||
byebug if survey_item.nil?
|
||||
if sufficient_survey_items[grade].include? survey_item_id
|
||||
row.append("#{survey_item.survey_item_responses.where(school:, academic_year:,
|
||||
grade:).average(:likert_score).to_f.round(2)}")
|
||||
|
|
@ -87,7 +86,6 @@ module Report
|
|||
row.append(academic_year.range)
|
||||
survey_items.each do |survey_item_id|
|
||||
survey_item = survey_items_by_id[survey_item_id]
|
||||
byebug if survey_item.nil?
|
||||
# filter out response rate at subcategory level <24.5% for school average
|
||||
subcategory = survey_item.scale.measure.subcategory
|
||||
if ::StudentResponseRateCalculator.new(subcategory:, school:, academic_year:).meets_student_threshold?
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ class DemographicLoader
|
|||
create_from_column(column: "Special Ed Status", row:, model: Sped)
|
||||
create_from_column(column: "Housing", row:, model: Housing)
|
||||
create_from_column(column: "Language", row:, model: Language)
|
||||
create_from_column(column: "Employment", row:, model: Employment)
|
||||
create_from_column(column: "Education", row:, model: Education)
|
||||
create_from_column(column: "Benefits", row:, model: Benefit)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,24 @@ class SurveyItemValues
|
|||
@response_id ||= value_from(pattern: /Response\s*ID/i)
|
||||
end
|
||||
|
||||
def employments
|
||||
e = value_from(pattern: /^Employment$/i)
|
||||
|
||||
return [] if e.nil? || e.empty?
|
||||
|
||||
e.split(",").map do |item|
|
||||
Employment.to_designation(item.strip)
|
||||
end
|
||||
end
|
||||
|
||||
def education
|
||||
Education.to_designation(value_from(pattern: /^Education$/i)&.strip)
|
||||
end
|
||||
|
||||
def benefits
|
||||
Benefit.to_designation(value_from(pattern: /^Benefits$/i)&.strip)
|
||||
end
|
||||
|
||||
def dese_id
|
||||
@dese_id ||= begin
|
||||
dese_id = value_from(pattern: /Dese\s*ID/i)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,18 @@ class SurveyResponsesDataLoader
|
|||
@speds ||= Sped.by_designation
|
||||
end
|
||||
|
||||
def employments
|
||||
@employments ||= Employment.by_designation
|
||||
end
|
||||
|
||||
def educations
|
||||
@educations ||= Education.by_designation
|
||||
end
|
||||
|
||||
def benefits
|
||||
@benefits ||= Benefit.by_designation
|
||||
end
|
||||
|
||||
def academic_years
|
||||
@academic_years ||= AcademicYear.all
|
||||
end
|
||||
|
|
@ -110,6 +122,9 @@ class SurveyResponsesDataLoader
|
|||
if row.respondent_type == :parent
|
||||
parent = Parent.find_or_create_by(response_id: row.response_id)
|
||||
parent.number_of_children = row.number_of_children
|
||||
parent.education = educations[row.education] if row.education.present?
|
||||
parent.benefits_id = benefits[row.benefits].id if row.benefits.present?
|
||||
|
||||
tmp_languages = row.languages.map { |language| languages[language] }.reject(&:nil?)
|
||||
parent.languages.delete_all
|
||||
parent.languages.concat(tmp_languages)
|
||||
|
|
@ -122,6 +137,10 @@ class SurveyResponsesDataLoader
|
|||
tmp_genders = row.genders_of_children.map { |race| genders[race] }.reject(&:nil?)
|
||||
parent.genders.concat(tmp_genders)
|
||||
|
||||
parent.employments.delete_all
|
||||
tmp_employments = row.employments.map { |employment| employments[employment] }.reject(&:nil?)
|
||||
parent.employments.concat(tmp_employments)
|
||||
|
||||
parent.housing = housings[row.housing] if row.housing.present?
|
||||
parent.save
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status,Housing,Language
|
||||
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own,English
|
||||
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent,Portuguese
|
||||
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown,Spanish
|
||||
4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose
|
||||
5,White or Caucasian,,,,,,,Prefer to self-describe
|
||||
6,Prefer not to disclose,,,,,,,
|
||||
7,Prefer to self-describe,,,,,,,
|
||||
8,Middle Eastern,,,,,,,
|
||||
99,Race/Ethnicity Not Listed,,,,,,,
|
||||
100,Multiracial,,,,,,,
|
||||
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status,Housing,Language,Employment,Education,Benefits
|
||||
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own,English,Two adults with full-time employment,No formal schooling completed,Yes
|
||||
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent,Portuguese,One adult with full-time employment,Some formal schooling,No
|
||||
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown,Spanish,Two adults with part-time employment,High school diploma or GED,Unknown
|
||||
4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose,One adult with part-time employment,Associates Degree,
|
||||
5,White or Caucasian,,,,,,,Prefer to self-describe,No full-time or part-time employment,Bachelors Degree,
|
||||
6,Prefer not to disclose,,,,,,,,Unknown,Masters Degree,
|
||||
7,Prefer to self-describe,,,,,,,,,Professional Degree,
|
||||
8,Middle Eastern,,,,,,,,,Doctoral Degree,
|
||||
99,Race/Ethnicity Not Listed,,,,,,,,,Unknown,
|
||||
100,Multiracial,,,,,,,,,,
|
||||
|
|
|
|||
|
9
db/migrate/20250624180025_create_employments.rb
Normal file
9
db/migrate/20250624180025_create_employments.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class CreateEmployments < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :employments do |t|
|
||||
t.string :designation
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
db/migrate/20250624180041_create_educations.rb
Normal file
9
db/migrate/20250624180041_create_educations.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class CreateEducations < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :educations do |t|
|
||||
t.string :designation
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
db/migrate/20250624180051_create_benefits.rb
Normal file
9
db/migrate/20250624180051_create_benefits.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class CreateBenefits < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :benefits do |t|
|
||||
t.string :designation
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20250624180139_add_education_to_parent.rb
Normal file
5
db/migrate/20250624180139_add_education_to_parent.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddEducationToParent < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_reference :parents, :education, foreign_key: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20250624180155_add_benefits_to_parent.rb
Normal file
5
db/migrate/20250624180155_add_benefits_to_parent.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddBenefitsToParent < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_reference :parents, :benefits, foreign_key: true
|
||||
end
|
||||
end
|
||||
10
db/migrate/20250624230522_create_parent_employment.rb
Normal file
10
db/migrate/20250624230522_create_parent_employment.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class CreateParentEmployment < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :parent_employments do |t|
|
||||
t.references :parent, null: false, foreign_key: true
|
||||
t.references :employment, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
37
db/schema.rb
37
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_24_230522) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
|
|
@ -50,6 +50,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
t.index ["school_id"], name: "index_admin_data_values_on_school_id"
|
||||
end
|
||||
|
||||
create_table "benefits", force: :cascade do |t|
|
||||
t.string "designation"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "categories", id: :serial, force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
|
|
@ -77,6 +83,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
t.index ["slug"], name: "index_districts_on_slug", unique: true
|
||||
end
|
||||
|
||||
create_table "educations", force: :cascade do |t|
|
||||
t.string "designation"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "ells", force: :cascade do |t|
|
||||
t.string "designation"
|
||||
t.string "slug"
|
||||
|
|
@ -85,6 +97,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
t.index ["designation"], name: "index_ells_on_designation", unique: true
|
||||
end
|
||||
|
||||
create_table "employments", force: :cascade do |t|
|
||||
t.string "designation"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "genders", force: :cascade do |t|
|
||||
t.integer "qualtrics_code"
|
||||
t.string "designation"
|
||||
|
|
@ -336,6 +354,15 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
t.index ["subcategory_id"], name: "index_measures_on_subcategory_id"
|
||||
end
|
||||
|
||||
create_table "parent_employments", force: :cascade do |t|
|
||||
t.bigint "parent_id", null: false
|
||||
t.bigint "employment_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["employment_id"], name: "index_parent_employments_on_employment_id"
|
||||
t.index ["parent_id"], name: "index_parent_employments_on_parent_id"
|
||||
end
|
||||
|
||||
create_table "parent_genders", force: :cascade do |t|
|
||||
t.bigint "parent_id", null: false
|
||||
t.bigint "gender_id", null: false
|
||||
|
|
@ -370,6 +397,10 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "housing_id"
|
||||
t.bigint "education_id"
|
||||
t.bigint "benefits_id"
|
||||
t.index ["benefits_id"], name: "index_parents_on_benefits_id"
|
||||
t.index ["education_id"], name: "index_parents_on_education_id"
|
||||
t.index ["housing_id"], name: "index_parents_on_housing_id"
|
||||
end
|
||||
|
||||
|
|
@ -558,12 +589,16 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do
|
|||
add_foreign_key "legacy_school_categories", "legacy_categories", column: "category_id"
|
||||
add_foreign_key "legacy_school_categories", "legacy_schools", column: "school_id"
|
||||
add_foreign_key "measures", "subcategories"
|
||||
add_foreign_key "parent_employments", "employments"
|
||||
add_foreign_key "parent_employments", "parents"
|
||||
add_foreign_key "parent_genders", "genders"
|
||||
add_foreign_key "parent_genders", "parents"
|
||||
add_foreign_key "parent_languages", "languages"
|
||||
add_foreign_key "parent_languages", "parents"
|
||||
add_foreign_key "parent_races", "parents"
|
||||
add_foreign_key "parent_races", "races"
|
||||
add_foreign_key "parents", "benefits", column: "benefits_id"
|
||||
add_foreign_key "parents", "educations"
|
||||
add_foreign_key "parents", "housings"
|
||||
add_foreign_key "respondents", "academic_years"
|
||||
add_foreign_key "respondents", "schools"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
FactoryBot.define do
|
||||
factory :benefit do
|
||||
designation { "MyString" }
|
||||
end
|
||||
|
||||
factory :education do
|
||||
designation { "MyString" }
|
||||
end
|
||||
|
||||
factory :employment do
|
||||
designation { "MyString" }
|
||||
end
|
||||
|
||||
factory :parent_language do
|
||||
parent { nil }
|
||||
language { nil }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
StartDate,EndDate,Status,IPAddress,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,DistributionChannel,UserLanguage,DESE ID,Number of Children,Gender-1,Gender-1_7_TEXT,Race-1,Race-1_7_TEXT,Gender-2,Gender-2_7_TEXT,Race-2,Race-2_7_TEXT,Gender-3,Gender-3_7_TEXT,Race-3,Race-3_7_TEXT,Gender-4,Gender-4_7_TEXT,Race-4,Race-4_7_TEXT,Gender-5,Gender-5_7_TEXT,Race-5,Race-5_7_TEXT,Gender,Gender_7_TEXT,p-scrp-q3,p-scrp-q2,p-valm-q1,p-valm-q2,p-valm-q3,p-valm-q4,p-comm-q1,p-comm-q2,p-comm-q3,p-tcom-q1,P-tcom-q2,p-tcom-q3,p-evnt-q4,p-comm-q4,p-evnt-q3,p-evnt-q1,p-evnt-q2,p-socx-q3,p-socx-q4,p-scrp-q1,p-socx-q1,p-sosu-q1,p-sosu-q2,p-sosu-q3,p-socx-q2,p-sosu-q4,p-phys-q3,p-acpr-q1,p-acpr-q2,p-acpr-q3,p-acpr-q4,p-cure-q1,p-cure-q2,p-cure-q3,p-cure-q4,Housing,Housing_100_TEXT,Employment,Employment_100_TEXT,Caregivers,Caregivers_100_TEXT,Education,Education_100_TEXT,Benefits,Benefits_100_TEXT,Language,Language_100_TEXT,Raw Income,Income,Raw ELL,ELL,Raw SpEd,SpEd,Progress Count
|
||||
5/1/2024 10:04:34,5/1/2024 10:10:49,0,72.93.86.98,100,374,1,2021-03-31T10:01:36,parent_survey_response_1,email,EN,1500025,1,,,1,,,,,,,,,,,,,,,,,,2,,4,5,5,4,5,5,5,5,5,4,4,5,4,5,3,4,5,4,4,5,5,5,5,5,5,5,1,2,2,2,1,4,5,5,5,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:03:52,5/1/2024 10:14:42,0,73.69.182.58,100,649,1,2021-04-01T10:01:36,parent_survey_response_2,email,EN,1500025,1,,,,,,,,,,,6,,,,7,,,,,,1,,4,4,5,5,5,5,5,5,5,5,5,5,3,5,4,5,5,5,5,5,4,4,4,4,5,5,1,5,4,5,5,5,5,5,5,1,,99,,2,,3,,1,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:06:44,5/1/2024 10:15:41,0,50.235.109.170,100,537,1,2021-04-02T10:01:36,parent_survey_response_3,email,EN,1500025,2,1,,4,,2,,"1,5",,,,,,,,,,,,,,2,,5,5,5,4,5,5,5,5,5,4,4,5,4,4,3,4,4,4,4,5,4,4,5,5,2,5,3,4,4,4,4,5,5,5,5,1,,1,,3,,6,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:14:23,5/1/2024 10:22:22,0,73.38.238.192,100,478,1,2021-04-03T10:01:36,parent_survey_response_4,email,EN,1500025,1,3,,7,,,,,,,,,,,,,,,,,,4,,5,5,5,5,5,5,5,4,5,4,4,4,2,5,4,5,4,5,5,5,3,5,5,5,2,5,1,5,5,5,5,5,5,5,5,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:04:34,5/1/2024 10:10:49,0,72.93.86.98,100,374,1,2021-03-31T10:01:36,parent_survey_response_1,email,EN,1500025,1,,,1,,,,,,,,,,,,,,,,,,2,,4,5,5,4,5,5,5,5,5,4,4,5,4,5,3,4,5,4,4,5,5,5,5,5,5,5,1,2,2,2,1,4,5,5,5,1,,1,,2,,1,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:03:52,5/1/2024 10:14:42,0,73.69.182.58,100,649,1,2021-04-01T10:01:36,parent_survey_response_2,email,EN,1500025,1,,,,,,,,,,,6,,,,7,,,,,,1,,4,4,5,5,5,5,5,5,5,5,5,5,3,5,4,5,5,5,5,5,4,4,4,4,5,5,1,5,4,5,5,5,5,5,5,1,,99,,2,,2,,1,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:06:44,5/1/2024 10:15:41,0,50.235.109.170,100,537,1,2021-04-02T10:01:36,parent_survey_response_3,email,EN,1500025,2,1,,4,,2,,"1,5",,,,,,,,,,,,,,2,,5,5,5,4,5,5,5,5,5,4,4,5,4,4,3,4,4,4,4,5,4,4,5,5,2,5,3,4,4,4,4,5,5,5,5,1,,1,,3,,3,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:14:23,5/1/2024 10:22:22,0,73.38.238.192,100,478,1,2021-04-03T10:01:36,parent_survey_response_4,email,EN,1500025,1,3,,7,,,,,,,,,,,,,,,,,,4,,5,5,5,5,5,5,5,4,5,4,4,4,2,5,4,5,4,5,5,5,3,5,5,5,2,5,1,5,5,5,5,5,5,5,5,1,,1,,2,,4,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:18:39,5/1/2024 10:23:49,0,73.69.158.255,100,310,1,2021-04-04T10:01:36,parent_survey_response_5,email,EN,1500025,2,2,,"1,2,3",,,,"4,5,8",,,,,,,,,,,,,,2,,5,4,5,5,5,5,1,1,1,1,1,1,3,1,4,4,5,1,1,1,4,1,1,1,4,5,1,5,5,5,5,1,5,1,1,1,,"2,4",,3,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:20:30,5/1/2024 10:25:16,0,73.182.146.201,100,285,1,2021-04-05T10:01:36,parent_survey_response_6,email,EN,1500025,1,,,,,,,,,,,,,,,1,,,,"2,3,4,5,8",,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,2,,2,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_7,email,EN,1500025,2,6,,5,,,,5,,,,,,,,,,,,,,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:20:30,5/1/2024 10:25:16,0,73.182.146.201,100,285,1,2021-04-05T10:01:36,parent_survey_response_6,email,EN,1500025,1,,,,,,,,,,,,,,,1,,,,"2,3,4,5,8",,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,2,,2,,2,,99,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_7,email,EN,1500025,2,6,,5,,,,5,,,,,,,,,,,,,,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,1,,1,,2,,100,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34
|
||||
5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_8,email,EN,1500025,2,Prefer not to disclose,,5,,,,5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
|
|
|
|||
|
5
spec/models/benefit_spec.rb
Normal file
5
spec/models/benefit_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Benefit, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/education_spec.rb
Normal file
5
spec/models/education_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Education, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/employment_spec.rb
Normal file
5
spec/models/employment_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Employment, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
|
@ -182,15 +182,12 @@ RSpec.describe Cleaner do
|
|||
1027 1028]
|
||||
valid_rows.each do |response_id|
|
||||
valid_row = data.find { |row| row.response_id == response_id }
|
||||
byebug unless valid_row.valid? == true
|
||||
expect(valid_row.valid?).to eq true
|
||||
end
|
||||
|
||||
invalid_rows = %w[1002 1006 1007 1009 1010 1011 1012 1013 1014 1015 1016 1021 1022 1023 1025 1029 1030 1031 1032
|
||||
1033 1034]
|
||||
invalid_rows.each do |response_id|
|
||||
invalid_row = data.find { |row| row.response_id == response_id }
|
||||
byebug if invalid_row.valid? == true
|
||||
expect(invalid_row.valid?).to eq false
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,48 @@ describe SurveyResponsesDataLoader do
|
|||
create(:language, designation: "Unknown")
|
||||
end
|
||||
|
||||
let(:education_list) do
|
||||
designations = [
|
||||
"No formal schooling completed",
|
||||
"Some formal schooling",
|
||||
"High school diploma or GED",
|
||||
"Associates Degree",
|
||||
"Bachelors Degree",
|
||||
"Masters Degree",
|
||||
"Professional Degree",
|
||||
"Doctoral Degree",
|
||||
"Unknown"
|
||||
]
|
||||
designations.map do |designation|
|
||||
create(:education, designation:)
|
||||
end
|
||||
end
|
||||
|
||||
let(:employment_list) do
|
||||
designations = [
|
||||
"Two adults with full-time employment",
|
||||
"One adult with full-time employment",
|
||||
"Two adults with part-time employment",
|
||||
"One adult with part-time employment",
|
||||
"No full-time or part-time employment",
|
||||
"Unknown"
|
||||
]
|
||||
designations.map do |designation|
|
||||
create(:employment, designation:)
|
||||
end
|
||||
end
|
||||
|
||||
let(:benefit_list) do
|
||||
designations = [
|
||||
"Yes",
|
||||
"No",
|
||||
"Unknown"
|
||||
]
|
||||
designations.map do |designation|
|
||||
create(:benefit, designation:)
|
||||
end
|
||||
end
|
||||
|
||||
let(:setup) do
|
||||
ay_2020_21
|
||||
ay_2022_23
|
||||
|
|
@ -177,6 +219,9 @@ describe SurveyResponsesDataLoader do
|
|||
multiracial
|
||||
|
||||
languages
|
||||
education_list
|
||||
employment_list
|
||||
benefit_list
|
||||
end
|
||||
|
||||
before :each do
|
||||
|
|
@ -281,6 +326,20 @@ describe SurveyResponsesDataLoader do
|
|||
it "loads the correct set of genders for parents" do
|
||||
assigns_genders_to_parents
|
||||
end
|
||||
|
||||
it "assigns the correct education for parents" do
|
||||
results = { "parent_survey_response_1" => "No formal schooling completed",
|
||||
"parent_survey_response_2" => "Some formal schooling",
|
||||
"parent_survey_response_3" => "High school diploma or GED",
|
||||
"parent_survey_response_4" => "Associates Degree",
|
||||
"parent_survey_response_5" => "Bachelors Degree",
|
||||
"parent_survey_response_6" => "Unknown",
|
||||
"parent_survey_response_7" => "Unknown" }
|
||||
|
||||
results.each do |key, value|
|
||||
expect(SurveyItemResponse.where(response_id: key).first.parent.education.designation).to eq value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue