Code blocks in qiuzzes

Code blocks in qiuzzes

by Stefan Warm -
Number of replies: 1

Hey,

what is the best way to import code blocks (for programming quiizzes) with the gift format?

I was trying to use markdown format to write unformated code. But I didn't get the right indentation as expected.

Any idea?

Thanks, Stefan


Average of ratings: -
In reply to Stefan Warm

Re: Code blocks in qiuzzes

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Stefan,

In your GIFT file, write:

::Multi choice 1::[markdown]
```
function myFunction(p1, p2) \{
····return p1 * p2;   // The function returns the product of p1 and p2
\}
```

where ···· stand for non-breaking spaces (Alt-255 on Windows) and where { and } are escaped with \.

Moodle will display:

function myFunction(p1, p2) {
    return p1 * p2;   // The function returns the product of p1 and p2
}