Draw the teacher survey data bar. Finishes #182226823

This commit is contained in:
Nelson Jovel 2022-05-25 19:32:59 -07:00
parent a134de3fdd
commit 3d7e62f21f
10 changed files with 394 additions and 85 deletions

View file

@ -57,8 +57,8 @@ class Measure < ActiveRecord::Base
next Score.new(nil, false, false, false) if incalculable_score
scores = []
scores << collect_survey_scale_average(teacher_scales, school, academic_year) if meets_teacher_threshold
scores << collect_survey_scale_average(student_scales, school, academic_year) if meets_student_threshold
scores << teacher_score(school:, academic_year:).average if meets_teacher_threshold
scores << student_score(school:, academic_year:).average if meets_student_threshold
scores << collect_admin_scale_average(admin_data_items, school, academic_year) if includes_admin_data_items?
average = scores.flatten.compact.remove_zeros.average
@ -72,6 +72,26 @@ class Measure < ActiveRecord::Base
@score[[school, academic_year]]
end
def student_score(school:, academic_year:)
@student_score ||= begin
meets_student_threshold = sufficient_student_data?(school:, academic_year:)
meets_teacher_threshold = sufficient_teacher_data?(school:, academic_year:)
meets_admin_data_threshold = all_admin_data_collected?(school:, academic_year:)
average = collect_survey_scale_average(student_scales, school, academic_year) if meets_student_threshold
Score.new(average, meets_teacher_threshold, meets_student_threshold, meets_admin_data_threshold)
end
end
def teacher_score(school:, academic_year:)
@teacher_score ||= begin
meets_student_threshold = sufficient_student_data?(school:, academic_year:)
meets_teacher_threshold = sufficient_teacher_data?(school:, academic_year:)
meets_admin_data_threshold = all_admin_data_collected?(school:, academic_year:)
average = collect_survey_scale_average(teacher_scales, school, academic_year) if meets_teacher_threshold
Score.new(average, meets_teacher_threshold, meets_student_threshold, meets_admin_data_threshold)
end
end
def warning_low_benchmark
1
end