Pattern match

Pattern match

by Sanaz Parsaei -
Number of replies: 6

hello,


I am using pattern match question type and I would like to mark the following correct, but I can't. Can anybody help me?


I would like to have  2ml as correct answer, but I can not get it right and I assume it is because the combination of digit and  letters.

I can get 2 ml correct though.


Average of ratings: -
In reply to Sanaz Parsaei

Re: Pattern match

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

I think the editor has eaten your regular expression sad

In reply to Marcus Green

Re: Pattern match

by Sanaz Parsaei -
Thank you Marcus but what that means and what should I do?

the pattern I added is:
match_any (
    match_m (21/2|2.5 ml)
    match_m (21/2|2.5)
)

I tried:
match_any (
    match_m (21/2ml|2.5ml)
    match_m (21/2|2.5)
)

or

match_any (
    match_m (21/2??|2.5??)
    match_m (21/2|2.5)
)

None of them are helping.

In reply to Sanaz Parsaei

Re: Pattern match

by Phil Butcher -

Methinks there's something wrong with your installation.

I just tried the first 

match_any (
    match_m (21/2|2.5 ml)
    match_m (21/2|2.5)
)

on our main VLE at the OU and it just worked. Everything shown matched i.e.

2.5 ml

21/2 ml

21/2

2.5

Question attached.

In reply to Phil Butcher

Re: Pattern match

by Sanaz Parsaei -

Thank you for trying the code.

Actually, it does not accept this answer: 2.5ml and this is what I am looking for.

In reply to Sanaz Parsaei

Re: Pattern match

by Phil Butcher -

Right, now I see the problem. I will investigate.

FYI when looking for a value and a unit I would use our 'variable numeric sets with unit' question type. This separates the number from the unit before doing the matching and will cope with

2.5 ml or 2.5ml or 2.5e0 ml.

But pmatch should work and I'll try and work out the fix.

In reply to Phil Butcher

Re: Pattern match

by Sanaz Parsaei -

Thank you so much Phil. That would be a great help to me.

Variable numeric  will help, but also I have some other answers like: 2 pills of 2.5 ml Which I think pattern match should work.

Please guide me if I am wrong.

Sanaz