mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-07 21:38:14 -08:00
chore: start adding overview page
This commit is contained in:
parent
1b0af124f7
commit
64b4d599c7
33 changed files with 783 additions and 199 deletions
8
app/controllers/dashboard/analyze_controller.rb
Normal file
8
app/controllers/dashboard/analyze_controller.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AnalyzeController < SqmApplicationController
|
||||
def index
|
||||
@presenter = Analyze::Presenter.new(params:, school: @school, academic_year: @academic_year)
|
||||
@background ||= BackgroundPresenter.new(num_of_columns: @presenter.graph.columns.count)
|
||||
end
|
||||
end
|
||||
11
app/controllers/dashboard/categories_controller.rb
Normal file
11
app/controllers/dashboard/categories_controller.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CategoriesController < SqmApplicationController
|
||||
helper GaugeHelper
|
||||
|
||||
def show
|
||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category:) }
|
||||
|
||||
@category = CategoryPresenter.new(category: Category.find_by_slug(params[:id]))
|
||||
end
|
||||
end
|
||||
8
app/controllers/dashboard/gps_controller.rb
Normal file
8
app/controllers/dashboard/gps_controller.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class GpsController < ActionController::Base
|
||||
def index
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# format.csv { send_data Report::Gps.to_csv, disposition: 'attachment', filename: "gps_#{Date.today}.csv" }
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
@ -49,7 +49,7 @@ module Dashboard
|
|||
academic_year = AcademicYear.all.order(range: :DESC).find do |ay|
|
||||
Subcategory.all.any? do |subcategory|
|
||||
rate = subcategory.response_rate(school:, academic_year: ay)
|
||||
rate.meets_student_threshold || rate.meets_teacher_threshold
|
||||
rate.meets_student_threshold? || rate.meets_teacher_threshold?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
44
app/controllers/dashboard/overview_controller.rb
Normal file
44
app/controllers/dashboard/overview_controller.rb
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Dashboard
|
||||
class OverviewController < SqmApplicationController
|
||||
before_action :check_empty_dataset, only: [:index]
|
||||
helper VarianceHelper
|
||||
|
||||
def index
|
||||
@variance_chart_row_presenters = measures.map(&method(:presenter_for_measure))
|
||||
@category_presenters = categories.map { |category| CategoryPresenter.new(category:) }
|
||||
@student_response_rate_presenter = ResponseRatePresenter.new(focus: :student, school: @school,
|
||||
academic_year: @academic_year)
|
||||
@teacher_response_rate_presenter = ResponseRatePresenter.new(focus: :teacher, school: @school,
|
||||
academic_year: @academic_year)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
score = measure.score(school: @school, academic_year: @academic_year)
|
||||
|
||||
VarianceChartRowPresenter.new(measure:, score:)
|
||||
end
|
||||
|
||||
def check_empty_dataset
|
||||
@has_empty_dataset = subcategories.none? do |subcategory|
|
||||
response_rate = subcategory.response_rate(school: @school, academic_year: @academic_year)
|
||||
response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
||||
end
|
||||
end
|
||||
|
||||
def measures
|
||||
@measures ||= subcategories.flat_map(&:measures)
|
||||
end
|
||||
|
||||
def subcategories
|
||||
@subcategories ||= categories.flat_map(&:subcategories)
|
||||
end
|
||||
|
||||
def categories
|
||||
@categories ||= Category.sorted.includes(%i[measures scales admin_data_items subcategories])
|
||||
end
|
||||
end
|
||||
end
|
||||
3
app/controllers/dashboard/reports_controller.rb
Normal file
3
app/controllers/dashboard/reports_controller.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class ReportsController < ApplicationController
|
||||
def index; end
|
||||
end
|
||||
44
app/controllers/dashboard/sqm_application_controller.rb
Normal file
44
app/controllers/dashboard/sqm_application_controller.rb
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Dashboard
|
||||
class SqmApplicationController < ApplicationController
|
||||
protect_from_forgery with: :exception, prepend: true
|
||||
before_action :set_schools_and_districts
|
||||
before_action :authenticate_district
|
||||
|
||||
helper HeaderHelper
|
||||
|
||||
private
|
||||
|
||||
def authenticate_district
|
||||
authenticate(district_name, "#{district_name}!")
|
||||
end
|
||||
|
||||
def district_name
|
||||
@district_name ||= @district.name.split(" ").first.downcase
|
||||
end
|
||||
|
||||
def set_schools_and_districts
|
||||
@district = District.find_by_slug district_slug
|
||||
@districts = District.all.order(:name)
|
||||
@school = School.find_by_slug(school_slug)
|
||||
@schools = School.includes([:district]).where(district: @district).order(:name)
|
||||
@academic_year = AcademicYear.find_by_range params[:year]
|
||||
@academic_years = AcademicYear.all.order(range: :desc)
|
||||
end
|
||||
|
||||
def district_slug
|
||||
params[:district_id]
|
||||
end
|
||||
|
||||
def school_slug
|
||||
params[:school_id]
|
||||
end
|
||||
|
||||
def authenticate(username, password)
|
||||
authenticate_or_request_with_http_basic do |u, p|
|
||||
u == username && p == password
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue