lib/tsuno/activity.rb
# Calculates the final grade from each section.
#
#   complex_grade(YAML.parse('test: ing'))
# @param [YAML::DBM] sections each section in YAML format
# @return [Float] the calculated grade
Calculates the final grade from each section.
Calculates the final grade from each section .
def complex_grade(sections)
      if sections[0]['weight']
        sections.map {|section|
          section['grade'] * section['weight']
        }.reduce(:+)
      else
        grades = sections.map {|section| section['grade']}
        grades.reduce(:+) / grades.size
      end
    end
def complex_grade ( sections ) if sections [ 0 ] [ 'weight' ] sections . map { | section | section [ 'grade' ] * section [ 'weight' ] } . reduce ( :+ ) else grades = sections . map { | section | section [ 'grade' ] } grades . reduce ( :+ ) / grades . size end end
Calculates the final grade from each section.
Calculates the final grade from each section .
the calculated grade
the calculated grade
Float
sections
<not_specific>
<not_specific>
sections each section in YAML format
sections each section in YAML format