fix: Overall response rate was incorrectly using the updated_at date instead of the recorded date. Also, it was just using the last date for all academic years instead of the last date the survey was taken per academic year.

This commit is contained in:
rebuilt 2023-08-15 16:13:47 -07:00
parent a8db6c5ecf
commit 315b398a5a
2 changed files with 30 additions and 13 deletions

View file

@ -5,12 +5,17 @@ class ResponseRatePresenter
@focus = focus
@academic_year = academic_year
@school = school
@survey_items = SurveyItem.student_survey_items if focus == :student
if focus == :student
@survey_items = Measure.all.flat_map do |measure|
measure.student_survey_items_with_sufficient_responses(school:, academic_year:)
end
end
@survey_items = SurveyItem.teacher_survey_items if focus == :teacher
end
def date
SurveyItemResponse.where(survey_item: survey_items, school:).order(updated_at: :DESC).first&.updated_at || Date.new
SurveyItemResponse.where(survey_item: survey_items, school:,
academic_year:).order(recorded_date: :DESC).first&.recorded_date || Date.today
end
def percentage
@ -24,7 +29,7 @@ class ResponseRatePresenter
end
def hover_message
"Percentages based on #{ actual_count } out of #{ respondents_count.round } #{ focus }s completing at least 25% of the survey."
"Percentages based on #{actual_count} out of #{respondents_count.round} #{focus}s completing at least 25% of the survey."
end
private