Advanced Fill in the Blanks 'papi Jo' (doc)


The Advanced Fill in the Blanks 'papi Jo' H5P activity is based on the semi-official H5P Advanced Fill in the Blanks activity by Sebastian Rettig. The bug fixes and improvements listed below have been submitted to Sebastian who generally approve them. My initial aim was to incite Sebastian to include my suggestions into his distribution. However, due to lack of time, that is not possible for the time being, so I have created my own fork in the meantime.

Bug fixes

  1. Make Highlight Positions "stick" when editing a content. Simply added double quotes to values in Semantics e.g. "value": "-1", "label": "- 1 (right before the blank)".
  2. Show confirmation dialog on "Check". This option is not compatible with the "Automatically check answers after input" option. Solution: use the ShowWhen papi Jo library to not display this option.


  1. In Semantics, added display overall feedback and incorrect answers "expanded": false to avoid cluttered editing screen especially when there are lots of incorrect answers provided.
  2. Added a Feedback for correct answer field.This (optional) feedback can be used to confirm that the user found the correct answer in order to re-enforce his choice.
  3. Added a regular expression option for wrong answers with 2 main features: detect wrong answers or parts of answers and detect missing words. That is the main improvement.
  4. Added an option for Show Solutions to display either only the first correct answer OR all of the alternatives (as in the original H5P Blanks activity).
  5. Allow the use of the forward slash in correct answers, e.g. 10/20, by escaping the slash like this 10\/20.
  6. For correct and showing solution input fields, fit the field size to the answer being contained (needs a monospace font for correct display, see point 9 below).
  7. Various adjustments to the ticks and crosses and tip icons for a more aesthetic display (subjective, of course).
  8. Hide tip icon if blank was answered correctly OR blank showing solution
  9. Placed a link to Google Font 'Roboto Mono' in the CSS file. This is needed to display a better fit for text inside input fields. The 'Roboto Mono' font looks much better than the default Courier or monospace fonts available.
  10. Added an automatic grow text field feature for the input field (on Sebastian's TODO list). It's working OK except when using Del or Backspace to delete already entered characters, so will need to be refined.


Since the Advanced Fill in the Blanks 'papi Jo' H5P activity is based on the H5P Advanced Fill in the Blanks activity, please refer to the original tutorial linked above. In this tutorial I will only add all the necessary information related to the differences between the 2 versions.

Step 1: Topic

Step 2: Creating Advanced Fill in the Blanks

Step 3: Advanced Fill in the Blanks editor

Step 4: Task Description

Which compound adjective would you use to describe the following:

Step 4b: Behaviour settings

Our tutorial is based on the use of the regular expressions (new) feature, so before proceeding you need to select the following options in the Behaviour settings:

Answer mode: The user types in the answers
Use Regular Expressions: Check this box

Step 5: Text with Blanks

Under Text with Blanks we will type the exercise like this:

a little girl who was born !!5 (five)!! !!years!! ago? a ____ girl

Now we should define all the possible correct alternatives as well as the potential incorrect ones. This is done in the "Blanks used in the text" section.

1.- For the first blank, we'll add the below as a correct answer: 

  • Correct answer: five-year-old/5-year-old
  • Hint: you may leave this empty or add a hint
  • Feedback for correct answer: Correct, a little girl that is 5 years old is a 5-year-old girl.
    This feedback should confirm that the user found the correct answer in order to re-enforce his choice. New feature in the 'papi Jo' version.

2.- And below add a set of incorrect answers and feedback if one of them is chosen:

Note.- When using the Regular Expressions option in the detection of potential incorrect answers, you have a choice of detecting a) the presence of incorrect elements or b) the absence of needed correct elements in the student's answer. In the incorrect answer text, absent needed elements are preceded by a double minus sign, e.g. --year.

Here are some examples. You can view the complete list of those potential incorrect answers together with the associated feedback messages if you download the H5P ADV FITB 'papi Jo' template to your computer.

Incorrect answer #0: detect the presence of an incorrect word in the student's answer

Incorrect answer text: (little|small)
Feedback: Of course, that's a little girl, but you must write a compound adjective in your answer.

Here we are using a very simple regular expression, Alternation with The Vertical Bar or Pipe Symbol. The enclosing brackets are optional here.

Incorrect answer #1: detect the absence of the word 'year' in the student's answer

Incorrect answer text: --year
Feedback: You need to use the noun "year" to form this compound adjective.

Please note that the use of the double minus sign here is not part of the set of conventional regular expressions. It's used to simplify things. The double minus sign can be followed by any valid regular expression.

Incorrect answer #2: detect the absence of the words '5' or 'five' in the student's answer

Incorrect answer text: --(5|five)
Feedback: You must specify the age of the little girl in your compound adjective (use 5 or five).

Incorrect answer #3: detect the incorrect presence of extra spaces on either side of the hyphen sign in the compound adjective

Incorrect answer text: ( -|- )
Feedback: Do not put a space (or any other punctuation mark) before or after the hyphen character (-).

Incorrect answer #4: Detect the incorrect presence of extra words on either side of the compound adjective

Incorrect answer text: (-.*-.*)\s(\w+)|\s(\w+)(-.*-.*)
Feedback: Have you not put one word too many at the beginning or at the end of your answer?

That's a very complex regular expression. You will probably never have to go to that extreme, unless you are or become an expert in regular expressions!

Extra options

You can also define which part of the text will highlight when the feedback is shown. This is done by putting the word between ("!!"). For example:

a little girl who was born !!5 (five)!! !!years!! ago? a ____ girl

Putting the words "5 (five)" between !! means that this word will highlight when we display the feedback for the first set of incorrect answers.

You should now see something like this:


Step 6: Adding more sentences

Proceed as with sentence #1

Step 7: Behaviour settings

We can now return to the Behaviour settings to select some more options.

Answer mode

If you are not using the Regular options option, then you can select The user selects from options as per the original ADV FITB activity.

Behaviour when user makes a spelling error
Warn the user about the error
Accept it as a correct answer
Consider it a regular mistake

These 3 options work in conjunction with the Regular Expressions option. I recommend selecting Warn the user about the error.

Case sensitive

This option also works in conjunction with the Regular Expressions option.

Automatically check answers after input
Enable "Show solutions" button
Require all fields to be answered before the solution can be viewed
Enable "Retry"

These 4 options work as per the original ADV FITB activity.

Show all alternative solutions
If your blanks have more than one correct solution, check this to display all the alternatives when showing solutions. This is a new 'papi Jo' option.

Please note that the size of the blanks are automatically adjusted to the text they contain, upon checking answers or showing solutions. This is possible because the text inside the blanks use a fixed-width font from Google, 'Roboto Mono'.


If you create a number of similar sentences with blanks within one H5P ADV FITB activity, you may find the Snippets feature quite useful. Snippets are texts that can be reused in feedback texts by inserting @snippetname into the feedback texts.

Using regular expressions

Regular expressions are a powerful tool for analysing students' answers with a view to provide ever more relevant feedback messages to help their learning. But they can be quite hard to master. Of course you can always limit the regular expressions you enter for the potential incorrect answers to a few simple expressions.

You can find some help in the documentation I have written for my Moodle Regexp Question Type here. although the regular expressions system is not identical. This part is the most relevant to using regular expressions in H5P ADV FITB 'papi jo': Detecting missing required words or character strings.

For more general help about Regular Expressions, visit these sites:

Unfortunately there is no mechanism to test if your regular expressions are valid within the H5P editor system. The only point that is tested is whether your expressions have correct matching of square or round brackets. If an incorrect matching is detected, you will get an error message upon saving your H5P activity. Something like this:

ERROR!!! Your round or square brackets are not correctly balanced in the following regular expression(s):
Blank # 1 small|little)