Class: Gaku::Grading::Collection::Calculations

Inherits:
Object
  • Object
show all
Defined in:
lib/gaku/grading/collection/calculations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grading_method, students, exam, gradable_scope) ⇒ Calculations

Returns a new instance of Calculations.



8
9
10
11
12
13
14
# 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

Instance Attribute Details

#examObject (readonly)

Returns the value of attribute exam.



6
7
8
# File 'lib/gaku/grading/collection/calculations.rb', line 6

def exam
  @exam
end

#gradable_scopeObject (readonly)

Returns the value of attribute gradable_scope.



6
7
8
# File 'lib/gaku/grading/collection/calculations.rb', line 6

def gradable_scope
  @gradable_scope
end

#grading_methodsObject (readonly)

Returns the value of attribute grading_methods.



6
7
8
# File 'lib/gaku/grading/collection/calculations.rb', line 6

def grading_methods
  @grading_methods
end

#studentsObject (readonly)

Returns the value of attribute students.



6
7
8
# File 'lib/gaku/grading/collection/calculations.rb', line 6

def students
  @students
end

Instance Method Details

#calculateObject



16
17
18
19
20
21
22
23
# 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