cirandas.net

ref: master

plugins/evaluation/lib/ext/profile.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
require_dependency 'profile'

class Profile

  has_many :evaluations, :class_name => "EvaluationPlugin::Evaluation", :foreign_key => :evaluated_id, :dependent => :destroy

  def evaluations_mean
    return if self.evaluations.blank?
    self.evaluations.map{|e| e.score}.instance_eval { reduce(:+) / size.to_f }
  end

end