parent
a258b32b39
commit
cab0a3955e
@ -0,0 +1,39 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
module Column
|
||||||
|
module Parent
|
||||||
|
class SocioEconomicStatus < Base
|
||||||
|
attr_reader :socio_economic_status, :label
|
||||||
|
|
||||||
|
def initialize(socio_economic_status:, label:, show_irrelevancy_message:)
|
||||||
|
@socio_economic_status = socio_economic_status
|
||||||
|
@label = label
|
||||||
|
@show_irrelevancy_message = show_irrelevancy_message
|
||||||
|
end
|
||||||
|
|
||||||
|
def n_size(construct:, school:, academic_year:)
|
||||||
|
SurveyItemResponse.joins(:parent).where(parent: { socio_economic_status: }, survey_item: construct.parent_survey_items, school:, academic_year:).select(:parent_id).distinct.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def score(construct:, school:, academic_year:)
|
||||||
|
return Score::NIL_SCORE if n_size(construct:, school:, academic_year:) < 10
|
||||||
|
|
||||||
|
averages = SurveyItemResponse.averages_for_socio_economic_status(construct.parent_survey_items, school, academic_year,
|
||||||
|
socio_economic_status)
|
||||||
|
average = bubble_up_averages(construct:, averages:).round(2)
|
||||||
|
Score.new(average:,
|
||||||
|
meets_teacher_threshold: false,
|
||||||
|
meets_student_threshold: true,
|
||||||
|
meets_admin_data_threshold: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def designations
|
||||||
|
language.map(&:designation)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Analyze
|
||||||
|
module Graph
|
||||||
|
class ParentsBySocioEconomicStatus
|
||||||
|
def to_s
|
||||||
|
"Parents by Socio-Economic Status"
|
||||||
|
end
|
||||||
|
|
||||||
|
def slug
|
||||||
|
"parents-by-socio-economic-status"
|
||||||
|
end
|
||||||
|
|
||||||
|
def columns
|
||||||
|
[].tap do |array|
|
||||||
|
array << Analyze::Graph::Column::Parent::SocioEconomicStatus.new(socio_economic_status: 0, label: ["No Advantage"], show_irrelevancy_message: false)
|
||||||
|
array << Analyze::Graph::Column::Parent::SocioEconomicStatus.new(socio_economic_status: 1, label: ["Low Advantage"], show_irrelevancy_message: false)
|
||||||
|
array << Analyze::Graph::Column::Parent::SocioEconomicStatus.new(socio_economic_status: 2, label: ["Mediumn Advantage"], show_irrelevancy_message: false)
|
||||||
|
array << Analyze::Graph::Column::Parent::SocioEconomicStatus.new(socio_economic_status: 3, label: ["High Advantage"], show_irrelevancy_message: false)
|
||||||
|
|
||||||
|
array << Analyze::Graph::Column::Parent::SocioEconomicStatus.new(socio_economic_status: [0, 1, 2, 3, nil], label: ["All Students"], show_irrelevancy_message: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def source
|
||||||
|
Analyze::Source::SurveyData.new(slices: nil, graph: self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def slice
|
||||||
|
Analyze::Slice::ParentsByGroup.new(graph: self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def group
|
||||||
|
Analyze::Group::Base.new(name: "Parents By Socio-Economic Status", slug: "parents-by-socio-economic-status", graph: self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class AddSocioEconomicStatusToParent < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
add_column :parents, :socio_economic_status, :integer, default: nil
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in new issue