What is the correct structure for xml code being exported into moodle?

What is the correct structure for xml code being exported into moodle?

by Corey Commins -
Number of replies: 4
Hello, I am a 3rd year student in college who is writing a quiz for a project. I am trying to upload questions to moodle using an xml file, however, it doesn't seem to able to recognise the questions or sometimes it tells me that document is simply not able to be uploaded. I am learniing xml during the course of this project, and I am unsure of what the correct structure for an xml file is when being uploaded to moodle. If you could take a look at my code and tell me if you see any (or many!) errors. Thank you!

<?xml version=1.0?>
<quiz>
<question type="category">
<category>
tom/dick/harry
</category>
</question>
<question type="multichoice">
<name>
<text>Question1</text>
</name>
<questiontext format="html">
<text>What is the capital of France</text>
</questiontext>
<penalty>1</penalty>
<defaultgrade>1</defaultgrade>
<answer fraction="100">
<text>Paris</text>
<feedback><text>Correct!</text></feedback>
</answer>
<answer fraction="0">
<text>Rome</text>
<feedback><text>Ooops!</text></feedback>
</answer>
<answer fraction="0">
<text>London</text>
<feedback><text>Ooops!</text></feedback>
</answer>
<shuffleanswers>1</shuffleanswers>
<single>true</single>
</question>
</quiz>

Also, is moodle capable of displaying images when using xml? If not, what would be a better tool to use?
Average of ratings: -
In reply to Corey Commins

Re: What is the correct structure for xml code being exported into moodle?

by Eoin Campbell -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
<?xml version=1.0?>
should be
<?xml version="1.0"?>

To check XML structures generally, create the question using the Moodle web interface, then export it to XML.
In reply to Eoin Campbell

Re: What is the correct structure for xml code being exported into moodle?

by Corey Commins -
Thanks for your reply, I tried to access the interface at hub.moodle.org, but on the page it said 'nothing to see here, move along'! How do I access the interface? And what exactly would it do to my code?
In reply to Eoin Campbell

Re: What is the correct structure for xml code being exported into moodle?

by Eoin Campbell -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Oops, forgot about markup escaping.
<xml version=1.0?>
should be
<xml version="1.0"?>

Also, I meant the Question editing interface within your own Moodle server installation, not the Hub.
If you don't have your own Moodle, see
http://demo.moodle.net/question/question.php?category=6&courseid=5&returnurl=http%3A%2F%2Fdemo.moodle.net%2Fquestion%2Fedit.php%3Fcourseid%3D5&qtype=multichoice

You can create a question using the interface, then export it to XML format to see what it looks like.
In reply to Eoin Campbell

Re: What is the correct structure for xml code being exported into moodle?

by Corey Commins -
Heya, just tried that and the code which was returned had many differences compared to my original, so the structure I had initially was wrong for uploading to moodle. Thanks a million for your help, I was really lost before!smile