Use shortcodes

To use shortcodes with Level up!, the plugin Shortcodes must be installed and enabled.

Shortcodes are short words delimited by square brackets such as [xpbadge] which can be added to text editors in Moodle. When displayed, they are transformed into content. The term shortcode was popularised by Wordpress.

List of shortcodes built-in Level up!

xpbadge

This displays the level badge of the user viewing the content.

[xpbadge]

xpprogressbar

This displays the progress bar indicating the learner's progression towards the next level.

[xpprogressbar]

xpladder

This displays a fraction of the ladder including the current user and a few adjacent users. It comes with optional parameters.

When the option withprogress is used, the column displaying the progress bar will be included in the ladder. Note that this requires the progress bar to be enabled in the additional columns of the ladder's settings.

By default, a link to the full ladder is added below the table, use the attribute hidelink to hide this link.

Examples

[xpladder]
[xpladder withprogress]
[xpladder hidelink withprogress]

Notes

  • The ladder must be enabled for the shortcode to work
  • When a course is using groups, the plugin will best guess which group to use for the user viewing the content

xpiflevel

Unlike other shortcodes, this allows you to hide or show content to a learner based on their level. You must wrap the content to display or hide between an opening and closing shortcode. This shortcode requires arguments to define which levels are required for the content to be displayed.

When a level is strictly specified, the content will be displayed regardless of the other arguments. The greater and less than arguments must all match for the content to be displayed. Watch out as that may sometimes result in the content to never be displayed! Note that teachers, or otherwise users with editing capabilities, will always see everything.

Examples

[xpiflevel 1 3 5]
    Displayed if the user's level is exactly 1, 3 or 5.
[/xpiflevel]

[xpiflevel >3]
    Displayed if the user's level is greater than 3.
[/xpiflevel]

[xpiflevel >=3]
    Displayed if the user's level is greater or equal to 3.
[/xpiflevel]

[xpiflevel >=10 <20 30]
    Displayed if the user's level is greater or equal to 10 AND is strictly less than 20
    OR is exactly equal to 30.
[/xpiflevel]

[xpiflevel <=10 >=20]
    Never displayed because the user's level can never be less or equal to 10 AND more or equal to 20.
[/xpiflevel]

Note that these shortcodes cannot be nested within one another.