Module: Course::LeaderboardsHelper

Includes:
Achievement::AchievementsHelper
Included in:
ControllerHelper
Defined in:
app/helpers/course/leaderboards_helper.rb

Instance Method Summary collapse

Methods included from Achievement::AchievementsHelper

#achievement_badge_path, #display_achievement_badge

Instance Method Details

#display_user_countInteger


6
7
8
# File 'app/helpers/course/leaderboards_helper.rb', line 6

def display_user_count
  @display_user_count ||= @settings.display_user_count
end

#leaderboard_position(course, course_user, display_user_count) ⇒ nil, Integer

Computes the position of a student on a course's leaderboard.


17
18
19
20
21
# File 'app/helpers/course/leaderboards_helper.rb', line 17

def leaderboard_position(course, course_user, display_user_count)
  index = course.course_users.students.without_phantom_users.includes(:user).
          ordered_by_experience_points.take(display_user_count).find_index(course_user)
  index && index + 1
end