WIP: show language graph on analyze page

mciea-main
rebuilt 8 months ago
parent e90e6a4f0f
commit 6b2d51c331

@ -15,8 +15,10 @@ class Language < ApplicationRecord
"Portuguese" "Portuguese"
in /^3$/i in /^3$/i
"Spanish" "Spanish"
in /^99$|^100$/i in /^99$/i
"Unknown" "Prefer not to disclose"
in /|^100$/i
"Prefer to self-describe"
else else
puts "************************************" puts "************************************"
puts "******** ERROR **********" puts "******** ERROR **********"

@ -0,0 +1,49 @@
# frozen_string_literal: true
module Analyze
module Graph
module Column
class Language < ColumnBase
attr_reader :language, :label
def initialize(languages:, label:)
@language = languages
@label = label
end
def basis
"parent surveys"
end
def show_irrelevancy_message?(measure:)
false
end
def show_insufficient_data_message?(measure:, school:, academic_years:)
false
end
def type
:parent
end
def n_size(measure:, school:, academic_year:)
SurveyItemResponse.joins([parent: :languages]).where(languages: { designation: designations }, school:, academic_year:).select(:parent_id).distinct.count
end
def score(measure:, school:, academic_year:)
average = SurveyItemResponse.joins([parent: :languages]).where(languages: { designation: designations }, school:, academic_year:).average(:likert_score)
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

@ -5,9 +5,10 @@ module Analyze
class ParentsByLanguage class ParentsByLanguage
attr_reader :speds attr_reader :speds
def initialize(speds:) ALL_LANGUAGES = Language.all
@speds = speds ENGLISH_LANGUAGES = ALL_LANGUAGES.select { |language| language.designation == "English" }
end UNKNOWN_LANGUAGES = ALL_LANGUAGES.select { |language| language.designation == "Prefer not to disclose" }
NON_ENGLISH_LANGUAGES = (ALL_LANGUAGES - ENGLISH_LANGUAGES - UNKNOWN_LANGUAGES)
def to_s def to_s
"Parents by Language" "Parents by Language"
@ -19,10 +20,9 @@ module Analyze
def columns def columns
[].tap do |array| [].tap do |array|
speds.each do |sped| array << Analyze::Graph::Column::Language.new(languages: ENGLISH_LANGUAGES, label: ["English", "Speaking"])
array << Analyze::Graph::Column::Sped.new(sped:) array << Analyze::Graph::Column::Language.new(languages: NON_ENGLISH_LANGUAGES, label: ["Non English", "Speaking"])
end array << Analyze::Graph::Column::Language.new(languages: UNKNOWN_LANGUAGES, label: ["Unknown"])
array << Analyze::Graph::Column::AllStudent.new
end end
end end

@ -96,11 +96,15 @@ module Analyze
end end
def groups def groups
@groups = graphs.map(&:group) @groups ||=
begin
selectable_groups = graph.class.name.demodulize.first(4)
graphs.select { |graph| graph.class.name.demodulize.first(4) == selectable_groups }.map(&:group)
.reject { |group| group.name.nil? } .reject { |group| group.name.nil? }
.sort_by { |group| group.name } .sort_by { |group| group.name }
.uniq .uniq
end end
end
def group def group
@group ||= groups.reduce(groups.first) do |acc, group| @group ||= groups.reduce(groups.first) do |acc, group|
@ -159,7 +163,8 @@ module Analyze
Analyze::Graph::StudentsByGender.new(genders: selected_genders), Analyze::Graph::StudentsByGender.new(genders: selected_genders),
Analyze::Graph::StudentsByIncome.new(incomes: selected_incomes), Analyze::Graph::StudentsByIncome.new(incomes: selected_incomes),
Analyze::Graph::StudentsBySped.new(speds: selected_speds), Analyze::Graph::StudentsBySped.new(speds: selected_speds),
Analyze::Graph::StudentsByEll.new(ells: selected_ells)] Analyze::Graph::StudentsByEll.new(ells: selected_ells),
Analyze::Graph::ParentsByLanguage.new]
end end
def graph def graph

@ -2,7 +2,7 @@
<div class="bg-gray p-3"> <div class="bg-gray p-3">
<% @presenter.sources.each do |source| %> <% @presenter.sources.each do |source| %>
<%# Source options; e.g. 'All Data' or 'Survey Data only' %>
<%= form_with(url: district_school_analyze_index_path, <%= form_with(url: district_school_analyze_index_path,
method: :get, method: :get,
data: { data: {
@ -15,6 +15,7 @@
<% params.reject{|key,_| key == "graph"}.each do |key, value| %> <% params.reject{|key,_| key == "graph"}.each do |key, value| %>
<input type="hidden" id="year" name="<%= key %>" value="<%= value %>"> <input type="hidden" id="year" name="<%= key %>" value="<%= value %>">
<% end %> <% end %>
<input type="radio" <input type="radio"
id="<%= source.slug %>" id="<%= source.slug %>"
class="form-check-input" class="form-check-input"
@ -22,7 +23,6 @@
value="<%= source.graph.slug %>" value="<%= source.graph.slug %>"
<%= source.slug == @presenter.source.slug ? "checked" : "" %>> <%= source.slug == @presenter.source.slug ? "checked" : "" %>>
<label for="<%= source.slug %>"><%= source.to_s %></label> <label for="<%= source.slug %>"><%= source.to_s %></label>
<% end %> <% end %>

@ -1,11 +1,11 @@
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status,Housing,Language
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education 1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own,English
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education 2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent,Portuguese
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown 3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown,Spanish
4,Hispanic or Latinx,99,Unknown,,, 4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose
5,White or Caucasian,,,,, 5,White or Caucasian,,,,,,,Prefer to self-describe
6,Prefer not to disclose,,,,, 6,Prefer not to disclose,,,,,,,
7,Prefer to self-describe,,,,, 7,Prefer to self-describe,,,,,,,
8,Middle Eastern,,,,, 8,Middle Eastern,,,,,,,
99,Race/Ethnicity Not Listed,,,,, 99,Race/Ethnicity Not Listed,,,,,,,
100,Multiracial,,,,, 100,Multiracial,,,,,,,

1 Race Qualtrics Code Race/Ethnicity Gender Qualtrics Code Sex/Gender Income ELL Special Ed Status Housing Language
2 1 American Indian or Alaskan Native 2 Male Economically Disadvantaged - N ELL Special Education Own English
3 2 Asian or Pacific Islander 1 Female Economically Disadvantaged - Y Not ELL Not Special Education Rent Portuguese
4 3 Black or African American 4 Non-Binary Unknown Unknown Unknown Unknown Spanish
5 4 Hispanic or Latinx 99 Unknown Prefer not to disclose
6 5 White or Caucasian Prefer to self-describe
7 6 Prefer not to disclose
8 7 Prefer to self-describe
9 8 Middle Eastern
10 99 Race/Ethnicity Not Listed
11 100 Multiracial
Loading…
Cancel
Save