KB1243 - Using FilterCodes for Course Enhancement

VCC Moodle includes an advanced feature called "FilterCodes" which allows you to personalize and enhance your online course by including course and user-specific details. FilterCodes are extremely powerful and useful. There are over fifty different filtercodes available, some of which can be combined (nested) with others to give you Moodle system or user information that would otherwise require a database query or use of Moodle's APIs.

In Moodle, FilterCodes are small snippets of text or keywords, wrapped in curly braces, like this:


They're similar in nature to "embed codes" seen in WordPress.  They can be embedded inside Moodle resources, activities, or blocks, to add unique information for each user or to display course-specific details. You can use them to address a Student by their first or full name or to show each user their current course completion status.

Practical Examples

User Greeting and Course Status

In this example, the Instructor has added FilterCodes to a Moodle Label to display the Student's name, and their Course Completion progress, as text and as a graphical progress bar. (The code below is added in HTML source mode, after clicking the editor's HTML source icon.)

<h3><strong><span class="" style="color: rgb(17, 119, 208);">Hello {alternatename}!</span></strong></h3>
<p>Your course progress: <strong>{courseprogress}</strong><br>{courseprogressbar}</p>

The final result appears like this in the course:
Image showing sample use of a FilterCode in a Moodle course

Navigation Links that won't break

Creating a "hard link" in your course is problematic in that it is usually course-specific, and will break or point your users to the wrong place if your course is copies into a new shell. If you need to create a navigation link to put your Students back to your course's front page or anywhere in your course, you can use FilterCodes to ensure that the correct Course and Sectio0n IDs are always used, no matter which VCC shell your content is copies to.  

Back to section / Back to course

Help students navigate your Moodle site by implementing this handy-dandy BACK button. Works at both the section and activity level.

<p style="float:right;"><a href="{wwwroot}/course/view.php?id={courseid}&amp;section={sectionid}" class="btn btn-outline" style="font-size:14px;">Go Back</a></p>

If you are in a section and want to go directly back to the main course outline but scroll down to the current section, try this:

<p style="float:right;"><a href="{wwwroot}/course/view.php?id={courseid}#section-{sectionid}" class="btn btn-outline" style="font-size:14px;">Back to course outline</a></p>

From the FilterCodes GitHub documentation page

Expandable/Collapsible Sections

Some filtercodes are for presentation only. In the following, the details and summary filtercodes allow you to create a collapsed line of text that reveals more text when it's clicked.
Using this, you could declutter some of your presentation and allow the user to reveal only the details they want to see.

Here's the text that you can enter into a Moodle label, just as you see it here:

{summary}User Details{/summary}
Name: {fullname}

Course Status: {coursecompletiondate dateTimeFormat}


The "summary" text is contained between a starting "summary" and ending /summary" filtercode.
This is the one line text that can describe the information that will be revealed.

The text after that, also contained between the starting "details" and ending "/details" filtercodes, is all the other detailed information that you want to reveal to the user. 

The end result should look like this:

Example of using FilterCode in a Moodle course

Related Resouces:



Article ID: 1181
Wed 4/28/21 12:22 PM
Tue 3/21/23 4:11 PM

Related Services / Offerings (1)

Online design or implementation of activities or resources in the Moodle LMS.