mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
Modify survey item response csv files for 2019-20 to correct incorrect likert scores
This commit is contained in:
parent
7cc90c7d0b
commit
36da912253
5 changed files with 14643 additions and 14623 deletions
|
|
@ -36,19 +36,23 @@ class SurveyResponsesDataLoader
|
|||
return if school.nil?
|
||||
|
||||
survey_items.map do |survey_item|
|
||||
next if SurveyItemResponse.where(response_id:, survey_item:).exists?
|
||||
|
||||
likert_score = row[survey_item.survey_item_id]
|
||||
next if likert_score.nil?
|
||||
next unless likert_score.valid_likert_score?
|
||||
|
||||
SurveyItemResponse.new(
|
||||
response_id:,
|
||||
academic_year:,
|
||||
school:,
|
||||
survey_item:,
|
||||
likert_score:
|
||||
)
|
||||
survey_item_response = SurveyItemResponse.where(response_id:, survey_item:).first
|
||||
if survey_item_response.present?
|
||||
survey_item_response.update!(likert_score:) if survey_item_response.likert_score != likert_score
|
||||
next
|
||||
else
|
||||
SurveyItemResponse.new(
|
||||
response_id:,
|
||||
academic_year:,
|
||||
school:,
|
||||
survey_item:,
|
||||
likert_score:
|
||||
)
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
6
spec/fixtures/secondary_test_2020-21_student_survey_responses.csv
vendored
Normal file
6
spec/fixtures/secondary_test_2020-21_student_survey_responses.csv
vendored
Normal file
|
|
@ -0,0 +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,#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,,,,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,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,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,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,
|
||||
|
|
|
@ -125,6 +125,16 @@ describe SurveyResponsesDataLoader do
|
|||
|
||||
expect(SurveyItemResponse.count).to eq number_of_survey_item_responses
|
||||
end
|
||||
|
||||
context 'when updating student survey responses from another csv file' do
|
||||
it 'updates the likert score to the score on the new csv file' do
|
||||
SurveyResponsesDataLoader.load_data filepath: Rails.root.join('spec', 'fixtures',
|
||||
'secondary_test_2020-21_student_survey_responses.csv')
|
||||
expect(SurveyItemResponse.joins(:survey_item).where(response_id: 'student_survey_response_3').where("survey_item.survey_item_id": 's-emsa-q1').first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.joins(:survey_item).where(response_id: 'student_survey_response_4').where("survey_item.survey_item_id": 's-emsa-q1').first.likert_score).to eq 1
|
||||
expect(SurveyItemResponse.joins(:survey_item).where(response_id: 'student_survey_response_5').where("survey_item.survey_item_id": 's-emsa-q1').first.likert_score).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue