Translations of this page:

User Tools

Site Tools


en:moodle:tests:embed-questions:start

Embedding questions

Follow these instructions to use questions in a running text.

Assign ID number for question category and question

Before you can imbed a question in Moodle, make sure that the question exists in a question collection of the course and has an 'idnumber'. The question must also be in a category with an 'idnumber'. As of Moodle 3.6, an 'idnumber' field has been added to the question and category forms.

To add an ID number to a question and a question category in the question collection in Moodle, follow the steps below:

  1. Open your Moodle course and navigate to the “Question bank”.
  2. Select the desired question and click “Edit” or select the “Categories” section in the drop-down menu above on the left side and click on the cogwheel to “Edit this category” for the desired category.
  3. In the category editing form, you will find the “ID number” field. Enter the desired ID number for the category and save the changes.
  4. Now select the question to which you would like to add an ID number and click on “Edit”.
  5. In the question editing form you will also find the field “ID number” or “idnumber”. Enter the desired ID number for the question and save the changes.

Note: Numbers and letters can be used for the ID number. By adding ID numbers to questions and categories, you can target them later or embed them in other parts of the Moodle course by referring to the respective ID number. Make sure that the ID numbers are unique to avoid conflicts.

Embed question

Follow the steps below to successfully embed a question:

  1. Open the Moodle text editor in a place where you can enter text and media, e.g. on a course page, a text page, a text and media box, in a book activity or when writing a forum post.
  2. Click on the “Show more buttons” and then “Embed question” button in the editor toolbar.
  3. Select the desired question category, for example “Embedded questions”.
  4. Select the question you want to embed, e.g. “Test question 1”. Make sure that the question has an 'idnumber' and is in the correct category.
  5. You can leave the other options as default or adjust them as required. Note that only question behaviors where the user can interact with the question without having to submit the entire quiz attempt can be selected.
  6. Click on the “Embed question” button. The editor inserts a cryptic code.
  7. Save the page to display the embedded question. The cryptic code will be replaced by the question and displayed in the center of the page. Note that the cryptic code ends with a 40-character hexadecimal string. This is for security purposes and prevents unauthorized users from guessing the embed code for an unapproved question.

If you want to embed a random question from a category, follow the same steps as above, with the exception of step 3. Instead of a specific question, select the option “Select a random embeddable question from this category”. This option will be displayed if there are at least 2 questions in the category. When a user encounters an embedded question, this question will be displayed directly on the page. Technically, the question is embedded in an invisible iframe that is automatically adjusted to the size of the question. The background of the iframe adapts to the page on which the question is embedded. The question behaves in exactly the same way as in a quiz attempt, provided that the quiz is set up with the same options as when the question was embedded. After the question has been answered, the user can start it again if desired. For questions with variants, a different variant is selected when the quiz is restarted.

en/moodle/tests/embed-questions/start.txt · Last modified: 2024/03/05 13:59 by maziyar