mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-18 02:06:25 -07:00
dirty commit: can't get references to work correctly between any tables
This commit is contained in:
parent
e1f0b78236
commit
a4fddbeced
183 changed files with 5461 additions and 5 deletions
31
app/models/dashboard/teacher_response_rate_calculator.rb
Normal file
31
app/models/dashboard/teacher_response_rate_calculator.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Dashboard
|
||||
class TeacherResponseRateCalculator < ResponseRateCalculator
|
||||
def survey_item_count
|
||||
@survey_item_count ||= survey_items_with_sufficient_responses.length
|
||||
end
|
||||
|
||||
def survey_items_have_sufficient_responses?
|
||||
survey_item_count.positive?
|
||||
end
|
||||
|
||||
def survey_items_with_sufficient_responses
|
||||
@survey_items_with_sufficient_responses ||= SurveyItemResponse.teacher_survey_items_with_sufficient_responses(
|
||||
school:, academic_year:
|
||||
).slice(*@subcategory.teacher_survey_items.map(&:id))
|
||||
end
|
||||
|
||||
def response_count
|
||||
@response_count ||= survey_items_with_sufficient_responses&.values&.sum
|
||||
end
|
||||
|
||||
def total_possible_responses
|
||||
@total_possible_responses ||= respondents.total_teachers
|
||||
end
|
||||
|
||||
def raw_response_rate
|
||||
(average_responses_per_survey_item / total_possible_responses.to_f * 100).round
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue