mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
WIP: show language graph on analyze page
This commit is contained in:
parent
e90e6a4f0f
commit
6b2d51c331
6 changed files with 124 additions and 68 deletions
|
|
@ -15,8 +15,10 @@ class Language < ApplicationRecord
|
|||
"Portuguese"
|
||||
in /^3$/i
|
||||
"Spanish"
|
||||
in /^99$|^100$/i
|
||||
"Unknown"
|
||||
in /^99$/i
|
||||
"Prefer not to disclose"
|
||||
in /|^100$/i
|
||||
"Prefer to self-describe"
|
||||
else
|
||||
puts "************************************"
|
||||
puts "******** ERROR **********"
|
||||
|
|
|
|||
49
app/presenters/analyze/graph/column/language.rb
Normal file
49
app/presenters/analyze/graph/column/language.rb
Normal file
|
|
@ -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
|
||||
attr_reader :speds
|
||||
|
||||
def initialize(speds:)
|
||||
@speds = speds
|
||||
end
|
||||
ALL_LANGUAGES = Language.all
|
||||
ENGLISH_LANGUAGES = ALL_LANGUAGES.select { |language| language.designation == "English" }
|
||||
UNKNOWN_LANGUAGES = ALL_LANGUAGES.select { |language| language.designation == "Prefer not to disclose" }
|
||||
NON_ENGLISH_LANGUAGES = (ALL_LANGUAGES - ENGLISH_LANGUAGES - UNKNOWN_LANGUAGES)
|
||||
|
||||
def to_s
|
||||
"Parents by Language"
|
||||
|
|
@ -19,10 +20,9 @@ module Analyze
|
|||
|
||||
def columns
|
||||
[].tap do |array|
|
||||
speds.each do |sped|
|
||||
array << Analyze::Graph::Column::Sped.new(sped:)
|
||||
end
|
||||
array << Analyze::Graph::Column::AllStudent.new
|
||||
array << Analyze::Graph::Column::Language.new(languages: ENGLISH_LANGUAGES, label: ["English", "Speaking"])
|
||||
array << Analyze::Graph::Column::Language.new(languages: NON_ENGLISH_LANGUAGES, label: ["Non English", "Speaking"])
|
||||
array << Analyze::Graph::Column::Language.new(languages: UNKNOWN_LANGUAGES, label: ["Unknown"])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -96,11 +96,15 @@ module Analyze
|
|||
end
|
||||
|
||||
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? }
|
||||
.sort_by { |group| group.name }
|
||||
.uniq
|
||||
end
|
||||
end
|
||||
|
||||
def group
|
||||
@group ||= groups.reduce(groups.first) do |acc, group|
|
||||
|
|
@ -159,7 +163,8 @@ module Analyze
|
|||
Analyze::Graph::StudentsByGender.new(genders: selected_genders),
|
||||
Analyze::Graph::StudentsByIncome.new(incomes: selected_incomes),
|
||||
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
|
||||
|
||||
def graph
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="bg-gray p-3">
|
||||
|
||||
<% @presenter.sources.each do |source| %>
|
||||
|
||||
<%# Source options; e.g. 'All Data' or 'Survey Data only' %>
|
||||
<%= form_with(url: district_school_analyze_index_path,
|
||||
method: :get,
|
||||
data: {
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
<% params.reject{|key,_| key == "graph"}.each do |key, value| %>
|
||||
<input type="hidden" id="year" name="<%= key %>" value="<%= value %>">
|
||||
<% end %>
|
||||
|
||||
<input type="radio"
|
||||
id="<%= source.slug %>"
|
||||
class="form-check-input"
|
||||
|
|
@ -22,7 +23,6 @@
|
|||
value="<%= source.graph.slug %>"
|
||||
<%= source.slug == @presenter.source.slug ? "checked" : "" %>>
|
||||
<label for="<%= source.slug %>"><%= source.to_s %></label>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status
|
||||
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education
|
||||
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education
|
||||
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown
|
||||
4,Hispanic or Latinx,99,Unknown,,,
|
||||
5,White or Caucasian,,,,,
|
||||
6,Prefer not to disclose,,,,,
|
||||
7,Prefer to self-describe,,,,,
|
||||
8,Middle Eastern,,,,,
|
||||
99,Race/Ethnicity Not Listed,,,,,
|
||||
100,Multiracial,,,,,
|
||||
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,Own,English
|
||||
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,Unknown,Spanish
|
||||
4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose
|
||||
5,White or Caucasian,,,,,,,Prefer to self-describe
|
||||
6,Prefer not to disclose,,,,,,,
|
||||
7,Prefer to self-describe,,,,,,,
|
||||
8,Middle Eastern,,,,,,,
|
||||
99,Race/Ethnicity Not Listed,,,,,,,
|
||||
100,Multiracial,,,,,,,
|
||||
|
|
|
|||
|
Loading…
Add table
Add a link
Reference in a new issue