mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
Cap response rate at 100 for both students and teachers
This commit is contained in:
parent
286e74b651
commit
c0a8905fba
2 changed files with 10 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
module ResponseRate
|
||||
TEACHER_RATE_THRESHOLD = 0.25
|
||||
STUDENT_RATE_THRESHOLD = 0.25
|
||||
TEACHER_RATE_THRESHOLD = 25
|
||||
STUDENT_RATE_THRESHOLD = 25
|
||||
|
||||
def initialize(subcategory:, school:, academic_year:)
|
||||
@subcategory = subcategory
|
||||
|
|
@ -15,14 +15,19 @@ module ResponseRate
|
|||
|
||||
return 0 unless total_possible_responses.positive?
|
||||
|
||||
(average_responses_per_survey_item / total_possible_responses.to_f * 100).round
|
||||
response_rate = (average_responses_per_survey_item / total_possible_responses.to_f * 100).round
|
||||
cap_at_100(response_rate)
|
||||
end
|
||||
|
||||
def meets_student_threshold?
|
||||
rate >= STUDENT_RATE_THRESHOLD * 100
|
||||
rate >= STUDENT_RATE_THRESHOLD
|
||||
end
|
||||
|
||||
def meets_teacher_threshold?
|
||||
rate >= TEACHER_RATE_THRESHOLD * 100
|
||||
rate >= TEACHER_RATE_THRESHOLD
|
||||
end
|
||||
|
||||
def cap_at_100(response_rate)
|
||||
response_rate > 100 ? 100 : response_rate
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
class TeacherResponseRate
|
||||
include ResponseRate
|
||||
|
||||
def rate
|
||||
cap_at_100(super)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cap_at_100(response_rate)
|
||||
response_rate > 100 ? 100 : response_rate
|
||||
end
|
||||
|
||||
def survey_item_count
|
||||
@survey_item_count ||= @subcategory.measures.map { |measure| measure.teacher_survey_items.count }.sum
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue