class Gaku::Grading::Collection::Calculations

Attributes

exam[R]
gradable_scope[R]
grading_methods[R]
students[R]

Public Class Methods

new(grading_method, students, exam, gradable_scope) click to toggle source
# File lib/gaku/grading/collection/calculations.rb, line 8
def initialize(grading_method, students, exam, gradable_scope)
  @exam            = exam
  @students        = students
  @grading_methods = grading_method
  @gradable_scope  = gradable_scope

end

Public Instance Methods

calculate() click to toggle source
# File lib/gaku/grading/collection/calculations.rb, line 16
def calculate
  {}.tap do |hash|
    @grading_methods.each do |grading_method|
      grading = grading_types[grading_method.grading_type].constantize.new(@exam, @students, gradable_scope, grading_method.criteria)
      hash[grading_method.id] = grading.grade
    end
  end
end

Private Instance Methods

grading_types() click to toggle source
# File lib/gaku/grading/collection/calculations.rb, line 27
def grading_types
  ActiveSupport::HashWithIndifferentAccess.new(
    score: 'Gaku::Grading::Collection::Score',
    percentage: 'Gaku::Grading::Collection::Percentage',
    ordinal: 'Gaku::Grading::Collection::Ordinal',
    interval: 'Gaku::Grading::Collection::Interval'
  )
end