mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Remove sufficient_data parameter from MeasureGraphRowPresenter
This commit is contained in:
parent
10e70557bd
commit
b4a6ae0bd7
4 changed files with 22 additions and 21 deletions
|
|
@ -23,18 +23,7 @@ class DashboardController < SqmApplicationController
|
|||
end
|
||||
|
||||
def presenter_for_measure(measure)
|
||||
sufficient_data = SurveyItemResponse.sufficient_data?(measure: measure, academic_year: academic_year, school: school)
|
||||
|
||||
unless sufficient_data
|
||||
return MeasureGraphRowPresenter.new(
|
||||
measure: measure,
|
||||
sufficient_data: false
|
||||
)
|
||||
end
|
||||
|
||||
score = SurveyItemResponse.for_measure(measure)
|
||||
.where(academic_year: academic_year, school: school)
|
||||
.average(:likert_score)
|
||||
score = sufficient_data?(measure: measure) ? score(measure: measure) : nil
|
||||
|
||||
MeasureGraphRowPresenter.new(
|
||||
measure: measure,
|
||||
|
|
@ -42,4 +31,14 @@ class DashboardController < SqmApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
def sufficient_data?(measure:)
|
||||
SurveyItemResponse.sufficient_data?(measure: measure, academic_year: academic_year, school: school)
|
||||
end
|
||||
|
||||
def score(measure:)
|
||||
SurveyItemResponse.for_measure(measure)
|
||||
.where(academic_year: academic_year, school: school)
|
||||
.average(:likert_score)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,6 +44,6 @@ module VarianceHelper
|
|||
end
|
||||
|
||||
def measures_with_insufficient_data(presenters:)
|
||||
presenters.filter { |presenter| !presenter.sufficient_data? }
|
||||
presenters.filter { |presenter| presenter.score == nil }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
class MeasureGraphRowPresenter
|
||||
include Comparable
|
||||
def initialize(measure:, score: 0, sufficient_data: true)
|
||||
|
||||
attr_reader :score
|
||||
|
||||
def initialize(measure:, score:)
|
||||
@measure = measure
|
||||
@score = score
|
||||
@sufficient_data = sufficient_data
|
||||
end
|
||||
|
||||
def sufficient_data?
|
||||
@sufficient_data
|
||||
@score != nil
|
||||
end
|
||||
|
||||
def measure_name
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ describe 'dashboard/index.html.erb' do
|
|||
context 'when there are measures for which, in the given academic year, the school has insufficient responses' do
|
||||
let(:measure_graph_row_presenters) {
|
||||
[
|
||||
MeasureGraphRowPresenter.new(measure: support_for_teaching, score: 0, sufficient_data: false),
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure), score: 0, sufficient_data: true),
|
||||
MeasureGraphRowPresenter.new(measure: effective_leadership, score: 0, sufficient_data: false),
|
||||
MeasureGraphRowPresenter.new(measure: professional_qualifications, score: 0, sufficient_data: false)
|
||||
MeasureGraphRowPresenter.new(measure: support_for_teaching, score: nil),
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure), score: rand),
|
||||
MeasureGraphRowPresenter.new(measure: effective_leadership, score: nil),
|
||||
MeasureGraphRowPresenter.new(measure: professional_qualifications, score: nil)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ describe 'dashboard/index.html.erb' do
|
|||
context 'when there are no measures for which, in the given academic year, the school has insufficient responses' do
|
||||
let(:measure_graph_row_presenters) {
|
||||
[
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure), score: 0, sufficient_data: true)
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure), score: rand)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue