PlayerGames Block

Companion sidebar block for the PlayerGames gamification 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

⚠️ 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.

✨ Features

🕹️ 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

📦 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.

  1. Install local_playergames first — this block will not install without it.
  2. Download the .zip file or clone this repository.
  3. Extract the folder into your Moodle blocks/ directory.
  4. Rename the folder to playergames (if necessary). Final path: your-moodle/blocks/playergames/
  5. Visit Site administration → Notifications to complete installation.

📖 Usage

For Administrators

  1. Turn on editing mode on the site front page or Dashboard.
  2. Use “Add a block” → PlayerGames to place the widget.
  3. 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

  1. The block appears automatically on the site front page and/or the Dashboard once an administrator adds it.
  2. Click the avatar thumbnail to open the avatar collection and equip a different one.
  3. Click the ❓ icon for a short explanation of XP, avatars and rankings.
  4. Click the 🕐 icon to open the full activity history log.
  5. 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.