fix: make sure averages for admin data scales are included in report

mciea-main
Nelson Jovel 2 years ago
parent 7666b5466b
commit 3117080f2d

@ -20,7 +20,14 @@ module Report
response_rate = scale.measure.subcategory.response_rate(school:, academic_year:) response_rate = scale.measure.subcategory.response_rate(school:, academic_year:)
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold? next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
score = scale.score(school:, academic_year:) score = if scale.scale_id.starts_with?("a-")
AdminDataValue.where(admin_data_item: scale.admin_data_items, school:,
academic_year:).map do |item|
item.likert_score
end.average
else
scale.score(school:, academic_year:)
end
begin_date = SurveyItemResponse.where(school:, begin_date = SurveyItemResponse.where(school:,
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date

@ -45,7 +45,9 @@ namespace :report do
Report::Measure.create_report(filename: "measure_report_attleboro.csv", measures:, schools:) Report::Measure.create_report(filename: "measure_report_attleboro.csv", measures:, schools:)
end end
end
namespace :scale do
task bll: :environment do task bll: :environment do
measure_ids = %w[ measure_ids = %w[
2A-i 2A-i

Loading…
Cancel
Save