Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

by Dan Stowell -
Number of replies: 6
Hi - I'm trying to get my head around Cloze questions. All seems OK so far, but what I'd like to know is how to include special characters like #, ~, }, { in the question text or in the answer/feedback text, without confusing Moodle.

For example, if I wanted to write a course about PHP with a cloze question:

Statement blocks in PHP begin with __ and end with __

or even

Single-line comments in PHP typically begin with // but can also begin with __

How could I do this? If I just type the hash, tilde, or brace characters, the Cloze interpreter will try and treat them as delimiters.

Thanks in advance.
Average of ratings: -
In reply to Dan Stowell

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

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

Hi Dan,

using Moodle 1.5.3+ stable, for a SHORTANSWER type of question embedded in a Cloze type of question, type this:

Single-line comments in PHP typically begin with which sequence of characters?
{1:SHORTANSWER:=\/\/#Correct, they begin with //~=__#Correct, they begin with __}

See result in screen shot below.

You need to escape all those signs { } # / with backslahes (in question text only, no problem in feedback text) and I see no problem with undersccores.

Joseph

Attachment Image1.jpg
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

by Dan Stowell -
You need to escape all those signs { } # / with backslahes (in question text only, no problem in feedback text)

Magic! I didn't expect it to be that simple - thanks. By the way, you do have to escape the } and the ~ symbols in the feedback text, as far as I can tell.

In reply to Dan Stowell

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
By the way, you do have to escape the } and the ~ symbols in the feedback text, as far as I can tell.

Yes, of course!

Joseph

In reply to Joseph Rézeau

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

by . madea -

Hey Joseph and company!

Ratz!  I found this answer doing a search on "hash" and followed the advice to no avail. 

I tried escaping my # character in my answer with backslashes \#\ and that's what appeared in the answer: \#\   At least the # appeared, but the backslashes weren't supposed to be there.

Here's what I need as an answer:
rkill /kill mc<client-prefix>node# <PID>

Here's what I've tried:
= rkill /kill mc&lt;client_prefix&gt;node&lt;node#&gt; &lt;PID&gt;
and
= rkill /kill mc&lt;client_prefix&gt;node&lt;node\#\&gt; &lt;PID&gt;
and
= rkill /kill mc&lt;client_prefix&gt;node&lt;node\\#\\&gt; &lt;PID&gt;
and
= rkill /kill mc&lt;client_prefix&gt;node&lt;node&hash;&gt; &lt;PID&gt;

None of the above provide what I need as an answer:
rkill /kill mc<client-prefix>node# <PID>

I'm using moodle 1.5.2... (And this is an answer in a multiple choice question, not a cloze question... I don't think that would matter, but it might.)

Any suggestions? 

Thanks!

madea
madea@mmsi.com


In reply to . madea

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

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

Hi madea

The following works for me (Moodle 1.5.3 stable):

rkill /kill mc&lt;client-prefix&gt;node# &lt;PID&gt;

see screen shot attached

Joseph

Attachment Image1.jpg
In reply to Joseph Rézeau

Re: Cloze: How to include # or ~ or {} symbols in answer/feedback? (i.e. escaping)

by Garth Braithwaite -
Thanks just what I was looking for.