mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
Refactor groups
Refactor graphs to take new slice format Add Students and Teachers and Parents graph. Add selector for that graph
This commit is contained in:
parent
774f627661
commit
6269414bca
26 changed files with 193 additions and 191 deletions
|
|
@ -26,11 +26,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::AllData.new(slices: [slice])
|
||||
Analyze::Source::AllData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::AllData.new
|
||||
Analyze::Slice::AllData.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: nil, slug: nil, graph: nil)
|
||||
end
|
||||
|
||||
def show_irrelevancy_message?(measure:)
|
||||
|
|
|
|||
|
|
@ -16,11 +16,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::AllData.new(slices: [slice])
|
||||
Analyze::Source::AllData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::AllData.new
|
||||
Analyze::Slice::AllData.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: nil, slug: nil, graph: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,11 +17,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsAndTeachers.new
|
||||
Analyze::Slice::StudentsAndTeachers.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: nil, slug: nil, graph: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Graph
|
||||
class StudentsAndTeachersAndParents
|
||||
include Analyze::Graph::Column
|
||||
def to_s
|
||||
"Students & Teachers & Parents"
|
||||
end
|
||||
|
||||
def slug
|
||||
"students-and-teachers-and-parents"
|
||||
end
|
||||
|
||||
def columns
|
||||
[AllStudent.new, AllTeacher.new, AllSurveyData.new]
|
||||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsAndTeachersAndParents.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: nil, slug: nil, graph: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -28,11 +28,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "ELL", slug: "ell", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,11 +28,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "Gender", slug: "gender", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "Grade", slug: "grade", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "Income", slug: "income", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: [slice], graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "Race", slug: "race", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ module Analyze
|
|||
end
|
||||
|
||||
def source
|
||||
Analyze::Source::SurveyData.new(slices: nil)
|
||||
Analyze::Source::SurveyData.new(slices: nil, graph: self)
|
||||
end
|
||||
|
||||
def slice
|
||||
Analyze::Slice::StudentsByGroup.new
|
||||
Analyze::Slice::StudentsByGroup.new(graph: self)
|
||||
end
|
||||
|
||||
def group
|
||||
Analyze::Group::Base.new(name: "Special Education", slug: "sped", graph: self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
15
app/presenters/analyze/group/base.rb
Normal file
15
app/presenters/analyze/group/base.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Analyze
|
||||
module Group
|
||||
class Base
|
||||
attr_reader :name, :slug, :graph
|
||||
|
||||
def initialize(name:, slug:, graph:)
|
||||
@name = name
|
||||
@slug = slug
|
||||
@graph = graph
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
module Analyze
|
||||
module Group
|
||||
class Ell
|
||||
def name
|
||||
"ELL"
|
||||
end
|
||||
|
||||
def slug
|
||||
"ell"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsByEll.new(ells: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
module Analyze
|
||||
module Group
|
||||
class Gender
|
||||
def name
|
||||
"Gender"
|
||||
end
|
||||
|
||||
def slug
|
||||
"gender"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsByGender.new(genders: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
module Analyze
|
||||
module Group
|
||||
class Grade
|
||||
def name
|
||||
"Grade"
|
||||
end
|
||||
|
||||
def slug
|
||||
"grade"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsByGrade.new(grades: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
module Analyze
|
||||
module Group
|
||||
class Income
|
||||
def name
|
||||
"Income"
|
||||
end
|
||||
|
||||
def slug
|
||||
"income"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsByIncome.new(incomes: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
module Analyze
|
||||
module Group
|
||||
class Race
|
||||
def name
|
||||
"Race"
|
||||
end
|
||||
|
||||
def slug
|
||||
"race"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsByRace.new(races: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -96,8 +96,10 @@ module Analyze
|
|||
end
|
||||
|
||||
def groups
|
||||
@groups = [Analyze::Group::Ell.new, Analyze::Group::Gender.new, Analyze::Group::Grade.new, Analyze::Group::Income.new,
|
||||
Analyze::Group::Race.new, Analyze::Group::Sped.new]
|
||||
@groups = graphs.map(&:group)
|
||||
.reject { |group| group.name.nil? }
|
||||
.sort_by { |group| group.name }
|
||||
.uniq
|
||||
end
|
||||
|
||||
def group
|
||||
|
|
@ -111,7 +113,13 @@ module Analyze
|
|||
end
|
||||
|
||||
def slices
|
||||
graphs.map { |graph| graph.slice }.uniq
|
||||
@slices ||= begin
|
||||
hash = {}
|
||||
graphs.map(&:slice).each do |slice|
|
||||
hash[slice.slug] = slice
|
||||
end
|
||||
hash.values
|
||||
end
|
||||
end
|
||||
|
||||
def source
|
||||
|
|
@ -121,7 +129,7 @@ module Analyze
|
|||
def show_secondary_graph?(measure:)
|
||||
return false unless measure.includes_parent_survey_items?
|
||||
|
||||
graph.slug == "all-data"
|
||||
["all-data", "students-and-teachers-and-parents"].include?(graph.slug)
|
||||
end
|
||||
|
||||
def columns_for_measure(measure:)
|
||||
|
|
@ -133,33 +141,25 @@ module Analyze
|
|||
end
|
||||
|
||||
def sources
|
||||
all_data_slice = Analyze::Slice::AllData.new
|
||||
all_data_slice.graph = Analyze::Graph::AllData.new
|
||||
all_data_slices = [all_data_slice]
|
||||
|
||||
all_data_source = Analyze::Source::AllData.new(slices: all_data_slices)
|
||||
all_data_source.graph = Analyze::Graph::AllData.new
|
||||
|
||||
students_and_teachers = Analyze::Slice::StudentsAndTeachers.new
|
||||
students_by_group = Analyze::Slice::StudentsByGroup.new
|
||||
students_by_group.graph = Analyze::Graph::StudentsByEll.new(ells: selected_ells)
|
||||
|
||||
survey_data_slices = [students_and_teachers, students_by_group]
|
||||
survey_data_source = Analyze::Source::SurveyData.new(slices: survey_data_slices)
|
||||
survey_data_source.graph = Analyze::Graph::StudentsAndTeachers.new
|
||||
|
||||
@sources = [all_data_source, survey_data_source]
|
||||
@sources ||= begin
|
||||
hash = {}
|
||||
graphs.map(&:source).each do |source|
|
||||
hash[source.slug] = source
|
||||
end
|
||||
hash.values
|
||||
end
|
||||
end
|
||||
|
||||
def graphs
|
||||
@graphs ||= [Analyze::Graph::AllData.new,
|
||||
Analyze::Graph::StudentsAndTeachers.new,
|
||||
Analyze::Graph::StudentsAndTeachersAndParents.new,
|
||||
Analyze::Graph::StudentsByRace.new(races: selected_races),
|
||||
Analyze::Graph::StudentsByGrade.new(grades: selected_grades),
|
||||
Analyze::Graph::StudentsByGender.new(genders: selected_genders),
|
||||
Analyze::Graph::StudentsByIncome.new(incomes: selected_incomes),
|
||||
Analyze::Graph::StudentsByEll.new(ells: selected_ells),
|
||||
Analyze::Graph::StudentsBySped.new(speds: selected_speds)]
|
||||
Analyze::Graph::StudentsBySped.new(speds: selected_speds),
|
||||
Analyze::Graph::StudentsByEll.new(ells: selected_ells)]
|
||||
end
|
||||
|
||||
def graph
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
module Analyze
|
||||
module Slice
|
||||
class AllData
|
||||
attr_accessor :graph
|
||||
|
||||
def to_s
|
||||
"All Data"
|
||||
end
|
||||
|
||||
def slug
|
||||
"all-data"
|
||||
class AllData < Base
|
||||
def initialize(graph:, label: "All Data", slug: "all-data")
|
||||
super(label:, slug:, graph:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
17
app/presenters/analyze/slice/base.rb
Normal file
17
app/presenters/analyze/slice/base.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
module Analyze
|
||||
module Slice
|
||||
class Base
|
||||
attr_reader :graph, :label, :slug
|
||||
|
||||
def initialize(label:, slug:, graph:)
|
||||
@label = label
|
||||
@slug = slug
|
||||
@graph = graph
|
||||
end
|
||||
|
||||
def to_s
|
||||
label
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +1,8 @@
|
|||
module Analyze
|
||||
module Slice
|
||||
class StudentsAndTeachers
|
||||
def to_s
|
||||
"Students & Teachers"
|
||||
end
|
||||
|
||||
def slug
|
||||
"students-and-teachers"
|
||||
end
|
||||
|
||||
def graph
|
||||
Analyze::Graph::StudentsAndTeachers.new
|
||||
class StudentsAndTeachers < Base
|
||||
def initialize(graph:, label: "Students & Teachers", slug: "students-and-teachers")
|
||||
super(label:, slug:, graph:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
module Analyze
|
||||
module Slice
|
||||
class StudentsAndTeachersAndParents < Base
|
||||
def initialize(graph:, label: "Students & Teachers & Parents", slug: "students-and-teachers-and-pareents")
|
||||
super(label:, slug:, graph:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,14 +1,8 @@
|
|||
module Analyze
|
||||
module Slice
|
||||
class StudentsByGroup
|
||||
attr_accessor :graph
|
||||
|
||||
def to_s
|
||||
"Students by Group"
|
||||
end
|
||||
|
||||
def slug
|
||||
"students-by-group"
|
||||
class StudentsByGroup < Base
|
||||
def initialize(graph:, label: "Students by Group", slug: "students-by-group")
|
||||
super(label:, slug:, graph:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
module Analyze
|
||||
module Source
|
||||
class AllData
|
||||
attr_reader :slices
|
||||
attr_accessor :graph
|
||||
attr_reader :slices, :graph
|
||||
|
||||
include Analyze::Slice
|
||||
|
||||
def initialize(slices:)
|
||||
def initialize(slices:, graph:)
|
||||
@slices = slices
|
||||
@graph = graph
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
module Analyze
|
||||
module Source
|
||||
class SurveyData
|
||||
attr_reader :slices
|
||||
attr_accessor :graph
|
||||
attr_reader :slices, :graph
|
||||
|
||||
include Analyze::Slice
|
||||
|
||||
def initialize(slices:)
|
||||
def initialize(slices:, graph:)
|
||||
@slices = slices
|
||||
@graph = graph
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
|||
|
|
@ -26,36 +26,38 @@
|
|||
<% 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| %>
|
||||
|
||||
<%= 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| %>
|
||||
<input type="hidden" id="year" name="<%= key %>" value="<%= value %>">
|
||||
<% end %>
|
||||
|
||||
<% params.reject{|key,_| key == "graph"}.each do |key, value| %>
|
||||
<input type="hidden" id="year" name="<%= key %>" value="<%= value %>">
|
||||
<% end %>
|
||||
<% @presenter.slices.each do | slice | %>
|
||||
<div class="mx-3">
|
||||
<input type="radio"
|
||||
id="<%= slice.slug %>"
|
||||
class="form-check-input"
|
||||
name="graph"
|
||||
value="<%= slice.graph.slug %>"
|
||||
<%= slice.slug == @presenter.slice.slug ? "checked" : "" %>
|
||||
<%= slice.slug == "all-data" ? "hidden" : "" %>>
|
||||
|
||||
<% source.slices.each do | slice | %>
|
||||
<div class="mx-3">
|
||||
<input type="radio"
|
||||
id="<%= slice.slug %>"
|
||||
class="form-check-input"
|
||||
name="graph"
|
||||
value="<%= slice.graph.slug %>"
|
||||
<%= slice.slug == @presenter.slice.slug ? "checked" : "" %>
|
||||
<%= slice.slug == "all-data" ? "hidden" : "" %>>
|
||||
|
||||
<label for="<%= slice.slug %>"
|
||||
<%= slice.slug == "all-data" ? "hidden" : "" %>>
|
||||
<%= slice.to_s %></label>
|
||||
</div>
|
||||
<label for="<%= slice.slug %>"
|
||||
<%= slice.slug == "all-data" ? "hidden" : "" %>>
|
||||
<%= slice.to_s %></label>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: "group_selectors" %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
<% if @presenter.show_secondary_graph?(measure:) %>
|
||||
<section class="mb-6">
|
||||
<%= link_to("Parent Survey", district_school_category_path( @district, @school, @presenter.category, {year: @presenter.selected_academic_years&.last&.range , anchor: "#{measure.scales.parent_scales.first.scale_id}"}), class: "construct-id", data: {turbo_frame: "_top"}) %>
|
||||
<h2> <%= measure.subcategory.name %> </h2>
|
||||
<% measure.scales.parent_scales.each do |scale| %>
|
||||
<label id="<%= scale.scale_id %>" > </label>
|
||||
<% end %>
|
||||
<%= link_to("Parent Survey", district_school_category_path( @district, @school, @presenter.category, {year: @presenter.selected_academic_years&.last&.range , anchor: "#{measure.scales.parent_scales.first.scale_id}"}), class: "construct-id", data: {turbo_frame: "_top"}) %>
|
||||
<h2> <%= measure.subcategory.name %> </h2>
|
||||
<%= render partial: "grouped_bar_chart" , locals: { measure: measure, columns: @presenter.columns_for_measure(measure:)} %>
|
||||
</section>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue