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.
The Lobby, the activity's home screen: the Campaign progress to resume, the history of the Campaign, the difficulty, the attempt count and Play, with the Settings, the Ranking, the practice Demo, How to play, the Shop with the PuzzleCoin balance, and giving up the Campaign
✨ Features
⚔️ Gameplay
- Match-3 turn-based combat: an 8×8 board where the student swaps pieces to attack an opponent. Seven piece types, each with its own effect — see How Combat Works.
- Symmetric opponent: every piece resolves exactly the same way on the opponent’s turn as on the student’s — the opponent deals damage, stacks a critical-hit multiplier, hexes, shields itself, heals and banks its own gold.
- Question challenges: filling the Mana Orb meter opens a question; a correct answer is a critical hit, a wrong one resets the Star multiplier. See Question Engine.
- Heroes: in a Campaign the student picks one of six heroes, each a specialist in HP, attack or armor, and grows it with upgrades bought in the shop through four stages. See Heroes.
- Eleven opponents with powers: a Campaign meets ten opponents, one per phase of every level, each with a power of its own (regenerating, an armed Shield, a stronger hex…), and a final boss that answers the specialty of the student’s hero. See Opponents.
- Two game modes: Campaign (up to 10 levels × 10 phases, where winning never costs an attempt) and Single Match (a self-contained, repeatable round). See Game Modes.
- Three difficulties, chosen by the student, that never change the grade: Easy, Normal and Hard scale the opponent, the coin reward and how often the opponent answers correctly, and Hard also gives the student more HP for its longer fights.
- Opening question: every phase starts with a question that decides who moves first; right answer, the student, otherwise the opponent. It counts as an answered question.
- Minimum questions per match: the opponent stays on its last HP if it falls before the student has answered the required number of questions, and each Orb combo then asks the next one.
- Resume anywhere: the board and the fight are saved while playing, so closing the tab or reloading picks the fight up where it was. The flag button also offers to leave and continue later, at no cost, or to give up the match. The next phase, or another try after a defeat, starts in the same page, so a game in full screen stays in full screen.
- Demo match: a guided practice fight (100 HP on both sides), always available from the Lobby, that never counts for grade, coins or attempts. A one-time balloon explains each piece the first time the student matches it, and the closing screen lists the pieces that never came up.
- Review after the match: every question answered, with the student’s answer and the correct one.
🏛️ Lobby and economy
- Lobby as a home screen: progress, the Campaign history, difficulty, the attempt count, the minimum-questions notice and Play, with buttons for Settings, the Ranking, the Demo, How to play, the Shop and giving up the Campaign.
- How to play: a help the student can open in the Lobby and, with the ? button, during the fight: the goal, the seven pieces, the questions, the difficulty, the shop, the game mode, how to move the pieces (mouse, touch or keyboard) and what each button of the game does. What the activity does not have (the questions of an empty bank, the Campaign text in a Single Match, the shop for a visitor) is left out.
- PuzzleCoin: the plugin’s own persistent currency, earned by winning phases and matches.
- Loadout shop: before a match, the student spends PuzzleCoin on consumables — Potion, Shield, Quick Magic, Sword and Question Hint — and uses them during the fight, within a fixed limit per phase. See Combat.
- Optional PlayerHUD link: with block_playerhud in the course, students can transfer PlayerHUD coins into PuzzleCoin, a retry can cost a PlayerHUD item, and a victory can award one. Without it, everything above still works.
- Class ranking: an optional leaderboard, independent of the grade, that respects separate groups. It lists the top 5 and the student’s own row, and each student can choose in the Lobby settings to appear as an anonymous student to the others. Points add up everything played, counting only victories the server verified: in a Campaign each Campaign is worth up to 100 points for how far it got (times the question accuracy when errors count), the one under way included; in a Single Match each match won is worth up to 100.
📚 Questions
- Three sources per activity: import from Moodle’s Question Bank, write questions by hand, or generate them with AI. Multiple choice and True/False.
- Teacher review: AI-generated questions are shown as a preview first and saved as pending; none is ever drawn in a match before it is approved. Bulk approve and delete.
- By level and by phase: in a Campaign, each question can be meant for a level, a phase or both; AI generation saves the batch with the level, phase and type chosen.
- Hints: an optional hint per question, usable through the Hint consumable.
📊 Grading and teacher tools
- Gradebook: a real grade item, scaled by the configured Maximum Grade (points, or no grade), with a pass grade and an optional “consider errors” variant. See Game Modes.
- Custom completion: require a number of attempts and/or wins.
- Limits and pacing: attempts per Campaign, how many Campaigns or matches a student may play, and an optional cooldown between matches or between Campaigns. The Lobby says beforehand what the next Play takes (the attempt it is, the retry cost, when the cooldown ends), and a start the rules refuse is explained in a dialog instead of an error page. A Campaign under way can be given up from the Lobby.
- Teacher report: per-student progress, average opponent damage and accuracy, the most missed questions, the grade distribution (left out, with the grade column, for an activity with no grade), the completion rate and, for a Campaign, how each difficulty has gone (phases won on the first try, by difficulty and by phase of the level) and which heroes the students chose (a Single Match activity shows its matches won by difficulty), respecting separate groups. The student table is paged, 50 students at a time, so a class of thousands opens as fast as a small one.
- Backup and restore, with the question bank, and with the attempts, heroes, loadout stock and question logs when user data is included. Duplicating the activity copies its settings and question bank, without any student’s data.
🛡️ Integrity
- Blind JSON: the correct answer never reaches the browser before the server judges it.
- Server replay: the server re-plays the student’s logged moves from a seed it issued and works out the real outcome, instead of trusting what the client reports.
- Single-use tokens and atomic locks against replayed or parallel requests.
♿ 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
- Privacy provider: metadata, export and deletion for every table that holds personal data, plus the sound and narration preferences.
- Automated tests: PHPUnit, headless JavaScript unit tests and Behat, green across the CI matrix (Moodle 4.5 → 5.3). See Automated Tests.
⏳ Not in this release
- 🥊 Dispute Mode (V2): a head-to-head mode on a shared board. It depends on a real-time transport that is not available yet, so it is designed but not built.
- ⏱️ Time limit per match: removed from the form because nothing enforced it. If it comes back, it will be designed to be checked on the server.
- 💲 Shop prices that mirror a PlayerHUD trade: prices are fixed today (see Combat); following a trade configured in PlayerHUD is a possible future step.
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.
- The student makes a move on the board.
- Combos and cascades keep the student’s turn going.
- 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:
- Correct answer — a critical hit: triple base damage, multiplied by whatever Star bonus that side has stacked up.
- Wrong answer — no damage to either side, but that side’s Star multiplier resets to 1.
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:
- Moodle’s Question Bank (
core_question) — the teacher imports an existing category, and any single-answer Multiple Choice or True/False question in it is copied into the activity. A teacher who already maintains a question bank for Quiz can reuse it immediately, with no content migration. Importing again refreshes the copies. - Manual entry — questions written directly in the activity.
- AI generation — optional, always reviewed by the teacher before anything is saved, and saved as pending until approved. See Third-party Service Disclosure.
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:
- Import from the Question Bank — a button beside Add question opens the import panel; pick a category and import its approved, single-answer Multiple Choice and True/False questions. Importing again refreshes the copies; a question that left the category is disabled rather than deleted, because past attempts may still refer to it. Embedded images and files are copied along. The category list shows how many questions each one would import, leaving out the ones the import skips (other question types, several correct choices, none).
- Add a question by hand, with an optional hint.
- Generate with AI — see below.
- Approve, reactivate, edit or delete questions, one by one or in bulk.
- Set the level and the phase a question is meant for, one by one in the question’s form or for the selected questions at once — see below.
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.
- Playing again: a Campaign ends when its last phase is won or its attempts run out (it keeps the progress it reached). The student may then start another Campaign at Level 1, Phase 1, up to Maximum Campaigns (1 to 10, or unlimited, the default). A new Campaign starts with the student’s PuzzleCoin and consumables back to zero: the Lobby says so, and the hero choice, which comes before the Campaign starts, says it again and offers a way back to the Lobby. Once a Campaign has ended the Lobby no longer shows the balance or the shop, and the next Campaign’s hero choice comes marked with the hero of the one that ended.
- Attempts and the end of a Campaign: with limited attempts the Lobby says which attempt the student is on (“Attempt 2 of 3”) and warns before the last one, and so does the give-up dialog of the match. When the last attempt is lost the end screen says “Campaign over” instead of offering to play again, with why, the phases won, the grade earned (when the activity is graded and the grade is not hidden) and the position in the class ranking (when it is on).
- Giving up a Campaign: a Campaign under way can be given up from the Lobby, after a confirmation. It ends where it stands and is graded on the progress it reached, as when attempts run out, and the next one can start if the activity allows it. When it is the last Campaign the activity allows, the confirmation says the student will not be able to play again. The Lobby history lists it as “Gave up”.
- Cooldown between Campaigns: the teacher may set a cooldown (in minutes, hours or days) that the student waits after a Campaign ends, however it ended (won, out of attempts or given up), before starting the next one. It counts from the moment the Campaign ended, so a Campaign given up long after its last defeat still waits the whole cooldown. Retrying the same Campaign after a defeat is never held back, and with only one Campaign allowed it has no effect. While it runs, the Lobby tells the student the time the next Campaign opens, and Play is refused before the hero choice.
- Resuming: closing the browser mid-campaign and coming back resumes the exact level and phase the student was on. After a defeat, the next attempt resumes on that same level and phase rather than starting over.
-
Opponent scaling: the opponent’s maximum HP grows with the current level and phase, using a fixed linear formula computed once on the server:
Formula Opponent HP base × (1 + 0.5 × (level − 1) + 0.1 × (phase − 1))The opponent’s damage scales the same way; the coin reward does not (see Combat). The student does not grow by itself: they keep up by buying upgrades for their hero (see Heroes), and the student’s HP starts from the activity’s Base student hit points (HP).
- Advancing: after winning a phase, the server checks that the reported fight really cleared that phase’s opponent HP, rotates the token, and the student continues to the next phase. The same request cannot be replayed to skip several phases off one victory.
- Difficulty per phase: the student picks a difficulty in the Lobby for the first phase and again on each “Phase won” screen for the next one. Leaving that screen does not close the choice: until the next phase has a move, an answer or an item used in it, the Lobby still offers the difficulty button. With no phase under way, as after a defeat, the button starts on the difficulty of the student’s last match.
- The opponent grows with the Campaign: on Normal and Hard, the opponents hit harder the further into the Campaign the phase is, from their usual strength at the first phase to 60% more at the last on Normal and 100% more on Hard, so the Campaign keeps pace with a hero that keeps growing. Easy does not change.
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.
- Specialty: each hero is a specialist in HP (the mages), attack (the warriors) or armor (the archers), and starts a little ahead in it, a twentieth of what that attribute can reach.
- Upgrades: after each phase, and from the Lobby, the student spends PuzzleCoin on upgrades of HP, attack or armor (12 coins each). What they buy counts from the next phase.
- Stages and evolution: the hero has four looks. A stage caps how many upgrades of each attribute can be bought, a quarter of the Campaign’s total for each stage (the total grows with the number of levels). At 25%, 50% and 75% of the Campaign the hero evolves for free, as soon as its specialty is at the stage’s cap, which opens the next stage’s cap.
- The shop: the same panel, in the Lobby and on the screen between phases. A folded line names the next opponent (the opponent’s card) and opens to its picture and what sets it apart: extra HP, harder hits, armor, its powers, the final boss’s answer to the hero and, once the phase exists, the items it brings. Below it come the hero’s attributes, each with its value, how many upgrades it has and a buy button (an attribute at the stage’s cap says Full), a short list of what the next evolution still needs (the specialty full and the milestone phase won), and the consumables. During the fight, the ? button at the top of the stage opens the same card, with a table that puts your hero and the opponent side by side (HP, attack and armor), so the powers can be read again after the first meeting, when the game’s notice no longer shows.
- Leaving or giving up: the flag button at the top of the stage offers three choices, each explained: keep playing; leave and continue later, at no cost (the match is saved as it is, and Play in the Lobby continues the phase on the same difficulty); or give up, which ends the match as a defeat: one attempt is spent and the coins earned in that phase are lost. A Demo just ends. A phase left under way can also be abandoned from the Lobby, through the link under the locked difficulty, with the same cost as giving up inside the game.
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.
- Item representing coins — lets a student transfer units of this item into PuzzleCoin from the shop, choosing how many (1:1); the exchange is a row of its own under the PuzzleCoin balance, written as a sentence: the item with its PlayerHUD balance, then “Transfer [amount] to PuzzleCoin (1:1)”. Typically PlayerHUD’s own PlayerCoin, but any item works. This is the only way PlayerHUD coins reach PuzzleCoin: victories are no longer credited to PlayerHUD automatically.
- Retry cost — optional; an item (and quantity) charged from the student’s 2nd attempt of each Campaign (the first attempt of every Campaign is free; in a Single Match, from the 2nd match), never raising the configured attempt limit. The Lobby shows the cost and the student’s balance before Play, and a start refused for lack of the item opens a dialog that says what is missing. It is meant to be earned through reinforcement content outside the game, so that the student who struggles most is not the one least able to afford another try. A student who is only resuming a fight is never charged.
- Win grant — optional; a fixed item awarded on every victory, on top of the coins. When the
relevant attempt limit is unlimited the item is still granted but without its XP, to prevent XP
farming. In a Campaign it is awarded on every phase won, so with a limit set the PlayerHUD
economy panel (“Total XP in the game”) counts the activity as phases × Campaigns × the item’s
XP (a Single Match counts one award per match allowed), as
mod_playerwordsandmod_playercrossalready do.
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:
- A real
<table role="grid">lies over the 8×8 board, and its cells are the same ones the mouse and touch act on. It is navigable cell by cell with the arrow keys, and each cell is read with its piece name. The focus outline shows only for keyboard users. Enter selects the piece on the focused cell (announced, and marked witharia-selected), and Enter on a neighbouring cell swaps the two; Enter on the same piece drops the selection. The number keys below play a move without walking the grid. - The game area is a labelled region (the activity’s name), not an application region, so a screen reader keeps its normal browse mode around the board and the buttons.
- The buttons (leave or give up, how to play, opponent info, music, sound effects, full screen, use item) are real
<button>elements with accessible names; music, sound effects and full screen also say whether they are on or off (aria-pressed). The history log and the tutorial balloon are not read aloud, so the live region below stays the one channel. - At the start of the student’s turn, the available moves are announced through an
aria-live="polite"region, which also carries the other turn-by-turn events — damage dealt and taken, energy bar full, a question answered, the opponent reviving, a phase advanced, and a Hex or Shield starting and ending on either fighter (the aura and label the sighted player sees). - Number keys
1–9execute the correspondingly-announced move, andSpacere-reads the list of available moves. - The question challenge is a native HTML
<dialog>: focus is trapped and centred by the browser, and restored to whatever triggered it when it closes. When it opens, the focus goes to the question, so the screen reader starts from what is being asked and the answers come next, by Tab. The picked answer is exposed as pressed (aria-pressed). Pressing Attack keeps the focus where it is until the answer is judged, and then a separate Continue button, new to the page, takes it: the keyboard is never thrown out to the page, and the screen reader meets Continue as a new control instead of an old one that changed. Once judged, the answers stay disabled, which a screen reader reads only as “unavailable”, so a hidden suffix names the student’s answer (“your answer, correct” or “your answer, wrong”) and, when it was wrong, the right one (“correct answer”). Everything outside an open modal dialog is inert and so is not heard, so while a dialog is open the announcements go to a live region inside it. - The Lobby, shop, ranking and report are ordinary Moodle pages and forms, so they follow the theme’s own accessibility behaviour.
Emoji and sound
- Emoji in the game’s texts are kept out of the accessibility tree (each one is wrapped in an
aria-hiddenspan) and removed from what is announced or spoken, so a button reads “Attack!” and not “crossed swords Attack!”. - The music is off until the student turns it on, and the sound effects are on: a browser cannot tell whether a screen reader is running, and a looping song under its voice is the worse default. A student who already chose keeps the choice. Both have buttons in the game (with their state) and switches in the Lobby.
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 value credited is always the one the server derived — an inflated claim is ignored (and
recorded as a
replay_divergedevent, so a systematic mismatch is visible). - A victory the server cannot confirm restarts the phase, and the attempt still counts. If no
restart is left, it counts as a defeat. A fight the replay cannot follow (
replay_inconclusive) credits only what the log can still verify. - Each phase records the version of the combat rules it started under (the engine version, kept apart from the plugin’s version), and is only replayed under the same rules. When an update changes the rules, a phase under way starts again on the new ones the next time the student resumes it: the Campaign’s progress, the attempts, the hero and the stock are kept, and the restart costs no attempt. An update that does not touch the rules (a text, the layout, a report) leaves every fight where it was. An automated test fails when the rule files change and the engine version does not.
- Whether each question was answered correctly always comes from the server’s own judgement, never from the client’s log.
- Coins are tracked in a server-side ledger, with a plausibility ceiling tied to the damage dealt.
- Advancing a phase additionally requires the reported damage to clear that phase’s opponent HP.
- Visitors (the guest account, or a logged-in user who is in the course only through guest access) can play the Demo only: nothing they do is graded or banked.
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:
- Turn correctly answering a content question into an immediate, visually rewarding combat event (a critical hit), rather than just a checkbox toward a grade
- Reuse a course’s existing Question Bank, so content-fixation activities a teacher already maintains for Quiz can be repurposed without any migration
- Keep the rigor of assessment intact underneath the game — attempts are limited, answers are validated server-side, and the grade is designed to reflect genuine progress/performance (see Game Modes), never client-reported numbers
- Reward sustained engagement with PuzzleCoin and the loadout shop, scoped to the activity, and optionally connect it to the course’s economy through the PlayerHUD integration
- Keep the teacher in control of the content: questions written by AI are only a draft until the teacher approves them
Suitable for:
- Any course already using
block_playerhudfor gamified progression - Teachers who already maintain a Question Bank category for the same content and want a second, game-based way to reinforce it
- Institutions exploring gamified content-fixation as a complement to (not a replacement for) formal quizzes
🕹️ 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.
-
PlayerGames: Central hub of the ecosystem — site-wide XP, seasons, daily mini-games, and the Ecosystem Dashboard that ties every installed Player plugin together. 👉 github.com/jeanlucio/moodle-local_playergames
-
PlayerHUD Block: XP, levels, inventory, drops, quests, RPG classes and ranking inside each course. PlayerPuzzle reads/writes to it for its entire optional economy — see PlayerHUD Integration. 👉 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
-
PlayerWords: A sibling activity module (word-guessing) that established the
grademethod/attempt-counting pattern PlayerPuzzle’s Single Match mode reuses. 👉 github.com/jeanlucio/moodle-mod_playerwords -
PlayerCross: A sibling activity module (crossword) sharing the same architectural patterns (
local\*_page_serviceentry-point classes, PlayerHUD integration conventions). 👉 github.com/jeanlucio/moodle-mod_playercross -
PlayerLand: Another game activity module of the ecosystem. 👉 github.com/jeanlucio/moodle-mod_playerland
-
PlayerGroup: Lets students autonomously form their own groups directly from the activity page — no teacher intervention needed. 👉 github.com/jeanlucio/moodle-mod_playergroup
-
AI Hub: Shared BYOK (bring your own key) broker for AI features across the ecosystem. PlayerPuzzle’s question generator uses it as a soft dependency when it is installed and has a key, falling back to Moodle’s own
core_ai— see Third-party Service Disclosure. 👉 github.com/jeanlucio/moodle-local_aihub
📦 Requirements
| Component | Version |
|---|---|
| Moodle | 4.5 – 5.3 |
| PHP | 8.1+ |
block_playerhud is an optional dependency — see PlayerHUD Integration.
🛠️ Installation & Configuration
- Download the
.zipfile or clone this repository. - Extract the folder into your Moodle
mod/directory. - Rename the folder to
playerpuzzle(if necessary). Final path:your-moodle/mod/playerpuzzle/ - Visit Site administration → Notifications to complete installation.
- Optional: install block_playerhud if you want the optional coin/upgrade economy — see PlayerHUD Integration.
- 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
- Add a PlayerPuzzle activity to a course.
- 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.
- 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.
- 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.
- 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. - Optionally connect PlayerHUD items — coin transfer, retry cost, victory award —
if
block_playerhudis installed in the course. - 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- What is sent: a prompt made of the topic the teacher typed, the number of questions requested (at most 10), the question type chosen, the name of the interface language, and fixed formatting instructions. No student data and no course content is included.
- Where it goes: through the companion
local_aihub plugin when it is installed and
has a key configured (bring your own key), otherwise through Moodle’s own
core_aisubsystem, where the course or activity “Enable AI tools” setting is honoured. The provider is therefore whichever one the administrator configured in the hub or incore_ai, and that provider’s own terms and cost apply. - What happens to the answer: it is treated as untrusted input. Every question is validated
and shaped, a malformed entry is dropped, and what is kept is saved as pending
(
approved = 0). A pending question is never drawn in a match until the teacher approves it. - Without an AI source: the generator is not offered, and manual entry and Question Bank import keep working.
📄 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
- Images: the heroes, opponents, stages and board pieces were generated with Google Gemini; the stone panel and the parchment banner were generated with ChatGPT. All were created for this plugin from original prompts. The art direction, the prompts and the review of every image are the author’s, who is responsible for the content.
- Sounds and music: public domain (CC0). Music: “King’s Feast” by RandomMind, loop version. Effects: “Book place” from RPG sounds and the confirmation sound from Interface Sounds, both by Kenney; the hit is a mix of two “RPG sounds” files (chop and metal click). Files are converted to MP3 and level-adjusted. See
pix/readme_moodle.txt.