mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 23:48:17 -07: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
542 B
Ruby
21 lines
542 B
Ruby
class SurveyItem < ActiveRecord::Base
|
|
belongs_to :scale
|
|
has_one :measure, through: :scale
|
|
|
|
has_many :survey_item_responses
|
|
|
|
def score(school:, academic_year:)
|
|
@score ||= Hash.new do |memo|
|
|
memo[[school, academic_year]] = survey_item_responses.where(school:, academic_year:).average(:likert_score).to_f
|
|
end
|
|
|
|
@score[[school, academic_year]]
|
|
end
|
|
|
|
scope :student_survey_items, lambda {
|
|
where("survey_item_id LIKE 's-%'")
|
|
}
|
|
scope :teacher_survey_items, lambda {
|
|
where("survey_item_id LIKE 't-%'")
|
|
}
|
|
end
|