Moodle: Activities & Resources: Quiz Question Types: Regular Expression Short Answer

Regular Expression Short Answer is an enhanced short answer question type that analyzes the student's response more thoroughly by using regular expression (RegExp) syntax. It is best used with questions that require natural language answers and not mathematical or scientific answers.

Possible answers must be written using RegExp syntax. Question settings allow entry of several possible answers, and the first answer entered must be the best possible answer.

Learning RegExp syntax can take some time, so be sure to use the following reference pages before attempting to create this question type. For more information on using RegExp syntax and further settings, see the following resources:


Here is an example of a regular expression short answer response in sentence form with a symbol, still marked correct because of how the RegExp was written in the question settings.

Correct Regular expression short answer example


Here is an example of where all possible answers were entered in an attempt to fish for points but earned zero based on the RegExp constructed.

Example of regex short answer marked incorrect


The following explains how to enter these questions in the question bank.

To Add a Regular Expression Short Answer Question to the Question Bank:

  1. Open Moodle and select your course.
  2. In the Quiz Administration menu, click Question Bank then click Questions.
    admin menu with question bank selected

  3. Click Create a new question.
    question bank with "create new question" selected
  4. Select Regular expression short answer from the sidebar at the left, then click Add at the bottom.
  5. General Settings include a Question Name, Question text, Default points, and Answer 1. Optional settings include General feedback, Help button mode, Case sensitivity, and Show alternate.

    NOTE: It is suggested that the instructor make sure that the category is correct for organizational reasons and that the question name is something specific (other than Number 1) so that it is easier to find and edit later.
  6. Answer 1 must be a correct answer that does not use RegExp syntax. It will also be the first or only correct answer shown depending on whether Show alternate is set to Yes (not recommended when generating a large number of answers using RegExp). Custom feedback can also be added.
    Answer 1 must be correct and not use regular expression.

  7. In the subsequent Answers, use RegExp syntax to provide more correct and incorrect responses. Custom feedback can also be added for each answer.Answers 2-4 that use RegExp to generate more correct and incorrect answers.
  8. After clicking Save changes and continue editing, you will be able to see errors if you have any in your RegExp. You can also click Show/Hide alternate answers and the (Re-)Calculate alternate answers button to preview all possible generated correct answers.
    Preview of generated correct responses.
  9. Finally, if your quiz setting for How questions behave is set to Adaptive mode (with or without penalties) above the answer blanks, the Help button mode can be set to None, Letter, Word, or Word or punctuation. If a penalty is to be set with the use of the help button, options for Settings for multiple tries and Buying letters or words appear below the answer blanks. If How questions behave is set to Interactive with multiple tries, then Hints provided under this setting will be presented to the test taker.
  10. When you are finished creating the question, answers, and reviewing the additional settings, Save your changes.
  11. To add your newly created question to a Quiz, see the GROK article Adding Quiz Questions to a Quiz.


Support & Training

The Faculty Technology Center (FTC) provides Moodle support by email, by phone, or live through Zoom. For contact information, please see the article Faculty Technology Center: LSU Overview. To connect through Zoom and for further information on support services and training, see the LSU Online & Continuing Education Faculty Resources & Support page.

The FTC also provides just-in-time faculty training opportunities and recorded training sessions. Attending at least one training session for Moodle upgrades is highly recommended. For a comprehensive list of available workshops and recordings, please see the LSU Online & Continuing Education Technology Training page.

7/26/2023 12:06:35 PM