mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
fix failing tests
This commit is contained in:
parent
a21a11f809
commit
a066f464c7
8 changed files with 201 additions and 120 deletions
|
|
@ -23,10 +23,16 @@ class AcademicYear < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# This may cause problems if academic years get loaded from csv instead of the current method that requires a code change to the seeder script. This is because a change in code will trigger a complete reload of the application whereas loading from csv does not. This means if we change academic year to load from csv, the set of academic years will be stale when new years are added.
|
||||
def self.academic_years
|
||||
@@academic_years ||= AcademicYear.all.map { |academic_year| [academic_year.range, academic_year] }.to_h
|
||||
end
|
||||
|
||||
# Needed to reset the academic years when testing with specs that create the same academic year in a before :each block
|
||||
def self.reset_academic_years
|
||||
@@academic_years = nil
|
||||
end
|
||||
|
||||
private_class_method :academic_years
|
||||
private_class_method :parse_year_range
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,18 +57,20 @@ class SurveyItemValues
|
|||
end
|
||||
|
||||
def schools
|
||||
@@schools ||= School.all.map { |school| [school.dese_id, school] }.to_h
|
||||
@schools ||= School.all.map { |school| [school.dese_id, school] }.to_h
|
||||
end
|
||||
|
||||
def grade
|
||||
@grade ||= begin
|
||||
raw_grade = (row['grade'] || row['Grade'] || row['What grade are you in?']).to_i
|
||||
raw_grade == 0 ? nil : raw_grade
|
||||
raw_grade = (row['grade'] || row['Grade'] || row['What grade are you in?'])
|
||||
return nil if raw_grade.blank?
|
||||
|
||||
raw_grade.to_i
|
||||
end
|
||||
end
|
||||
|
||||
def gender
|
||||
gender_code = row['gender'] || row['Gender'] || 99
|
||||
gender_code = row['gender'] || row['Gender'] || row['What is your gender?'] || row['What is your gender? - Selected Choice'] || 99
|
||||
gender_code = gender_code.to_i
|
||||
gender_code = 4 if gender_code == 3
|
||||
gender_code = 99 if gender_code.zero?
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
|
||||
class SurveyResponsesDataLoader
|
||||
def self.load_data(filepath:, rules: [Rule::NoRule])
|
||||
File.open(filepath) do |file|
|
||||
|
|
@ -14,7 +12,6 @@ class SurveyResponsesDataLoader
|
|||
process_row(row: SurveyItemValues.new(row:, headers:, genders: genders_hash, survey_items: all_survey_items),
|
||||
rules:)
|
||||
end
|
||||
|
||||
SurveyItemResponse.import survey_item_responses.compact.flatten, batch_size: 500
|
||||
end
|
||||
end
|
||||
|
|
@ -101,7 +98,7 @@ class SurveyResponsesDataLoader
|
|||
def self.get_survey_item_ids_from_headers(headers:)
|
||||
CSV.parse(headers, headers: true).headers
|
||||
.filter(&:present?)
|
||||
.filter { |header| header.start_with? 't-' or header.start_with? 's-' }
|
||||
.filter { |header| header.start_with? 't-', 's-' }
|
||||
end
|
||||
|
||||
private_class_method :process_row
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Start Date,End Date,Response Type,IP Address,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,Recipient Last Name,Recipient First Name,Recipient Email,External Data Reference,Location Latitude,Location Longitude,Distribution Channel,User Language,district,school,DESE ID,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,s-emsa-q1,s-emsa-q2,s-emsa-q3,s-tint-q1,s-tint-q2,#N/A,s-tint-q4,s-tint-q5,s-acpr-q1,s-acpr-q2,s-acpr-q3,s-acpr-q4,#N/A,#N/A,s-cure-q3,s-cure-q4,#N/A,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,#N/A,#N/A,s-grmi-q4,s-appa-q1,s-appa-q2,#N/A,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,#N/A,#N/A,s-vale-q4,#N/A,s-acst-q2,s-acst-q3,#N/A,#N/A,s-grit-q1,s-grit-q2,s-grit-q3,s-grit-q4,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A
|
||||
2020-09-29 18:28:41,2020-09-29 18:48:28,0,73.249.89.226,6,1186,0,2020-09-30T18:48:50,student_survey_response_1,,,,,,,anonymous,EN,1,8,160505,,,,dddd,4,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,some non-integer response,6,,,,5,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,EN,,,,
|
||||
2020-09-29 18:28:41,2020-09-29 18:48:28,0,73.249.89.226,6,1186,0,2020-09-30T18:48:50,student_survey_response_1,,,,,,,anonymous,EN,1,8,1500025,,,,dddd,4,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,some non-integer response,6,,,,5,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,EN,,,,
|
||||
2021-02-23 15:12:58,2021-02-23 15:13:17,0,50.207.254.114,0,19,0,2021-02-24T15:13:19,student_survey_response_2,,,,,,,anonymous,EN,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,NA,,,,,,,,,,,,,,,,,,,,,EN,,,,
|
||||
2021-03-31 9:50:19,2021-03-31 9:59:01,0,108.7.17.250,100,522,1,2021-03-31T09:59:02,student_survey_response_3,,,,,42.53340149,-70.96530151,anonymous,EN,3,2,1600310,12,4,108,3300,7,1,,1,,,,,,,,,,,,2,4,2,1,4,3,3,,,,,3,3,3,3,,,,,NA,,,,,,,,,3,2,3,3,2,1,3,4,1,3,3,4,4,2,4,3,3,4,3,3,3,4,3,3,3,3,3,,,,,,,,,,3,4,4,2,3,3,1,,3,,EN,Math teacher,,,
|
||||
2021-03-31 9:50:09,2021-03-31 10:00:16,0,67.186.188.168,100,607,1,2021-03-31T10:00:17,student_survey_response_4,,,,,42.63510132,-71.30139923,anonymous,EN,3,2,1600310,12,18,108,2064,7,1,,1,2,1,,,,,,,,,,,,,,,,,,,,,,,,,3,5,3,3,,,,,,,,,,4,4,3,4,5,1,1,5,1,3,2,4,4,1,2,1,3,2,3,3,3,4,2,5,3,4,5,5,3,3,4,3,,,,,4,4,4,4,3,5,2,,2,,EN,,,,English teacher
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_5,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1600310,6,15,109,3710,7,1,,1,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,
|
||||
2021-03-31 9:50:19,2021-03-31 9:59:01,0,108.7.17.250,100,522,1,2021-03-31T09:59:02,student_survey_response_3,,,,,42.53340149,-70.96530151,anonymous,EN,3,2,1500505,12,4,108,3300,7,1,,1,,,,,,,,,,,,2,4,2,1,4,3,3,,,,,3,3,3,3,,,,,NA,,,,,,,,,3,2,3,3,2,1,3,4,1,3,3,4,4,2,4,3,3,4,3,3,3,4,3,3,3,3,3,,,,,,,,,,3,4,4,2,3,3,1,,3,,EN,Math teacher,,,
|
||||
2021-03-31 9:50:09,2021-03-31 10:00:16,0,67.186.188.168,100,607,1,2021-03-31T10:00:17,student_survey_response_4,,,,,42.63510132,-71.30139923,anonymous,EN,3,2,1500505,12,18,108,2064,7,1,,1,2,1,,,,,,,,,,,,,,,,,,,,,,,,,3,5,3,3,,,,,,,,,,4,4,3,4,5,1,1,5,1,3,2,4,4,1,2,1,3,2,3,3,3,4,2,5,3,4,5,5,3,3,4,3,,,,,4,4,4,4,3,5,2,,2,,EN,,,,English teacher
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_5,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1500505,6,15,109,3710,7,1,,1,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,
|
||||
|
|
|
|||
|
|
|
@ -1,9 +1,9 @@
|
|||
Start Date,End Date,Response Type,IP Address,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,LASID,Recipient Last Name,Recipient First Name,Recipient Email,External Data Reference,Location Latitude,Location Longitude,Distribution Channel,User Language,district,school,DESE ID,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,s-emsa-q1,s-emsa-q2,s-emsa-q3,s-tint-q1,s-tint-q2,#N/A,s-tint-q4,s-tint-q5,s-acpr-q1,s-acpr-q2,s-acpr-q3,s-acpr-q4,#N/A,#N/A,s-cure-q3,s-cure-q4,#N/A,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,#N/A,#N/A,s-grmi-q4,s-appa-q1,s-appa-q2,#N/A,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-q1-1,s-phys-q2,s-phys-q3,s-phys-q4,s-vale-q1,#N/A,#N/A,s-vale-q4,#N/A,s-acst-q2,s-acst-q3,#N/A,#N/A,s-grit-q1,s-grit-q2,s-grit-q3,s-grit-q4,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,race,What is your race/ethnicity?(Please select all that apply) - Selected Choice,grade,gender
|
||||
2020-09-29 18:28:41,2020-09-29 18:48:28,0,73.249.89.226,6,1186,0,2020-09-30T18:48:50,student_survey_response_1,123456,,,,,,,anonymous,EN,1,8,160505,,,,dddd,4,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,0,some non-integer response,6,,,,5,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,EN,,,,,1,888,11th,1
|
||||
Start Date,End Date,Response Type,IP Address,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,LASID,Recipient Last Name,Recipient First Name,Recipient Email,External Data Reference,Location Latitude,Location Longitude,Distribution Channel,User Language,district,school,DESE ID,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,s-emsa-q1,s-emsa-q2,s-emsa-q3,s-tint-q1,s-tint-q2,#N/A,s-tint-q4,s-tint-q5,s-acpr-q1,s-acpr-q2,s-acpr-q3,s-acpr-q4,#N/A,#N/A,s-cure-q3,s-cure-q4,#N/A,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,#N/A,#N/A,s-grmi-q4,s-appa-q1,s-appa-q2,#N/A,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-q1-1,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-acst-q4,s-acst-q5,s-grit-q1,s-grit-q2,s-grit-q3,s-grit-q4,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,race,What is your race/ethnicity?(Please select all that apply) - Selected Choice,grade,gender
|
||||
2020-09-29 18:28:41,2020-09-29 18:48:28,0,73.249.89.226,6,1186,0,2020-09-30T18:48:50,student_survey_response_1,123456,,,,,,,anonymous,EN,1,8,1500025,,,,dddd,4,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,0,some non-integer response,6,,,,5,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,EN,,,,,1,888,11th,1
|
||||
2021-02-23 15:12:58,2021-02-23 15:13:17,0,50.207.254.114,0,19,0,2021-02-24T15:13:19,student_survey_response_2,234567,,,,,,,anonymous,EN,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,NA,,,,,,,,,,,,,,,,,,,,,EN,,,,,"2,3,4",888,10,
|
||||
2021-03-31 9:50:19,2021-03-31 9:59:01,0,108.7.17.250,100,522,1,2021-03-31T09:59:02,student_survey_response_3,345678,,,,,42.53340149,-70.96530151,anonymous,EN,3,2,1600310,12,4,108,3300,7,1,,,,,,,,,,,,,,2,4,2,1,4,3,3,,,,,3,3,3,3,,,,,NA,,,,,,,,,3,2,3,3,2,1,3,3,4,1,3,3,4,4,2,4,3,3,4,3,3,3,4,3,3,3,3,3,,,,,,,,,,3,4,4,2,3,3,1,,3,,EN,Math teacher,,,,6,888,8,2
|
||||
2021-03-31 9:50:09,2021-03-31 10:00:16,0,67.186.188.168,100,607,1,2021-03-31T10:00:17,student_survey_response_4,456789,,,,,42.63510132,-71.30139923,anonymous,EN,3,2,1600310,12,18,108,2064,7,1,,2,2,1,,,,,,,,,,,,,,,,,,,,,,,,,3,5,3,3,,,,,,,,,,4,4,3,4,5,1,,1,5,1,3,2,4,4,1,2,1,3,2,3,3,3,4,2,5,3,4,5,5,3,3,4,3,,,,,4,4,4,4,3,5,2,,2,,EN,,,,English teacher,7,888,8,3
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_5,567890,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1600310,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,"1,2,3,4,5,8,6,7",888,7,4
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_6,,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1600310,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,"1,2,3,4,5,8",888,3,NA
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_7,,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1600310,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,,,4,
|
||||
2021-03-31 9:50:19,2021-03-31 9:59:01,0,108.7.17.250,100,522,1,2021-03-31T09:59:02,student_survey_response_3,345678,,,,,42.53340149,-70.96530151,anonymous,EN,3,2,1500505,12,4,108,3300,7,1,,,,,,,,,,,,,,2,4,2,1,4,3,3,,,,,3,3,3,3,,,,,NA,,,,,,,,,3,2,3,3,2,1,3,3,4,1,3,3,4,4,2,4,3,3,4,3,3,3,4,3,3,3,3,3,,,,,,,,,,3,4,4,2,3,3,1,,3,,EN,Math teacher,,,,6,888,8,2
|
||||
2021-03-31 9:50:09,2021-03-31 10:00:16,0,67.186.188.168,100,607,1,2021-03-31T10:00:17,student_survey_response_4,456789,,,,,42.63510132,-71.30139923,anonymous,EN,3,2,1500505,12,18,108,2064,7,1,,2,2,1,,,,,,,,,,,,,,,,,,,,,,,,,3,5,3,3,,,,,,,,,,4,4,3,4,5,1,,1,5,1,3,2,4,4,1,2,1,3,2,3,3,3,4,2,5,3,4,5,5,3,3,4,3,,,,,4,4,4,4,3,5,2,,2,,EN,,,,English teacher,7,888,8,3
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_5,567890,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1500505,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,"1,2,3,4,5,8,6,7",888,7,4
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_6,,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1500505,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,"1,2,3,4,5,8",888,3,NA
|
||||
2021-03-31 9:51:39,2021-03-31 10:01:36,0,73.47.153.77,100,596,1,2021-03-31T10:01:36,student_survey_response_7,,,,,,42.65820313,-71.30580139,anonymous,EN,3,2,1500505,6,15,109,3710,7,1,,2,2,2,,,,,,,,,,3,3,4,3,3,3,3,4,3,4,3,4,4,5,4,3,4,3,5,2,2,3,,,,,,,,,,,,1,,2,5,1,3,3,2,4,3,5,4,,,,,,,,,,,,5,4,3,4,4,4,4,4,4,,,,,,,2,,2,,EN,,,Social Studies teacher,,,,4,
|
||||
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"1,2,3,4,5,8",,,
|
||||
|
|
|
|||
|
|
|
@ -1,6 +1,6 @@
|
|||
Start Date,End Date,Response Type,IP Address,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,Recipient Last Name,Recipient First Name,Recipient Email,External Data Reference,Location Latitude,Location Longitude,Distribution Channel,User Language,District,school,,DESE ID,t-prep-q1,t-prep-q2,t-prep-q3,t-pcom-q1,t-pcom-q2,t-pcom-q3,t-pcom-q4,t-pcom-q5,t-ieff-q1,t-ieff-q2,t-ieff-q3,t-ieff-q4,t-qupd-q3,t-qupd-q2,t-qupd-q1,t-qupd-q4,t-coll-q1,t-coll-q2,t-coll-q3,t-prtr-q1,t-prtr-q2,t-prtr-q3,t-inle-q1,t-inle-q2,t-inle-q3,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,#N/A,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,,,,
|
||||
2020-10-09 9:42:45,2020-10-09 11:08:57,0,50.204.125.194,93,5172,0,2020-10-16 11:09:03,teacher_survey_response_1,,,,,,,anonymous,EN,1,1,4,160505,,,,,,3,,,,,,,,,,,3,3,3,NA,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,,
|
||||
2020-10-09 9:21:30,2020-10-09 14:28:09,0,50.204.125.194,24,18398,0,2020-10-16 14:28:18,teacher_survey_response_2,,,,,,,anonymous,EN,1,1,4,160505,,,,,,,,,,,,,,,,,,,NA,,,,,NA,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2020-12-06 8:28:00,2020-12-06 8:36:52,0,73.61.140.32,100,532,1,2020-12-06 8:36:52,teacher_survey_response_3,,,,,41.92610168,-71.30110168,anonymous,EN,1,2,2,350302,5,5,5,5,5,5,5,1,5,5,5,5,3,2,1,5,4,5,5,4,4,5,5,5,5,3,3,3,3,1,3,3,4,3,2,4,4,4,4,3,3,2,2,2,4,4,4,3,2,3,2,5,4,5,5,3,4,4,3,5,2,1,3,4,3,3,4,4,3,3,,9,9,
|
||||
2020-12-06 8:41:41,2020-12-06 8:51:25,0,96.230.183.162,100,584,1,2020-12-06 8:51:25,teacher_survey_response_4,,,,,41.98530579,-71.5184021,anonymous,EN,1,2,2,350302,5,5,5,4,4,4,4,1,4,4,4,4,3,3,3,2,5,2,4,5,4,5,4,4,4,3,3,3,3,4,4,3,3,3,3,3,4,3,3,4,4,3,2,4,4,4,4,4,3,2,3,4,5,3,2,2,4,4,3,3,4,3,3,3,3,3,3,4,3,3,,9,6,
|
||||
2020-12-06 8:44:42,2020-12-06 8:55:58,0,216.41.82.178,100,675,1,2020-12-06 8:55:58,teacher_survey_response_5,,,,,41.92610168,-71.30110168,anonymous,EN,1,2,2,350302,5,4,4,2,2,4,1,2,4,4,4,4,3,3,3,2,4,3,5,4,3,4,3,3,4,2,2,4,4,2,4,3,4,4,3,3,2,3,2,3,3,2,4,4,3,4,4,3,2,2,4,4,5,2,3,1,4,4,3,3,3,2,2,4,4,3,3,3,3,3,,7,5,"These questions are very difficult to address during a PANDEMIC! So it is not your average typical year. Our principal may not be as concerned about academics, because they are too busy navigating the complexities COVID has caused. I am honestly unsure why we would get surveyed during this time. "
|
||||
Start Date,End Date,Response Type,IP Address,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,Recipient Last Name,Recipient First Name,Recipient Email,External Data Reference,Location Latitude,Location Longitude,Distribution Channel,User Language,District,school,,DESE ID,t-prep-q1,t-prep-q2,t-prep-q3,t-pcom-q1,t-pcom-q2,t-pcom-q3,t-pcom-q4,t-pcom-q5,t-ieff-q1,t-ieff-q2,t-ieff-q3,t-ieff-q4,t-qupd-q3,t-qupd-q2,t-qupd-q1,t-qupd-q4,t-coll-q1,t-coll-q2,t-coll-q3,t-prtr-q1,t-prtr-q2,t-prtr-q3,t-inle-q1,t-inle-q2,t-inle-q3,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,,,
|
||||
2020-10-09 9:42:45,2020-10-09 11:08:57,0,50.204.125.194,93,5172,0,2020-10-16 11:09:03,teacher_survey_response_1,,,,,,,anonymous,EN,1,1,4,1500025,,,,,,3,,,,,,,,,,,3,3,3,NA,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,
|
||||
2020-10-09 9:21:30,2020-10-09 14:28:09,0,50.204.125.194,24,18398,0,2020-10-16 14:28:18,teacher_survey_response_2,,,,,,,anonymous,EN,1,1,4,1500025,,,,,,,,,,,,,,,,,,,NA,,,,,NA,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2020-12-06 8:28:00,2020-12-06 8:36:52,0,73.61.140.32,100,532,1,2020-12-06 8:36:52,teacher_survey_response_3,,,,,41.92610168,-71.30110168,anonymous,EN,1,2,2,1500505,5,5,5,5,5,5,5,1,5,5,5,5,3,2,1,5,4,5,5,4,4,5,5,5,5,3,3,3,3,1,3,3,4,3,2,4,4,4,4,3,3,2,2,2,4,4,4,3,2,3,2,5,4,5,5,3,4,4,3,5,2,1,3,4,3,3,4,4,3,3,,9,9
|
||||
2020-12-06 8:41:41,2020-12-06 8:51:25,0,96.230.183.162,100,584,1,2020-12-06 8:51:25,teacher_survey_response_4,,,,,41.98530579,-71.5184021,anonymous,EN,1,2,2,1500505,5,5,5,4,4,4,4,1,4,4,4,4,3,3,3,2,5,2,4,5,4,5,4,4,4,3,3,3,3,4,4,3,3,3,3,3,4,3,3,4,4,3,2,4,4,4,4,4,3,2,3,4,5,3,2,2,4,4,3,3,4,3,3,3,3,3,3,4,3,3,,9,6
|
||||
2020-12-06 8:44:42,2020-12-06 8:55:58,0,216.41.82.178,100,675,1,2020-12-06 8:55:58,teacher_survey_response_5,,,,,41.92610168,-71.30110168,anonymous,EN,1,2,2,1500505,5,4,4,2,2,4,1,2,4,4,4,4,3,3,3,2,4,3,5,4,3,4,3,3,4,2,2,4,4,2,4,3,4,4,3,3,2,3,2,3,3,2,4,4,3,4,4,3,2,2,4,4,5,2,3,1,4,4,3,3,3,2,2,4,4,3,3,3,3,3,,7,5
|
||||
|
|
|
|||
|
|
|
@ -1,7 +1,9 @@
|
|||
StartDate,EndDate,Status,IPAddress,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,District,School,"Please select the month, day and year of your birthday. - Month","Please select the month, day and year of your birthday. - Day","Please select the month, day and year of your birthday. - Year",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-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-peff-q1,s-peff-q2,s-peff-q3,s-peff-q4,s-peff-q5,s-peff-q6,Gender,Race
|
||||
2022-11-21 10:03:00,2022-11-21 10:12:16,0,208.118.224.220,100,555,1,2022-11-21T10:12:16,R_1gTpYL1ytWhdp0e,3,1600310,7,25,110,72509,7,3,3,,3,3,3,3,3,3,,3,3,3,3,3,3,2,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,,,,,,,,,,,,,,,,,,,3,3,3,3,3,3,1,3,3,3,3,,,,,,,2,
|
||||
2022-11-21 14:59:02,2022-11-21 15:08:02,0,71.233.3.7,40,540,0,2022-11-22T15:8:7,R_YXLsXvtKwOlUfoB,3,1600310,11,28,110,275751,7,,,,,,,,,,,,,,,,,,,,,,,,3,3,3,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2022-11-21 10:03:34,2022-11-21 10:12:43,0,208.118.224.218,100,548,1,2022-11-21T10:12:44,R_31AX0jLj2zqTooN,3,1600310,9,28,110,277136,7,4,4,4,4,3,4,4,4,5,5,5,5,4,4,4,4,4,4,4,,4,4,4,3,3,3,3,4,4,4,4,2,4,3,4,4,4,4,3,,,,,,,,,,,,,,,,,,,,,,,5,5,5,4,5,5,1,2
|
||||
2022-11-18 11:06:49,2022-11-18 11:30:12,0,208.118.224.209,100,1402,1,2022-11-18T11:30:13,R_4Ouz8n5dnnXVRPb,3,1600310,9,4,112,287185,5,3,3,3,4,3,5,5,5,5,4,5,4,4,3,4,4,3,4,4,2,3,3,3,4,4,4,4,3,3,3,3,3,3,3,3,3,4,3,3,,,,,,,,,,,,,,,,,,,,,,,5,4,4,4,4,4,1,2
|
||||
2022-11-21 13:12:42,2022-11-21 13:24:30,0,131.239.118.9,100,707,1,2022-11-21T13:24:31,R_yJgj7CCKWQ91KtX,3,1600310,12,19,110,297405,7,3,4,4,4,3,4,3,4,,,,,,,,,,,,,,,,,,,,3,4,4,4,,,,4,4,3,3,4,4,4,4,4,4,3,4,3,4,2,3,4,3,3,4,3,4,3,3,3,3,4,4,4,4,4,4,4,2,"2,4"
|
||||
2022-11-21 8:57:59,2022-11-21 9:02:56,0,131.239.118.46,40,297,0,2022-11-22T9:2:57,R_2CEu0sVwZkjRhvt,3,1600310,11,8,111,281578,6,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,,3,4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2022-11-21 10:03:00,2022-11-21 10:12:16,0,208.118.224.220,100,555,1,2022-11-21T10:12:16,butler_student_survey_response_1,3,1600310,7,25,110,72509,7,3,3,,3,3,3,3,3,3,,3,3,3,3,3,3,2,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,,,,,,,,,,,,,,,,,,,3,3,3,3,3,3,1,3,3,3,3,,,,,,,2,
|
||||
2022-11-21 14:59:02,2022-11-21 15:08:02,0,71.233.3.7,40,540,0,2022-11-22T15:8:7,butler_student_survey_response_2,3,1600310,11,28,110,275751,7,,,,,,,,,,,,,,,,,,,,,,,,3,3,3,2,,,,,,,,,,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2022-11-21 10:03:34,2022-11-21 10:12:43,0,208.118.224.218,100,548,1,2022-11-21T10:12:44,butler_student_survey_response_3,3,1600310,9,28,110,277136,7,4,4,4,4,3,4,4,4,5,5,5,5,4,4,4,4,4,4,4,,4,4,4,3,3,3,3,4,4,4,4,2,4,3,4,4,4,4,3,3,,,,,,,,,,,,,,,,,,,,,,5,5,5,4,5,5,1,2
|
||||
2022-11-18 11:06:49,2022-11-18 11:30:12,0,208.118.224.209,100,1402,1,2022-11-18T11:30:13,butler_student_survey_response_4,3,1600310,9,4,112,287185,5,3,3,3,4,3,5,5,5,5,4,5,4,4,3,4,4,3,4,4,2,3,3,3,4,4,4,4,3,3,3,3,3,3,3,3,3,4,3,3,,,,,,,,,,,,,,,,,,,,,,,5,4,4,4,4,4,1,2
|
||||
2022-11-21 13:12:42,2022-11-21 13:24:30,0,131.239.118.9,100,707,1,2022-11-21T13:24:31,butler_student_survey_response_5,3,1600310,12,19,110,297405,7,3,4,4,4,3,4,3,4,,,,,,,,,,,,,,,,,,,,3,4,4,4,,,,4,4,3,3,4,4,4,4,4,4,3,4,3,4,2,3,4,3,3,4,3,4,3,3,3,3,4,4,4,4,4,4,4,2,"2,4"
|
||||
2022-11-21 8:57:59,2022-11-21 9:02:56,0,131.239.118.46,40,297,0,2022-11-22T9:2:57,butler_student_survey_response_6,3,1600310,11,8,111,281578,6,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,,3,4,,,,,,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
2022-11-21 13:12:42,2022-11-21 13:24:30,0,131.239.118.9,100,707,1,2022-11-21T13:24:31,butler_student_survey_response_7,3,1600310,12,19,110,297405,,3,4,4,4,3,4,3,4,,,,,,,,,,,,,,,,,,,,3,4,4,4,,,,4,4,3,3,4,4,4,4,4,4,3,4,3,4,2,3,4,3,3,4,3,4,3,3,3,3,4,4,4,4,4,4,4,2,"2,4"
|
||||
2022-11-21 13:12:42,2022-11-21 13:24:30,0,131.239.118.9,100,707,1,2022-11-21T13:24:31,butler_student_survey_response_8,3,1600310,12,19,110,297405,0,3,4,4,4,3,4,3,4,,,,,,,,,,,,,,,,,,,,3,4,4,4,,,,4,4,3,3,4,4,4,4,4,4,3,4,3,4,2,3,4,3,3,4,3,4,3,3,3,3,4,4,4,4,4,4,4,2,"2,4"
|
||||
|
|
|
|||
|
|
|
@ -7,101 +7,175 @@ describe SurveyResponsesDataLoader do
|
|||
Rails.root.join('spec', 'fixtures', 'test_2022-23_butler_student_survey_responses.csv')
|
||||
end
|
||||
|
||||
let(:ay_2020_21) { AcademicYear.find_by_range '2020-21' }
|
||||
let(:ay_2020_21) { create(:academic_year, range: '2020-21') }
|
||||
let(:ay_2022_23) { create(:academic_year, range: '2022-23') }
|
||||
|
||||
let(:attleboro_high_school) { School.find_by_slug 'attleboro-high-school' }
|
||||
let(:butler_middle_school) { School.find_by_slug 'butler-middle-school' }
|
||||
|
||||
let(:t_pcom_q3) { SurveyItem.find_by_survey_item_id 't-pcom-q3' }
|
||||
let(:t_pcom_q2) { SurveyItem.find_by_survey_item_id 't-pcom-q2' }
|
||||
let(:s_phys_q1) { SurveyItem.find_by_survey_item_id 's-phys-q1' }
|
||||
let(:s_phys_q2) { SurveyItem.find_by_survey_item_id 's-phys-q2' }
|
||||
|
||||
let(:female) { Gender.find_by_qualtrics_code 1 }
|
||||
let(:male) { Gender.find_by_qualtrics_code 2 }
|
||||
let(:another_gender) { Gender.find_by_qualtrics_code 3 }
|
||||
let(:non_binary) { Gender.find_by_qualtrics_code 4 }
|
||||
let(:unknown_gender) { Gender.find_by_qualtrics_code 99 }
|
||||
|
||||
before :all do
|
||||
Rails.application.load_seed
|
||||
let(:school) { create(:school, slug: 'lee-elementary-school', dese_id: 1_500_025) }
|
||||
let(:lowell) { create(:district, name: 'Lowell', slug: 'lowell') }
|
||||
let(:second_school) { create(:school, slug: 'lee-middle-high-school', dese_id: 1_500_505, district: lowell) }
|
||||
let(:butler_school) do
|
||||
create(:school, name: 'Butler Elementary School', slug: 'butler-elementary-school', dese_id: 1_600_310,
|
||||
district: lowell)
|
||||
end
|
||||
|
||||
describe 'self.load_data' do
|
||||
context 'loading teacher survey responses' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_teacher_responses
|
||||
end
|
||||
it 'ensures teacher responses load correctly' do
|
||||
assigns_academic_year_to_survey_item_responses
|
||||
assigns_school_to_the_survey_item_responses
|
||||
loads_survey_item_responses_for_a_given_survey_response
|
||||
loads_all_survey_item_responses_for_a_given_survey_item
|
||||
captures_likert_scores_for_survey_item_responses
|
||||
is_idempotent
|
||||
end
|
||||
let(:t_pcom_q3) { create(:survey_item, survey_item_id: 't-pcom-q3') }
|
||||
let(:t_pcom_q2) { create(:survey_item, survey_item_id: 't-pcom-q2') }
|
||||
let(:t_coll_q1) { create(:survey_item, survey_item_id: 't-coll-q1') }
|
||||
let(:t_coll_q2) { create(:survey_item, survey_item_id: 't-coll-q2') }
|
||||
let(:t_coll_q3) { create(:survey_item, survey_item_id: 't-coll-q3') }
|
||||
let(:t_sach_q1) { create(:survey_item, survey_item_id: 't-sach-q1') }
|
||||
let(:t_sach_q2) { create(:survey_item, survey_item_id: 't-sach-q2') }
|
||||
let(:t_sach_q3) { create(:survey_item, survey_item_id: 't-sach-q3') }
|
||||
|
||||
let(:s_phys_q1) { create(:survey_item, survey_item_id: 's-phys-q1') }
|
||||
let(:s_phys_q2) { create(:survey_item, survey_item_id: 's-phys-q2') }
|
||||
let(:s_phys_q3) { create(:survey_item, survey_item_id: 's-phys-q3') }
|
||||
let(:s_phys_q4) { create(:survey_item, survey_item_id: 's-phys-q4') }
|
||||
let(:s_vale_q1) { create(:survey_item, survey_item_id: 's-phys-q1') }
|
||||
let(:s_vale_q2) { create(:survey_item, survey_item_id: 's-phys-q2') }
|
||||
let(:s_vale_q3) { create(:survey_item, survey_item_id: 's-phys-q3') }
|
||||
let(:s_vale_q4) { create(:survey_item, survey_item_id: 's-phys-q4') }
|
||||
let(:s_acst_q1) { create(:survey_item, survey_item_id: 's-acst-q1') }
|
||||
let(:s_acst_q2) { create(:survey_item, survey_item_id: 's-acst-q2') }
|
||||
let(:s_acst_q3) { create(:survey_item, survey_item_id: 's-acst-q3') }
|
||||
let(:s_acst_q4) { create(:survey_item, survey_item_id: 's-acst-q4') }
|
||||
let(:s_emsa_q1) { create(:survey_item, survey_item_id: 's-emsa-q1') }
|
||||
let(:s_emsa_q2) { create(:survey_item, survey_item_id: 's-emsa-q2') }
|
||||
let(:s_emsa_q3) { create(:survey_item, survey_item_id: 's-emsa-q3') }
|
||||
|
||||
let(:female) { create(:gender, qualtrics_code: 1) }
|
||||
let(:male) { create(:gender, qualtrics_code: 2) }
|
||||
let(:another_gender) { create(:gender, qualtrics_code: 3) }
|
||||
let(:non_binary) { create(:gender, qualtrics_code: 4) }
|
||||
let(:unknown_gender) { create(:gender, qualtrics_code: 99) }
|
||||
|
||||
let(:setup) do
|
||||
ay_2020_21
|
||||
ay_2022_23
|
||||
school
|
||||
second_school
|
||||
butler_school
|
||||
t_pcom_q3
|
||||
t_pcom_q2
|
||||
t_coll_q1
|
||||
t_coll_q2
|
||||
t_coll_q3
|
||||
t_sach_q1
|
||||
t_sach_q2
|
||||
t_sach_q3
|
||||
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 # ./spec/services/survey_responses_data_loader_spec.rb:163:in `block (4 levels) in <top (required)>'
|
||||
s_acst_q4
|
||||
s_emsa_q1
|
||||
s_emsa_q2
|
||||
s_emsa_q3
|
||||
female
|
||||
male
|
||||
another_gender
|
||||
non_binary
|
||||
unknown_gender
|
||||
end
|
||||
|
||||
before :each do
|
||||
AcademicYear.reset_academic_years
|
||||
|
||||
setup
|
||||
end
|
||||
|
||||
describe 'loading teacher survey responses' do
|
||||
before do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_teacher_responses
|
||||
end
|
||||
|
||||
context 'student survey responses' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_student_responses
|
||||
end
|
||||
it 'ensures teacher responses load correctly' do
|
||||
assigns_academic_year_to_survey_item_responses
|
||||
assigns_school_to_the_survey_item_responses
|
||||
loads_survey_item_responses_for_a_given_survey_response
|
||||
loads_all_survey_item_responses_for_a_given_survey_item
|
||||
captures_likert_scores_for_survey_item_responses
|
||||
is_idempotent
|
||||
end
|
||||
end
|
||||
|
||||
it 'ensures student responses load correctly' do
|
||||
assigns_academic_year_to_student_survey_item_responses
|
||||
assigns_school_to_student_survey_item_responses
|
||||
loads_student_survey_item_response_values
|
||||
student_survey_item_response_count_matches_expected
|
||||
captures_likert_scores_for_student_survey_item_responses
|
||||
assigns_grade_level_to_responses
|
||||
assigns_gender_to_responses
|
||||
is_idempotent_for_students
|
||||
end
|
||||
|
||||
context 'when updating student survey responses from another csv file' do
|
||||
before do
|
||||
SurveyResponsesDataLoader.load_data filepath: Rails.root.join('spec', 'fixtures',
|
||||
'secondary_test_2020-21_student_survey_responses.csv')
|
||||
end
|
||||
it 'updates the likert score to the score on the new csv file' do
|
||||
s_emsa_q1 = SurveyItem.find_by_survey_item_id 's-emsa-q1'
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
end
|
||||
end
|
||||
describe 'student survey responses' do
|
||||
before do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_student_responses
|
||||
end
|
||||
|
||||
context 'when using Lowell rules to skip rows in the csv file' do
|
||||
it 'ensures student responses load correctly' do
|
||||
assigns_academic_year_to_student_survey_item_responses
|
||||
assigns_school_to_student_survey_item_responses
|
||||
loads_student_survey_item_response_values
|
||||
student_survey_item_response_count_matches_expected
|
||||
captures_likert_scores_for_student_survey_item_responses
|
||||
assigns_grade_level_to_responses
|
||||
assigns_gender_to_responses
|
||||
is_idempotent_for_students
|
||||
end
|
||||
|
||||
context 'when updating student survey responses from another csv file' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_student_responses,
|
||||
SurveyResponsesDataLoader.load_data filepath: Rails.root.join('spec', 'fixtures',
|
||||
'secondary_test_2020-21_student_survey_responses.csv')
|
||||
end
|
||||
it 'updates the likert score to the score on the new csv file' do
|
||||
s_emsa_q1 = SurveyItem.find_by_survey_item_id 's-emsa-q1'
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5',
|
||||
survey_item: s_emsa_q1).first.likert_score).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
# figure out why this is failing
|
||||
describe 'when using Lowell rules to skip rows in the csv file' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_student_responses,
|
||||
rules: [Rule::SkipNonLowellSchools]
|
||||
end
|
||||
|
||||
it 'rejects any non-lowell school' do
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_1').count).to eq 0
|
||||
expect(SurveyItemResponse.count).to eq 69
|
||||
end
|
||||
|
||||
it 'loads the correct number of responses for lowell schools' do
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_2').count).to eq 0
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3').count).to eq 12
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4').count).to eq 15
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5').count).to eq 14
|
||||
end
|
||||
|
||||
context 'when loading 22-23 butler survey responses' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_butler_student_responses,
|
||||
rules: [Rule::SkipNonLowellSchools]
|
||||
end
|
||||
|
||||
it 'rejects any non-lowell school' do
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_1').count).to eq 0
|
||||
expect(SurveyItemResponse.count).to eq 128
|
||||
it 'loads all the responses for Butler' do
|
||||
expect(SurveyItemResponse.where(school: butler_school).count).to eq 56
|
||||
end
|
||||
|
||||
it 'loads the correct number of responses for lowell schools' do
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_2').count).to eq 0
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3').count).to eq 25
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4').count).to eq 22
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5').count).to eq 27
|
||||
end
|
||||
|
||||
context 'when loading 22-23 bundler survey responses' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_butler_student_responses,
|
||||
rules: [Rule::SkipNonLowellSchools]
|
||||
end
|
||||
|
||||
it 'loads all the responses for Butler' do
|
||||
expect(SurveyItemResponse.count).to eq 310
|
||||
end
|
||||
it 'blank entries for grade get loaded as nils, not zero values' do
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_1').first.grade).to eq 7
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_2').first.grade).to eq 7
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_3').first.grade).to eq 7
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_4').first.grade).to eq 5
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_5').first.grade).to eq 7
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_6').first.grade).to eq 6
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_7').first.grade).to eq nil
|
||||
expect(SurveyItemResponse.where(response_id: 'butler_student_survey_response_8').first.grade).to eq 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -112,15 +186,15 @@ def assigns_academic_year_to_survey_item_responses
|
|||
end
|
||||
|
||||
def assigns_school_to_the_survey_item_responses
|
||||
expect(SurveyItemResponse.find_by_response_id('teacher_survey_response_1').school).to eq attleboro_high_school
|
||||
expect(SurveyItemResponse.find_by_response_id('teacher_survey_response_1').school).to eq school
|
||||
end
|
||||
|
||||
def loads_survey_item_responses_for_a_given_survey_response
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_1').count).to eq 5
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_2').count).to eq 0
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_3').count).to eq 69
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_4').count).to eq 69
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_5').count).to eq 69
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_3').count).to eq 8
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_4').count).to eq 8
|
||||
expect(SurveyItemResponse.where(response_id: 'teacher_survey_response_5').count).to eq 8
|
||||
end
|
||||
|
||||
def loads_all_survey_item_responses_for_a_given_survey_item
|
||||
|
|
@ -158,15 +232,15 @@ def assigns_academic_year_to_student_survey_item_responses
|
|||
end
|
||||
|
||||
def assigns_school_to_student_survey_item_responses
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_3').school).to eq butler_middle_school
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_3').school).to eq second_school
|
||||
end
|
||||
|
||||
def loads_student_survey_item_response_values
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_1').count).to eq 3
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_2').count).to eq 0
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3').count).to eq 25
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4').count).to eq 22
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5').count).to eq 27
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_3').count).to eq 12
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_4').count).to eq 15
|
||||
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5').count).to eq 14
|
||||
end
|
||||
|
||||
def student_survey_item_response_count_matches_expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue