⚠️ This plugin is under active development. It is not yet published on the Moodle Plugin Directory.
The PlayerGames Block is a thin sidebar widget for the PlayerGames gamification ecosystem. It mirrors a user’s site-wide Player Hub profile — avatar, level, season XP, streak, and rankings — wherever a site administrator adds it, without holding any data or business logic of its own.
Everything the widget shows and does is delegated to local_playergames, which this block
depends on directly.
👈 Use the sidebar to jump to any section on this page.
🖼️ Screenshots
Browse with the arrows, the dots, or the left/right keys. Click the image to zoom.
The PlayerGames block in the Dashboard drawer: avatar, level, XP bar, today's mini-games and streak — all site-wide data at a glance
✨ Features
- 🦊 Avatar at a glance: shows the equipped avatar; clicking it opens the same avatar-collection modal used by the Player Hub, so equipping there or here stays in sync.
- 📊 Season progress: level, XP and a progress bar toward the next level.
- 🎮 Today’s games: shortcuts to the day’s available mini-games, with done/pending/locked state.
- 🔥 Streak, freezes & check-ins: compact stats with accessible labels.
- 📘 Learning XP (optional): shows the XP mirrored from course activity via
block_playerhud, when that bridge and the admin setting are both active — student-only, never mixed with season XP. - 🏆 Ranking position + one-click opt-in: season and learning ranking positions, each with its own toggle to appear or not — no need to open the full Hub.
- ❓ Built-in help: a short modal explaining the two XP pools, avatars and rankings — the same content shown on every Player Hub page.
- 🕐 Activity history shortcut: a direct link to the full log of XP, streak and freeze events.
- 🔌 Three states, no logic of its own:
- Normal — active player: avatar, level, XP bar, today’s games, streak and rankings all visible.
- Paused — the user opted out of gamification, with a link to reactivate directly from the block.
- Hidden — no active season, or the viewer is excluded by the site’s participant-group setting.
All three states are computed by
local_playergames; the block only picks which template to render.
🕹️ PlayerGames Ecosystem
The PlayerGames Block is a companion to local_playergames, the ecosystem’s central hub. It is
designed to complement — not overlap with — block_playerhud:
| Scope | Where it appears | |
|---|---|---|
block_playerhud |
Per-course XP, items, quests, story | Inside a course |
block_playergames (this plugin) |
Site-wide season XP, streak, rankings | Site front page and Dashboard, not inside courses |
-
PlayerGames Hub (
local_playergames): the required dependency — hub page, rankings, missions, avatar catalog, activity log. 👉 github.com/jeanlucio/moodle-local_playergames -
PlayerHUD Block (
block_playerhud): per-course gamification block. Its course XP can optionally mirror into this ecosystem’s “Learning XP” pool. 👉 github.com/jeanlucio/moodle-block_playerhud -
AI Hub (
local_aihub): shared BYOK broker for AI-assisted cartridge generation inlocal_playergames. Optional. 👉 github.com/jeanlucio/moodle-local_aihub
📦 Requirements
| Component | Version |
|---|---|
| Moodle | 4.5+ |
| PHP | 8.1+ |
local_playergames |
Required (hard dependency) |
🛠️ Installation
⚠️ This plugin is not yet published on the Moodle Plugin Directory. Install manually from this repository.
- Install
local_playergamesfirst — this block will not install without it. - Download the
.zipfile or clone this repository. - Extract the folder into your Moodle
blocks/directory. - Rename the folder to
playergames(if necessary). Final path:your-moodle/blocks/playergames/ - Visit Site administration → Notifications to complete installation.
📖 Usage
For Administrators
- Turn on editing mode on the site front page or Dashboard.
- Use “Add a block” → PlayerGames to place the widget.
- Click the avatar to equip a different one, the ❓ icon for a quick explanation, or the 🕐 icon for the full activity history.
💡 Recommendation: this block is designed for the site front page and the Dashboard, not for individual courses (that role belongs to
block_playerhud). For the widget to become visible automatically to everyone:
- Add it to the site front page while editing — the front page is shared by the whole site, so this alone makes it visible to every user with a single action.
- Add it to the default Dashboard page (Site administration → Appearance → Default Dashboard page) so new dashboards start with it. Existing users who already customised their own Dashboard will not get it retroactively unless you also use “Reset Dashboard for all users” — a destructive action that resets everyone’s personal Dashboard layout, so use it deliberately.
For Students
- The block appears automatically on the site front page and/or the Dashboard once an administrator adds it.
- Click the avatar thumbnail to open the avatar collection and equip a different one.
- Click the ❓ icon for a short explanation of XP, avatars and rankings.
- Click the 🕐 icon to open the full activity history log.
- Toggle “Show in ranking” directly from the block — no need to visit the full Player Hub.
🧪 Automated Tests
The only business logic that belongs to this plugin — which of the three states to render — is
covered by PHPUnit. Everything else is orchestration of local_playergames managers, already
tested in that plugin.
PHPUnit — Unit & Integration Tests
| Test file | Cases | What is covered |
|---|---|---|
output/widget_test.php |
9 | State selection: paused when gamification is opted out, hidden with no active season or when excluded by the participant-group setting, normal otherwise; normal-state data sanity (username, level, XP); the normal state’s link to pause gamification; learning XP hidden when the admin setting is off; self and learning ranking position + opt-in toggle text once the user opts into each ranking |
privacy/provider_test.php |
2 | Implements null_provider; get_reason() points to a real lang string |
| Total | 11 |
Line coverage by class (PHPUnit + Xdebug):
| Class | Line coverage |
|---|---|
output\widget |
100% |
privacy\provider |
100% |
| Overall | 100% |
vendor/bin/phpunit --testsuite block_playergames
Behat — Acceptance Tests
| Feature file | Scenarios | What is covered |
|---|---|---|
block_playergames_widget.feature |
3 | Normal-state pause link opens the gamification preferences page; opting out from the widget shows the paused state; reactivating from the paused state restores the normal widget |
| Total | 3 |
php admin/tool/behat/cli/init.php
vendor/bin/behat --tags=@block_playergames --profile=chrome
🔐 Security & Privacy
Access Control
Capability-based access control: block/playergames:view is granted to every authenticated user,
since the widget lives on shared, site-wide pages rather than inside a course.
Privacy API
This block implements the null_provider interface — it holds no personal data of its own. All
personal data (profile, XP, streak, activity log, avatar) is owned and declared by
local_playergames.
Write Operations
All write actions — equipping an avatar, toggling ranking visibility — go through the web services
already validated and secured by local_playergames. This block performs no writes of its own.
📄 License
This project is licensed under the GNU General Public License v3 (GPLv3).
Copyright: 2026 Jean Lúcio
Maintained by Jean Lúcio.