PlayerPuzzle

Turn-based Match-3 RPG gamified activity for Moodle — full documentation.

English | Português

View on GitHub Download .zip

Moodle License Status Latest Release PlayerGames Ecosystem Author

Moodle Plugin CI Last Commit Open Issues

PlayerPuzzle (mod_playerpuzzle) is a turn-based Match-3 RPG gamified activity for Moodle: the student combines pieces on an 8×8 board to attack a computer-controlled opponent, answering questions to land critical hits. The questions come from the activity’s own bank — imported from the course’s Moodle Question Bank, written by hand, or generated with AI and approved by the teacher. The teacher chooses between a self-contained Single Match or a Campaign of up to 10 levels (10 phases each), where the student picks a hero that grows with upgrades bought in the shop and meets opponents with powers of their own. Winning earns PuzzleCoin, spent in a loadout shop before the next match, and the optional companion block_playerhud can feed coins in, charge for a retry or award an item.

👈 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

⚔️ Gameplay

🏛️ Lobby and economy

📚 Questions

📊 Grading and teacher tools

🛡️ Integrity

See Security & Anti-Cheat.

♿ Accessibility

The board is a real grid over the pieces (arrow-key navigation, Enter to select a piece and swap it with a neighbour, number-key moves, and aria-live turn announcements), with real labelled buttons, a native <dialog> for questions and an optional spoken narration. See Accessibility.

🔐 Privacy and quality

⏳ Not in this release

Everything listed above works today and is covered by the automated test suite.

⚔️ How Combat Works

Combat runs on an 8×8 Match-3 board, portrait-first (540×960), adapting to a landscape layout on wider screens.

Turn Structure

Who moves first. Every phase opens with an opening question, in the same window as a Question Challenge. Answer it right and you move first; miss it, skip it, or let it fail and the opponent does. It changes nothing else in the fight (no damage, no Star multiplier lost), and an answer counts towards the minimum of questions like any other. A Demo has no opening question, and an activity with no question in its bank starts straight away with the student’s turn.

  1. The student makes a move on the board.
  2. Combos and cascades keep the student’s turn going.
  3. Once the board settles, it becomes the Opponent’s turn: the computer scans the board and executes one valid swap. Whatever it matches resolves through the exact same seven pieces and effects as the student’s own turn (see below) — the opponent can deal damage, build up a multiplier, hex the student, shield itself, heal, and bank gold, exactly like the student does on their own turn.

The Seven Pieces

Every effect is symmetric: a piece does the same thing no matter which side is playing it — only who benefits changes (whoever’s turn it currently is).

Piece Effect
⭐ Star Adds +0.1 to a damage multiplier, stacking across turns; consumed on that side’s critical hit and reset to 1 when that side answers a question wrong
📖 Grimoire Fills a 0–100 hex meter of its own (+10 per piece); on reaching 100, arms 3 damage rounds against the opponent (one per their own turn) and resets, carrying over any overshoot
❓ Mana Orb Fills a 100-point energy bar of its own for each side; reaching 100 pauses combat and opens the Question Challenge — the student answers for real; whether the opponent’s “answer” is right is decided on the server, with a chance set by the difficulty (see below)
⚔️ Swords Direct damage to the opponent — no question needed. Scales with level/phase, and a 4- or 5-piece match deals 1.5x/2x the damage of a 3-piece match
🛡️ Shield Fills a 0–100 meter of its own (+10 per piece); on reaching 100, negates the next hit that side takes in full, no matter how large, then resets
🧪 Potion Heals that side’s own HP by a quarter of the base damage per piece, so a 3-piece match heals three quarters of what a 3-piece Sword match deals — damage always outweighs healing
🪙 Coin Adds to that side’s own gold count for the match — see the combo formula and net compensation in PlayerHUD integration

Status effects on the fighters. While a Hex is on a side, a purple haze with bubbles rising from it surrounds that fighter and a label beside it shows the rounds left (“Hex 3”); while a block is armed, a golden bubble surrounds the fighter and a label says “Shield”. The labels sit on the side that faces the other fighter and are as large as the room allows, so they read on a phone. Both effects are announced to screen readers when they start and when they end, and the animation stops for players who ask for reduced motion.

The Question Challenge

When either side’s Mana Orb bar reaches 100%, the match pauses and opens the question dialog:

The opponent “answers” too when its own Mana Orb bar fills, but it never sees the right answer: the server decides whether the opponent guessed correctly, with a probability that depends on the difficulty (see below).

This is the moment the plugin ties Match-3 skill to actual content knowledge: matching pieces well fills the bar and builds up the multiplier, but the real payoff only lands if the student also answers correctly.

Minimum Questions and the Opponent Holding On

The teacher can require a minimum number of answered questions per match (3 by default). The Lobby tells the student before the match starts, and a counter shows the progress during it. If the opponent would fall before that number is reached, it stays on its last 1 HP instead of dying, and every Orb piece the student matches fills the whole mana bar, so a single Orb combo asks the next question. Once the minimum is met, the next hit defeats it. A strong hit therefore costs nothing, and a match can never be won without actually engaging with the questions.

Difficulty

The student chooses Easy, Normal or Hard. The choice changes the fight, never the grade:

  Easy Normal Hard
Opponent HP ×0.5 ×1 (final boss +15%) ×3
Opponent’s base hit ×0.5 ×1 ×2
Growth of its hit over the Campaign none up to +60% up to +100%
Opponent armor its own only its own +25 points over the Campaign its own +25 points
Student’s hit ×1 ×1 ×2
Student’s HP in the fight ×1 ×1 ×2.5
Critical hit (a right answer) 3× the hit of whoever answered, times their Star multiplier the same the same
Coins per 3-coin match ×2/3 (10 for every 15) ×1 ×4/3 (20 for every 15)
Opponent answers right (Multiple Choice / True-False) 33% / 50% 66% / 75% 100% / 100%
How the opponent plays the first Sword match it finds weighs the pieces (Sword and Potion count most) as on Normal, and it also values more the pieces that feed its powers (the wolf, the Orb)
Opponent’s items (Potion, Sword) none 1 per level after the first, +1 on the final boss 1 more than on Normal
Opponent’s powers yes yes yes
Grade the same the same the same

The hero is the same on every difficulty: its HP, attack and armor come only from what is bought in the shop, and the shop shows those values. On Hard it fights with 2.5× that HP. As an example, an activity with the default values (a base HP of 100 on both sides, a base damage of 10) and 2 levels, with the student’s HP before any upgrade. The opponent’s HP and both sides’ hits grow with every phase; the student’s HP only grows with what they buy in the shop:

Phase   Opponent HP Its hit Its critical Its armor Student HP Student’s hit Student’s critical
Level 1, Phase 1 (slime) Easy 50 5 15 0% 100 10 30
  Normal 100 10 30 0% 100 10 30
  Hard 300 20 60 0% 250 20 60
Level 1, Phase 6 (ghost) Easy 75 8 24 0% 100 15 45
  Normal 150 17 52 7% 100 15 45
  Hard 450 38 114 7% 250 30 90
Level 2, Phase 10 (vampire, final boss) Easy 144 12 36 15% 100 24 72
  Normal 331 38 115 40% 100 24 72
  Hard 864 96 288 40% 250 48 144

The criticals are shown with a Star multiplier of ×1, before the other side’s armor; the student’s hits are before the hero’s attack and the opponent’s armor. On the Hard final boss, one of the opponent’s criticals (288) is more than the student’s starting HP (250): that is what the shop and the hero’s upgrades have to cover.

On Hard the student needs 1.5 times as many hits as on Normal to bring the opponent down, since its HP triples while their own hit doubles; on Easy, half as many. On Hard the opponent’s hit is 2.2 to 2.5 times the Normal one while the student’s HP grows 2.5×, so the student survives about as many hits as on Normal.

On Easy the halving is on the opponent only: its HP and its hits are halved while the student’s own hits, Potions and hex keep their full value, so an Easy match is shorter and not only safer. On Hard both sides’ hits double, the opponent’s HP triples and the student’s grows 2.5×: a match lasts about as long as a Normal one, and what makes it harder is the opponent itself (it answers every question right, its hits grow over the Campaign and it has more items), not hits that bring down a hero at full HP. On Normal the final boss also has 15% more HP, which puts it a little above what a hero with every upgrade can reach.

The hero grows over a Campaign (HP, attack and armor, all bought in the shop) and the opponents’ powers stay the same, so from Normal up the opponent’s hits also grow with the Campaign’s progress, from nothing at the first phase to 60% more at the last on Normal and 100% more on Hard; Easy does not grow. Their armor grows too: every opponent, on Normal and Hard, absorbs 25 points more of each hit at the last phase than at the first, on top of the armor it already had (the golem and the plant start at 15% and end at 40%, the others go from nothing to 25%), so a hero that has put its buys in armor meets a defense that answers it. On Hard this keeps the fight demanding to the end, and the Potions, Swords and Shields from the shop weigh far more there than on Normal.

The activity’s values change the difficulty too, as much as the student’s choice. The opponent’s base HP over the base damage decides how long a fight lasts, and long fights favour the opponent, above all on Hard, where it answers every question right and gathers Stars for more turns. The student’s base HP over the base damage decides how many hits they can take. In simulated matches of a 3-level Campaign on Hard, with a student who answers 90% of the questions right and a base damage of 10:

Opponent’s base HP Student’s base HP Tries per phase
100 100 (the default) 2.9 to 3.6
100 250 1.1
250 250 3.8 to 5.1

Raising only the student’s HP makes the game much easier; raising both makes the fight 2.5 times longer, and on Hard that makes it harder than with both at 100. On Normal the same three rows come to 2.1 to 2.3, 1.1 and 1.5 to 1.8.

In Campaign the choice is made for each phase: in the Lobby for the first one, and on the “Phase won” screen for the next.

The Loadout Shop and Consumables

Consumables are bought before a match, in the Lobby shop, with PuzzleCoin, and used from the combat panel during the fight. Each use comes out of the student’s stock and is limited per phase or match:

Consumable Effect Price Uses per phase
🧪 Potion Heals 1.25× the base damage 8 3
🛡️ Shield Arms the block of the next hit at once, without spending what the Shield meter already had; cannot be used while a block is armed 10 1
🔮 Quick Magic Arms three hex rounds on the opponent at once, without spending what the Grimoire meter already had 12 1
⚔️ Sword An extra attack of one base damage, without ending the turn 10 3
💡 Hint Shows the hint of the open question, when it has one 5 no fixed limit

Prices and limits are fixed, the same for everyone, and the shop shows each item’s limit on its own card. During the fight, the number on each item is how many can still be used in the phase: the stock, up to the phase’s limit. After a match, Play again opens the same shop inside the game, as the screen between phases does, to stock up before the next try or match. A student’s first match normally starts with an empty loadout: PuzzleCoin is earned by winning, or transferred in from PlayerHUD. Coins are collected on the board with the Coin piece — see PlayerHUD Integration for how they are netted against the opponent’s and banked. A teacher can switch hints off for the whole activity.

Saved Progress

While a fight is on, the board, the HP and the meters are saved to the server every few seconds and when the page is left. Reloading, or coming back later, rebuilds the fight from the server’s own record of the moves rather than from whatever the browser says.

Server-Side Truth

Every number that governs combat — the opponent’s and student’s maximum HP, and the base damage figure Sword/Star/Grimoire/Potion all scale from — is computed once on the server for the current level and phase (see Game Modes for how these scale) and handed to the client as configuration; the client never recalculates any of it. The server also re-plays the moves the student made to work out the real outcome — see Security & Anti-Cheat.

🎯 Question Engine

Source

Each activity has its own question bank, filled from three sources on the Manage questions page:

Only approved questions are ever drawn in a match.

Blind JSON — the Answer Never Leaks

The question text and every answer option are sent to the browser, but the correct answer id is not. question_fetcher.php strips it server-side before the question ever reaches the client. When the student submits a choice, mod_playerpuzzle_validate_answer checks it against the real record in the database and returns only a boolean plus (on a wrong answer) the correct option — so nothing in the page source or network traffic ever reveals the answer in advance. This is the first of the plugin’s three anti-cheat pillars.

Managing Questions

Teachers (users with the Manage the PlayerPuzzle question bank capability) get a Manage questions page in the activity. It lists every question with its answers, type and source, the level and phase it is meant for, its status and how many times it has been drawn, and offers:

Only approved questions are ever drawn in a match. A question already answered in a phase is not asked again in that phase while the pool still has another; once all have been asked they come around again.

Finding and sorting. The list can be filtered by level (in a Campaign), by phase (including No level set and No phase set) and by status (approved, pending, disabled), and sorted by most recent, level and phase, status, most drawn, type or source. The filters apply as soon as they change and travel with every action, so approving, editing or setting a level or a phase on a filtered list brings the teacher back to the same list. The bulk actions (approve, set level, set phase, delete) appear in a bar once questions are selected.

Questions by Level and Phase

In a Campaign, each question can be meant for a level and for a phase of a level (every level has 10). The two are independent and start as Any, so the teacher only fills in what they want to use:

The teacher sets What for Example
The level only Content of its own for each level: a unit, a chapter Level 2 asks about chapter 2
The phase only Rising difficulty inside every level The easy ones open the level, the hard ones close it
Both A question for one exact point of the Campaign The question of level 3’s boss

A phase is played with the questions whose level and phase both match it or are Any. When none does, the game draws from every approved question, so a phase nobody prepared is never left without questions. A Single Match and the Demo have no levels or phases and always draw from every approved question. A bank re-import never changes a question’s level or phase.

The levels offered go up to the activity’s number of levels. If the teacher lowers that number later, the questions meant for a level that no longer exists are never drawn, and the question list says how many there are.

AI Generation

When an AI source is available (the AI Hub plugin with a key, or Moodle’s own core_ai), the teacher can type a topic, a number of questions (up to 10) and their type: Multiple choice and True/False, Multiple choice only or True/False only. In a Campaign they can also choose the level and the phase the questions are saved for. The result is shown as a preview the teacher can edit, and only the questions they select are saved — as pending. Nothing the AI wrote reaches a student before the teacher approves it. See Third-party Service Disclosure for what is sent.

Hints

A question can carry a hint. It is shown only to a student who spends a Hint consumable while that question is open, and a teacher can turn hints off for the whole activity.

Minimum Questions Per Match

The activity settings let a teacher require a minimum number of questions to be answered before a match can end in victory (3 by default). The Lobby shows the requirement before the match starts, a counter shows the progress during it, and the opponent stays on its last HP if it falls too early — see How Combat Works. The count is kept by the server on every answer, never reported by the client.

🎮 Game Modes

The teacher picks one mode per activity instance.

Campaign

A continuous run through up to 10 levels, each split into 10 phases. Winning a phase never costs a new attempt — only a defeat does. Maximum attempts is the number of attempts in each Campaign.

Heroes

In a Campaign the student chooses one of six heroes on a screen of its own, when pressing Play for the first time (the activity opens at the Lobby, where the help and the shop are), and keeps it to the end of that Campaign; a new Campaign asks again. In a Single Match or a Demo the hero is chosen when the student presses Play, has the same specialty head start, with no upgrades to buy, and a Single Match opens the choice with the hero last used.

Opponents

A Campaign meets the same ten opponents on every level, one per phase, from the easiest to the hardest; the last phase of the last level is fought against the final boss instead. A Single Match fights the opponent the teacher picks in the activity settings. Each has a stage of its own, and most stand out in one way: they hit 15% harder, their armor absorbs 15% of every hit they take, or they have 15% more HP. Each also has a power, which the game explains the first time the student meets it and which the opponent’s card shows again at any time:

Phase Opponent Stands out Power
1 Slime — Regenerates 1% of its max HP as each of its turns begins
2 Goblin hits harder Ambush: its Swords deal double damage on its first turn
3 Ice golem armor Starts the fight with its Shield armed
4 Mummy hits harder Curse: starts with its Grimoire 20% full, and its hex lasts 4 rounds instead of 3
5 Carnivorous plant armor Root: the Potions it matches heal 50% more
6 Ghost — Intangible: every 10 of its turns its Shield arms by itself
7 Pirate skeleton hits harder Loot: every 4 of its turns it takes 10% of the student’s coins from the match, and hits harder the more it took
8 Wolf hits harder Its question comes sooner: each Mana Orb gives it 24% mana instead of 20%
9 Giant spider more HP Its hex comes sooner: each Grimoire fills 15% of its meter instead of 10%
10 Dragon hits harder Fire breath: every 10 of its turns, before it moves, a hit of 1.5 times the base damage that a Shield blocks
Final boss Vampire 20% more HP Drain: each of its hits heals it by 30% of the damage it deals

The final boss also answers the student’s hero with a second power borrowed from another opponent: against an attack specialist it gets 15% armor, like the golem’s, against an armor specialist the spider’s fast Grimoire (the hex goes through armor), and against an HP specialist the dragon’s breath, every 12 of its turns. On Normal and Hard the opponents also bring Potions and Swords of their own, more of them further into the Campaign (see Difficulty).

Single Match

A single, self-contained round — no levels or phases, always fought at the configured base HP, scaled by the difficulty the student chose. The teacher sets how many matches a student may play (1 to 10, or unlimited) and may add a cooldown (in minutes, hours or days) between matches. The student chooses the difficulty in the Lobby for each match. While a cooldown is running, the Lobby tells the student the time the next match opens, so they learn it before pressing Play, and Play is refused before the hero choice.

Grading

The grade is always scaled by the activity’s Maximum Grade (points, or no grade — scales are not supported), never by a fixed 100, and never changes with the difficulty chosen.

Campaign — each Campaign scores on its own:

Campaign score = (furthest phase won ÷ total phases configured) × Maximum Grade

“Furthest phase won” is the highest level/phase the student reached with a victory in that Campaign, across all of its attempts — not a count of won attempts, because one continuous attempt can cover dozens of phases. The teacher’s Grading method combines the Campaigns: highest, average, first, last, or average over all required Campaigns. The first Campaign counts from the start; each later one only once it ends, so starting another never lowers the grade.

Single Match — each match scores either the Maximum Grade (a win) or zero (a loss), and the teacher’s Grading method combines the matches the same way (in the average over all required matches, an unplayed match counts as zero).

Consider errors — available once the activity requires a minimum number of questions. In Campaign, the progress rate is multiplied by the share of questions answered correctly across the whole Campaign; in Single Match, a win is weighted by that match’s own accuracy.

The grade is sent to the gradebook after every phase or match, so it is never stuck waiting for the end of a campaign, and recomputed for everyone when a grading setting changes.

Why Two Modes Instead of One

A Campaign “attempt” and a Single Match “attempt” are structurally different — a continuous run across many phases versus independent, repeatable rounds — so the plugin models them separately rather than forcing one grading and attempt-counting scheme to fit both.

💰 PlayerHUD Integration

PlayerPuzzle has its own persistent currency, PuzzleCoin, so it works fully without anything else installed. block_playerhud is an optional companion: when it is in the course, the teacher can connect three things to it. The plugin only reads or writes to the block when one of them is configured.

PuzzleCoin

Coins are collected on the board with the Coin piece. A 3-piece match earns the configured Coin gain (15 by default), a 4-piece match 1.5× that, and a 5-piece match 2× — the same curve Sword damage uses. Unlike every other combat value, coin gain deliberately does not scale by level or phase, so the fixed shop prices stay balanced for the whole campaign; only the difficulty changes it (a third less on Easy, a third more on Hard).

The opponent banks its own coins when it matches the Coin piece on its turn. It has no shop and never spends them; they only net against the student’s: the amount banked is max(0, student's coins − opponent's coins), and only on a victory (every phase won, in Campaign). A defeat banks nothing, and a Demo match never does. The result is added to the student’s PuzzleCoin balance, spent in the loadout shop.

What the Teacher Can Connect

Each of these is a plain dropdown of the block’s own configured items — the same pattern the sibling mod_playerwords/mod_playercross activities use — so the integration never required a change to block_playerhud itself.

If block_playerhud is missing, or older than the version this integration needs (v1.7.1), the form says so and the three options are simply not offered.

♿ Accessibility

The Design

The game is drawn with ordinary HTML elements on a stage that scales to the page, not on a canvas, so there is no opaque drawing for assistive technology to miss. The pieces, scenery and effects are hidden from screen readers, and the game is operated through real, labelled controls instead of an afterthought bolt-on layer:

Emoji and sound

Spoken Narration

The announcements can also be spoken through the browser’s Web Speech API, with a Speak game announcements aloud switch in the Lobby settings. It is off by default, so it never competes with the screen reader a student is already running, and the choice is remembered per user.

Testing

A Behat feature reads the announcements and plays through the keyboard using only Moodle’s standard steps. It proves the mechanism; checking with a real screen reader (NVDA, JAWS, VoiceOver) is still worthwhile for timing and pronunciation, which no test framework captures.

🔐 Security & Anti-Cheat

Every combat number a student sees is a claim the client makes about itself. PlayerPuzzle treats none of it as trustworthy until the server confirms it, through three pillars:

1. Server as the Source of Truth

The opponent’s HP for the current level/phase and the student’s side (the hero’s HP, attack and armor) are computed once, server-side, when the phase starts (combat::calculate_boss_hp() and combat::phase_student()), and handed to the client as read-only configuration. The client never recalculates them, and the replay fights with the same frozen values. Every activity setting that decides how a fight plays out is frozen with the phase, the minimum of questions and the number of levels included, so a teacher editing the activity while a student is mid-phase never changes that phase.

2. Verified Outcomes

Capping a number is not the same as knowing it was earned by playing, so the server works the outcome out itself. When a match starts it issues a random seed, and the board is generated from it on both sides. The client logs every swap and every question outcome, and sends the log with the checkpoint it already saves every few seconds; the server re-plays the log with its own copy of the rules and derives the real damage, HP, coins and result.

The client and server rules are kept identical by shared test vectors: a headless run of the real JavaScript engine produces the expected boards and cascades, and the PHP port must match them bit for bit.

3. Single-Use Anti-Replay Tokens

Every state-changing call (starting a match, resuming a campaign attempt, advancing a phase) issues a fresh token and invalidates the previous one. A captured request can’t be replayed to re-trigger the same reward twice — resuming a campaign mid-run rotates the token exactly like finishing one does, so the guarantee holds across a session that spans multiple page loads, not just within a single match. Economic operations (using up a token, advancing a phase, buying or transferring coins) also run under an atomic lock per attempt or per student, so two parallel requests cannot both succeed. Starting an attempt checks the attempt and Campaign limits, the cooldown and the retry cost under one lock per student and activity, with the retry cost charged last, so two Plays at once never both pass, and a refused start never charges anything.

Blind JSON

The correct answer id is never sent to the client — see Question Engine for how this is enforced at the data layer, not just the UI layer.

🎓 Educational Purpose

PlayerPuzzle is designed to:

Suitable for:

🕹️ PlayerGames Ecosystem

PlayerPuzzle is part of the PlayerGames gamification ecosystem for Moodle. None of the plugins below are required — PlayerPuzzle works standalone — but installing the ones relevant to a course unlocks the integrations documented throughout this page.

📦 Requirements

Component Version
Moodle 4.5 – 5.3
PHP 8.1+

block_playerhud is an optional dependency — see PlayerHUD Integration.

🛠️ Installation & Configuration

  1. Download the .zip file or clone this repository.
  2. Extract the folder into your Moodle mod/ directory.
  3. Rename the folder to playerpuzzle (if necessary). Final path: your-moodle/mod/playerpuzzle/
  4. Visit Site administration → Notifications to complete installation.
  5. Optional: install block_playerhud if you want the optional coin/upgrade economy — see PlayerHUD Integration.
  6. Add a PlayerPuzzle activity to any course, pick a Game Mode and (optionally) which PlayerHUD items to use. Then open Manage questions (in the activity’s navigation bar, under More when it does not fit) to import a Question Bank category, add questions by hand or generate them with AI.

📖 Usage

For Teachers

  1. Add a PlayerPuzzle activity to a course.
  2. Choose a Game Mode — Campaign or Single Match — see Game Modes — and the opponent of a Single Match, the HP and damage, and how many levels a Campaign has. The form caps the base HP at 10,000, the base damage at 1,000 and the coin gain at 1,000, far above the defaults and only there to catch a typo.
  3. Open Manage questions (in the activity’s navigation bar, under More when it does not fit) to fill the activity’s question bank: import a Question Bank category, add questions by hand, or generate them with AI (pending questions need your approval before they are drawn). See Question Engine.
  4. Optionally set a Minimum Questions per Match, whether wrong answers should count against the grade, a cooldown between matches or between Campaigns, and whether hints are allowed.
  5. Set the Grade (points, or no grade), a pass grade and the Grading method, which combines a student’s Campaigns or matches. Both formulas scale to the Maximum Grade, never to a fixed 100.
  6. Optionally connect PlayerHUD items — coin transfer, retry cost, victory award — if block_playerhud is installed in the course.
  7. Decide whether the class Ranking is shown, and use the activity’s Report page to follow progress, the most missed questions, the grade distribution, the results by difficulty and the heroes chosen.

For Students

  1. Open the activity to reach the Lobby: your progress (Campaign), the difficulty and the minimum-questions notice, and, when the activity has them, the attempt you are on, what the next attempt costs in PlayerHUD and when a cooldown ends. If Play is refused, a dialog says why. The difficulty is a button: press it to step through Easy, Normal and Hard (a line under it says what each changes). Once a phase is under way (a move, an answer or an item used) it is locked until its “Phase won” screen; before that, you can still change it. In a Campaign, the Campaign button opens your Campaign history: a line for each Campaign with its hero, the phases won, the attempts used and its points.
  2. Use Play Demo for a guided practice fight that never counts for anything, and How to play to read the rules: it is also behind the ? button during a fight, while the button with the dragon icon opens the opponent’s card.
  3. Open the Shop, which shows your PuzzleCoin balance, to buy consumables before the match, and — when the teacher connected PlayerHUD — to transfer coins in. Settings holds music (off until you turn it on), sound effects and spoken narration (also off) and, when the ranking is on, whether your name shows in it; Ranking shows the class standings.
  4. Select Play Game to start (or resume) a match. In a Campaign the first Play asks you to choose your hero, and a Campaign under way can be given up from the Lobby, after a confirmation.
  5. Match pieces to attack the opponent, fill the Mana Orb bar to trigger a Question Challenge, and answer correctly for a critical hit. With a mouse or touch, press a piece and then a neighbour, or drag one. With the keyboard, Tab into the board, move between squares with the arrow keys, press Enter to select a piece and Enter on a neighbouring square to swap the two (Enter on the same piece drops the selection), or press 1 to 9 to play the move the game announced, and Space to hear the list again. See Accessibility. The flag button at the top lets you leave and continue later, at no cost, or give up the match.
  6. After a phase or match, review the questions you answered. In Campaign mode, winning a phase never costs a new attempt — only losing does.

🧪 Automated Tests

PlayerPuzzle ships with an extensive PHPUnit suite covering the combat engine, the question pipeline, anti-cheat security, PlayerHUD integration, backup/restore, completion and privacy. Every CI push runs the full matrix (Moodle 4.5 → 5.3, PHP 8.1 → 8.4, PostgreSQL & MariaDB).

PHPUnit — Unit & Integration Tests (tests/)

Test file Cases
access_test.php 1
backup_restore_test.php 23
generator_test.php 2
install_xml_test.php 1
lib_completion_info_test.php 7
lib_crud_test.php 12
lib_grade_item_update_test.php 5
lib_grant_potential_test.php 5
lib_pluginfile_test.php 5
lib_reset_userdata_test.php 4
lib_settings_navigation_test.php 1
lib_supports_test.php 2
lib_update_grades_test.php 7
mod_form_test.php 32
uninstall_test.php 2
Subtotal 109

Completion Tests (tests/completion/)

Test file Cases
custom_completion_test.php 12
Subtotal 12

Event Tests (tests/event/)

Test file Cases
course_module_viewed_test.php 2
game_completed_test.php 3
game_started_test.php 2
Subtotal 7

Web Services Tests (tests/external/)

Test file Cases
advance_phase_test.php 33
buy_stock_test.php 12
buy_upgrade_test.php 7
core_libraries_test.php 2
draw_question_test.php 16
generate_questions_test.php 2
get_phase_questionlog_test.php 5
get_shop_test.php 4
save_combat_state_test.php 14
save_generated_questions_test.php 5
save_progress_test.php 43
set_ranking_preference_test.php 2
set_sound_preference_test.php 5
start_match_test.php 5
transfer_hud_coins_test.php 10
use_stock_test.php 19
validate_answer_test.php 20
Subtotal 204

Form Tests (tests/form/)

Test file Cases
import_form_test.php 4
question_form_test.php 13
Subtotal 17

Local Business-Logic Tests (tests/local/)

Test file Cases
ai_question_generator_test.php 23
attempt_consumables_test.php 8
attempt_questions_test.php 2
campaign_giveup_test.php 6
campaign_history_test.php 9
campaigns_test.php 14
coin_ledger_test.php 4
combat_state_test.php 5
game_page_service_test.php 63
grade_calculator_test.php 41
hero_page_service_test.php 5
hero_shop_test.php 5
heroes_test.php 9
howtoplay_test.php 5
hud_service_test.php 17
instance_list_service_test.php 4
last_hero_test.php 2
lobby_page_service_test.php 60
match_abandon_test.php 2
move_log_test.php 21
opponent_card_test.php 11
opponents_test.php 9
question_bank_sync_test.php 24
question_editor_files_test.php 3
question_list_service_test.php 7
questions_repository_test.php 33
ranking_service_test.php 12
replay_credit_test.php 8
report_service_test.php 37
seen_opponents_test.php 2
sound_preferences_test.php 8
text_test.php 1
user_hero_test.php 7
user_stock_test.php 10
Subtotal 477

Combat Engine Tests (tests/local/engine/)

Test file Cases
board_engine_test.php 28
combat_engine_test.php 57
combat_test.php 23
combat_vectors_test.php 25
engine_version_test.php 2
golden_vectors_test.php 5
prng_test.php 5
question_fetcher_test.php 29
replay_test.php 35
replay_vectors_test.php 40
security_test.php 58
Subtotal 307

Privacy Tests (tests/privacy/)

Test file Cases
provider_test.php 41
Subtotal 41
Grand Total 1174
vendor/bin/phpunit --testsuite mod_playerpuzzle_testsuite

Coverage (moodle-coverage, PHPUnit + Xdebug): 92.5% of the plugin’s lines (7080/7650).

Full test-by-test breakdown and coverage table →

JavaScript — Unit Tests (tests/js/engine/)

The deterministic match-3/combat/PRNG math, run headless via Node’s own test runner (node --test) — no Jest, no browser. First plugin in the ecosystem with a JS test layer of its own.

Test file Cases
board_rules.test.js 28
combat_rules.test.js 57
prng.test.js 5
replay_mirror.test.js 18
vectors.test.js 3
Subtotal 111
node --test tests/js/engine/*.test.js

JavaScript — Stage Tests (tests/js/stage/)

The small runtime that draws the game with HTML elements (tweens, clock, asset loading and sound) and the contract between the game and its HUD, run headless with node --test. The tween and clock vectors in tests/fixtures/ were sampled from the Phaser the plugin used to ship, so the timing is the one players already knew.

Test file Cases
assets.test.js 8
clock.test.js 14
emoji.test.js 6
hero_grid.test.js 1
hud_contract.test.js 6
modal_contrast.test.js 4
no_globals.test.js 1
portrait_layout.test.js 3
status_effects.test.js 7
tween.test.js 20
Subtotal 70
node --test tests/js/stage/*.test.js

Behat — Acceptance Tests

Feature file Scenarios
mod_playerpuzzle_accessibility.feature 4
mod_playerpuzzle_gameplay.feature 4
mod_playerpuzzle_hero.feature 10
mod_playerpuzzle_howtoplay.feature 4
mod_playerpuzzle_match.feature 3
mod_playerpuzzle_ranking.feature 3
mod_playerpuzzle_settings.feature 1
mod_playerpuzzle_smoke.feature 2
mod_playerpuzzle_stage.feature 5
Subtotal 36
php admin/tool/behat/cli/init.php
vendor/bin/behat --tags=@mod_playerpuzzle --profile=chrome

🔎 Third-party Service Disclosure

PlayerPuzzle works without any external service. Gameplay talks only to the Moodle site itself, and the questions a student sees come from Moodle’s own Question Bank (see Question Engine) or from the activity’s own question bank.

Optional AI question generation

The only feature that reaches an external service is the optional AI question generator on the Manage questions page. It is available only to users who hold the mod/playerpuzzle:managequestions capability, and only when an AI source is available.

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

🎨 Credits