User:Frank Ralf/Converting Moodle glossary XML to question XML

From MoodleDocs
Jump to: navigation, search

See Glossary items used in a quiz

Glossary XML

<?xml version="1.0" encoding="UTF-8" ?> 
<GLOSSARY>
<INFO>
<NAME>Animals</NAME>
<INTRO>A list of wild animals</INTRO>
<ALLOWDUPLICATEDENTRIES>0</ALLOWDUPLICATEDENTRIES>
<DISPLAYFORMAT>dictionary</DISPLAYFORMAT>
<SHOWSPECIAL>1</SHOWSPECIAL>
<SHOWALPHABET>1</SHOWALPHABET>
<SHOWALL>1</SHOWALL>
<ALLOWCOMMENTS>0</ALLOWCOMMENTS>
<USEDYNALINK>1</USEDYNALINK>
<DEFAULTAPPROVAL>1</DEFAULTAPPROVAL>
<GLOBALGLOSSARY>1</GLOBALGLOSSARY>
<ENTBYPAGE>10</ENTBYPAGE>
 
<ENTRIES>
 
<ENTRY>
<CONCEPT>Gorilla</CONCEPT>
<DEFINITION>Gorillas are the largest of the primates.</DEFINITION>
 
<FORMAT>0</FORMAT>
<USEDYNALINK>1</USEDYNALINK>
<CASESENSITIVE>0</CASESENSITIVE>
<FULLMATCH>0</FULLMATCH>
<TEACHERENTRY>1</TEACHERENTRY>
 
</ENTRY>
</ENTRIES>
 
</INFO>
</GLOSSARY>
Note

The tag names have to be in uppercase.

Converted to Question XML

<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<question type="shortanswer">
<name>
<text>Gorilla question</text>
</name>
<questiontext>
<text>Gorilla</text>
</questiontext>
<answer fraction="100">
<text>Gorillas are the largest of the primates.</text>
</answer>
</question>
</quiz>
Note

The tag names have to be in lowercase.

XML mapping

As I understand the basic mapping is as follows:

Glossary
<ENTRY>
<CONCEPT>Gorilla</CONCEPT>
<DEFINITION>Gorillas are the largest of the primates.</DEFINITION>
</ENTRY>
Quiz question
<question type="shortanswer">
<questiontext>Gorilla</questiontext>
<answer>Gorillas are the largest of the primates.</answer>
</question>
Note

This code is simplified and won't work in praxis.