Module: Course::Achievement::AchievementsHelper

Included in:
ControllerHelper, Course::Assessment::AssessmentsHelper, LeaderboardsHelper, UsersHelper
Defined in:
app/helpers/course/achievement/achievements_helper.rb

Instance Method Summary collapse

Instance Method Details

#achievement_badge_path(achievement = nil) ⇒ String

Returns the path of achievement badge, if badge is present. Otherwise, return default achievement badge.


20
21
22
# File 'app/helpers/course/achievement/achievements_helper.rb', line 20

def achievement_badge_path(achievement = nil)
  image_path(achievement&.badge&.medium&.url || 'achievement_blank.png')
end

#display_achievement_badge(achievement) ⇒ String

Returns the HTML code to display the achievement badge. If badge is present, return medium version of the badge (see ImageUploader for more versions). Otherwise, return default achievement badge.


9
10
11
12
13
# File 'app/helpers/course/achievement/achievements_helper.rb', line 9

def display_achievement_badge(achievement)
  (:span, class: ['image']) do
    image_tag(achievement_badge_path(achievement))
  end
end