Class: Gaku::Grading::Single::Score

Inherits:
BaseMethod show all
Defined in:
lib/gaku/grading/single/score.rb

Instance Attribute Summary

Attributes inherited from BaseMethod

#criteria, #gradable, #gradable_scope, #gradable_type, #result, #student

Instance Method Summary collapse

Methods inherited from BaseMethod

#grade, #initialize

Constructor Details

This class inherits a constructor from Gaku::Grading::Single::BaseMethod

Instance Method Details

#grade_examObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/gaku/grading/single/score.rb', line 3

def grade_exam
  @score = nil
  exam = @gradable
  exam.exam_portions.select(&:score?).each_with_index do |exam_portion, index|
    ep_score = @student.exam_portion_scores.find_by(gradable: gradable_scope, exam_portion_id: exam_portion.id)
    @score = @score.to_f + ep_score.score if ep_score.score
  end

  @result = { id: @student.id, score: @score }
end