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

This commit is contained in:
Nelson Jovel 2024-03-19 08:16:07 -07:00
parent d90669b74d
commit 9f5ca007a1
2 changed files with 10 additions and 1 deletions

View file

@ -20,7 +20,14 @@ module Report
response_rate = scale.measure.subcategory.response_rate(school:, academic_year:)
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:,
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date

View file

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