mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
feat: rename export reports
This commit is contained in:
parent
37042aead5
commit
48128eaa8e
1 changed files with 33 additions and 27 deletions
|
|
@ -26,21 +26,10 @@ class ExportsController < ApplicationController
|
|||
year_params = params.select { |param| param.start_with?("academic_year") }.values
|
||||
academic_years = AcademicYear.where(range: year_params)
|
||||
group = params["school_group"]
|
||||
|
||||
if group == "district"
|
||||
district_id ||= params[:district]&.to_i if params[:district].present?
|
||||
district = District.find(district_id) if district_id.present?
|
||||
district ||= District.first
|
||||
schools = district.schools
|
||||
elsif group == "school"
|
||||
schools = [School.find_by_name(params["school"])]
|
||||
elsif group == "all"
|
||||
schools = School.all
|
||||
end
|
||||
|
||||
schools = schools_for_group(group)
|
||||
report = params[:report]
|
||||
|
||||
if ["Survey Item - By Item", "Survey Item - By Grade", "Survey Item Response"].include?(report)
|
||||
if ["Survey Item - By Item", "Survey Item - By Grade", "Survey Entries - by Measure"].include?(report)
|
||||
use_student_survey_items = student_survey_types[params[:student_survey_type]]
|
||||
reports[report].call(schools, academic_years, use_student_survey_items)
|
||||
else
|
||||
|
|
@ -52,20 +41,37 @@ class ExportsController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def schools_for_group(group)
|
||||
if group == "district"
|
||||
district_id ||= params[:district]&.to_i if params[:district].present?
|
||||
district = District.find(district_id) if district_id.present?
|
||||
district ||= District.first
|
||||
district.schools
|
||||
elsif group == "school"
|
||||
[School.find_by_name(params["school"])]
|
||||
elsif group == "all"
|
||||
School.all
|
||||
end
|
||||
end
|
||||
|
||||
def reports
|
||||
{ "Subcategory" => lambda { |schools, academic_years|
|
||||
data = Report::Subcategory.to_csv(schools:, academic_years:)
|
||||
send_data data, disposition: "attachment", filename: "subcategory_#{Date.today}.csv"
|
||||
},
|
||||
"Measure Summary" => lambda { |schools, academic_years|
|
||||
data = Report::MeasureSummary.to_csv(schools:, academic_years:, measures: Measure.all)
|
||||
send_data data, disposition: "attachment",
|
||||
filename: "measure_summary_#{Date.today}.csv"
|
||||
},
|
||||
"Measure Detailed" => lambda { |schools, academic_years|
|
||||
data = Report::Measure.to_csv(schools:, academic_years:, measures: ::Measure.all)
|
||||
send_data data, disposition: "attachment", filename: "measure_detailed_#{Date.today}.csv"
|
||||
},
|
||||
{ "Subcategory - School & District" => lambda { |schools, academic_years|
|
||||
data = Report::Subcategory.to_csv(schools:, academic_years:)
|
||||
send_data data, disposition: "attachment",
|
||||
filename: "subcategory_#{Date.today}.csv"
|
||||
},
|
||||
"Measure - District only" => lambda { |schools, academic_years|
|
||||
data = Report::MeasureSummary.to_csv(schools:, academic_years:,
|
||||
measures: Measure.all)
|
||||
send_data data, disposition: "attachment",
|
||||
filename: "measure_summary_#{Date.today}.csv"
|
||||
},
|
||||
"Measure - School & District" => lambda { |schools, academic_years|
|
||||
data = Report::Measure.to_csv(schools:, academic_years:,
|
||||
measures: ::Measure.all)
|
||||
send_data data, disposition: "attachment",
|
||||
filename: "measure_detailed_#{Date.today}.csv"
|
||||
},
|
||||
"Beyond Learning Loss" => lambda { |schools, academic_years|
|
||||
measure_ids = %w[2A-i 2A-ii 2B-i 2B-ii 2C-i 2C-ii 4B-i 5B-i 5B-ii 5D-i]
|
||||
scales = measure_ids.map do |measure_id|
|
||||
|
|
@ -88,7 +94,7 @@ class ExportsController < ApplicationController
|
|||
disposition: "attachment", filename: "survey_item_by_grade_#{Date.today}.csv"
|
||||
},
|
||||
|
||||
"Survey Item Response" => lambda { |schools, academic_years, use_student_survey_items|
|
||||
"Survey Entries - by Measure" => lambda { |schools, academic_years, use_student_survey_items|
|
||||
data = Report::SurveyItemResponse.to_csv(schools:, academic_years:, use_student_survey_items:)
|
||||
send_data data, disposition: "attachment", filename: "survey_item_response_#{Date.today}.csv"
|
||||
} }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue