Gapfill question type

Revision as of 22:42, 10 September 2014 by Marcus Green (talk | contribs) (Tables with category columns)

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.2. Up-to-date documentation for the latest stable version of Moodle is probably available here: Gapfill question type.

The Gapfill Question Type

All you need to learn to get started with this question type is the contents of one 7 word sentence as follows

Put square braces around the missing words

For the programmers and mathematicians, don't worry that it says square braces, you can use other delimiters on a per question basis. The classic example of a question is a question where the text reads.

The [cat] sat on the [mat]

Which will create a question with two gaps where the answers are cat and mat. Although it was designed with the idea of single missing words it will accept a sequence of words with spaces between them in the gaps. This type of question can be particularly useful for teaching languages. The question type ships with a file called sample_questions.xml which illustrates the various ways it can be used. You can get the text of these files from this link and you can find instructions on how to import questions from this type of file here

Gapfill Edit

By default the student will see the questions in dragdrop mode where they can use the mouse to drag the answers from a displayed list into the matching field. When a student is answering one of these questions javascript only updates the text contents of the field, so even in this mode it is possible to type the answers into the field. As of version 1.4 it was updated to work with touch devices such as tablets and mobile phones and this post in the forum shows how it works with a wide range of devices.

At Runtine

Gapfill runtime

Changing the display answer options allows the question to be presented with either no prompts or dropdown lists. Here is where you can make that change Display answer config

This is how the same question will appear with dropdown lists.

Gapfill with dropdowns

There is a drop down list of alternative delimiting characters ## {} and @@ which will allow a question in the form The {cat} sat on the {mat}. It is possible to select dropdown or gapfill mode. Dropdown shows a list of all possible answers in each field and gapfill shows only an empty field with no list of options to select.

By default marking is not case sensitive. So if the student enters CAT in a field of the form [cat] it will be considered correct. The editing form has an option to make the marking process case sensitive.

Each (correct) field is worth exactly 1 mark, so The [cat] sat on the [mat] has a maximum possible score of 2 marks. There is no concept of negative marking. The question supports the standard behaviours, hinting and combined feedback options.

Gapfill complete

The editing form offers a field for adding wrong or distractor options. These only make sense in dragdrop or dropdown mode. Wrong answers must be entered as a comma delimited list and a shuffled list of correct and incorrect answers will be displayed with the question. If you need commas to appear in your distractors they can be escaped with a backslash \,

Regular Expressions

It is possible to use regular expressions in answers, for example if you wanted both the US and UK spelling of colour as an answer you could add a field with the broken bar operator to act as an OR as in "What [color|colour] is the sky?". You can search for any string that starts with c and ends with r as "What [c.*r] is the sky". More complex regular expressions should also work.

You could use regular expressions to mitigate common spelling errors, e.g. {cal[e|a]ndar} (note the selection of alternative delimiters to get around the use of the square brackets in the operator. This question type makes no attempt to check the validity of your regular expressions. You can read more about using regular expressions in the documentation for the PReg type see and also

Show Correct Responses

In interactive mode (set in the question behaviour of the quiz) it is possible to have a question indicate the number of questions that are correct and for this to be displayed for each field. This takes the form of red/green background colour and a tick or cross. To make this happen check the "show number of correct responses option" in the hint field under the multiple tries option.

hints r

No Duplicates Mode

This allows a question in the form Name three examples of X. So you could ask "Name the colours of medals awarded in the Olympic Games". The syntax of the question fields would be [gold|silver|bronze] three times. Note the separator is the broken bar character which acts as an OR operator. Make sure you select gapfill mode for this type of question, otherwise you will have confusing draggable prompts appearing.

By checking the No duplicates box in the question editing form, when it comes to marking any duplicates will be discarded. Correct answers will still be displayed with a green check/tick (as they are actually correct), but marks will only be awarded for the first occurrence of the selection. As of version 1.1, when this happens the background of the duplicated values will be displayed in yellow and a message added to the feedback will say "Credit is partial because you have duplicate answers".

Duplicate answers

Tables with category columns

By combining No duplicates mode with the | (or) operator it is possible to create tables with category columns. So in the following screen shot there are two distinct gaps containing [lion|tiger] [dog|wolf] but these are duplicated to allow for all four answers. These are then placed in a table to allow the student to drag into the appropriate category columns. Gapfill Categories
This screen shot shows how the question text appears in the editor. Note that the shading for the heading row is done by including <th> tags for the first row instead of <td> tags and by setting the class table tag as <table class=gapfilltable>, The gapfilltable class is supplied in the css for the question type. If you are using the HTML editor, switch to HTML mode and paste in the following code as an example.

<table class="gapfilltable" border="2" rules="rows">

Disable Regex

The Gapfill question uses regular expressions by default to compare the answer given by a user with the correct answer stored in the database. There are times where it is more convenient to turn this off and use plain string comparisons. This is true where the answer text contains characters that have a special meaning in regular expressions such as < > * . / \. This can be done by checking the Disable Regex option in the More options section as in the screen shot. Disable Regex

Alternative Gapfill Questions

This question was designed to be simpler to use than the core Cloze question type. however the Gapfill type has fewer features than the Cloze type.

The OU (UK Open University) has two Moodle Question Types that covers similar ground. and