Class: Gaku::Grading::Single::Calculations
- Inherits:
-
Object
- Object
- Gaku::Grading::Single::Calculations
- Defined in:
- lib/gaku/grading/single/calculations.rb
Instance Attribute Summary collapse
-
#collection_students ⇒ Object
readonly
Returns the value of attribute collection_students.
-
#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.
-
#student ⇒ Object
readonly
Returns the value of attribute student.
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(grading_methods, student, exam, gradable_scope, collection_students = nil) ⇒ Calculations
constructor
A new instance of Calculations.
Constructor Details
#initialize(grading_methods, student, exam, gradable_scope, collection_students = nil) ⇒ Calculations
Returns a new instance of Calculations.
8 9 10 11 12 13 14 |
# File 'lib/gaku/grading/single/calculations.rb', line 8 def initialize(grading_methods, student, exam, gradable_scope, collection_students = nil) @exam = exam @student = student @grading_methods = grading_methods @collection_students = collection_students @gradable_scope = gradable_scope end |
Instance Attribute Details
#collection_students ⇒ Object (readonly)
Returns the value of attribute collection_students.
6 7 8 |
# File 'lib/gaku/grading/single/calculations.rb', line 6 def collection_students @collection_students end |
#exam ⇒ Object (readonly)
Returns the value of attribute exam.
6 7 8 |
# File 'lib/gaku/grading/single/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/single/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/single/calculations.rb', line 6 def grading_methods @grading_methods end |
#student ⇒ Object (readonly)
Returns the value of attribute student.
6 7 8 |
# File 'lib/gaku/grading/single/calculations.rb', line 6 def student @student end |
Instance Method Details
#calculate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gaku/grading/single/calculations.rb', line 16 def calculate {}.tap do |hash| @grading_methods.each do |grading_method| if grading_method.interval? grading = Gaku::Grading::Collection::Interval.new(@exam, collection_students, gradable_scope, grading_method.criteria ) hash[grading_method.id] = grading.grade else grading = grading_types[grading_method.grading_type].constantize.new(@exam, @student, gradable_scope, grading_method.criteria) hash[grading_method.id] = grading.grade end end end end |