class Result

Constants

MARKING_STATES

Public Instance Methods

get_negative_extra_percentage() click to toggle source
# File app/models/result.rb, line 60
def get_negative_extra_percentage
  extra_marks.negative.percentage.sum('extra_mark')
end
get_negative_extra_points() click to toggle source

Returns the sum of all the negative bonus marks

# File app/models/result.rb, line 47
def get_negative_extra_points
  extra_marks.negative.points.sum('extra_mark')
end
get_positive_extra_percentage() click to toggle source
# File app/models/result.rb, line 56
def get_positive_extra_percentage
  extra_marks.positive.percentage.sum('extra_mark')
end
get_positive_extra_points() click to toggle source

returns the sum of all the POSITIVE extra marks

# File app/models/result.rb, line 42
def get_positive_extra_points
  extra_marks.positive.points.sum('extra_mark')
end
get_subtotal() click to toggle source

returns the sum of the marks not including bonuses/deductions

# File app/models/result.rb, line 33
def get_subtotal
  total = 0.0
  self.marks.all(:include => [:markable]).each do |m|
    total = total + m.get_mark
  end
  total
end
get_total_extra_percentage() click to toggle source
# File app/models/result.rb, line 64
def get_total_extra_percentage
  return 0.0 if extra_marks.empty?
  get_positive_extra_percentage + get_negative_extra_percentage
end
get_total_extra_percentage_as_points() click to toggle source
# File app/models/result.rb, line 69
def get_total_extra_percentage_as_points
  get_total_extra_percentage * submission.assignment.total_mark / 100
end
get_total_extra_points() click to toggle source
# File app/models/result.rb, line 51
def get_total_extra_points
  return 0.0 if extra_marks.empty?
  get_positive_extra_points + get_negative_extra_points
end
mark_as_partial() click to toggle source
# File app/models/result.rb, line 79
def mark_as_partial
  return if self.released_to_students
  self.marking_state = Result::MARKING_STATES[:partial]
  self.save
end
unrelease_results() click to toggle source

un-releases the result

# File app/models/result.rb, line 74
def unrelease_results
  self.released_to_students = false
  self.save
end
update_total_mark() click to toggle source

calculate the total mark for this assignment

# File app/models/result.rb, line 23
def update_total_mark
  total = get_subtotal + get_total_extra_points
  # added_percentage
  percentage = get_total_extra_percentage
  total = total + (percentage * submission.assignment.total_mark / 100)
  self.total_mark = total
  self.save
end