Wild cards and Gapfill

Wild cards and Gapfill

by David Jefferson -
Number of replies: 8

(2.5) I have gap fill test question that has the answers as:

[Line-of-road|yard treatment| brush control]

I wanted to add wildcard so line of road (no hyphens) would be marked correct. I changed it to line*of*road, took the quiz, typed in line of road and got it wrong. how can I fix that

Average of ratings: -
In reply to David Jefferson

Re: Wild cards and Gapfill

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

Good question David, I find wildcards quite a challenge so it is interesting to experiment with permutations.

You might try line*.of*.road

(Note the period after the asterix) Which will mark as correct 

line of road

and

line-of-road

However that regular expression is looking for something like the string

lines

followed by any character zero or more times. This means it would also mark as correct

lineofroad

and

linezofkroad

It would be possible to make an expression that limits the acceptable answers more closely but it would mean a more complex regular expression.

The Gapfill question parses wildcards uses the PHP preg_match function so whatever that understands will be used on your string. You can see some documentation of various question and regular expression stuff 

http://docs.moodle.org/20/en/Regular_Expression_Short-Answer_question_type

and the recently updated documentation for this question typel

http://docs.moodle.org/25/en/Preg_question_type

 

In reply to Marcus Green

Re: Wild cards and Gapfill

by David Jefferson -

it worked, thank you

 

I'm glad to be taking an intro php course. This will all make sense.

In reply to Marcus Green

Re: Wild cards and Gapfill

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Marcus,

I'm sure I got it to work some time ago but no longer now.

using gapfill question type from your github $plugin->version  = 2006082509; $plugin->release ='1.2';

If I want to use the square brakets special characters in gapfill, then I have to select a different separator, OK so I use the curled braces instead. But even then it does not work.

Ask a question about the color of the sky.

Q1 What {[color|colour]} is the sky?

Q2 What {colou?r} is the sky?

 The regular expression works in Q2, not in Q1.

screenshot #1

Why is that?

Joseph

 

In reply to Joseph Rézeau

Re: Wild cards and Gapfill

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

The delimiter (e.g. [ or {) is discarded before the string is sent to preg_match and so if you have switched to { the question text should read

Q1 What {color|colour} is the sky?

I have included a sample_questions.xml file with the distribution but it doesn't cover wildcard usage. In my next update I will include one or more examples.

I was showing some people this question type recently and I had an inspiration to claim that I could explain it's basic usage in a single sentence 

"put square braces around the missing words"

Of course regex usage would require a few more sentences.

 

 

 

In reply to Marcus Green

Re: Wild cards and Gapfill

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Marcus "The delimiter (e.g. [ or {) is discarded before the string is sent to preg_match..."

Ah, you changed that from the first version I had tested. And it's a good idea. So the answer to the OP's query would be (using the { } character delimiters):

{Line[-| ]of[-| ]road|yard treatment| brush control}

or, or course

{Line-of-road|Line of road|yard treatment| brush control}

or (using the default square brackets delimiters):

[Line-of-road|Line of road|yard treatment| brush control]

Joseph

 

 

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Wild cards and Gapfill

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

That looks nice. I have taken a look at Olegs question type and I like the way he includes a regex tester widget. In the move from 1.1 to 1.2 I did quite a bit of "behind the scenes" refactoring in preparation for future developments.

I also worked on the "Olympic medal" feedback as shown in this screen shot. It would be better without the slightly misleading correct answer count but I feel it is an improvement. 

 

Attachment duplicate_gapfill.png
In reply to Joseph Rézeau

Re: Wild cards and Gapfill

by David Jefferson -

This is what I used- David

What are the 3 phases of railroad weed control? 
[yard treatment|line*.of*.road|brush control]
[yard treatment|line*.of*.road|brush control]
[yard treatment|line*.of*.road|brush control]
In reply to David Jefferson

Re: Wild cards and Gapfill

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

That will probably reject brush    control (note extra spaces). But you probably don't want to trap every single permutation smile