mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 15:38:21 -07:00
fix: make sure all likert scores get counted even when the survey item id has different capitalization. Add tests for uploading parent data. Change the parent response rate calcuation to count all students in the school instead of just for the grades that were given the student survey
This commit is contained in:
parent
8984023aa4
commit
e741b60bec
10 changed files with 118 additions and 8 deletions
|
|
@ -51,6 +51,7 @@ class Seeder
|
|||
|
||||
def seed_sqm_framework(csv_file)
|
||||
admin_data_item_ids = []
|
||||
survey_item_ids = []
|
||||
CSV.parse(File.read(csv_file), headers: true) do |row|
|
||||
next if row["Source"] == "No source"
|
||||
|
||||
|
|
@ -105,6 +106,7 @@ class Seeder
|
|||
survey_item.ideal_low_benchmark = ideal_low if ideal_low
|
||||
survey_item.on_short_form = marked? on_short_form
|
||||
survey_item.update! prompt: row["Question/item (23-24)"].strip
|
||||
survey_item_ids << survey_item.id
|
||||
end
|
||||
|
||||
active_admin = row["Active admin & survey items"]
|
||||
|
|
@ -122,6 +124,7 @@ class Seeder
|
|||
end
|
||||
AdminDataValue.where.not(admin_data_item_id: admin_data_item_ids).delete_all
|
||||
AdminDataItem.where.not(id: admin_data_item_ids).delete_all
|
||||
SurveyItem.where.not(id: survey_item_ids).delete_all
|
||||
end
|
||||
|
||||
def seed_demographics(csv_file)
|
||||
|
|
|
|||
|
|
@ -47,10 +47,6 @@ class Overview::OverviewPresenter
|
|||
ParentResponseRatePresenter.new(school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def parent_response_rate_presenter
|
||||
ResponseRatePresenter.new(focus: :parent, school: @school, academic_year: @academic_year)
|
||||
end
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
score = measure.score(school: @school, academic_year: @academic_year)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,3 +22,4 @@ class ParentResponseRatePresenter < ResponseRatePresenter
|
|||
"parent"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -40,3 +40,4 @@ class StudentResponseRatePresenter < ResponseRatePresenter
|
|||
"student"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,3 +18,4 @@ class TeacherResponseRatePresenter < ResponseRatePresenter
|
|||
"teacher"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ class SurveyItemValues
|
|||
|
||||
def initialize(row:, headers:, survey_items:, schools:, academic_years: AcademicYear.all)
|
||||
@row = row
|
||||
# Remove any newlines in headers
|
||||
headers = headers.map { |item| item.delete("\n") if item.present? }
|
||||
# Remove any newlines in headers and
|
||||
@headers = normalize_headers(headers:)
|
||||
@headers = include_all_headers(headers:)
|
||||
@survey_items = survey_items
|
||||
@schools = schools
|
||||
|
|
@ -25,6 +25,13 @@ class SurveyItemValues
|
|||
copy_data_to_main_column(main: /Gender/i, secondary: /Gender Secondary|Gender-1/i)
|
||||
end
|
||||
|
||||
def normalize_headers(headers:)
|
||||
headers
|
||||
.select(&:present?)
|
||||
.map { |item| item.strip }
|
||||
.map { |item| item.downcase if item.match(/[stp]-/i) }
|
||||
end
|
||||
|
||||
def copy_data_to_main_column(main:, secondary:)
|
||||
main_column = headers.find { |header| main.match(header) }
|
||||
row[main_column] = value_from(pattern: secondary) if row[main_column].nil?
|
||||
|
|
@ -97,7 +104,7 @@ class SurveyItemValues
|
|||
end
|
||||
|
||||
def likert_score(survey_item_id:)
|
||||
row[survey_item_id] || row["#{survey_item_id}-1"]
|
||||
row[survey_item_id] || row["#{survey_item_id}-1"] || value_from(pattern: /#{survey_item_id}/i)
|
||||
end
|
||||
|
||||
def school
|
||||
|
|
@ -196,7 +203,7 @@ class SurveyItemValues
|
|||
output = nil
|
||||
matches = headers.select do |header|
|
||||
pattern.match(header)
|
||||
end.map { |item| item.delete("\n") }
|
||||
end
|
||||
|
||||
matches.each do |match|
|
||||
output ||= row[match]&.strip
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ class SurveyResponsesDataLoader
|
|||
.parse(headers)
|
||||
.first
|
||||
.filter(&:present?)
|
||||
.map(&:downcase)
|
||||
.filter { |header| header.start_with?("t-", "s-", "p-") }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue