How to write Regular Expression in Quiz?

How to write Regular Expression in Quiz?

by J. Chan -
Number of replies: 2

Hi Joseph

I wonder if you could show me how to write a simple regular expression in Regular Expression Quiz for the following example:

Question: The factors of 15 are ...

Answer : To consider all possibilities:

Student may enter: 1, 3, 5, 15

or 1,3,5,15

or 1, 3, 5 and 15

If I enter in the 1st correct answer as 1, 3, 5, 15 (100%)

and the 2nd correct as .*1.*3.*5.*15.* (100%)

would this detect the the student input when he enter 1,3,5,15?

The quiz can work when I replace all numbers with words or key words in a question. The quiz can calculate quite an accurate score when students enter the appropriate english words, but not for the case of numbers. I wonder why?

Can you show me some hints?

Thanks in advance

Cheers

James

Average of ratings: -
In reply to J. Chan

Re: How to write Regular Expression in Quiz?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
James,
There are many possibilities, depending on how "tolerant" you want to be with the way your students enter their answer. Here are some examples...
Answer 1: 1, 3, 5, 15
will accept: 1, 3, 5, 15
Answer 2: (1 3 5 15|1,3,5,15|1,3,5 and 15|1, 3, 5 and 15)
will accept:
1 3 5 15
1,3,5,15
1,3,5 and 15*
1, 3, 5 and 15
Answer 3:
(one three five fifteen|one,three,five,fifteen|one,three,five and fifteen|one, three, five and fifteen)
will accept:
one three five fifteen
one,three,five,fifteen*
one,three,five and fifteen*
one, three, five and fifteen
Please note that any extraneous blank space is automatically deleted by the analysis system, which means that all of these answers will be accepted:
1 3 5 15
1 3 5 15
1, 3, 5, 15
However, the following will not be accepted (because the punctuation is not coherent)
1, 3 5, 15
one three, five and fifteen
* personally I would not accept those asterisked responses because they do not follow the punctuation rules of English
Joseph
In reply to Joseph Rézeau

Re: How to write Regular Expression in Quiz?

by J. Chan -

Hi Joseph

Thanks for your information. It is very useful to me.

BTW, does the rule applies to the Regular expression for Short Answer in Lesson?

Cheers

James