Quiz Import XML schema

Quiz Import XML schema

by Jerome McDonough -
Number of replies: 4
This is the first semester in which I've had a reason to the use the Quiz facility in Moodle, and I was very happy to see the XML import facility, as that appeared to be a wonderful way to take older text-base quizzes, mark them up fast and get them into the Moodle.  I was a bit less happy (and surprised) when I couldn't find an XML schema for the Moodle quiz import XML language.  As I teach XML at the iSchool at Illinois, I figured I'd just write one.  I looked around a bit online first to see if someone had beaten me to the punch, but couldn't find a pre-existing schema.  I did find some people who tried and all came up against the rock of the <question> element's required content varies depending on the type of question it is.  That's a fairly common problem, with a common solution: define the question element as being an abstract type, and then use an xsi:type attribute to resolve the type definition to something concrete (i.e. a multi choice question will get the right subelements for a multi choice question, an essay question the right subelements for an essay question, etc.).  I've attached my first, incomplete pass of a schema, along with an XML file exported from our Moodle and modified slightly to conform to the schema.

Question: Am I reinventing the wheel here?  Is this a previously solved problem?  Even if it's not, is there interest in having a schema which formalizes the XML import language?  I am brand new around here, so not sure if this is seen as an issue that needs work or not.  If it is, I'm happy to continue fleshing out this schema and hand it over to Moodle for use/future development/maintenance.

Best,

Jerome McDonough
iSchool, University of Ilinois

Average of ratings: -
In reply to Jerome McDonough

Re: Quiz Import XML schema

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't think you are re-inventing the wheel. Probably this has not been done before because people don't normally use the type of XML tooling that uses schemas to do this. They just use a basic text editor. Also, the the Moodle format are probably older than XSD.

Thanks for sharing the file. It would be useful to add a link to https://docs.moodle.org/37/en/Moodle_XML_format.
In reply to Tim Hunt

Re: Quiz Import XML schema

by Jerome McDonough -
Will do, but I'd rather get the schema complete first, so that it handles the full range of questions that Moodle supports. Is there an example document somewhere that shows all the question variants' XML form?
In reply to Jerome McDonough

Re: Quiz Import XML schema

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you can read PHP code, then the code in question/format/xml/format.php might make the possible outputs clear.

Also, just create questions in Moodle through the UI and export them.

Finally, if you look at the Database schema (defined in files like question/type/.../db/install.xml). The XML format should be able to represent anything stored in the database, so that could be a useful cross-check.
Average of ratings: Useful (1)