mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
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.
21 lines
518 B
Ruby
21 lines
518 B
Ruby
class Scale < ApplicationRecord
|
|
belongs_to :measure
|
|
has_many :survey_items
|
|
has_many :admin_data_items
|
|
|
|
def score(school:, academic_year:)
|
|
@score ||= Hash.new do |memo|
|
|
memo[[school, academic_year]] = survey_items.map do |survey_item|
|
|
survey_item.score(school:, academic_year:)
|
|
end.average
|
|
end
|
|
@score[[school, academic_year]]
|
|
end
|
|
|
|
scope :teacher_scales, lambda {
|
|
where("scale_id LIKE 't-%'")
|
|
}
|
|
scope :student_scales, lambda {
|
|
where("scale_id LIKE 's-%'")
|
|
}
|
|
end
|