Embedded Answers (Cloze) with Regexp question type
| Embedded Answers (Cloze) with Regexp question type | |
|---|---|
| Type | question type |
| Set | N/A |
| Downloads | https://github.com/rezeau/moodle-qtype_multianswerrgx |
| Issues | https://github.com/rezeau/moodle-qtype_multianswerrgx/issues |
| Discussion | https://moodle.org/mod/forum/discuss.php?d=464651 |
| Maintainer(s) | Joseph Rézeau |
| Important notice |
|---|
|
First read the documentation at Inserting RegExp sub-questions in Cloze type questions |
Instructions for use
Inserting regexp sub-questions in the question text
The insertion of regexp sub-questions inside the question text of a cloze/multianswer follows the same pattern as the insertion of SHORTANSWER sub-questions. See the documentation here. For REGEXP sub-questions you have a choice of 4 formats:
- regexp (REGEXP or RX), case is unimportant,
- regexp (REGEXP_C or RXC), case must match.
Here are some examples of use.
Question text
The colours of the French flag are: {1:REGEXP:%100%blue, white and red#Congratulations!~--.*(blue|red|white).*#You have not even found one of the colours of the French flag!~--.*(&&blue&&red&&white).*#You have not found all the colours of the French flag~--.*blue.*#The colour of the sky is missing!}.
What about the German flag? {1:REGEXP_C:%100%It's black, red and gold#Very good!~%80%it's black, red and gold#OK, but you should start your answer with a capital letter}.
Result

It is highly advisable to have installed also the Cloze question editor additional plugin.
Most of the features of the REGEXP question type are available when inserting a REGEXP inside a Clozergx question. However, the Hints (Letter/Word) feature is not available, nor the automatic feedback formatting. The permutation feature is available, and the "developed" syntax will be displayed when clicking the Decode and verify the question text button, and then clicking the Question {#n} Regular expression short answer button. The full list of accepted alternative correct answers will also be displayed. If you want to display the full list of accepted alternative correct answers, you may simply retrieve them from the Show/Hide alternate answers button, and add them as feedback in the Cloze question. In the example above, replace the semi-colons with line breaks (or list bullets) for a better display.
Result

Answers Validation
When you validate your Question, the question engine checks the validity of your expression, according to the features explained above. If an error is found, an ERROR message is displayed above the erroneous Answer(s) and you cannot save the Question until that error has been corrected. The validation system works in the same way as in the Regexp question type.

The Add cloze gaps feature
Besides allowing the user to add REGEXP sub-questions to the question text of a multianswerrgx question this feature makes it easy to create a classical Cloze question. This new feature needs to be enabled in the Admin settings when installing (or editing) the multianswerrgx question type plugin.
Currently it's limited to creating cloze gaps every 5 or 9 words. There is an option to skip capitalised words (on their first appearance in the text). Once the desired gaps have been created with the default SA/SHORTANSWER question type they can be edited and their question type can be changed if desired. There is also an option to remove all the gaps, including gaps that have been created (or edited) with a sub-question type other than SHORTANSWER.

And here is the result in Question Preview:

Cloze editor plugin for the new TinyMCE editor for Moodle 4.1 and newer
- You can download a Moodle plugin from the Moodle plugins database that will let you create these questions from a graphical interface within your Moodle site. The author, Stephan Robotta has kindly agreed to add the REGEXP question type to the list of question types available.😍
How to use the Cloze editor to create a REGEXP sub-question
The Cloze editor has an extensive description of use on the author's Github. The following will therefore only deal with the special case of inserting REGEXP sub-questions with this tool.
1.- Type your REGEXP question text as plain text, including the first correct answer. Then select that correct answer. (1) Then click on the Cloze question editor button in the TinyMCE editor toolbar. (2)

2.- After clicking on the Cloze question editor button you can see a pop-up window where you can select the REGEXP question type.

3.- Clicking on the Select question type displays another pop-up window.

3.- On that window you can see the question type which you selected (REGEXP). The Answer 1 field has been automatically filled in with the correct answer word(s) that you have selected in the question text (blue, white and red) (1) and the Grade field has been set to Correct (2). All you need to do here is to add the Feedback for that correct answer (Congratulations!) (3).
Now you need to add more correct/incorrect answers. Click on the Add another answer blank (4).
4.- When you click on that Add another answer blank button, you get a copy of the previous Answer. So you need to remove & edit the Anwer, Feedback and Grade fields accordingly. Here is what your Cloze question editor should look like after you have added all the needed blanks for a new French flag REGEXP sub-question.
