mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Refactor student_response_rate
This commit is contained in:
parent
fcec3de233
commit
5cccbcdf9b
3 changed files with 9 additions and 6 deletions
|
|
@ -6,9 +6,7 @@ class StudentResponseRate < ResponseRate
|
|||
private
|
||||
|
||||
def survey_item_count
|
||||
@student_survey_item_count ||= @subcategory.measures.map do |measure|
|
||||
measure.student_survey_items.count
|
||||
end.sum
|
||||
@student_survey_item_count = SurveyItem.student_survey_items_for_measures(@subcategory.measures).count
|
||||
end
|
||||
|
||||
def response_count
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
class SurveyItem < ActiveRecord::Base
|
||||
belongs_to :measure
|
||||
has_many :survey_item_responses
|
||||
|
||||
scope :student_survey_items_for_measures, lambda { |measures|
|
||||
joins(:measure).where(measure: measures).where("survey_item_id LIKE 's-%'")
|
||||
}
|
||||
scope :teacher_survey_items_for_measures, lambda { |measures|
|
||||
joins(:measure).where(measure: measures).where("survey_item_id LIKE 't-%'")
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ class TeacherResponseRate < ResponseRate
|
|||
end
|
||||
|
||||
def survey_item_count
|
||||
@teacher_survey_item_count ||= @subcategory.measures.map do |measure|
|
||||
measure.teacher_survey_items.count
|
||||
end.sum
|
||||
@teacher_survey_item_count ||= SurveyItem.teacher_survey_items_for_measures(@subcategory.measures).count
|
||||
end
|
||||
|
||||
def response_count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue