mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
continue refactoring
This commit is contained in:
parent
e89358dacc
commit
b7abf2bc8b
4 changed files with 13 additions and 13 deletions
|
|
@ -2,4 +2,9 @@
|
||||||
|
|
||||||
class Score < Struct.new(:average, :meets_teacher_threshold?, :meets_student_threshold?, :meets_admin_data_threshold?)
|
class Score < Struct.new(:average, :meets_teacher_threshold?, :meets_student_threshold?, :meets_admin_data_threshold?)
|
||||||
NIL_SCORE = Score.new(nil, false, false, false)
|
NIL_SCORE = Score.new(nil, false, false, false)
|
||||||
|
def in_zone?(zone:)
|
||||||
|
return false if average.nil? || average.is_a?(Float) && average.nan?
|
||||||
|
|
||||||
|
average.between?(zone.low_benchmark, zone.high_benchmark)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,12 @@ class AnalyzeBarPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def y_offset
|
def y_offset
|
||||||
|
benchmark_height = analyze_zone_height * 2
|
||||||
case zone.type
|
case zone.type
|
||||||
when :ideal, :approval
|
when :ideal, :approval
|
||||||
(analyze_zone_height * 2) - bar_height_percentage
|
benchmark_height - bar_height_percentage
|
||||||
else
|
else
|
||||||
(analyze_zone_height * 2)
|
benchmark_height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -49,8 +50,7 @@ class AnalyzeBarPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def average
|
def average
|
||||||
average = score.average
|
average = score.average || 0
|
||||||
return 0 if average.nil?
|
|
||||||
|
|
||||||
average.round(6)
|
average.round(6)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ class VarianceChartRowPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def percentage
|
def percentage
|
||||||
(@score - zone.low_benchmark) / (zone.high_benchmark - zone.low_benchmark)
|
low_benchmark = zone.low_benchmark
|
||||||
|
(@score - low_benchmark) / (zone.high_benchmark - low_benchmark)
|
||||||
end
|
end
|
||||||
|
|
||||||
def zone
|
def zone
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,7 @@ class Zones
|
||||||
@warning_low_benchmark = 1
|
@warning_low_benchmark = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
Zone = Struct.new(:low_benchmark, :high_benchmark, :type) do
|
Zone = Struct.new(:low_benchmark, :high_benchmark, :type)
|
||||||
def contains?(number)
|
|
||||||
return false if number.nil? || number.is_a?(Float) && number.nan?
|
|
||||||
|
|
||||||
number.between?(low_benchmark, high_benchmark)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def all_zones
|
def all_zones
|
||||||
[
|
[
|
||||||
|
|
@ -48,6 +42,6 @@ class Zones
|
||||||
end
|
end
|
||||||
|
|
||||||
def zone_for_score(score)
|
def zone_for_score(score)
|
||||||
all_zones.find { |zone| zone.contains?(score) } || insufficient_data
|
all_zones.find { |zone| Score.new(score).in_zone?(zone:) } || insufficient_data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue