Adding the game as a Page resource
-
Turn on Edit mode in your course
Open the course and switch on the Edit mode toggle at the top right. You need a role that can add activities, which the standard Teacher role can.
-
Add a Page resource
In the section where the game should go, click Add content and choose Activity or resource (on Moodle 4.4 and earlier, click Add an activity or resource). Pick Page from the activity chooser and give it a name such as "Logic warm-up: Minesweeper".
-
Open the source code view of Page content
Scroll to Page content. In the TinyMCE editor, open the Tools menu (or the View menu) and choose Source code. On older sites still running the Atto editor, click Show more buttons first, then the HTML button. Paste the snippet into the code window and click Save in that window.
-
Save and display
Back in the visual editor the board shows as a placeholder or live frame. Scroll down and click Save and display. Moodle opens the finished page, and you should be able to play a round straight away.
-
If the board is missing, use a URL resource instead
If the saved page shows no game at all, your site cleans HTML everywhere. Delete the Page, add a URL resource instead, put the game address in External URL, and under Appearance set Display to Embed. Moodle then builds the frame itself, so there is no HTML for it to remove.
Why the iframe survives in a Page and not in a forum
Moodle protects every course from harmful code by cleaning the HTML that users save. The cleaner, HTML Purifier, removes iframes outright. What matters is which text Moodle cleans:
- Not cleaned: Page content, Text and media areas, and the descriptions of activities and resources. Moodle leaves these alone on purpose so that teachers can add media, scripts and inline frames. Your iframe stays exactly as pasted.
- Cleaned: anything students can write in — forum posts, assignment submissions, wiki pages, glossary and database entries, blogs. The editor shows the iframe while you type, then it disappears on save.
- Cleaned unless trusted: activities that support trusted text, such as
forum posts and glossary entries. If an administrator enables Enable trusted content (Site
administration > Security > Site security settings), text from roles with the
moodle/site:trustcontentcapability — Teacher and Manager by default — is marked trusted and skips cleaning.
Two administrator settings change the picture. Content cleaning everywhere (Site administration > Development > Experimental settings) cleans Pages and descriptions too, and then the iframe disappears from every editor field; the URL resource is the way round it. Allow EMBED and OBJECT tags, on the Site security settings page, is often suggested as a fix but only covers those two older tags and has no effect on iframes.
Not an admin? You rarely need one: a Page works on a default Moodle site. If it does not, ask your Moodle administrator whether Content cleaning everywhere is on, or use the URL resource route below.
The URL resource route
A URL resource needs no HTML at all, so nothing can strip it. With Edit mode on:
- Click Add content > Activity or resource and choose URL.
- Enter a name and paste
https://play-minesweeper.games/embed/?size=beginner&noguess=1into External URL, including thehttps://. - Under Appearance, set Display to Embed.
- Add the credit line to the description: "Minesweeper by play-minesweeper.games", linked to the site.
- Click Save and display.
Moodle draws the frame and sizes it to fill the page, so the board shows with space around it. If Embed is not in the Display list, the administrator has limited the Available display options for URL resources; Open loads the game in the same window instead, and In pop-up opens a separate window.
Troubleshooting
- The page shows nothing where the game should be. Open Edit settings and look at Page content in Source code. If the iframe is gone, the site cleans content everywhere; switch to the URL resource. If it is there, the frame is being blocked.
- The frame is there but empty or shows a block message. The school web filter blocks the domain. Open the game address in a normal tab on the school network to confirm, and see our notes on playing Minesweeper at school.
- The bottom row is cut off. The height was changed or the snippet was
trimmed. Restore
height="472"in Source code; the board needs the full height for its header and status line. - The game shows as code text. It was pasted into the visual editor, not the Source code window. Delete it and paste again through Tools > Source code.
- The game vanished after a course restore on another site. Backups keep Page content, but a site with Content cleaning everywhere switched on cleans it when the page is displayed. Re-add the game as a URL resource there.
Using it in class
The Minesweeper lesson for teachers is a 15-minute logic activity designed around this board. In Moodle, put the board on a Page with the rules students should discover underneath, and follow it with a forum where they explain one deduction in their own words. For paper practice or homework, link the printable Minesweeper worksheets; every sheet comes with an answer key.