mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-11 08:21:12 -07:00
feat: add ability to filter export data by student survey item type. Ability added to 'by grade' 'by item' and 'survey item responses' reports
This commit is contained in:
parent
cd91496279
commit
aee0bc9883
4 changed files with 16 additions and 10 deletions
|
|
@ -37,7 +37,7 @@ class ExportsController < ApplicationController
|
|||
|
||||
report = params[:report]
|
||||
|
||||
if report == "Survey Item - By Item"
|
||||
if ["Survey Item - By Item", "Survey Item - By Grade", "Survey Item Response"].include?(report)
|
||||
use_student_survey_items = student_survey_types[params[:student_survey_type]]
|
||||
reports[report].call(schools, academic_years, use_student_survey_items)
|
||||
else
|
||||
|
|
@ -78,14 +78,15 @@ class ExportsController < ApplicationController
|
|||
send_data data, disposition: "attachment",
|
||||
filename: "survey_item_by_item_#{Date.today}.csv"
|
||||
},
|
||||
"Survey Item - By Grade" => lambda { |schools, academic_years|
|
||||
"Survey Item - By Grade" => lambda { |schools, academic_years, use_student_survey_items|
|
||||
data = Report::SurveyItemByGrade.to_csv(schools:, academic_years:,
|
||||
use_student_survey_items: ::SurveyItem.student_survey_items.pluck(:id))
|
||||
use_student_survey_items:)
|
||||
send_data data,
|
||||
disposition: "attachment", filename: "survey_item_by_grade_#{Date.today}.csv"
|
||||
},
|
||||
"Survey Item Response" => lambda { |schools, academic_years|
|
||||
data = Report::SurveyItemResponse.to_csv(schools:, academic_years:)
|
||||
|
||||
"Survey Item Response" => 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"
|
||||
} }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
# Report::SurveyItemResponse.create(schools: District.find_by_name("Lee Public Schools").schools, academic_years: AcademicYear.where(range: "2023-24 Spring"), filename: "test.csv")
|
||||
module Report
|
||||
class SurveyItemResponse
|
||||
def self.create(schools:, academic_years:, filename:)
|
||||
data = to_csv(schools:, academic_years:)
|
||||
def self.create(schools:, academic_years:, filename:, use_student_survey_items:)
|
||||
data = to_csv(schools:, academic_years:, use_student_survey_items:)
|
||||
FileUtils.mkdir_p Rails.root.join("tmp", "reports")
|
||||
filepath = Rails.root.join("tmp", "reports", filename)
|
||||
write_csv(data:, filepath:)
|
||||
data
|
||||
end
|
||||
|
||||
def self.to_csv(schools:, academic_years:)
|
||||
def self.to_csv(schools:, academic_years:, use_student_survey_items:)
|
||||
data = []
|
||||
data << ["Response ID", "Race", "Gender", "Grade", "School ID", "District", "Academic Year", "Student Physical Safety",
|
||||
"Student Emotional Safety", "Student Sense of Belonging", "Student-Teacher Relationships", "Valuing of Learning", "Academic Challenge", "Content Specialists & Support Staff", "Cultural Responsiveness", "Engagement In School", "Appreciation For Diversity", "Civic Participation", "Perseverance & Determination", "Growth Mindset", "Participation In Creative & Performing Arts", "Valuing Creative & Performing Arts", "Social & Emotional Health"]
|
||||
|
|
@ -19,6 +19,8 @@ module Report
|
|||
jobs = Queue.new
|
||||
schools.each { |school| jobs << school }
|
||||
|
||||
use_student_survey_items = use_student_survey_items.to_set
|
||||
|
||||
workers = pool_size.times.map do
|
||||
Thread.new do
|
||||
while school = jobs.pop(true)
|
||||
|
|
@ -42,6 +44,8 @@ module Report
|
|||
|
||||
response_hash.each do |_key, responses|
|
||||
mutex.synchronize do
|
||||
next unless responses.map(&:survey_item_id).to_set.subset?(use_student_survey_items)
|
||||
|
||||
row = []
|
||||
info = responses.first
|
||||
response_id = info.response_id
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class ExportsPresenter
|
|||
@selected_school ||= @schools.first
|
||||
|
||||
@schools_grouped_by = params["school_group"]
|
||||
@show_student_survey_types = params[:report] == "Survey Item - By Item"
|
||||
@show_student_survey_types = ["Survey Item - By Item", "Survey Item - By Grade",
|
||||
"Survey Item Response"].include?(params[:report])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Exports page</h1>
|
||||
<h1 class="mt-5">Exports page</h1>
|
||||
<%= turbo_frame_tag "results" do %>
|
||||
<%= form_with(action: exports_path,
|
||||
method: :get,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue