Class Result
In: app/models/result.rb
Parent: ActiveRecord::Base

Methods

Constants

MARKING_STATES = { :complete => 'complete', :partial => 'partial', :unmarked => 'unmarked'

Public Instance methods

[Source]

    # File app/models/result.rb, line 56
56:   def get_negative_extra_percentage
57:     return extra_marks.negative.percentage.sum('extra_mark')
58:   end

Returns the sum of all the negative bonus marks

[Source]

    # File app/models/result.rb, line 43
43:   def get_negative_extra_points
44:     return extra_marks.negative.points.sum('extra_mark')
45:   end

[Source]

    # File app/models/result.rb, line 52
52:   def get_positive_extra_percentage
53:     return extra_marks.positive.percentage.sum('extra_mark')
54:   end

returns the sum of all the POSITIVE extra marks

[Source]

    # File app/models/result.rb, line 38
38:   def get_positive_extra_points
39:     return extra_marks.positive.points.sum('extra_mark')
40:   end

returns the sum of the marks not including bonuses/deductions

[Source]

    # File app/models/result.rb, line 29
29:   def get_subtotal
30:     total = 0.0
31:     self.marks.find(:all, :include => [:markable]).each do |m|
32:       total = total + m.get_mark
33:     end
34:     return total
35:   end

[Source]

    # File app/models/result.rb, line 60
60:   def get_total_extra_percentage
61:     return 0.0 if extra_marks.empty?    
62:     return get_positive_extra_percentage + get_negative_extra_percentage
63:   end

[Source]

    # File app/models/result.rb, line 65
65:   def get_total_extra_percentage_as_points
66:     return (get_total_extra_percentage * submission.assignment.total_mark / 100)
67:   end

[Source]

    # File app/models/result.rb, line 47
47:   def get_total_extra_points
48:     return 0.0 if extra_marks.empty?
49:     return get_positive_extra_points + get_negative_extra_points
50:   end

[Source]

    # File app/models/result.rb, line 75
75:   def mark_as_partial
76:     return if self.released_to_students == true
77:     self.marking_state = Result::MARKING_STATES[:partial]
78:     self.save
79:   end

un-releases the result

[Source]

    # File app/models/result.rb, line 70
70:   def unrelease_results
71:     self.released_to_students = false
72:     self.save
73:   end

calculate the total mark for this assignment

[Source]

    # File app/models/result.rb, line 19
19:   def update_total_mark
20:     total = get_subtotal + get_total_extra_points
21:     # added_percentage
22:     percentage = get_total_extra_percentage   
23:     total = total + (percentage * submission.assignment.total_mark / 100)
24:     self.total_mark = total
25:     self.save
26:   end

[Validate]