Module: CourseUser::StaffConcern

Extended by:
ActiveSupport::Concern
Included in:
CourseUser
Defined in:
app/models/concerns/course_user/staff_concern.rb

Overview

This concern related to staff performance calculation.

Instance Method Summary collapse

Instance Method Details

#average_marking_timeFloat

Returns the average marking time of the staff.

Returns:

  • (Float)

    Time in seconds.


41
42
43
44
45
46
47
48
# File 'app/models/concerns/course_user/staff_concern.rb', line 41

def average_marking_time
  @average_marking_time ||=
    if valid_submissions.empty?
      nil
    else
      valid_submissions.sum { |s| s.published_at - s. } / valid_submissions.size
    end
end

#marking_time_stddevFloat

Returns the standard deviation of the marking time of the staff.

Returns:

  • (Float)

53
54
55
56
57
# File 'app/models/concerns/course_user/staff_concern.rb', line 53

def marking_time_stddev
  # An array of time in seconds.
  time_diff = valid_submissions.map { |s| s.published_at - s. }
  standard_deviation(time_diff)
end

#published_submissionsObject

Returns the published submissions for the purpose of calculating marking statistics.

This inlcudes only submissions from non-phantom, student course_users.


28
29
30
31
32
33
34
35
36
# File 'app/models/concerns/course_user/staff_concern.rb', line 28

def published_submissions
  @published_submissions ||=
    Course::Assessment::Submission.
    joins(experience_points_record: :course_user).
    where('course_users.role = ?', CourseUser.roles[:student]).
    where('course_users.phantom = ?', false).
    where('course_assessment_submissions.publisher_id = ?', user_id).
    where('course_users.course_id = ?', course_id)
end