sqm-dashboards/app/models/student_response_rate.rb
rebuilt d4df7cbc06 Add scales to framework. Change calculations to first group and then
average those groupings and the way up the framework.  Likert scores for
a survey_item are averaged.  Then all the survey_items in a scale are
averaged.  Then student scales in a measure are averaged.  And teacher
scales in a measure are averaged.  Then the average of those two
calculations becomes the score for a measure.  Then the measures in a
subcategory are averaged.
2022-02-24 14:53:06 +01:00

26 lines
766 B
Ruby

class StudentResponseRate
include ResponseRate
private
def survey_item_count
@student_survey_item_count ||= @subcategory.measures.map { |measure| measure.student_survey_items.count }.sum
end
def response_count
@student_response_count ||= @subcategory.measures.map do |measure|
measure.student_survey_items.map do |survey_item|
survey_item.survey_item_responses.where(school: @school, academic_year: @academic_year).count
end.sum
end.sum
end
def total_possible_responses
@total_possible_student_responses ||= begin
total_responses = Respondent.where(school: @school, academic_year: @academic_year).first
return 0 unless total_responses.present?
total_responses.total_students
end
end
end