Sha256: 2ead804135a3e213f496064dcb617c578c7eff60fd87847d02b81ba718606fa5

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module Gaku
  module Grading
    module Collection
      class  Calculations

        attr_reader :grading_methods, :students, :exam

        def initialize(grading_method, students, exam)
          @exam            = exam
          @students        = students
          @grading_methods = grading_method
        end

        def calculate
          {}.tap do |hash|
            @grading_methods.each do |grading_method|
              grading = grading_types[grading_method.grading_type].constantize.new(@exam, @students, grading_method.criteria)
              hash[grading_method.id] = grading.grade
            end
          end
        end

        private

        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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
gaku-0.2.4 core/lib/gaku/grading/collection/calculations.rb
gaku_core-0.2.4 lib/gaku/grading/collection/calculations.rb
gaku-0.2.3 core/lib/gaku/grading/collection/calculations.rb
gaku_core-0.2.3 lib/gaku/grading/collection/calculations.rb
gaku-0.2.2 core/lib/gaku/grading/collection/calculations.rb
gaku_core-0.2.2 lib/gaku/grading/collection/calculations.rb
gaku-0.2.1 core/lib/gaku/grading/collection/calculations.rb
gaku_core-0.2.1 lib/gaku/grading/collection/calculations.rb
gaku-0.2.0 core/lib/gaku/grading/collection/calculations.rb
gaku_core-0.2.0 lib/gaku/grading/collection/calculations.rb