sqm-dashboards/app/models/survey_item.rb
rebuilt 50256cacce Create academic year checkbox selectors. Refresh page with years selected on
checkbox change.  Draw bar graphs for each academic year selected.
Center bar graphs in their column.  Color the columns to match the
sample colors on the checkboxes.  Add scores on beta to top of graph.
Automatically display the most recent year of data for the district.
Modify logic for the insufficient data message or the 'measure not based
on student/teacher surveys' message so it only shows if there are no
bars with data to display.
2022-06-08 15:42:54 -07:00

25 lines
702 B
Ruby

class SurveyItem < ActiveRecord::Base
belongs_to :scale
has_one :measure, through: :scale
has_one :subcategory, through: :measure
has_many :survey_item_responses
def score(school:, academic_year:)
@score ||= Hash.new do |memo, (school, academic_year)|
memo[[school, academic_year]] =
survey_item_responses.exclude_boston.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-%'")
}
scope :short_form_items, lambda {
where(on_short_form: true)
}
end