How to Embed a Simulation in Moodle
Updated 2026-10-02
To embed a simulation in Moodle, you paste one short piece of code into the editor's HTML view, and students can run the experiment without leaving your course. This guide shows you how to do it with Simulic, in a Page or in a Text and media area on the course page. It also covers the part that trips most teachers up: what to ask your Moodle administrator when the simulation disappears after you save. Finally, you will see how to place a simulation in a quiz question and how to set the frame height.
What you need
- A free Simulic teacher account. Students never need one.
- Editing rights in the Moodle course.
- A simulation. This guide uses Ohm's law, where students change the voltage and resistance and watch the current.
- Possibly a quick message to your administrator, if your site does not allow iframes in the editor. There is a ready-made message below.
Step 1: Copy the embed code from Simulic
- Open the simulation page and click Share.
- On the Simulation tab, set the starting values. For Ohm's law, the default is a voltage of 4.5 V and a resistance of 500 Ω; keep it or choose your own. These settings are pinned to the new link.
- Go to the Share Links tab. Under New link, name the link after the course or group, for example "Physics 10 · Group A", choose the Language, and click Create link.
- In the link card, open Embed code and click Copy embed code.
Make one link per group. Each link keeps its own play count and answers, and Duplicate copies a link with the same settings and question set but none of the answers.
Step 2: Paste the code into Moodle
You have two places to put the simulation. Use a Page when the simulation needs its own screen with instructions, like a virtual lab. Use a Text and media area when you want it right on the course page between other activities.
In a Page
- Turn editing on in your course and add a Page to the section you want.
- Give the page a name and write your instructions in the page content.
- Put the cursor where the simulation should go and switch the editor to its HTML (source code) view.
- Paste the embed code.
- Switch back to the normal view if you like, then save.
In a Text and media area
- Turn editing on and add a Text and media area to the section.
- Switch the editor to its HTML (source code) view.
- Paste the embed code and save.
How you reach the HTML view depends on your Moodle version and which editor your site uses: it is usually a button with a code icon or an option in the editor's menu. Menu names can differ slightly between versions. The in-app embed help page keeps a short version of these steps for Moodle and eight other platforms.
Pasting the code into the normal view does not work: Moodle shows the code as text instead of running it. Always use the HTML view.
Try what your students will see
This is the Ohm's law simulation embedded the same way it will appear in your course. With the default 4.5 V and 500 Ω, the current is I = U/R = 4.5 / 500 = 0.009 A, or 9 mA. Double the voltage to 9 V and the current doubles to 18 mA. Put the voltage back to 4.5 V and raise the resistance to 1000 Ω, and the current halves to 4.5 mA.
If the simulation does not appear: ask your administrator
Moodle cleans the HTML that users save, to keep sites safe. On many sites that cleaning removes iframes, so you save the page and get an empty space, or the <iframe> line has vanished when you reopen the HTML view. Teachers cannot change this; an administrator has to allow iframes in the editor.
What exactly they change depends on the site. In Moodle it is usually tied to how the site cleans HTML and whether "trusted content" is enabled for teachers. Your administrator will know which applies. You can send them something like this:
Hello, I'd like to embed interactive simulations from simulic.com in my course (Page and Text and media area). When I paste the iframe code in the editor's HTML view and save, the iframe is removed. Could you allow iframes from https://simulic.com for teachers? The embed needs no student login and sets no cookies. Thank you!
If the answer is no, or you need it today, post the play link instead: click Copy link on the Share page and add it to the course as a link. It opens the simulation full screen in a new tab, and any questions you attached come with it.
Put a simulation in a Moodle quiz question
Moodle question text uses the same editor, so you can paste the embed code into a question's text in HTML view, exactly as above, and the same iframe permission applies. Students then answer the Moodle question while the simulation runs above it, and Moodle grades it as usual.
For example, a numerical question could read: "Set the voltage to 6.0 V and the resistance to 300 Ω. What current does the circuit carry, in mA?" Answer: 20 mA.
You can also skip the Moodle quiz and attach questions to the Simulic link itself. On the Questions tab of the Share page, build a set with up to 5 questions (short text, multiple choice or number, checked with a tolerance such as 20 mA ± 0.5) and up to 3 prediction questions that keep the simulation locked until students commit. Students type a nickname and answer inside the embed; you see results on the link card and can download a CSV. These answers do not go to the Moodle gradebook. The free plan collects 100 student answers a month, and Pro removes the limit (pricing).
Which approach fits which lesson is covered in how to add simulations to quiz questions. For quick checks that shape your next lesson, see using simulations for formative assessment.
Set the frame height
The embed code starts at 640 px tall and ends with a small script that makes the frame grow with its content. Moodle often removes scripts even when it keeps the iframe, so plan for the fixed height:
- Simulation only: keep 640.
- With a few questions on the link: change
height="640"to about 850. - With 5 questions and predictions: try 1000 or more.
Change the number in the code before you paste it, or later in the HTML view. Inside a quiz question, a frame of 640 px usually leaves enough room for the question below it.
Troubleshooting
The iframe disappears when I save
The site's HTML cleaning removed it. Send your administrator the message above. In the meantime, use the play link.
The page shows the code as text
You pasted into the normal editor view. Delete the text, switch to the HTML (source code) view and paste again.
The frame says the link is not available
The link is turned off. Click Turn on link on the Share page. If it says the link has expired, a last day was set in the Pro Options; change or clear it.
Students have to scroll inside the frame
The resize script was removed and the frame is 640 px tall. Raise the height in the HTML view.
For other platforms, read the guide to embedding a simulation in your LMS.
FAQ
Do students need a Simulic account to use the simulation in Moodle?
No. They log in to Moodle as usual and the simulation runs. The embed sets no cookies and needs no second login.
Why does Moodle remove my iframe?
Moodle cleans saved HTML, and on many sites that removes iframes. Only an administrator can allow them.
Should I use a Page or a Text and media area?
Use a Page for a lab with instructions on its own screen. Use a Text and media area to show the simulation directly on the course page.
Can I embed a simulation in a Moodle quiz question?
Yes, if your site allows iframes: paste the embed code into the question text in HTML view. Moodle grades the question as usual.
What can I do if my admin will not allow iframes?
Add the play link to your course instead. It opens the simulation full screen, with any questions you attached.