diff --git a/app/controllers/analyze_controller.rb b/app/controllers/analyze_controller.rb
index 1248a388..ad0f09e9 100644
--- a/app/controllers/analyze_controller.rb
+++ b/app/controllers/analyze_controller.rb
@@ -2,7 +2,7 @@
class AnalyzeController < SqmApplicationController
before_action :assign_categories, :assign_subcategories, :assign_measures, :assign_academic_years,
- :response_rate_timestamp, :races, :selected_races, :graph, :graphs, only: [:index]
+ :response_rate_timestamp, :races, :selected_races, :graph, :graphs, :background, only: [:index]
def index; end
private
@@ -66,10 +66,18 @@ class AnalyzeController < SqmApplicationController
end
def graph
- @graph ||= params[:graph] || 'students-and-teachers'
+ graphs.each do |graph|
+ @graph = graph if graph.value == params[:graph]
+ end
+
+ @graph ||= graphs.first
end
def graphs
@graphs ||= [AnalysisGraph::StudentsAndTeachers.new, AnalysisGraph::StudentsByGroup.new]
end
+
+ def background
+ @background ||= BackgroundPresenter.new(num_of_columns: graph.columns.count)
+ end
end
diff --git a/app/helpers/analyze_helper.rb b/app/helpers/analyze_helper.rb
index de725518..243c55ae 100644
--- a/app/helpers/analyze_helper.rb
+++ b/app/helpers/analyze_helper.rb
@@ -1,48 +1,20 @@
# frozen_string_literal: true
module AnalyzeHelper
- def zone_label_width
- 15
- end
-
- def zone_label_x
- 2
- end
-
- def analyze_graph_height
- 85
- end
-
def svg_height
400
end
- def graph_width
- 85
- end
-
- def benchmark_y
- (analyze_zone_height * 2) - (benchmark_height / 2.0)
- end
-
- def benchmark_height
- 1
- end
-
- def grouped_chart_column_width
- graph_width / data_sources
- end
-
- def column_end_x(position)
- zone_label_width + (grouped_chart_column_width * position)
+ def zone_label_width
+ 15
end
- def column_start_x(position)
- column_end_x(position - 1)
+ def graph_width
+ 85
end
- def bar_label_height
- (100 - ((100 - analyze_graph_height) / 2))
+ def analyze_graph_height
+ 85
end
def analyze_zone_height
@@ -53,14 +25,6 @@ module AnalyzeHelper
analyze_zone_height / 100.0
end
- def zone_label_y(position)
- 8.5 * (position + position - 1)
- end
-
- def data_sources
- 3
- end
-
def analyze_category_link(district:, school:, academic_year:, category:)
year = academic_year.range
"/districts/#{district.slug}/schools/#{school.slug}/analyze?year=#{year}&academic_years=#{year}&category=#{category.category_id}"
diff --git a/app/models/analysis_graph/students_and_teachers.rb b/app/models/analysis_graph/students_and_teachers.rb
index 4453eccd..bdda0ac1 100644
--- a/app/models/analysis_graph/students_and_teachers.rb
+++ b/app/models/analysis_graph/students_and_teachers.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module AnalysisGraph
class StudentsAndTeachers
def to_s
@@ -7,5 +9,9 @@ module AnalysisGraph
def value
'students-and-teachers'
end
+
+ def columns
+ [StudentGroupedBarColumnPresenter, TeacherGroupedBarColumnPresenter, GroupedBarColumnPresenter]
+ end
end
end
diff --git a/app/models/analysis_graph/students_by_group.rb b/app/models/analysis_graph/students_by_group.rb
index 468230b0..dff36037 100644
--- a/app/models/analysis_graph/students_by_group.rb
+++ b/app/models/analysis_graph/students_by_group.rb
@@ -7,5 +7,9 @@ module AnalysisGraph
def value
'students-by-group'
end
+
+ def columns
+ [StudentGroupedBarColumnPresenter]
+ end
end
end
diff --git a/app/presenters/background_presenter.rb b/app/presenters/background_presenter.rb
new file mode 100644
index 00000000..c150b87a
--- /dev/null
+++ b/app/presenters/background_presenter.rb
@@ -0,0 +1,44 @@
+class BackgroundPresenter
+ include AnalyzeHelper
+ attr_reader :num_of_columns
+
+ def initialize(num_of_columns:)
+ @num_of_columns = num_of_columns
+ end
+
+ def zone_label_x
+ 2
+ end
+
+ def benchmark_y
+ (analyze_zone_height * 2) - (benchmark_height / 2.0)
+ end
+
+ def benchmark_height
+ 1
+ end
+
+ def grouped_chart_column_width
+ graph_width / data_sources
+ end
+
+ def column_end_x(position)
+ zone_label_width + (grouped_chart_column_width * position)
+ end
+
+ def column_start_x(position)
+ column_end_x(position - 1)
+ end
+
+ def bar_label_height
+ (100 - ((100 - analyze_graph_height) / 2))
+ end
+
+ def zone_label_y(position)
+ 8.5 * (position + position - 1)
+ end
+
+ def data_sources
+ num_of_columns
+ end
+end
diff --git a/app/presenters/grouped_bar_column_presenter.rb b/app/presenters/grouped_bar_column_presenter.rb
index de8edcd6..0b721047 100644
--- a/app/presenters/grouped_bar_column_presenter.rb
+++ b/app/presenters/grouped_bar_column_presenter.rb
@@ -81,6 +81,18 @@ class GroupedBarColumnPresenter
zone_label_width + (grouped_chart_column_width * position)
end
+ def grouped_chart_column_width
+ graph_width / data_sources
+ end
+
+ def bar_label_height
+ (100 - ((100 - analyze_graph_height) / 2))
+ end
+
+ def data_sources
+ 3
+ end
+
private
YearlyScore = Struct.new(:year, :score)
diff --git a/app/views/analyze/_data_filters.html.erb b/app/views/analyze/_data_filters.html.erb
index 2c71dc43..ee510db6 100644
--- a/app/views/analyze/_data_filters.html.erb
+++ b/app/views/analyze/_data_filters.html.erb
@@ -5,7 +5,7 @@
>
+ <%= graph.value == @graph.value ? "checked" : "" %>>
<% end %>
diff --git a/app/views/analyze/_graph_background.html.erb b/app/views/analyze/_graph_background.html.erb
index 2f93116e..ab6cc079 100644
--- a/app/views/analyze/_graph_background.html.erb
+++ b/app/views/analyze/_graph_background.html.erb
@@ -1,10 +1,10 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -13,19 +13,19 @@
-
diff --git a/app/views/analyze/_grouped_bar_chart.html.erb b/app/views/analyze/_grouped_bar_chart.html.erb
index 0741d155..7bb79535 100644
--- a/app/views/analyze/_grouped_bar_chart.html.erb
+++ b/app/views/analyze/_grouped_bar_chart.html.erb
@@ -1,10 +1,10 @@
diff --git a/app/views/analyze/_grouped_bar_column.html.erb b/app/views/analyze/_grouped_bar_column.html.erb
index 9b5ab441..536eb45f 100644
--- a/app/views/analyze/_grouped_bar_column.html.erb
+++ b/app/views/analyze/_grouped_bar_column.html.erb
@@ -1,7 +1,7 @@
-
+
<% score_label_y = [5, 10, 15, 5, 10, 15 ] %>
- <% presenter.bars.each_with_index do |bar, index| %>
-
+ <% column.bars.each_with_index do |bar, index| %>
+
<% if ENV["SCORES"].present? && ENV["SCORES"].upcase == "SHOW" %>
@@ -10,24 +10,24 @@
<% end %>
<% end %>
-