//////////////// GIFT FORMAT ASCII FILE///////////////////
the standard deviation of a uniformly distributed random variable
from 2 to 14 is{
=$$2\sqrt{3}$$
~$$4\sqrt{3}$$
~$$2\sqrt{2}$$
~$$7\sqrt{0.3}$$
}
$$C$$ and $$D$$ are two independent Gaussian random variables. Then
$$\sqrt{C^{2} + D^{2}}$$ is{
=Rayleigh
~Gaussian
~uniformly distributed
~binomial
}random variable
////////////////////////////////// end of file
Thanks
suresh
So I tried to recreate one of the questions directly in Moodle and exporting it as GIFT:
See the included file
So seems like you must escape all your { and }. (But I haven't tried importing it yet. So no guarantees!)
Thanks for the idea. But I am surprised, why moodle doc doesnot say that, latex symbols must be escaped...
suresh
We have to help each other with the documentation! It is all in WIKI form. It is easy to create a login that is needed if you are to contribute.
It is best to write something you have discovered as soon as possible, without worrying whether it is perfect. If you see something that is wrong or incomplete in the DOCs fix it!
I've now gone to http://docs.moodle.org/en/Import_questions#GIFT
and written this:
If you want to use curly braces, { or }, or equal sign, =, in a GIFT file (for example in a math question including TeX expressions) you must "escape" them by preceding them with a \ directly in front of each { or } or =. It is possible to use a replace program/macro/editor filter to do this conversion before importing to Moodle.
Log in and make it better! Copy good things from the forums into the docs!
IMHO GIFT import without support for LaTeX is another example of the "digitial divide" that exists between math and the other disciplines that use Moodle.
Thanks. I would appreciate if you could post your sed script. But I am surprised why the escaping of latex symbol is not documented in moodle GIFT docs...
suresh
The need to escape special characters is documented. Click the help icon next to the import button (the small orange question mark), then click on the link "More info about the GIFT format." You will see the following:
Special Characters ~ = # { } :
These symbols ~ = # { } control the operation of this filter and cannot be used as normal text within questions. Since these symbols have a special role in determining the operation of this filter, they are called "control characters." But sometimes you may want to use one of these characters, for example to show a mathematical formula in a question. The way to get around this problem is "escaping" the control characters. This means simply putting a backslash (\) before a control character so the filter will know that you want to use it as a literal character instead of as a control character.
Here is my sed script:
s/=/\\=/g
s/~/\\~/g
s/#/\\#/g
s/{/\\{/g
s/}/\\}/g
s/\t\\=/\t=/
s/\t\\~/\t~/
s/\t\\#/\t#/
s/\\{$/{/
s/\\{\r$/{/
s/^\\}/}/
If you are on a Unix machine, you can run sed from the command line:
where scriptfile is a file containing the above script, infile is the original GIFT file (with special characters unescaped) and outfile is the new GIFT file (with special characters escaped). Of course you will import outfile into Moodle.
To use the script requires that you format infile as follows.
- Always put the opening curly brace (which precedes the answer(s)) at the very end of a line
- always put the closing curly brace (which follows the answer(s)) at the very beginning of a new line
- start each answer on a new line preceded by a tab
Sometimes I've found that there have been mistakes in the help link which depend on a local language pack, so it can be good to change to English to see if there is anything different or more there.
I understand better now. Thanks for the script also
suresh