sqm-dashboards/app/models/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

17 lines
461 B
Ruby

module ResponseRate
def initialize(subcategory:, school:, academic_year:)
@subcategory = subcategory
@school = school
@academic_year = academic_year
end
def rate
return 0 unless survey_item_count.positive?
average_responses_per_survey_item = response_count / survey_item_count.to_f
return 0 unless total_possible_responses.positive?
(average_responses_per_survey_item / total_possible_responses.to_f * 100).round
end
end