Make sure blank grades in csv load as nils instead of zeros

pull/1/head
rebuilt 3 years ago
parent 669fb7f1f0
commit 01851d8527

@ -61,7 +61,12 @@ class SurveyItemValues
end
def grade
@grade ||= raw_grade = (row['grade'] || row['Grade'] || row['What grade are you in?']).to_i
@grade ||= begin
raw_grade = (row['grade'] || row['Grade'] || row['What grade are you in?'])
return nil if raw_grade.blank?
raw_grade = raw_grade.to_i
end
end
def gender

@ -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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
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,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
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"

1 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
2 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 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
3 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 butler_student_survey_response_2 3 1600310 11 28 110 275751 7 3 3 3 2
4 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 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 5 5 5 4 5 5 1 2
5 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 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
6 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 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
7 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 butler_student_survey_response_6 3 1600310 11 8 111 281578 6 3 3 4
8 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
9 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

@ -93,14 +93,25 @@ describe SurveyResponsesDataLoader do
expect(SurveyItemResponse.where(response_id: 'student_survey_response_5').count).to eq 27
end
context 'when loading 22-23 bundler survey responses' do
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 'loads all the responses for Butler' do
expect(SurveyItemResponse.count).to eq 310
expect(SurveyItemResponse.count).to eq 400
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

Loading…
Cancel
Save