mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
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:
parent
bf5b9e88f3
commit
aafaeeaf41
2 changed files with 73 additions and 56 deletions
|
|
@ -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
|
||||
|
|
@ -20,11 +25,11 @@ class ResponseRatePresenter
|
|||
end
|
||||
|
||||
def color
|
||||
percentage > 75 ? 'purple' : 'gold'
|
||||
percentage > 75 ? "purple" : "gold"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue