diff --git a/app/models/language.rb b/app/models/language.rb index a7c3cbe9..a361ac6e 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -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 **********" diff --git a/app/presenters/analyze/graph/column/language.rb b/app/presenters/analyze/graph/column/language.rb new file mode 100644 index 00000000..caa5b1b0 --- /dev/null +++ b/app/presenters/analyze/graph/column/language.rb @@ -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 diff --git a/app/presenters/analyze/graph/parents_by_language.rb b/app/presenters/analyze/graph/parents_by_language.rb index 28ca7aa6..7dde24fd 100644 --- a/app/presenters/analyze/graph/parents_by_language.rb +++ b/app/presenters/analyze/graph/parents_by_language.rb @@ -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 diff --git a/app/presenters/analyze/presenter.rb b/app/presenters/analyze/presenter.rb index d3dde077..b501794c 100644 --- a/app/presenters/analyze/presenter.rb +++ b/app/presenters/analyze/presenter.rb @@ -96,10 +96,14 @@ module Analyze end def groups - @groups = graphs.map(&:group) - .reject { |group| group.name.nil? } - .sort_by { |group| group.name } - .uniq + @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 @@ -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 diff --git a/app/views/analyze/_data_filters.html.erb b/app/views/analyze/_data_filters.html.erb index f1eecfa4..a1698a36 100644 --- a/app/views/analyze/_data_filters.html.erb +++ b/app/views/analyze/_data_filters.html.erb @@ -1,32 +1,8 @@

Data Filters

- <% @presenter.sources.each do |source| %> - -<%= form_with(url: district_school_analyze_index_path, - method: :get, - data: { - turbo_frame: "results", - turbo_action: "advance", - controller: "analyze", - action: "input->analyze#submit" - }) do |f| %> - - <% params.reject{|key,_| key == "graph"}.each do |key, value| %> - - <% end %> - > - - - <% end %> - - -<% if source.slug != "all-data" %> +<% @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: { @@ -36,28 +12,52 @@ action: "input->analyze#submit" }) do |f| %> - <% params.reject{|key,_| key == "graph"}.each do |key, value| %> - - <% end %> + <% params.reject{|key,_| key == "graph"}.each do |key, value| %> + + <% end %> - <% @presenter.slices.each do | slice | %> -
- <%= slice.slug == "all-data" ? "hidden" : "" %>> - - -
+ id="<%= source.slug %>" + class="form-check-input" + name="graph" + value="<%= source.graph.slug %>" + <%= source.slug == @presenter.source.slug ? "checked" : "" %>> + + <% end %> + + + <% if source.slug != "all-data" %> + <%= form_with(url: district_school_analyze_index_path, + method: :get, + data: { + turbo_frame: "results", + turbo_action: "advance", + controller: "analyze", + action: "input->analyze#submit" + }) do |f| %> + + <% params.reject{|key,_| key == "graph"}.each do |key, value| %> + + <% end %> + + <% @presenter.slices.each do | slice | %> +
+ + <%= slice.slug == "all-data" ? "hidden" : "" %>> + + +
+ <% end %> <% end %> - <% end %> <% end %> <% end %> - <%= render partial: "group_selectors" %> +<%= render partial: "group_selectors" %>
diff --git a/data/demographics.csv b/data/demographics.csv index 742624b4..9823c81c 100644 --- a/data/demographics.csv +++ b/data/demographics.csv @@ -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,,,,,,,