Skip to content
Python based Xlator to Moodle XML format
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



This application is used to convert a quiz specified in a specific format of text file, to MOODLE XML format.

Currently tested in python 2.7. Will not work in python3 as prints have a different syntax. You are welcome to port it . Also tested only on windows environment only.


python -i -o

If -o option is not used, the output will be to console.

In this repository a sample input file name called sample1.txt is provided . and a generated sample output is also provided call sample2.xml is provided. To convert the text file into an XML file (say output.xml) following would be the command line

python -i sample1.txt -o output.txt

A global debug flag in is by default set to 0, if you set it to 1, it will output debug information.

Cannot document what the debug info actually means, but you can Send it to me along with input file, it will help me fix problem


Appreciation/Cribs/CR , feel free to contact me @

Supported Question Types

  1. Short Answer
  2. True/False.
  3. Multi Choice

Also Marks/Feedback for each of these question types can be specified. By default the Marks is taken as 1.

Key Constructs

A parser looks of the following constructs. (Plz don’t use these as a part of description of question/answer/choices. Dunno what will happen)`

  1. to identify questions that are short answer type. Only these constructs must be present in the line.
  2. f or truefalse type of questions
  3. type of question
  4. / for essay answer question
  5. Q>> keyword To identify question.
  6. C>> keyword tTo identify choice
  7. F>> keyword To identify feedback
  8. Marks>> keyword for marks (IDeally should have been M, but ....)
  9. D>> key work for description. The use case is suppose you want to describe a scenario, and then asks questions related to the description, this key word is used. See the attached sampleQpaper.txt for its usage.

Seem the attached "sampleQpaper.txt to understand how to write the txt file that specifies your questions/answers/choices


You can sepcify regular expression as answers. But have never been able to make it to work in Moodle server. It interprets the RE literaly. There are articles which describes how RE is supposed to work, but was unable have a success with it

You can’t perform that action at this time.