Ignore spaces

Ignore spaces

by John Pap -
Number of replies: 4

Hello everybody,

I'd like to have a question type which ignores spaces.

For example, the answer is M = (N % 3) * 4

But the correct answers here are many, including M=(N%3)*4 

- Is there a way to do that ?

I searched many plugins and question types, but I was unable to find out a solution.

* I can use wildcards but a wildcard can match any character so if someone answers M=(2N%3)*4 will see correct, which is not smile

- Can I set a wildcard to space character only ?

Any tips ?

Thanks.

Average of ratings: -
In reply to John Pap

Re: Ignore spaces

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moving to quiz forum...

Although, can this be done with, Regular_Expression_Short-Answer_question_type

Average of ratings: Useful (3)
In reply to Howard Miller

Re: Ignore spaces

by John Pap -

Thanks,

I have this plugin and the truth is still can't find how.

I try with parentheses, ?, *.

Any hint could be very helpful.

In reply to John Pap

Re: Ignore spaces

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

If you find a question type that will does a string match that ignores spaces and will accept

M=(N%3)*4

and also

M = ( N % 3) *4

It will also need to accept variations on 

M=4*(N%3)


Average of ratings: Useful (1)
In reply to John Pap

Re: Ignore spaces

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

Hi John,

It might help if you said which QUESTION is asked to which you are expecting this answer.

A simple way to reduce acceptable answers would be to give clear instructions to the student, e.g. "do not use any blanks/spaces in your answer" OR "please separate ALL elements of your answer with blanks/spaces".

The REGEXP question type was primarily aimed at analysing answers written in "natural language", not maths or physics formulas, etc. However, it is possible to achieve what you want by entering those 2 formulas which will accept answers with or without blanks.

Formula #1: see below

will accept 128 possible answers, such as:

M = (N % 3 ) * 4
    M = (N % 3 ) *4
    M = (N % 3 )* 4
    M = (N % 3 )*4
    M = (N % 3) * 4
    M = (N % 3) *4
    M = (N % 3)* 4
    M = (N % 3)*4
    M = (N %3 ) * 4
    M = (N %3 ) *4
    M = (N %3 )* 4
    M = (N %3 )*4
    M = (N %3) * 4
    M = (N %3) *4
    M = (N %3)* 4
    M = (N %3)*4
    M = (N% 3 ) * 4
    M = (N% 3 ) *4
    M = (N% 3 )* 4
    M = (N% 3 )*4
    M = (N% 3) * 4
    M = (N% 3) *4
    M = (N% 3)* 4
    M = (N% 3)*4
    M = (N%3 ) * 4

etc.

Further to Marcus Green's suggestion, this formula will accept an inversion:

Formula #2: see below

will also accept 128 possible answers including:

M = 4 * (N % 3 )
M = 4 * (N % 3)
M = 4 * (N %3 )
M = 4 * (N %3)
M = 4 * (N% 3 )
M = 4 * (N% 3)
M = 4 * (N%3 )
M = 4 * (N%3)
M = 4 *(N % 3 )
M = 4 *(N % 3)
M = 4 *(N %3 )
M = 4 *(N %3)
M = 4 *(N% 3 )
M = 4 *(N% 3)

etc.

EDIT the text editor on this forum modifies my reg expressions so I have attached them as pics.

Hope that helps. Don't thank me, as POTUS would tweet "I am a genius", even if I say so myself.wink

Attachment 2018-01-15_13-59-38.jpg