Class: Gaku::Grading::Collection::Calculations
- Inherits:
-
Object
- Object
- Gaku::Grading::Collection::Calculations
- Defined in:
- lib/gaku/grading/collection/calculations.rb
Instance Attribute Summary collapse
-
#exam ⇒ Object
readonly
Returns the value of attribute exam.
-
#gradable_scope ⇒ Object
readonly
Returns the value of attribute gradable_scope.
-
#grading_methods ⇒ Object
readonly
Returns the value of attribute grading_methods.
-
#students ⇒ Object
readonly
Returns the value of attribute students.
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(grading_method, students, exam, gradable_scope) ⇒ Calculations
constructor
A new instance of Calculations.
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
#exam ⇒ Object (readonly)
Returns the value of attribute exam.
6 7 8 |
# File 'lib/gaku/grading/collection/calculations.rb', line 6 def exam @exam end |
#gradable_scope ⇒ Object (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_methods ⇒ Object (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 |
#students ⇒ Object (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
#calculate ⇒ Object
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 |