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.

Parameters:

  • achievement (Course::Achievement|nil) (defaults to: nil)

    The achievement for which to display the badge.

Returns:

  • (String)

    The image path to display for the achievement.


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.

Parameters:

Returns:

  • (String)

    A HTML fragment containing the image to display for the achievement.


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