Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

User:Frank Ralf/Moodle XML1: Difference between revisions

From MoodleDocs
Line 69: Line 69:
== Converting Moodle Glossary XML to Question XML ==
== Converting Moodle Glossary XML to Question XML ==
* [http://moodle.org/mod/forum/discuss.php?d=162866 Glossary items used in a quiz]
* [http://moodle.org/mod/forum/discuss.php?d=162866 Glossary items used in a quiz]
=== Glossary XML ===
<code xml>
  <?xml version="1.0" encoding="UTF-8" ?>
- <GLOSSARY>
- <INFO>
  <NAME>Front page Secondary glossary (global)</NAME>
  <INTRO>Another glossary on the front page: secondary + global</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>Orwell</CONCEPT>
  <DEFINITION>Author of the famous novell "1984"</DEFINITION>
  <FORMAT>0</FORMAT>
  <USEDYNALINK>1</USEDYNALINK>
  <CASESENSITIVE>0</CASESENSITIVE>
  <FULLMATCH>0</FULLMATCH>
  <TEACHERENTRY>1</TEACHERENTRY>
  </ENTRY>
- <ENTRY>
  <CONCEPT>gorilla</CONCEPT>
  <DEFINITION>Gorillas are the largest of the primates. They are ground-dwelling and predominantly herbivorous. They inhabit the forests of central Africa.</DEFINITION>
  <FORMAT>0</FORMAT>
  <USEDYNALINK>1</USEDYNALINK>
  <CASESENSITIVE>0</CASESENSITIVE>
  <FULLMATCH>0</FULLMATCH>
  <TEACHERENTRY>1</TEACHERENTRY>
  </ENTRY>
- <ENTRY>
  <CONCEPT>Africa</CONCEPT>
  <DEFINITION>A big continent.</DEFINITION>
  <FORMAT>0</FORMAT>
  <USEDYNALINK>1</USEDYNALINK>
  <CASESENSITIVE>0</CASESENSITIVE>
  <FULLMATCH>0</FULLMATCH>
  <TEACHERENTRY>1</TEACHERENTRY>
  </ENTRY>
- <ENTRY>
  <CONCEPT>ape</CONCEPT>
  <DEFINITION>Except for gorillas and humans, all true apes are agile climbers of trees.</DEFINITION>
  <FORMAT>0</FORMAT>
  <USEDYNALINK>1</USEDYNALINK>
  <CASESENSITIVE>0</CASESENSITIVE>
  <FULLMATCH>0</FULLMATCH>
  <TEACHERENTRY>1</TEACHERENTRY>
  </ENTRY>
  </ENTRIES>
  </INFO>
  </GLOSSARY>
</code>

Revision as of 17:30, 24 November 2010

This is only for keeping notes on some of my findings regarding Moodle XML.

Minimum Question XML

Other than stated at Quedoc's Moodle XML documentation (Minimum requirements) the minimum working Moodle XML file seems to be the following (short answer question). It gets imported using the default import settings.

Missing fields are populated with the default values during import which can be seen by re-exporting the question(s).

<?xml version="1.0" encoding="UTF-8"?> <quiz>

 <question type="shortanswer">
   <name>
     <text>Minimum question</text>
   </name>
   <questiontext>
     <text>What's the minimum XML required for import?</text>
   </questiontext>
   <answer fraction="100">
     <text>This here!</text>
   </answer>

</question> </quiz>

Moodle XML Minimum question.png


Re-export

This is how the question looks after exporting it again:

<?xml version="1.0" encoding="UTF-8"?> <quiz>

 <question type="shortanswer">
   <name>
     <text>Minimum question</text>
   </name>
   <questiontext format="moodle_auto_format">
     <text>What's the minimum XML required for import?</text>
   </questiontext>
   <image></image>
   <generalfeedback>
     <text></text>
   </generalfeedback>
   <defaultgrade>1</defaultgrade>
   <penalty>0.1</penalty>
   <hidden>0</hidden>
   <shuffleanswers>0</shuffleanswers>
   <usecase>0</usecase>
    <answer fraction="100">
     <text>This here!</text>
     <feedback>
       <text></text>
     </feedback>
   </answer>

</question> </quiz>

OpenOffice & XML

Some useful resources for using XML filters in OpenOffice for converting XML files:

Converting Moodle Glossary XML to Question XML

Glossary XML

 <?xml version="1.0" encoding="UTF-8" ?> 

- <GLOSSARY> - <INFO>

 <NAME>Front page Secondary glossary (global)</NAME> 
 <INTRO>Another glossary on the front page: secondary + global</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>Orwell</CONCEPT> 
 <DEFINITION>Author of the famous novell "1984"</DEFINITION> 
 <FORMAT>0</FORMAT> 
 <USEDYNALINK>1</USEDYNALINK> 
 <CASESENSITIVE>0</CASESENSITIVE> 
 <FULLMATCH>0</FULLMATCH> 
 <TEACHERENTRY>1</TEACHERENTRY> 
 </ENTRY>

- <ENTRY>

 <CONCEPT>gorilla</CONCEPT> 
 <DEFINITION>Gorillas are the largest of the primates. They are ground-dwelling and predominantly herbivorous. They inhabit the forests of central Africa.</DEFINITION> 
 <FORMAT>0</FORMAT> 
 <USEDYNALINK>1</USEDYNALINK> 
 <CASESENSITIVE>0</CASESENSITIVE> 
 <FULLMATCH>0</FULLMATCH> 
 <TEACHERENTRY>1</TEACHERENTRY> 
 </ENTRY>

- <ENTRY>

 <CONCEPT>Africa</CONCEPT> 
 <DEFINITION>A big continent.</DEFINITION> 
 <FORMAT>0</FORMAT> 
 <USEDYNALINK>1</USEDYNALINK> 
 <CASESENSITIVE>0</CASESENSITIVE> 
 <FULLMATCH>0</FULLMATCH> 
 <TEACHERENTRY>1</TEACHERENTRY> 
 </ENTRY>

- <ENTRY>

 <CONCEPT>ape</CONCEPT> 
 <DEFINITION>Except for gorillas and humans, all true apes are agile climbers of trees.</DEFINITION> 
 <FORMAT>0</FORMAT> 
 <USEDYNALINK>1</USEDYNALINK> 
 <CASESENSITIVE>0</CASESENSITIVE> 
 <FULLMATCH>0</FULLMATCH> 
 <TEACHERENTRY>1</TEACHERENTRY> 
 </ENTRY>
 </ENTRIES>
 </INFO>
 </GLOSSARY>