mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
Show parent response rate
This commit is contained in:
parent
fcf8f011c2
commit
8984023aa4
12 changed files with 98 additions and 48 deletions
2
app/models/parent.rb
Normal file
2
app/models/parent.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class Parent < ApplicationRecord
|
||||
end
|
||||
|
|
@ -8,6 +8,7 @@ class SurveyItemResponse < ActiveRecord::Base
|
|||
belongs_to :school
|
||||
belongs_to :survey_item, counter_cache: true
|
||||
belongs_to :student, foreign_key: :student_id, optional: true
|
||||
belongs_to :parent, optional: true
|
||||
belongs_to :gender, optional: true
|
||||
belongs_to :income, optional: true
|
||||
belongs_to :ell, optional: true
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ 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)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,4 +76,3 @@ class ResponseRatePresenter
|
|||
respondents.enrollment_by_grade.keys
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -67,11 +67,7 @@ class SurveyItemValues
|
|||
end
|
||||
|
||||
def survey_item_response(survey_item:)
|
||||
@survey_item_response ||= Hash.new do |memo, survey_item|
|
||||
memo[survey_item] = survey_item_responses[[response_id, survey_item.id]]
|
||||
end
|
||||
|
||||
@survey_item_response[survey_item]
|
||||
survey_item_responses[[response_id, survey_item.id]]
|
||||
end
|
||||
|
||||
def survey_item_responses
|
||||
|
|
@ -192,6 +188,10 @@ class SurveyItemValues
|
|||
@sped ||= Sped.to_designation(raw_sped)
|
||||
end
|
||||
|
||||
def number_of_children
|
||||
@number_of_children ||= value_from(pattern: /Number\s*Of\s*Children/i).to_i
|
||||
end
|
||||
|
||||
def value_from(pattern:)
|
||||
output = nil
|
||||
matches = headers.select do |header|
|
||||
|
|
|
|||
|
|
@ -87,10 +87,20 @@ class SurveyResponsesDataLoader
|
|||
end
|
||||
|
||||
def process_survey_items(row:)
|
||||
student = Student.find_or_create_by(response_id: row.response_id, lasid: row.lasid)
|
||||
student.races.delete_all
|
||||
tmp_races = row.races.map { |race| races[race] }
|
||||
student.races += tmp_races
|
||||
student = nil
|
||||
parent = nil
|
||||
if row.respondent_type == :student
|
||||
student = Student.find_or_create_by(response_id: row.response_id, lasid: row.lasid)
|
||||
student.races.delete_all
|
||||
tmp_races = row.races.map { |race| races[race] }
|
||||
student.races += tmp_races
|
||||
end
|
||||
|
||||
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.save
|
||||
end
|
||||
|
||||
row
|
||||
.survey_items
|
||||
|
|
@ -103,12 +113,12 @@ class SurveyResponsesDataLoader
|
|||
end
|
||||
|
||||
response = row.survey_item_response(survey_item:)
|
||||
create_or_update_response(survey_item_response: response, likert_score:, row:, survey_item:, student:)
|
||||
create_or_update_response(survey_item_response: response, likert_score:, row:, survey_item:, student:, parent:)
|
||||
end
|
||||
.compact
|
||||
end
|
||||
|
||||
def create_or_update_response(survey_item_response:, likert_score:, row:, survey_item:, student:)
|
||||
def create_or_update_response(survey_item_response:, likert_score:, row:, survey_item:, student:, parent:)
|
||||
gender = genders[row.gender]
|
||||
grade = row.grade
|
||||
income = incomes[row.income.parameterize]
|
||||
|
|
@ -124,6 +134,8 @@ class SurveyResponsesDataLoader
|
|||
survey_item_response.ell = ell
|
||||
survey_item_response.sped = sped
|
||||
survey_item_response.student = student
|
||||
survey_item_response.parent = parent
|
||||
|
||||
survey_item_response
|
||||
else
|
||||
SurveyItemResponse.new(
|
||||
|
|
@ -138,7 +150,8 @@ class SurveyResponsesDataLoader
|
|||
income:,
|
||||
ell:,
|
||||
sped:,
|
||||
student:
|
||||
student:,
|
||||
parent:
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue