regular expressions in short answer question

regular expressions in short answer question

by Luis Vázquez de Lara -
Number of replies: 6

Hi, 

I use Moodle since version 1.9. I have a number of short answer question with regular expressions, that usee to work fine.

I upgraded from 2.3 to 2.8, and the last version doesn´t recognize the negative lookbehind code:

.*(?<!a)normal.*/i

Students are looking at a Rx and the diagnosis is a normal x ray. (in spanish, anormal means abnormal).

This regexp works fine in Moodle 2.3, but not in 2.8.

Please some help 

Luis


Average of ratings: -
In reply to Luis Vázquez de Lara

Re: regular expressions in short answer question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle short-answer question type has never supported regular expressions. Someone must have customised your Moodle 1.9.

You can find regular-expression question types in the plugins database.

In reply to Tim Hunt

Re: regular expressions in short answer question

by Luis Vázquez de Lara -

Thank you very much for your response. 

I have always used regular expression with the short answer question of the lesson activity. I just check the option "regular expression" :


I am currently using Moodle 2.8, and as you can see, it has the option "regular expressions".

I am really confused with your answer. In fact,  when the option is checked, I work with regular expressions and generally behave the way I want, except for the "look behind " code (that worked well with Moodle 2.3).

Luis

In reply to Luis Vázquez de Lara

Re: regular expressions in short answer question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Sorry, my mistake. I did not see that this thread was in the Lesson forum.

In reply to Luis Vázquez de Lara

Re: regular expressions in short answer question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Luis,

In Moodle 2.4 and lower, using just part of your example,  "(?<!a)normal", I was able to get any answer but normal ignored, and normal would get points. Any Moodle newer than 2.4, gives a warning: Warning: preg_match(): Compilation failed: unrecognized character after (? or (?- at offset 3 in.....

I know that over the past couple of years, there was some work done on the Lesson activity. Maybe this part got broken as lookahead still seems to work, while lookbehind is broken.


In reply to AL Rachels

Re: regular expressions in short answer question

by Luis Vázquez de Lara -

Hi Al,

Thank you very much for your response. I am testing the hypothesis that students who train with regular expressions instead of multichoice perform better when trying to make a diagnosis with a new set of radiographies.  The training set is in a lesson... 

Is there something I can do to fix this?

Thanks

Luis

In reply to Luis Vázquez de Lara

Re: regular expressions in short answer question

by Luis Vázquez de Lara -

Hi again,

As I posted before, I would like to know how reliable is going to be working with regular expression in the lesson activity. I am in the middle of some research work involving regular expressions. If there is something I can do, please tell me.

Thanks

Luis