Gapfill with Short Answer

Gapfill with Short Answer

by Michael Heber -
Number of replies: 1

I am trying to write a question in a Quiz that uses the Gapfill pluggin with short answer (regex) as a list with word boundries. The format looks like this below.

Please list the 3 components necessary to perform this operation?

1) [ \banswer\b.*\b1\b | \banswer\b.*\b2\b |\banswer\b.*\b3\b]

2) [ \banswer\b.*\b1\b | \banswer\b.*\b2\b |\banswer\b.*\b3\b]

3) [ \banswer\b.*\b1\b | \banswer\b.*\b2\b |\banswer\b.*\b3\b]


So when I grade this if the first field contains a correct answer it marks it correct, but none of the other fields grade correctly. So my questions are is it possible to accomplish what I am trying? and am I using this formatting correctly?

Thanks

Mike

Average of ratings: -
In reply to Michael Heber

Re: Gapfill with Short Answer

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

This line in the source might (or might not) explain what you are experiencing.

https://github.com/marcusgreen/moodle-qtype_gapfill/blob/0a11ec28017b498a2371e2aebe8bfbac4b329c05/question.php#L613


        /* if the gap contains | then only match complete words
         * this is to avoid a situation where [cat|dog]
         * would match catty or bigcat and adog and doggy
         */
        if (strpos($pattern, "|")) {
            $regexp = '/\b(' . $pattern . ')\b/u';
        } else {
            $regexp = '/^' . $pattern . '$/u';
        }