Class: Gaku::Grading::Collection::BaseMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/gaku/grading/collection/base_method.rb

Direct Known Subclasses

Interval, Ordinal, Percentage, Score

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gradable, students, gradable_scope, criteria = nil) ⇒ BaseMethod

Pass a gradable object [exam or assignment] and students



8
9
10
11
12
13
14
# File 'lib/gaku/grading/collection/base_method.rb', line 8

def initialize(gradable, students, gradable_scope, criteria = nil)
  @gradable_scope = gradable_scope
  @gradable = gradable
  @students = students
  @criteria = criteria
  @result = []
end

Instance Attribute Details

#criteriaObject (readonly)

Returns the value of attribute criteria.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def criteria
  @criteria
end

#gradableObject (readonly)

Returns the value of attribute gradable.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def gradable
  @gradable
end

#gradable_scopeObject (readonly)

Returns the value of attribute gradable_scope.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def gradable_scope
  @gradable_scope
end

#gradable_typeObject (readonly)

Returns the value of attribute gradable_type.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def gradable_type
  @gradable_type
end

#resultsObject (readonly)

Returns the value of attribute results.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def results
  @results
end

#studentsObject (readonly)

Returns the value of attribute students.



5
6
7
# File 'lib/gaku/grading/collection/base_method.rb', line 5

def students
  @students
end

Instance Method Details

#gradeObject

Obtain graded hash of results



17
18
19
20
21
22
23
24
25
26
# File 'lib/gaku/grading/collection/base_method.rb', line 17

def grade
  case @gradable
  when Gaku::Exam
    grade_exam
  when Gaku::Assignment
    grade_assignment(@gradable)
  end

  Gaku::Grading::Collection::Result.new(@gradable.id, @result).as_json
end