mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
add race columns to graph
This commit is contained in:
parent
94a58a87d7
commit
26f739090b
14 changed files with 271 additions and 8 deletions
|
|
@ -10,14 +10,13 @@ module Analyze
|
|||
end
|
||||
|
||||
def columns
|
||||
[Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
Analyze::Graph::Column::Student,
|
||||
[Analyze::Graph::Column::AmericanIndian,
|
||||
Analyze::Graph::Column::Asian,
|
||||
Analyze::Graph::Column::Black,
|
||||
Analyze::Graph::Column::Hispanic,
|
||||
Analyze::Graph::Column::MiddleEastern,
|
||||
Analyze::Graph::Column::Unknown,
|
||||
Analyze::Graph::Column::White,
|
||||
Analyze::Graph::Column::Student]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
37
app/presenters/analyze/graph/column/american_indian.rb
Normal file
37
app/presenters/analyze/graph/column/american_indian.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class AmericanIndian < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
# TODO: offset labels so they don't overlap
|
||||
'American Indian or Alaskan Native'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
# TODO: implement this logic. Resize messages so they are bound to their column
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
# TODO: make sure the score calculation bubble up instead of just average
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
34
app/presenters/analyze/graph/column/asian.rb
Normal file
34
app/presenters/analyze/graph/column/asian.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class Asian < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'Asian or Pacific Islander'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
34
app/presenters/analyze/graph/column/black.rb
Normal file
34
app/presenters/analyze/graph/column/black.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class Black < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'Black or African American'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 3
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# TODO: resize bars so they never extend beyond the bounds of the column
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
|
|
|
|||
34
app/presenters/analyze/graph/column/hispanic.rb
Normal file
34
app/presenters/analyze/graph/column/hispanic.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class Hispanic < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'Hispanic or Latinx'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
34
app/presenters/analyze/graph/column/middle_eastern.rb
Normal file
34
app/presenters/analyze/graph/column/middle_eastern.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class MiddleEastern < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'Middle Eastern'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 8
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
17
app/presenters/analyze/graph/column/race_score.rb
Normal file
17
app/presenters/analyze/graph/column/race_score.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
module RaceScore
|
||||
def race_score(measure:, school:, academic_year:, race:)
|
||||
survey_items = measure.student_survey_items
|
||||
average = SurveyItemResponse.where(school:,
|
||||
academic_year:,
|
||||
survey_item: survey_items,
|
||||
student: StudentRace.where(race:))
|
||||
.average(:likert_score)
|
||||
Score.new(average, true, true, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
34
app/presenters/analyze/graph/column/unknown.rb
Normal file
34
app/presenters/analyze/graph/column/unknown.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class Unknown < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'Unknown'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 99
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
34
app/presenters/analyze/graph/column/white.rb
Normal file
34
app/presenters/analyze/graph/column/white.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
module Column
|
||||
class White < GroupedBarColumnPresenter
|
||||
include Analyze::Graph::Column::RaceScore
|
||||
def label
|
||||
'White or Caucasian'
|
||||
end
|
||||
|
||||
def basis
|
||||
'student'
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?
|
||||
!measure.includes_student_survey_items?
|
||||
end
|
||||
|
||||
def show_insufficient_data_message?
|
||||
false
|
||||
end
|
||||
|
||||
def score(year_index)
|
||||
race_score(measure:, school:, academic_year: academic_years[year_index], race:)
|
||||
end
|
||||
|
||||
def race
|
||||
Race.find_by_qualtrics_code 5
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# SurveyItemResponse.where(student: StudentRace.where(race: Race.find_by_qualtrics_code(8)).limit(10).map(&:student)).count
|
||||
|
||||
# TODO figure out why earlier years don't have races attached
|
||||
require 'csv'
|
||||
|
||||
class StudentLoader
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<%# TODO Hook up the buttons so that only the selected races are shown for each column %>
|
||||
<h3 class="sub-header-4 mt-5">Data Filters</h3>
|
||||
<div class="bg-gray p-3" data-controller="analyze">
|
||||
<% @graphs.each do |graph| %>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<%= render partial: "data_filters", locals: {district: @district, school: @school, academic_year: @academic_year, category: @category, subcategory: @subcategory} %>
|
||||
</div>
|
||||
|
||||
<%# TODO : make sure the caching rules work with the new graphs %>
|
||||
<% cache [@subcategory, @school, @selected_academic_years, @response_rate_timestamp] do %>
|
||||
<div class="bg-color-white flex-grow-1 col-9">
|
||||
<% @measures.each do |measure| %>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# TODO: fix failing tests
|
||||
require 'rails_helper'
|
||||
include AnalyzeHelper
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue