You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
417 B
17 lines
417 B
class Array
|
|
def average
|
|
self.sum.to_f / self.size
|
|
end
|
|
end
|
|
|
|
class SurveyResponseAggregator
|
|
def self.score(academic_year:, school:, construct:)
|
|
SurveyResponse
|
|
.where(academic_year: academic_year)
|
|
.where(school: school)
|
|
.filter { |survey_response| survey_response.survey_item.construct == construct }
|
|
.map { |survey_response| survey_response.likert_score }
|
|
.average
|
|
end
|
|
end
|