ElearningWorld.org

For the online learning world

Elearning WorldLMSMoodleTechnical

5 ways to personalize Moodle LMS with FilterCodes

One of my favourite and most useful open source plugins for Moodle LMS is FilterCodes, a filter type plugin for Moodle 2.7 to 4.x which offers an extensive collection of over 170 easy to use plain text tags that you can use anywhere that filters are supported. No PHP programming, HTML or CSS coding knowledge is required. I created FilterCodes to enable Moodle Administrators, Managers and Teachers to personalize users’ experience by adding dynamic content. This month, I would like to share with you just 5 of the many ways you can use it too.

1. Greeting: Hello Your Name

The most basic of all FilterCodes tags are {firstname}, {lastname} and {fullname}. These tags do exactly what you might expect – they insert the user’s first name, last name and their full name. For example, you could create an HTML block, a Label on the Front/Home page or dashboard, or even in a course to personally welcome learners after they sign in. Another useful tag is {coursename} which gets replaced with the name of a course when the page is displayed (not in the editor). If you are not in a course, it gets replaced with the site name.

For example, enter and save the following:

Hi {firstname}! Welcome to {coursename}.

When you save and display the page, assuming you were logged in as “Michael Milette” and in a course called “FilterCodes 101”, this would display:

Hi Michael! Welcome to FilterCodes 101.

2. Display a greeting, but only if logged-in

Let’s say you wanted to display this message on the Front/Home page, but only if the user is logged in. FilterCodes includes a selection of over 40 conditional {if…} tags including {ifloggedin}{/ifloggedin} and {ifloggedout}{/ifloggedout}. The way these tags work is very simple. Anything between the {ifloggedin} and {/ifloggedin} tags will be displayed only if the user is logged in. If the user is logged out, it won’t display anything.

For example, enter and save:

{ifloggedin}Hi {firstname}! Your current timezone is set to {timezone}. Be sure to set your timezone correctly in your profile to ensure that the date and time of events and deadlines appear in your local time.{/ifloggedin}

Tip: You might even link the word profile to the user’s own profile (/user/profile.php), assuming that your instance of Moodle is installed in the webroot of your site. If it is installed in a subdirectory called moodle (example: example.com/moodle), then the link would be /moodle/user/profile.php.

You can also use the {ifloggedout}{/ifloggedout} tags to display alternative content if the user has yet to log in. Example:

{ifloggedin}Hi {firstname}! Your current timezone is set to {timezone}. Be sure to set your timezone correctly in your profile to ensure that the date and time of events and deadlines appear in your local time.{/ifloggedin}{ifloggedout}To get started, create an account or sign in.{/ifloggedout}

Take it one step further by turning the words create an account into a link (example: /login/signup.php), and set the link for sign in to your site’s login page (example: /login/). Be sure not to include the { or } braces when linking the text or the tag won’t work.

3. Display courses and categories as cards

If you are using the Boost or Classic theme, or any theme that does not offer alternative ways of displaying courses on the front/home page, FilterCodes includes tags that can modernize the appearance of your list of courses.

Step 1: Disable Moodle’s display of categories and courses.

Turn off the display of courses on the front/home page. As a site administrator, navigate to Site Administration > Front page settings, and set Front page and Front page items when logged in to None.

Step 2: Add a label to the Front/Home page.

Navigate to the Front/Home page and turn editing on. Add a Label resource to the page and include the following text. Make the headings Heading (large) size. Depending on your theme, you may need to edit the HTML to change it to an <h2> heading for accessibility.

Check for upcoming courses in these cities

{categorycards}

Available Courses

{coursecards}

This will display your categories (categories are city names in this example). Note that there are settings in FilterCodes’ settings page to control how this appears:

It will also display a list of courses:

For consistency, courses that do not have a course image will display the same colour/pattern image that Moodle will display on the Dashboard / My Courses (Moodle 4.0+) page.

4. Display course progress bar – in a course!

If your courses have completion tracking enabled, you can display a progress bar right in your course, similar to the one seen on the Dashboard / My Courses (Moodle 4.0+) page. Simply add a {chart progressbar {coursegradepercent} Overall completion} tag in a block or label on your course page.

5. Display information based on the user’s role

There are several conditional {if…} FilterCodes’ tags that enable you to display content to users with specific roles. For example, you can add the following content to an HTML block on the Dashboard, restricting the display of some information to just Moodle site Administrators and Managers:

Hello {fullname}!

Today is: {now}
Your Location: {city}, {country}
Your Timezone: {timezone}

{ifminsitemanager}
Active users: {usersactive} of a total of {usercount}
Users online: {usersonline}
Total courses: {coursecount}
Users from countries: {userscountrycount}
{/ifminsitemanager}

{button /course/}See all courses{/button}

This will display the following custom block. The active users, users online, total courses and users from countries information will only be seen by Site Managers and Administrators. The rest of the information will be displayed to all users.

Did you notice how easy it is to create a button using the {button}{/button} tags?

With a little custom HTML and bootstrap classes, you could improve the appearance of this information panel, all without developing any custom PHP code.

Troubleshooting

We have only touched the surface of the possibilities of using the FilterCodes plugin. If you have any problems using FilterCodes or any of its tags, take a look at the Troubleshooting tips in the documentation. To learn more about FilterCodes, download and install it on your Moodle LMS-based sites, visit the FilterCodes plugin page on Moodle.org.

After reading this article, my wife suggested that I challenge readers to share their creative ideas. Let me know how you use FilterCodes on your Moodle LMS site.

See you next month!

Michael Milette

Michael Milette
Follow me

Michael Milette

Michael Milette is the owner and an independent consultant with TNG Consulting Inc. in Canada. He works with government, non-profit organizations, businesses and educational institutions on Moodle-related projects. Michael writes about implementing Moodle LMS, developing in Moodle, Moodle administration, using the FilterCodes plugin (his own project), creating multi-language Moodle implementations and courses, and WCAG 2.1 accessibility.

2 thoughts on “5 ways to personalize Moodle LMS with FilterCodes

  • Anonymous

    Hello,

    thank you for the great tips. I am new to FilterCodes and definitely will explore it.

    I really like the idea of the if functions, which makes it easy to use only one label and write everything for all different roles. That is amazing. So far I used the restrictions in the activities and had to create difefrent labels for different people.

    I tried to use your examples on my frontpage, but some of the codes are not working.

    I used:

    {ifminsitemanager}
    Active users: {usersactive} of a total of {usercount}
    Users online: {usersonline}
    Total courses: {coursecount}
    Users from countries: {userscountrycount}
    {/ifminsitemanager}

    {button /course/}See all courses{/button}

    Active users: 783 of a total of 784
    Users online: 1
    Total courses: 41
    Users from countries: {userscountrycount}

    {button /course/}See all courses{/button}

    Can you maybe help me out, what this can be?

    I tried it on our Live-site (Moodle 3.9) as well as on our Sandbox (Moodle 4.0).

    I also read somewhere that {coursename ID} would show the Coursename of the course with a particular ID – this is also not functioning for me.

    Thank you so much and many greetings,

    Tanja

    Reply
    • Hi Tanja,

      I am so glad to hear that you are finding FilterCodes amazing. With regards to the issues you are experiencing, I suspect that you may have installed an older version of FilterCodes. The tags that don’t seem to work were all introduced in release 2.3.0 in April 2022. Even better, upgrade to the latest version of FilterCodes release 2.3.1. It includes a couple of bug fixes with the {mygroups} and {ifingroup} tags.

      If you have any more questions, please feel free to join the discussion page or report an issue in the bug tracker.

      You may also find some helpful information in the Troubleshooting or FAQ sections of the documentation.

      Best regards,

      Michael

Add a reply or comment...