-
Improvement
-
Resolution: Fixed
-
Minor
-
4.3
-
MOODLE_403_STABLE
-
MOODLE_403_STABLE
-
MDL-78207-master -
-
3
-
HQ 2023 Sprint i2.2 Moppies
Activities can add extra HTML to the activity card using the afterlink feature. This integration allows things like:
- In mod_forum, this HTML is a bootstrap pill with unread messages.
- In mod_resource is plain text with the file details.
The new activity card design proposed for 4.3 differentiates badge information from other HTML content. The badge will appear just after the activity name and any other content will appear on the lower part of the card.
This issue is to implement the new "badge" integration allowing plugins to:
- Decide if they want to display a badge near the activity name
- Return the plain text (not HTML) badge content
- Optionally, set the badge style (notice, alert, warning...). Important note: it should be a "badge-none" class to display the badge as a transparent background and without a border (needed in some cases when the badge is secondary information like the file extension)
- An optional URL to direct the user when the badge is clicked
- An optional ID to add the element in case the module wants to add some JS to the badge events.
- Optionally, any other extra HTML attributes to the badge element (for example, data attributes).
To test the integration, this issue also includes moving the current mod_forum unread messages pill from the generic information to the pill one.
Technical shaping
The current afterlink is the typical integration that allows anarchy because they don't limit the content plugins can add to the course page.
In this case, the badge should only allow plain text and some specifications like the badge style. To limit the excess of creativity of the plugins, the best approach is to allow plugins to implement a specific class. For example, mod_PLUGINNAME\output\courseformat\activitybadge that extends from an original core_courseformat\output\activitybadge. The core_courseformat\output\activitybadge will delegate most data attributes to protected methods.
Using this approach, we can guarantee activities will only override some methods.
Finally, the activity badge can be rendered using the existing course/format/templates/local/content/cm/badges mustache or creating a new one.