PlayerHUD Filter

Shortcode-based content integration filter for the PlayerHUD ecosystem — full documentation.

English | Português

View on GitHub Download .zip

Moodle License Status Latest Release PlayerGames Ecosystem Role Author

Moodle Plugin CI Last Commit Open Issues

The PlayerHUD Filter is a required companion plugin for the PlayerHUD Block. It enables the insertion of collectible item drops, trade offers, and the compact HUD widget directly inside Moodle course content using shortcodes.

This filter allows teachers to embed interactive drop elements within pages, labels, books, and other HTML-supported activities, integrating seamlessly with the PlayerHUD gamification system.

👈 Use the sidebar to jump to any section on this page.


✨ Features

🕹️ PlayerGames Ecosystem

This plugin is part of the PlayerGames gamification ecosystem. Together, these plugins transform Moodle into an immersive experience:

📦 Requirements

Component Version
Moodle 4.5+
PHP Compatible with your Moodle version
Required dependency PlayerHUD Block

🛠️ Installation

  1. Ensure the PlayerHUD Block is installed first — the filter depends on the block and will not install without it.

    👉 https://github.com/jeanlucio/moodle-block_playerhud

  2. Download the .zip file or clone this repository.
  3. Extract the folder into your Moodle filter/ directory.
  4. Rename the folder to playerhud (if necessary). Final path: your-moodle/filter/playerhud/
  5. Visit Site administration > Notifications to complete installation.
  6. Enable the filter in: Site administration > Plugins > Filters > Manage filters.

📖 Usage

  1. Ensure the PlayerHUD Block is added and configured in the course.
  2. Enable the PlayerHUD Filter (see Installation).
  3. Insert one of the shortcodes below inside any content area that runs Moodle filters — pages, labels, book chapters, forum posts, etc.
  4. Item drops and trade widgets render dynamically within the course; students collect/trade according to the rules defined in the PlayerHUD Block’s Management Panel.

Shortcodes are stripped out (rendered as empty) for guests, on the site front page, for a user whose block/playerhud:view capability is prohibited, and for a student who has paused their own gamification — in every one of those cases nothing about the underlying item or trade is ever sent to the browser.

Shortcode Reference

[PLAYERHUD_WIDGET]

Renders the compact PlayerHUD widget: avatar, XP/level, recent items stash, ranking badge, and (when RPG mode is enabled) the karma bar and class portrait. Takes no attributes.

[PLAYERHUD_WIDGET]

[PLAYERHUD_DROP code=... mode=... text=... button_text=... button_emoji=...]

Renders a collectible item drop trigger.

Attribute Required Values Default Description
code Yes Alphanumeric The drop’s unique collection code, generated when the drop is created in the Management Panel.
mode No card, text, image card Visual presentation: a self-contained card with icon and button, an inline text link, or an icon-only clickable image.
text No Any string The item’s name Custom label shown next to the trigger (ignored for secret items until collected).
button_text No Any string “Take” Overrides the collect button’s label (card/text modes).
button_emoji No Any emoji 🖐 Overrides the collect button’s leading emoji (card mode).
[PLAYERHUD_DROP code=XPTO123]
[PLAYERHUD_DROP code=XPTO123 mode=text text="Grab the sword"]
[PLAYERHUD_DROP code=XPTO123 mode=image]
[PLAYERHUD_DROP code=XPTO123 button_text="Collect!" button_emoji="⚔️"]

A secret item (marked as such in the Management Panel) always renders as a generic mystery placeholder — name, description, and XP hidden — until the student actually collects it, even if a custom text attribute is supplied.

An item can optionally be restricted to specific RPG classes; a student outside the allowed classes never sees the shortcode’s output at all (not even a placeholder).

[PLAYERHUD_TRADE code=...]

Renders an inline NPC shop trade card, with live affordability checking against the current user’s inventory.

Attribute Required Values Description
code Yes 6-character code shown in the trade’s Management Panel entry Identifies the trade to render.
[PLAYERHUD_TRADE code=A1B2C3]

The trade code is a short lookup convenience, not a security boundary — access to the trade itself is always re-validated server-side (sesskey, capability, and group checks) when the student actually performs it.

Notes

🧪 Automated Tests

The filter ships with unit/integration (PHPUnit) and browser acceptance (Behat) tests, executed on every CI push against the full Moodle 4.5 → 5.2 matrix (PostgreSQL & MariaDB).

PHPUnit — Unit & Integration Tests

Test file Cases
filter_test.php 28
Total 28
vendor/bin/phpunit --testsuite filter_playerhud

Overall line coverage (PHPUnit + Xdebug): 79%.

Behat — Acceptance Tests

Feature file Scenarios
filter_playerhud_modals.feature 6
Total 6
php admin/tool/behat/cli/init.php
vendor/bin/behat --tags=@filter_playerhud --profile=chrome

Full test-by-test breakdown and coverage table →

🔐 Security & Compliance

Privacy Provider

The PlayerHUD Filter implements Moodle’s null_provider — it only displays data owned and stored by the PlayerHUD Block (items, drops, trades, inventory); it never persists any personal data of its own. See the block’s own documentation for its full GDPR export/delete coverage.

📄 License

This project is licensed under the GNU General Public License v3 (GPLv3).

Copyright: 2026 Jean Lúcio