@ -21,13 +21,13 @@ module Analyze
end
end
def bars
def bars
@bars || = yearly_scores . map . each_with_index do | yearly_score , index |
@bars || = academic_years . map . with_index do | academic_year , index |
year = yearly_score . year
Analyze :: BarPresenter . new ( measure : , academic_year : ,
Analyze :: BarPresenter . new ( measure : , academic_year : year ,
score : score ( academic_year ) ,
score : yearly_score . score ,
x_position : bar_x ( index ) ,
x_position : bar_x ( index ) ,
color : bar_color ( year) )
color : bar_color ( academic_ year) )
end . reject ( & :blank? ) . select { | bar | bar . score . average & . positive? }
end . reject ( & :blank? ) . select { | bar | bar . score . average & . positive? }
@bars
end
end
def label
def label
@ -46,6 +46,10 @@ module Analyze
raise NotImplementedError
raise NotImplementedError
end
end
def n_size ( academic_year )
raise NotImplementedError
end
def basis
def basis
" student surveys "
" student surveys "
end
end
@ -107,11 +111,6 @@ module Analyze
% i [ student teacher ] . include? type
% i [ student teacher ] . include? type
end
end
def n_size ( academic_year )
SurveyItemResponse . where ( survey_item : measure . student_survey_items , school : , grade : grades ,
academic_year : ) . select ( :response_id ) . distinct . count
end
def popover_content ( academic_year )
def popover_content ( academic_year )
" #{ n_size ( academic_year ) } #{ type . to_s . capitalize } s "
" #{ n_size ( academic_year ) } #{ type . to_s . capitalize } s "
end
end
@ -126,12 +125,12 @@ module Analyze
private
private
YearlyScore = Struct . new ( :year , :score )
# YearlyScore = Struct.new(:year, :score )
def yearly_scores
# def yearly_scores
yearly_scores = academic_years . each . map do | year |
# @yearly_scores ||= academic_years.each.map do |year |
YearlyScore . new ( year , score ( year ) )
# YearlyScore.new(year, score(year))
end . reject { | year | year . score . nil? || year . score . blank? }
# end.reject { |year| year.score.nil? || year.score.blank? }
end
# end
def bar_color ( year )
def bar_color ( year )
@available_academic_years || = AcademicYear . order ( :range ) . all
@available_academic_years || = AcademicYear . order ( :range ) . all
@ -140,7 +139,7 @@ module Analyze
def bar_x ( index )
def bar_x ( index )
column_start_x + ( index * bar_width * 1 . 2 ) +
column_start_x + ( index * bar_width * 1 . 2 ) +
( ( column_end_x - column_start_x ) - ( yearly_score s. size * bar_width * 1 . 2 ) ) / 2
( ( column_end_x - column_start_x ) - ( academic_ years. size * bar_width * 1 . 2 ) ) / 2
end
end
end
end
end
end