⚠️ This plugin is under active development. It is not yet published on the Moodle Plugin Directory. Some features described below are planned and not yet implemented.
PlayerGames (local_playergames) is the central hub of the PlayerGames gamification
ecosystem for Moodle. It serves four main purposes:
- Ecosystem Dashboard — a visual overview of all Player plugins installed on the site, with status, dependencies, and quick-access links.
- Player Hub — a site-wide gamification platform for students and/or other Moodle users (teachers, managers, administrators), with XP, levels, seasons, missions, achievements, avatars and daily streak. The administrator configures which groups participate.
- Daily Mini-games — concept-reinforcement mini-games and a daily check-in powered by content cartridges (JSON, optionally AI-generated via the companion local_aihub plugin), working as a Duolingo-style learning loop.
- Companion Sidebar Block — block_playergames mirrors a player’s profile (avatar, level, XP, streak, today’s games, ranking) on the site front page and Dashboard.
👈 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 Player Hub: a student's level, XP, streak, active missions and today's mini-games, all in one place
✨ Features
✅ Implemented
- 🗺️ Ecosystem Dashboard: SVG overview of all Player plugins — installed, missing, dependencies, status, and quick-action links for admins.
- 🎮 Player Hub — XP & Levels: Site-wide XP across configurable seasons. Each mini-game awards a fixed amount of XP, and admins set how many scoring plays per day each game allows — XP is earned exclusively through gameplay, so teachers with different course loads and students enrolled in different numbers of courses all compete on equal footing.
- 🪜 Player Hub — Configurable Level Ladder: Admins edit the per-level XP thresholds and titles from the Levels and titles page — restore the default 5-tier ladder or generate a longer linear progression with one click.
- 📅 Player Hub — Daily Check-in: Earn XP just for being on the site once a day (the first page you open), capped per season. Optionally counts toward the daily streak.
- 🏆 Player Hub — Season Ranking: Leaderboard with privacy controls (opt-in), tie-breaks and a staff/student split — see Ranking Behavior.
- 📘 Player Hub — Course XP: An optional, separate XP pool mirrored from a student’s
per-course activity in
block_playerhud, with its own opt-in ranking — see Course XP. - 🔥 Player Hub — Streak & Freeze: Daily streak tracking. Freeze consumables prevent streak loss and are earned via missions; the daily check-in can keep the streak alive when configured.
- 🎯 Player Hub — Missions: Daily, streak-based (7, 14 and 30 days), cumulative XP and victory-based missions, with targets and rewards the administrator sets, and more of the same kinds when wanted.
- 🏅 Player Hub — Achievements: Permanent achievements that persist across seasons.
- 🏷️ Player Hub — Titles: The title of each level, shown on the Player Hub.
- 🦊 Player Hub — Avatar Collection: Emoji avatars unlocked permanently by the highest level a player has ever reached, grouped into 4 tiers that follow the level ladder — see Avatars.
- 🕐 Unified Activity Log: A single, chronological log of every XP, streak and freeze event (season XP, course XP, freeze earned/used, streak broken), with a shared “how it works” help modal explaining season XP, course XP, avatars and rankings.
- 📦 Cartridge System: Content source for the mini-games. Supports multiple active cartridges
simultaneously.
- All games: manual creation (inline editor), JSON upload, or AI generation (see AI Provider Chain).
- PlayerQuiz and PlayerBattle: question cartridges can also be created from a Moodle Question Bank kept for reuse by the whole site (multiple-choice questions only, copied as plain text) — see How PlayerQuiz Works.
- PlayerGuess and PlayerFill: always use concept cartridges, which can also be created from a global glossary of the site.
- 🧠 PlayerQuiz: Daily multiple-choice mini-game using concepts from the active cartridge — see How PlayerQuiz Works.
- 🔡 PlayerGuess: Daily word-guessing mini-game — guess the term letter by letter — see How PlayerGuess Works.
- 📝 PlayerFill: Daily crossword-style mini-game — numbered positions; the same number shares the same letter across multiple terms; solving one reveals letters in others (cascade effect). Grid generated in PHP without external libraries — see How PlayerFill Works.
- ⚔️ PlayerBattle: Daily match-3 RPG mini-game — an 8×8 board, turn-based combat against an opponent, and a question whenever the mana bar fills; a right answer lands a critical hit. XP only for a victory — see How PlayerBattle Works.
- 🧭 Administration tab: Cards for everything an administrator sets up — cartridges, seasons, the games of a season, the rules — in the order it is done, each saying what it does and where things stand. The plugin’s pages in the Moodle administration follow the same order — see Administration.
- 🧩 PlayerGames Block: Companion sidebar block (
block_playergames) showing the user’s equipped avatar, level, XP, streak, today’s games, and ranking position on the site front page and Dashboard, linking to the full Player Hub; while no season is active it says so, and tells when the next one starts — see PlayerGames Ecosystem. - 📅 Season Management: Create, edit, close, delete and auto-renew seasons with configuration snapshots. The scores of the most recent closed seasons are kept (two by default, configurable); the nightly retention task removes older ones, keeping each player’s final result for the hall of fame.
- 🔐 Privacy (GDPR): Complete Privacy Provider — metadata declaration, export and deletion of all stored personal data; shared cartridges are preserved with the uploader anonymised.
- 🧪 Automated Tests: 320-case PHPUnit suite and 42 Node tests for PlayerBattle’s rules, green across the full CI matrix, Moodle 4.5 to 5.3 (see the Automated Tests section).
⏳ In Development / Planned
- 🛡️ Publication Polish: Full accessibility audit (including the Classic theme and touch devices) and broader Behat acceptance coverage (PHPUnit suite and PHPCS compliance are already in place).
🤖 AI Provider Chain
Key storage and provider transport (Gemini, Groq, DeepSeek, OpenAI-compatible) live in a dedicated companion plugin, local_aihub. PlayerGames itself only builds the cartridge generation prompt (topic, language, concept count, level) and parses the AI’s JSON response back into concepts, so it stays free of key management while still supporting AI-assisted cartridge generation wherever the Hub is installed.
The language field comes filled in with the language of the person on the page and can be changed, and the content level goes from very easy to very hard. For concepts, the prompt asks only for single words, letters only, with a length that serves PlayerGuess and PlayerFill.
Resolution order
| Priority | Source | Notes |
|---|---|---|
| 1 | local_aihub | Tried first when installed. Resolves personal keys, then site-wide keys, across Gemini / Groq / DeepSeek / OpenAI-compatible providers. |
| 2 | Moodle core_ai |
Institutional fallback, used only if the Hub is not installed or returns no usable source. Uses whichever providers the admin configured in Site administration → AI → AI providers. |
A real provider failure (e.g. an invalid key configured in the Hub) is preserved and surfaced to the user — it is never silently masked as “no AI source available”.
Installing
local_aihubis optional. Without it, cartridge AI generation still works if the site hascore_aiconfigured; PlayerGames only loses the BYOK personal-key option (each teacher bringing their own Gemini/Groq/DeepSeek/OpenAI key) that the Hub provides.
Integration API for other plugins
cartridge\ai_generator exposes a small, stable API that other plugins in the ecosystem can
call directly:
use local_playergames\cartridge\ai_generator;
$gen = new ai_generator();
if ($gen->has_key()) {
// Free-form prompt, routed through the same chain as cartridge generation.
$text = $gen->generate_text('Optional system instruction', 'Your prompt here');
}
has_key(): bool—trueif eitherlocal_aihubhas a usable key orcore_aihas a configured provider.generate_text(string $system, string $user, bool $jsonmode = false): string— sends a free system+user prompt through the chain and returns the raw text response.send(string $prompt): array— lower-level variant returning the full result array (success,data,message,provider).generate(string $topic, string $language, int $count, int $level, string $context = ''): array— the structured cartridge-concept generator; use only when you need concept arrays in{term, definition}format.
Every AI generation triggered from PlayerGames is tagged in the Hub’s own usage log with the
component (local_playergames) and a short description of what was generated (e.g. the cartridge
topic), so site administrators can see AI usage per consuming plugin from the Hub’s admin report.
📦 Cartridge Format
Content cartridges are JSON files that power the mini-games. A concept cartridge (terms and definitions, as below) feeds PlayerGuess and PlayerFill; a question cartridge (questions with their answers) feeds PlayerQuiz and PlayerBattle:
{
"name": "Gamification Fundamentals",
"version": "1.0",
"language": "en",
"concepts": [
{
"term": "gamification",
"definition": "Use of game elements in non-game contexts"
}
]
}
- Validated by the importer before saving; a
categoryordifficultyof an older file is ignored - Terms for PlayerGuess: filtered by configurable length (default 4–8 letters) and must be a single alphabetic word (no spaces, digits or hyphens) — see How PlayerGuess Works
- Question cartridges: each question accepts an optional
generalfeedbackstring, shown to the player after they answer - Question cartridges can be created from a Moodle Question Bank (the Import from question bank tab of the cartridge page): the multiple-choice questions of a category kept for reuse by the whole site are copied as plain text, up to the importer’s limit. Questions with an image, sound or video are left out, and the cartridge is a copy: later changes in the bank do not reach it
- Concept cartridges can be created from a global glossary (the Glossary tab of the cartridge page): the approved entries become concepts, up to the importer’s limit. Glossaries of a single course are not offered — only those Moodle marks as global
- Admin can have multiple active cartridges simultaneously
- Multi-language: each cartridge declares its
language
🧠 How PlayerQuiz Works
PlayerQuiz is the first daily mini-game. It draws multiple-choice questions from the active cartridges and shows them one at a time.
Questions from the Moodle Question Bank
The Import from question bank tab of the cartridge page copies the multiple-choice questions of a category into a new question cartridge, which the games then use like any other. The category is limited to what Moodle keeps for reuse: question banks created to share questions across courses (Moodle 5.x) or categories in the system context (Moodle 4.5). A course’s own bank is never offered, so questions that belong to one course are not exposed to the whole site. The list only shows categories the person importing may use, and the choice is checked again on import.
Only the latest ready version of each question is copied, as plain text, and a question needs one answer worth the full grade and at least four wrong ones. Questions with an image, sound or video are left out, and the result says how many. The cartridge is a copy: to refresh it after the bank changes, import the category again and deactivate the old cartridge.
The play loop
- One question is shown at a time, with a per-question countdown.
- Wrong answer (or the timer running out) → the correct option is revealed, then the next question loads.
- Correct answer → the play ends and XP is awarded.
- With an attempt limit set, running out of attempts ends the play in failure (no XP) and closes PlayerQuiz until the next day.
Because a play ends on the first correct answer, a player rarely answers the whole pool — most questions in a session are just a buffer that provides variety and room to be wrong before repeating.
Two independent limits (this trips people up)
| Setting | Axis | Meaning |
|---|---|---|
Games per day (xp_games_quiz) |
the day | How many plays earn XP per day. Also sets the daily XP cap: XP per game × games per day. |
Questions per session (quiz_session_size) |
inside one play | How many questions are drawn into a single play (the “deck” of that round). |
Example — with XP per game = 25, games per day = 3, questions per session = 20: a player can complete 3 plays today (cap 75 XP), and each play is built from a fresh draw of 20 questions. The two numbers answer different questions: how many rounds today vs how big each round’s deck is.
Fresh questions and repeats
- Each page load builds a brand-new shuffled session — there is no saved “session of the day”.
- Questions are remembered as “seen today” only when a play is completed with a correct answer. Those are then excluded from the other plays of the same day, so completed plays never repeat questions.
- Leaving mid-play or failing records nothing — reopening the page gives a fresh random draw that may include the same questions.
- The “seen today” memory is per day: the next day starts clean and may re-draw questions from previous days. There is no cross-day exclusion.
- Reloading never grants extra XP — it only changes which questions appear; XP is still capped by games per day and only counts on a correct answer.
Admin settings
Site administration → Plugins → Local plugins → PlayerGames → Rules → Game rules
| Setting | Default | What it does |
|---|---|---|
| Time per question (seconds) | 120 (2 min) | Countdown per question. Reaching zero counts as a wrong answer and advances. 0 disables the timer. |
| Maximum attempts | Unlimited | Wrong answers (including timeouts) that close PlayerQuiz for the rest of the day without XP, picked from Unlimited or 1 to 10. With Unlimited the game continues until the player answers correctly, so a play always pays XP. |
| Questions per session | 20 | Size of each play’s draw, chosen from a capped list (5–50). |
How the timer and the attempts interlock
- A timer expiry is treated exactly like a wrong answer.
- A play can only fail when a maximum-attempts limit is set; with Unlimited the game loops until a correct answer.
- With a limit, the wrong answers of the day are kept on the server: a new login goes on from them.
- A failed play awards no XP and closes PlayerQuiz until the next day, the same rule as the other games: a lost day is lost. The defeat is kept on the server, so a reload, another browser or a new login does not reopen the game, and the hub shows it as Come back tomorrow.
Why the session size is capped
Every question of a session is rendered into the page HTML at once (the browser just reveals them one by one). A very large session would format and ship hundreds of questions the player will never see — wasted server work and a heavy page. The capped list (max 50) keeps plenty of variety without that cost. Truly large sessions would require a different architecture (loading questions on demand), which is not how the game works today.
🔡 How PlayerGuess Works
PlayerGuess is a daily word-guessing mini-game: guess a term from the active cartridge, letter by letter, within a limited number of attempts.
The play loop
- The board shows the term’s definition (as a hint) and its length, but not the term itself.
- Each guess must be the exact same length as the target and contain only letters.
- After each guess, every letter is marked correct (right letter, right position), present (right letter, wrong position) or absent — the classic Wordle feedback, computed server-side so the term is never exposed to the browser before the round ends.
- Correct guess → the round ends in a win and XP is awarded.
- Running out of attempts → the round ends in a loss and the term is revealed.
- Guessing and validation always happen server-side against the day’s assigned concept — the client never receives or trusts anything about the target term until the round is over.
One concept per day, shared assignment pipeline
Every night, a scheduled task assigns one random concept to PlayerGuess (and, independently, to PlayerQuiz) from the currently active cartridges — the same pipeline used across the daily mini-games. For PlayerGuess specifically, only concepts whose term:
- has a normalised length within the admin-configured range (default 4–8 letters), and
- is a single alphabetic word — no spaces, digits or hyphens
are eligible. This filter is applied identically at assignment time and again when validating a guess, so a term that happens to fit the length window but contains, say, a hyphen is never assigned to a PlayerGuess day.
Admin settings
Site administration → Plugins → Local plugins → PlayerGames → Rules → Game rules
| Setting | Default | What it does |
|---|---|---|
| Maximum attempts | 6 | Guesses allowed before the round ends in a loss and the term is revealed. |
| Minimum term length | 4 | Shortest term eligible for the daily assignment. |
| Maximum term length | 8 | Longest term eligible for the daily assignment. |
Site administration → Plugins → Local plugins → PlayerGames → Rules → Game XP
| Setting | Default | What it does |
|---|---|---|
| XP per PlayerGuess game | 25 | XP awarded on a winning round. |
Guess has one concept a day, so it has one round a day and pays its XP once, on the win; there is no “games per day” setting for it.
Round state
The in-progress round (guesses made so far, whether it’s finished, whether it was won) is kept in the database, one row per user and day. It automatically resets if the stored round no longer matches today’s assigned concept (a new day, or a re-assigned concept). This means:
- Leaving the page and coming back — even after logging out or from another browser — resumes the round exactly where it was left, including a finished round: a win or a loss stays final for the rest of the day, and the attempt limit cannot be reset by logging in again.
- Only a win pays XP (through the same daily-play accounting used by the other games). A loss is kept so the round stays lost, but earns nothing.
- The term is only revealed once the round is over.
- Rows of earlier days are purged by the daily cleanup task.
📝 How PlayerFill Works
PlayerFill is a daily crossword-style mini-game: solve every one of the day’s terms, where letters shared between terms are revealed automatically as other terms are solved.
The play loop
- Each day’s puzzle is made of several terms (see “Word count per day” below), shown as one row per term with its definition as a permanent hint.
- Every letter position in the puzzle is assigned a shared slot number: the same letter, anywhere across any of the day’s terms, always gets the same number. A hidden position shows its slot number instead of a blank; once revealed, it shows the letter.
- A guess is checked as a whole word, not letter by letter — type the full term for a row and submit it.
- Correct guess → that row is marked solved, and every slot it covers is revealed everywhere else in the puzzle. This can immediately solve another still-pending row too, when every one of its letters happens to already be covered by rows solved so far (the cascade effect) — without the player ever typing that row’s answer directly.
- Solving every term → the day ends in a win and XP is awarded.
- Running out of attempts on any single term → the whole day ends in a loss immediately (since a win requires every term to be solved, one exhausted term already makes that impossible), and every unsolved term’s spelling is revealed.
- Guessing and validation always happen server-side against the day’s assigned terms — the client never receives or trusts anything about an unsolved term’s spelling until its row is solved or the day ends.
Word count per day, shared assignment pipeline
Every night, a scheduled task assigns a configurable number of concepts to PlayerFill (default 5, admin-configurable between 4 and 8) from the currently active cartridges — the same pipeline used across the daily mini-games, extended for PlayerFill’s need for several terms at once instead of one. Only concepts whose term:
- has a normalised length within the admin-configured range (default 3–12 letters), and
- is a single alphabetic word — no spaces, digits or hyphens
are eligible, the same filter PlayerGuess applies to its own single daily term. If fewer eligible concepts exist than the configured word count, PlayerFill is simply left unassigned for that day rather than starting an undersized puzzle.
The word of the day of PlayerGuess is left out of PlayerFill, and the other way round, also when two cartridges hold the same word: solving one game would otherwise give the answer of the other away. It goes in only when the other words are not enough for the puzzle, so the day is never left without a game.
The page explains the rules above the puzzle (each clue is below its tiles, the same number hides the same letter, and how many attempts each word has) and shows under each word how many attempts it has left.
Admin settings
Site administration → Plugins → Local plugins → PlayerGames → Rules → Game rules
| Setting | Default | What it does |
|---|---|---|
| PlayerFill words per day | 5 | How many terms make up each day’s puzzle. Clamped between 4 and 8. |
| PlayerFill maximum attempts per word | 4 | Guesses allowed on a single term before the whole day ends in a loss. |
| Minimum term length for PlayerFill | 3 | Shortest term eligible for the daily assignment. |
| Maximum term length for PlayerFill | 12 | Longest term eligible for the daily assignment. |
Site administration → Plugins → Local plugins → PlayerGames → Rules → Game XP
| Setting | Default | What it does |
|---|---|---|
| XP per PlayerFill game | 25 | XP awarded on a winning day. |
Fill has one puzzle a day, so it has one round a day and pays its XP once, on the win; there is no “games per day” setting for it.
Round state
The in-progress puzzle (which terms are solved, which slots are revealed, attempts used per term) is kept in the database, one row per user and day, and every guess is validated server-side against a term that is never exposed to the browser ahead of time. It automatically rebuilds if the stored puzzle no longer matches today’s assigned terms (a new day, or a re-assigned set).
- Leaving the page and coming back — even after logging out or from another browser — resumes the puzzle exactly where it was left, including a finished day: a win or a loss stays final for the rest of the day, and the attempt limit cannot be reset by logging in again.
- Only a win pays XP (through the same daily-play accounting used by the other games). A loss is kept so the round stays lost, but earns nothing.
- The words are only revealed once the round is over.
- Rows of earlier days are purged by the daily cleanup task.
Adapted from mod_playercross
PlayerFill’s letter-to-slot algorithm is ported from the standalone mod_playercross activity’s
puzzle builder. mod_playercross itself evolved a richer mechanic on top of it — a separate
cipher-locked “mystery phrase” solved through clue words, with a bonus for guessing it directly and
per-attempt partial grading — none of which carries over here: PlayerGames pays a fixed amount of
XP per win regardless of how it was reached, so partial-credit grading has no place in this hub,
and a set of peer terms that reveal each other is already a complete, self-contained puzzle without
needing a separate phrase layered on top.
⚔️ How PlayerBattle Works
PlayerBattle is the daily match-3 mini-game. The player fights an opponent on an 8×8 board: lining up pieces hurts the opponent, and the Orb brings a question — a right answer lands a critical hit. The questions come from the same cartridges as PlayerQuiz.
The board
Swap two neighbouring pieces to line up three or more of the same kind. The pieces that match are destroyed, new ones fall in, and any match they make counts too (a cascade). A swap that makes no match slides back and does not cost the turn. The player moves first, then the opponent, in turns.
| Piece | Effect |
|---|---|
| ⭐ Star | +0.1 to the damage multiplier of whoever matched it. The multiplier raises Sword hits and the critical hit, and is spent by the critical hit or lost on a wrong answer. |
| 📖 Grimoire | Fills a hex meter. When full, it casts a hex on the other side for three turns: it loses the damage unit of whoever cast it at the start of each of its turns, and the shield does not stop it. |
| ❓ Orb | Fills the mana bar (20 per piece, 100 is full). When it fills, the player faces a question. |
| ⚔️ Sword | Direct damage: one damage unit for a match of three, ×1.5 for four, ×2 for five. |
| 🛡️ Shield | Fills a shield meter. When full, it cancels the next hit taken (a Sword, a critical hit or a wrong answer). The hex goes through it. |
| 🧪 Potion | Heals a quarter of the damage unit per piece, up to the maximum HP. |
Both sides start with 200 HP. A match of three Swords hits for 10 when the player makes it and for 8 when the opponent does. These numbers are fixed: they come from simulated battles, in which a player who answers every question right wins almost always, one who answers two in three about three times in four, and one who guesses blindly among five options about one time in five. A battle lasts roughly 18 to 29 turns and asks 5 to 9 questions.
The questions
- When the mana bar fills, the board stops and a question appears; the battle goes on after the answer.
- A right answer is a critical hit on the opponent: three times the damage unit, times the multiplier.
- A wrong answer costs the player one plain hit from the opponent, and the multiplier.
- The opponent has no questions: when its own mana fills, it lands a critical hit by itself.
- Ten questions are drawn for each battle and asked in a shuffled order. If they run out, the order is drawn again, never starting with the question just asked.
- Cartridge text is shown as plain text. The feedback of a question, when it has one, is shown after the answer.
XP and daily plays
PlayerBattle follows the same daily rule as the other games: how much XP a play gives and how many plays a day count come from the Game XP settings the season was created with.
- A victory spends one daily play and gives the season’s XP for the game. Past the day’s quota, a victory is still saved, but gives no XP.
- A defeat is saved but gives no XP. With Maximum attempts at Unlimited, the default, it does not spend the play and the player may try again at once. With a limit of 1 to 10, that many defeats close PlayerBattle until the next day, as a lost day closes the other games; the hub shows it as Come back tomorrow. With a limit, a battle left or reloaded after the first move counts as a defeat too, and the page says so with the attempts left: the server cannot tell it from a lost connection.
- The day keeps the best result: a victory over a defeat, then the one that dealt the most damage.
- The first victory completes the First Victory mission.
- The questions shown count as seen for the day, in a defeat too, so the next try brings new ones. When every question has been seen, they repeat rather than leaving the player stuck.
A result is accepted once for each battle the page opened, so a result sent twice earns nothing.
The board is played in the browser and the server cannot replay it, so it checks what it can. The questions are judged on the server: the page never receives which option is right, and the counts of questions answered and right are the server’s own. A victory is recorded as such only if the battle lasted at least 15 seconds and answered at least 2 questions; otherwise it is recorded as a defeat. This stops a result sent without playing. It does not stop someone who plays through with a script that answers questions and waits.
Content and settings
PlayerBattle asks question cartridges, including the ones imported from a Moodle Question Bank (see How PlayerQuiz Works), as chosen for the season in the Season games card of the Administration tab.
| Where | Setting |
|---|---|
| Season games | Whether PlayerBattle runs in the season and which cartridges its questions come from. |
| Rules → Game XP | XP per PlayerBattle game and how many plays a day give XP. |
| Rules → Game rules | Maximum attempts: how many lost battles close the game for the day, Unlimited by default. |
Playing it
- Mouse or touch: click a piece and then a neighbour, or drag a piece towards a neighbour.
- Keyboard: Tab enters the board, the arrow keys move between the pieces, Enter or Space selects one, and an arrow key then swaps it with the neighbour in that direction. Esc drops the selection.
- Screen readers: every cell of the board is a button named with its row, column and piece, and the selected one is marked as pressed; what happens in the battle is announced.
- The question and the end of the battle are dialogs: while one is open, the keyboard stays inside it. The answers can also be chosen with the keys 1 to 5 or A to E.
- Animations are skipped when the browser asks for reduced motion.
- Sound is off until the player turns it on with the Sound button; the choice is kept in that browser.
Privacy
The result of each day is stored with the player: whether it was a victory, the damage dealt, the questions answered right and in total, the XP, the duration and the time. It is exported and deleted with the rest of the player’s data, and removed with the season by the retention task.
🦊 Avatars
PlayerGames has its own emoji avatar collection, unlocked permanently by the highest level a player has ever reached — no shop, no file uploads, just a level-tier reward.
Catalog and tiers
The default catalog has 17 emoji avatars split across 4 tiers (5 in tier 1, 4 each in tiers 2–4): 🤖 👾 🦊 🐱 🐶 (tier 1), 🕵️ 🤺 🧚 🧜 (tier 2), 🧝 🧙 🦸 🥷 (tier 3), and 🧛 🦹 🐉 🦁 (tier 4).
Unlock rule
Unlocks are based on the highest level the player has ever reached, for life — not their current level, and not scoped to the current season. Every time a player earns enough XP to level up, PlayerGames records the new level only if it exceeds the best level stored for that player; closing a season, which resets season XP back to zero, never takes an already-unlocked avatar away.
Tier thresholds
The tiers are spread evenly across the level ladder, so every avatar stays reachable however many levels the ladder has: tier 1 opens at level 1 and each later tier a further quarter of the ladder up.
| Tier | 5 levels (default ladder) | 20 levels |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 6 |
| 3 | 3 | 11 |
| 4 | 4 | 16 |
There is nothing to set: the tiers follow the ladder of Levels and titles, which shows where each one opens, and move with it when it changes.
Equip and display
A player can equip any avatar they’ve unlocked (or unequip back to their default Moodle profile picture) from a tier-grouped picker — locked avatars show grayed out alongside their required level. The equipped avatar replaces the default profile picture in the Player Hub’s profile card and in the PlayerGames block’s widget, and stays in sync between the two since both read and write through the same avatar manager.
📘 Course XP
Course XP is a separate, optional XP pool that mirrors a student’s per-course XP earned in
block_playerhud into PlayerGames, purely for cross-course visibility — it is never summed
with season XP and never affects levels, avatar unlocks or the season ranking. It measures how
engaged a student is with the courses gamified with PlayerHUD, not what they learned.
Where it comes from
When block_playerhud is installed and a student earns or loses course XP, PlayerGames listens
for that change and mirrors the delta into its own windowed course XP total. Nothing needs
to be configured on the block_playerhud side beyond having it installed — the bridge is
optional and stays dormant if block_playerhud isn’t present.
The window
Course XP is not a lifetime total: it only counts XP earned within a rolling window
(default 12 months, configurable in months; 0 means unlimited/lifetime). Data is kept in
monthly buckets, so the window ages correctly month by month, and a nightly scheduled task
recomputes every user’s windowed total to correct any drift and drop buckets that have aged out.
Visibility
Course XP is shown only when both are true:
- the admin has turned it on (Site administration → Plugins → Local plugins → PlayerGames → Rules → Course XP), and
- the site’s participant setting allows students (
studentsorboth).
Unlike most other student-facing features, visibility is not tied to whether the viewer is flagged as staff — a teacher who is also a genuine PlayerHUD-earning student in another course still sees their own course XP.
Its own ranking
Course XP has its own separate, opt-in ranking — a single top-50 list (not split by staff/student like the season ranking), gated by its own admin toggle. Players with zero windowed XP are excluded entirely rather than occupying a rank, and each player has an independent opt-in toggle from the season ranking’s own visibility setting. Position lookup for players outside the top 50 follows the same tie-break rule as the season ranking (highest XP first, then earliest to reach it).
Where it’s shown
Both the Player Hub page and the PlayerGames block’s sidebar widget read from the same manager and follow the same visibility and ranking rules, so the two surfaces are always consistent with each other.
🏆 Ranking Behavior
The season ranking is opt-in, split by participant group, and shows a player their own position even outside the visible top 50.
Opt-in and the top-50 list
Players choose whether to appear in the ranking from their profile. The visible list is the
top 50 by season XP, ordered by XP descending → the moment they reached that XP ascending →
user id ascending — a fully deterministic tie-break, so two players with the same XP are ranked
by who got there first.
Staff / student split
Rankings are split into two groups: students and staff. Staff are the site administrators and everyone who can edit at least one course, such as managers and editing teachers. Everyone else counts as a student, a non-editing teacher included. Whether a viewer sees one or both groups depends on their own role and the site’s participant setting:
- A regular student or teacher sees only their own group’s ranking.
- An admin, or any staff member when the site is configured to allow both groups to participate, sees both the Students and Staff tabs.
Your own position, even outside the top 50
A player who opted into the ranking but isn’t in the visible top 50 still sees their own exact position — computed with a single indexed count query against the same ordering rule used for the visible list, not by scanning the whole ranking.
Who stays on the list
Opting out of the gamification (Preferences → Gamification) takes a player off both rankings at once,
and turning it back on starts hidden: they choose again whether to show up. A player whose role lost
the local/playergames:viewhub capability, or whom a change of the participant setting no longer
allows, is also left out of the list, within a minute (the lists are cached for 60 seconds).
How the staff group is kept up to date
Working out who counts as staff takes several queries for every teacher of the site, so a scheduled
task, Refresh the set of staff users (refresh_staff_ids), does it every 10 minutes and the
hub only reads the result. This has two consequences for administrators:
- A change of someone’s roles can take up to about 10 minutes to move them between the Students and Staff groups. What a person is allowed to do is never decided by this copy: pages and services check the role live.
- The site needs its cron running. If it is not, the plugin keeps working: after one hour with no refresh the hub works the set out again by itself, at the cost of a slower page for whoever opens it first.
Scope
This page describes the season ranking (tied to season XP and reset when a season closes). Course XP has its own separate, single (not staff/student-split) ranking with its own opt-in — see that section for details.
🎓 Educational Purpose
PlayerGames is designed to:
- Reinforce daily learning through spaced repetition (Duolingo-like loop)
- Motivate students to access the platform more frequently, building familiarity with the learning environment in a natural and engaging way
- Foster healthy competition between students and teachers across different courses, regardless of how many courses each participant is enrolled in or teaches
- Integrate students and teachers from different courses around a common gamified experience
- Promote active learning habits through daily challenges and streak mechanics
- Explore diverse knowledge areas through concept cartridges — from discipline-specific content to cross-cutting topics like foreign language learning
- Give institutional visibility into the impact of gamification (Engagement Meter)
Suitable for:
- Institutions with multiple gamified courses using block_playerhud
- Administrators and managers looking to measure gamification impact
- Any Moodle user group (students, teachers, managers, admins) that can be configured to participate in the Hub
🕹️ PlayerGames Ecosystem
PlayerGames is the hub of a broader gamification ecosystem. Together, these plugins transform Moodle into an immersive experience:
-
PlayerGames Block: Companion sidebar widget for the site front page and Dashboard — equipped avatar, level, XP, streak, today’s games and ranking position, all delegated to this plugin. Requires
local_playergames. 👉 github.com/jeanlucio/moodle-block_playergames -
AI Hub: Shared BYOK (bring your own key) broker — personal and site-wide Gemini/Groq/ DeepSeek/OpenAI-compatible keys, consumed by PlayerGames for AI-assisted cartridge generation. Optional: PlayerGames still works through Moodle’s own
core_aiwithout it. 👉 github.com/jeanlucio/moodle-local_aihub -
PlayerHUD Block: XP, levels, inventory, drops, quests, RPG classes, story, karma, and ranking inside each course. Its course XP can optionally mirror into PlayerGames’ Course XP pool. 👉 github.com/jeanlucio/moodle-block_playerhud
-
PlayerHUD Filter: Enables item drops via shortcodes inside course content. 👉 github.com/jeanlucio/moodle-filter_playerhud
-
PlayerHUD Availability Restriction: Restricts access to course activities based on the student’s current level or collected items. 👉 github.com/jeanlucio/moodle-availability_playerhud
-
PlayerGroup: Lets students autonomously form their own groups directly from the activity page. 👉 github.com/jeanlucio/moodle-mod_playergroup
📦 Requirements
| Component | Version |
|---|---|
| Moodle | 4.5 – 5.3 |
| PHP | 8.1+ |
🛠️ Installation & Configuration
⚠️ This plugin is not yet published on the Moodle Plugin Directory. Install manually from this repository.
- Download the
.zipfile or clone this repository. - Extract the folder into your Moodle
local/directory. - Rename the folder to
playergames(if necessary). Final path:your-moodle/local/playergames/ - Visit Site administration → Notifications to complete installation.
- Open the Administration tab of PlayerGames (or Site administration → Plugins → Local plugins → PlayerGames) and follow its cards in order: create a cartridge, create and activate the first season, and choose the games it runs. The XP, level, avatar and game rules have working defaults you can review under Rules — see Administration.
- Optional: install local_aihub if you want AI-assisted cartridge generation with personal/site API keys — see AI Provider Chain.
🧭 Administration
Everything an administrator sets up is gathered in the Administration tab of PlayerGames, as cards, in the order the work is usually done. Each card says what the function does and, where there is one, where things stand: which season is active, how many cartridges are on, and so on. A card is a link to the page of the function.
The tab shows up for whoever can open at least one card, and each card is shown only if the user can open where it leads.
The cards
| Group | Card | What it is for | Needs |
|---|---|---|---|
| Get started | Cartridges | The packs of questions and concepts the games draw from. Import a file, generate one with AI or write it by hand. | Manage cartridges |
| Seasons | The period in which students earn XP and compete in the ranking. Create, edit, activate, close and delete seasons. | Site administrator | |
| Season games | Which games run in the season and which cartridges the questions or words of each one come from (PlayerQuiz and PlayerBattle use question cartridges; PlayerGuess and PlayerFill, concept cartridges). | Site administrator | |
| Rules | Participation and seasons | Who plays (students, staff or both), whether seasons renew by themselves and how long they last. | Site administrator |
| Game XP | How much XP each game gives and how many times a day it can be played for XP. | Site administrator | |
| Game rules | Time per question, attempts and the other rules of each game. | Site administrator | |
| Levels and titles | How much XP each level takes and the title it gives. The avatars unlock along this ladder. | Site administrator | |
| Streak and freeze | How the daily streak works and how a freeze is earned. | Site administrator | |
| Missions | The goals that give extra XP or a freeze: their targets and rewards, and new ones of the same kinds. | Site administrator | |
| Course XP | The XP courses give through PlayerHUD, shown apart from the season XP. | Site administrator | |
| Data | Reset data | Deletes the seasons and everything the players earned, to start again from zero. The cartridges and the settings stay. | Site administrator |
| Help and integrations | AI keys | Keys used to generate questions with AI. Shown only when the AI Hub plugin is installed. | Site administrator |
| Documentation | This guide, in English and Portuguese. | Anyone who sees the tab |
The Engagement Meter and the Plugin ecosystem are not cards: they already have a tab of their own.
Who sees what
- Site administrators see every card.
- Managers (the Moodle Manager role) see Cartridges and Documentation: the permission to manage cartridges is given to managers by default, while seasons, levels and rules need the permission to change the site configuration, which only site administrators have.
- Everyone else has no Administration tab.
When there is no active season, the Player Hub tells the administrator so and offers a button to the seasons page.
Editing and deleting a season
On the seasons page each season has Edit and, unless it is the active one, Delete.
- Edit changes the name and the dates. A closed season keeps its dates, as they are history; only its name changes. The status is never changed here — use Activate and Close season for that.
- Delete asks for confirmation and removes the season with its game settings and the XP, missions and results of its players. The daily scores of those days go too, unless another season covers the same days. The active season cannot be deleted: close it first. Deleting cannot be undone.
- Close season asks for confirmation too, as a closed season cannot be reopened. Closed before its planned end, the season ends today: its end date changes to today’s, so the days it never used are free for the next season.
Seasons never share a day. Creating or editing a season whose dates cross another one is refused, with the name and dates of the other season, because the retention task and Delete remove the scores of a season by its dates. The form suggests a start date after the last season when that one still runs: after closing a season today, the next one can start tomorrow.
Resetting all the data
Deleting the seasons and the cartridges one by one leaves what belongs to no season: streaks, freezes, achievements, avatar progress, the activity history and the course XP mirrored from PlayerHUD. Reset data deletes all of it, for every user, to start again from zero, after a pilot for instance.
- Deleted: every season, the active one included, with its game settings; the season results and the hall of fame; the daily scores, battles and rounds; the season profiles and mission progress; the streaks, freezes, achievements and avatar progress; the activity and freeze history; the course XP mirrored from PlayerHUD (the XP in PlayerHUD itself is not touched).
- Kept: the cartridges with their questions and concepts, the levels and titles, the avatar catalogue, the missions and achievements themselves, every setting, and each user’s choice to take part.
The page lists how many records each group holds, and nothing is deleted until the administrator types the confirmation word (RESET; ZERAR in Portuguese). It cannot be undone. The site log records who did it, when and how many records went (event PlayerGames data reset).
The same order in the Moodle administration
The plugin’s pages in Site administration → Plugins → Local plugins → PlayerGames follow the same groups: Get started (Cartridges, Seasons, Season games), Rules (Participation and seasons, Game XP, Game rules, Levels and titles, Streak and freeze, Missions, Course XP), Monitoring (Engagement Meter) and Data (Reset data). The Administration tab is a shortcut to them, not a replacement.
Missions
A mission asks for one of four things: games in one day, a streak of days, XP in the season or PlayerBattle victories. The site starts with six (streaks of 7, 14 and 30 days among them), and the administrator can change their target and rewards, give them a name, switch them off, or add more of the same kinds. A mission is done once per season, apart from the daily ones, which start again every day.
The streak missions follow the streak of the hub, which a freeze protects and which the Streak activity setting counts from games only, or from a game or the daily check-in. The streak goes on from one season to the next, but its missions count at most the days the season has had, so that a player who arrives with a long streak starts them from the first day, like everyone else.
Once somebody completes a mission in the active season, it cannot be switched off and its target and rewards stay as they are until the season ends, so that everyone plays by the same rules; only its name can change. A mission somebody has started can be switched off, but not deleted, because the seasons count the missions their players completed.
Most XP of a season
The seasons page shows, for each season, the most XP a player can earn in it: every game won on every day, every check-in up to its cap, and every mission the season can reach. The games and the check-in follow the rules the season froze when it was created; the missions are the ones on now. The XP of the courses is kept apart and is not part of it.
Season games opens the active season, or the next one if none is active. With no season at all it leads to the seasons page.
With every cartridge checked, a game also uses the ones created later. With none checked the game is switched off for the season: the switch follows the boxes, and turning it on again checks them all.
For PlayerGuess and PlayerFill, each cartridge shows how many of its words serve the game, and the page warns when the chosen cartridges are not enough. In the hub, the card of the game says why there is nothing to play: no active cartridge, no words that meet the requirements or no questions in the chosen cartridges, or words of the day not drawn yet. Deleting the only cartridge a game uses switches the game off, and the page says so.
First setup
- Create a cartridge (Cartridges): the games need something to ask.
- Create a season and activate it (Seasons).
- Choose the games the season runs and their cartridges (Season games).
- Review the rules (Rules): the defaults work, but the XP, the levels and who plays are yours to set.
📖 Usage
For Administrators
- Install the plugin and complete the Moodle upgrade step.
- Optionally install local_aihub if you
want AI-assisted cartridge generation with personal/site keys (see
AI Provider Chain) — otherwise cartridges can still be created manually
or generated through Moodle’s own
core_ai. - Create a content cartridge in the Cartridges page (upload one or generate it): the games need something to ask.
- Create the first season in the Seasons page and activate it, setting name and dates.
- Choose the games the season runs, and where their questions come from, in Season games.
- Review the rules (XP, levels, who plays) under Rules: the defaults work, and you can tune them.
- Monitor gamification impact in the Engagement Meter page.
Steps 3 to 6 are cards in the Administration tab, in this order (the Engagement Meter has its own tab); see Administration.
For Teachers
- If
local_aihubis installed, access its My AI Keys page to configure a personal API key (optional — site keys work if the admin configured them). - Use the PlayerGames hub or any Player plugin — AI features will use the configured key chain automatically.
For Students
- Visit the Player Hub to see your XP, level, ranking position, streak, and daily missions.
- Play the daily mini-games to earn XP.
- Toggle “Show in ranking” in your profile to control ranking visibility.
🧪 Automated Tests
PlayerGames ships with a PHPUnit suite covering the gamification engine, the cartridge pipeline, scheduled tasks, privacy and events, and with Node tests for the rules of PlayerBattle. Every CI push runs the full matrix (Moodle 4.5 → 5.3, PostgreSQL & MariaDB).
PHPUnit — Unit & Integration Tests
| Test file | Cases | What is covered |
|---|---|---|
cartridge/importer_test.php |
14 | Concept and quiz import; type inference; fields of an older file ignored; schema-error paths; fields of the wrong type; the whole import saved in one transaction |
cartridge/exporter_test.php |
5 | Concept/quiz export structure and full import→export round-trip including root metadata |
cartridge/quiz_generator_test.php |
12 | Quiz response parsing, save_standalone persistence; responses with fields of the wrong type |
cartridge/ai_generator_test.php |
7 | Concept response parser: wrapped/bare/fenced JSON, invalid and missing-concepts errors; delegation to the AI Hub facade with a core_ai fallback; responses with fields of the wrong type |
cartridge/payload_test.php |
3 | Cleaning of imported and AI-returned fields: a scalar becomes text and anything else counts as missing; a single value is wrapped as a list; numbers are clamped with a fallback |
hub/xp_manager_test.php |
17 | Level thresholds, per-game cap enforcement, uncapped mission award, level-up event, season ranking position/tie-break |
hub/avatar_manager_test.php |
15 | Default catalog seeding, tier thresholds, lifetime best-level tracking, unlock/equip rules, locked-equip rejection |
hub/learning_xp_manager_test.php |
22 | Windowed monthly buckets, visibility gating (independent of staff status), ranking opt-in and position, recompute correctness |
hub/daily_play_manager_test.php |
6 | Multiple plays split XP evenly; play beyond the daily quota rejected; last play trimmed to the exact cap; the extra payload (victory) reaches the event and completes the battle mission only when flagged; every pending game links to its page and a played one does not |
hub/level_manager_test.php |
8 | Ladder seeding, XP/title lookups, save renumber + zero floor, restore defaults, linear generation and bounds |
hub/checkin_manager_test.php |
11 | Check-in insert + XP award, idempotency, season cap, optional streak advance, participant eligibility |
hub/served_questions_test.php |
3 | Per-day “already shown” set grouped by source, idempotent scoping, invalid items ignored |
hub/streak_manager_test.php |
12 | Streak start/continue/reset, freeze consumption, overnight break processing |
hub/season_manager_test.php |
28 | Season lifecycle, active/upcoming resolution, exclusive activation, snapshot, create_next; whether any season exists; editing (a closed season keeps its dates), deleting only a season’s own data, the active season refused; closing early ends the season today; overlapping dates found and named |
hub/mission_manager_test.php |
15 | Mission sync, progress/completion with XP reward, daily resets; the streak missions counted from the start of the season; several missions of one kind; description from the target; switching off, deleting and the lock of a mission completed this season; the range of each kind |
hub/season_xp_test.php |
2 | The days of a season, first and last included; the most XP of a season, game by game, with the check-in cap and the missions the season can reach |
hub/achievement_manager_test.php |
6 | Achievement sync, granting (first game/level/all-games-day), idempotency |
hub/title_manager_test.php |
2 | Level→title key clamping and translation |
observer_test.php |
5 | game_completed drives streak/mission/achievement; records streak even without a season; mirrors block_playerhud XP changes into Course XP |
hook_callbacks_test.php |
5 | Primary navigation link: the hub for a student, none after opting out, the dashboard for a teacher who opted out, none for a guest, and the staff lookup skipped (counted in queries) when gamification is on |
games/quiz_loader_test.php |
12 | Completeness filter, session size, active-only, id filter, metadata, random draw, fresh-question exclusion and pool reuse |
games/quiz_settings_test.php |
6 | Timer, max-attempts and session size configuration |
games/day_loss_test.php |
7 | A lost day: the allowed defeats close it, Unlimited never does, it stays closed, it belongs to one user, game and day, and the word games read it from their own round |
games/guess_manager_test.php |
7 | Daily concept resolution, term normalisation, Wordle-style letter feedback (including duplicate letters), guess validation |
games/fill_manager_test.php |
10 | Word count/max-attempts config clamping, shared letter→slot assignment (including disjoint terms), tile reveal state, cross-reveal cascade, per-day term ordering and filtering, POST response payload reveal rules |
games/battle_manager_test.php |
12 | PlayerBattle on the server: questions delivered ready for the browser with the text escaped once, no battle without questions, a defeat saved without XP and without spending the play, a victory with the season XP (also past the quota, with none), the best result of the day, a battle accepted once, counters kept in range, only the questions delivered counted as seen |
games/word_pool_test.php |
7 | Which terms serve PlayerGuess and PlayerFill: the rule itself, length ranges, cartridges of the season, enough words for a day, count per cartridge |
games/season_game_config_test.php |
7 | Source helpers; enabled-record lookup; per-season listing; default seeding and preservation |
external/set_avatar_test.php |
3 | Equip/unequip via the AJAX endpoint, rejecting a locked avatar |
external/set_ranking_visibility_test.php |
2 | Season ranking opt-in/opt-out toggle |
external/set_learning_ranking_visibility_test.php |
2 | Course XP ranking opt-in/opt-out toggle |
task/assign_daily_games_test.php |
17 | Per-game concept assignment, PlayerFill’s multi-concept assignment and pool-too-small skip, idempotency, no-cartridge and empty-cartridge cases, PlayerGuess eligibility filter, task name; PlayerGuess and PlayerFill never share a word while others are left |
task/reset_daily_missions_test.php |
1 | Daily mission reset + streak break orchestration |
task/close_expired_seasons_test.php |
2 | Closes expired season; auto-renew creates and activates next |
task/purge_old_scores_test.php |
3 | Retention-window purge; keep-within-window no-op; battle results of seasons beyond the window are purged too |
task/recompute_learning_xp_test.php |
2 | Nightly window recompute prunes aged-out buckets and corrects cache drift |
privacy/provider_test.php |
9 | Metadata, contexts, userlist, export, and the three deletion paths; every declared table lists exactly its real columns |
output/hub_test.php |
2 | Who is offered the seasons page while there is no season: the administrator, and no one else |
output/season_games_test.php |
2 | The season games page: cartridges ticked as they were saved, all of them without a list and none with an empty one; warning about too few words |
local/access_test.php |
16 | Staff detection (site admin, course-editing capability), bulk staff-id resolution, hub visibility rules; where each role lands |
local/admin_cards_test.php |
8 | Administration tab: cards and groups by permission (administrator, manager, student), the tab in the navigation, the state of each card, a season name escaped once, and the documentation link opening in a new tab |
local/game_page_test.php |
2 | The notice of the game pages when no season is active, and that it never says the game was already played |
local/question_bank_reuse_test.php |
3 | Which question bank categories are kept for reuse (shared banks on Moodle 5.x, system context on 4.5), question counts, what a user may choose |
cartridge/question_bank_importer_test.php |
8 | Copy into a new active question cartridge, left out questions with a medium (counted), unusable questions, latest ready version only, nothing to import, private categories and users who may not use them refused, text flattened keeping case and entities |
cartridge/glossary_importer_test.php |
4 | Global glossaries listed with their approved entries, import into a concept cartridge, refusal of a course glossary and of an empty one |
local/text_test.php |
4 | Plain-text names: text as typed, the level title, cartridge pages escaping names once, and edit forms filling inputs with the stored text |
local/data_reset_test.php |
4 | Every table deleted or kept, the personal-data tables deleted, the seasons counted alone, and a reset that deletes the play, keeps the content, the settings and the users’ choices, and logs who did it |
local/engagement_report_test.php |
14 | Empty metrics, course counting, player-course detection, scope split; the comparison kept for an hour per period and set of courses |
ecosystem/plugin_registry_test.php |
2 | Catalog structure and unique components |
ecosystem/plugin_status_test.php |
1 | Installed status keyed by component; hub reported installed |
event/events_test.php |
1 | All nine events trigger, are captured and render a description |
db_upgrade_test.php |
6 | Upgrade step that removes an index duplicating a key: two identical indexes become one, a column with no index gets the key’s index, a single index is left alone; concept games lose the glossary source and the category |
uninstall_test.php |
2 | Uninstall removes only the plugin’s own prefixed user preferences, and does nothing when there are none |
| Total | 320 |
vendor/bin/phpunit --testsuite local_playergames
Node — PlayerBattle rules
The board and combat rules of PlayerBattle are plain modules (amd/src/battle/) that also load in
Node, so they are tested without a browser. The CI runs them with node --test.
| Test file | Cases | What is covered |
|---|---|---|
js/battle/prng.test.js |
5 | The seeded generator: same seed, same sequence; different seeds differ; values in [0, 1); a fixed known sequence; seeds coerced to unsigned 32 bits |
js/battle/board_rules.test.js |
14 | A new grid has only the types in play and no match; the number of types is the one asked for; matches found with their size; a piece in two matches is destroyed once; type 0 is a piece, not an empty cell; swaps; which type a swap would match; the opponent’s move; shuffling; gravity and refill |
js/battle/combat_rules.test.js |
23 | Starting state and the pinned balance; combo bonus; Sword damage and the multiplier; Potion; the Shield and Grimoire meters; the Orb filling the mana bar; the critical hit and the cost of a wrong answer; hex ticks; victory and defeat; the rules never change the state they are given |
| Total | 42 |
node --test tests/js/battle/*.test.js
Coverage
Line/method coverage is measured locally with Xdebug (moodle-coverage, a bench tool — not part
of CI) rather than published as a single plugin-wide percentage: this codebase deliberately does
not unit-test Moodle’s own output renderers (classes/output/*) beyond the two that decide who
sees what (the hub’s seasons button and the Administration tab), the cartridge management UI
controller, or ai_generator’s real HTTP calls (only its response-parsing logic is tested, since
mocking the network round-trip has low ROI) — none of that is a gap the PHPUnit suite is meant to
close, so a raw plugin-wide number would just measure that policy rather than test quality. The
classes it is meant to cover — game managers, hub services, scheduled tasks, events, external
functions and the Privacy Provider — are what the case counts in the table above exercise, and
games/fill_manager and task/assign_daily_games (the classes PlayerFill added or changed) are
both at 100% line and method coverage.
Behat — Acceptance Tests
| Feature file | Scenarios | What is covered |
|---|---|---|
play_quiz.feature |
2 | The PlayerQuiz play flow end to end |
php admin/tool/behat/cli/init.php
vendor/bin/behat --tags=@local_playergames --profile=chrome
🔎 Third-party Service Disclosure
PlayerGames includes optional AI-assisted cartridge generation. This is entirely optional — all content can be created manually.
Architecture
AI generation is routed through the companion
local_aihub plugin when installed, which
owns the key storage and the provider transport; if the Hub is not installed, PlayerGames falls
back to Moodle’s own core_ai subsystem, whichever providers the site administrator configured
there.
Supported Providers (via local_aihub)
- Google Gemini — https://ai.google.dev/
- Groq — https://console.groq.com/
- DeepSeek — https://platform.deepseek.com/
- OpenAI-compatible APIs — Any provider following the OpenAI API format (e.g. OpenRouter, self-hosted models via LM Studio, Ollama proxy, etc.)
These services operate under their own terms of service and privacy policies. Full disclosure of exact model IDs and data destinations is documented in local_aihub’s own Third-party Service Disclosure.
Data Transmission
When AI generation is used, the prompt built by PlayerGames (topic, language, level,
and any optional reference text the teacher provides) is passed to whichever source
resolved the request (the Hub or core_ai) for processing. PlayerGames:
- Does not store prompts or AI responses beyond the cartridge concepts created inside Moodle
- Never includes student data in an AI prompt
No external communication occurs unless an AI feature is explicitly used.
Cost
None required by PlayerGames itself. If local_aihub is installed, any cost is whatever the
underlying provider charges through that plugin’s own BYOK keys; without it, PlayerGames falls
back to Moodle’s core_ai, which may be free if the site admin has configured a no-cost
institutional provider.
Demo Credentials
Not applicable — no credentials are required to install or use PlayerGames; AI-assisted cartridge generation is entirely opt-in.
📄 License
This project is licensed under the GNU General Public License v3 (GPLv3).
Copyright: 2026 Jean Lúcio
Support
Found a bug or have a question? Open an issue on the issue tracker.
Maintainer
Maintained by Jean Lúcio.