Close
Print
Text Size
s-   M   +B

Information: Importing Quiz Questions - Different file formats

To create a quiz in Moodle, you
  1. Create or import questions into the question bank
  2. Create a new quiz type activity on the main course page
  3. Add questions from the question bank into the quiz
Importing Questions:

Importing questions allows you to easily add questions into your course question bank from an external source, such as a text file or a quiz file created through a program like Examview.  You can import from a file you upload or that is already located in the course Files area. A number of file formats are supported:
  • GIFT format - Text file - supports Multiple-Choice, True-False, Short Answer, Matching, Numerical and fill-in-the-blank (called "missing word") questions.
  • Aiken format - Text file - supports multiple choice questions
  • Moodle XML format - XML file - good for copying questions from one course to another
  • Missing Word - Text file - supports multiple choice and short answer questions
  • Blackboard - dat file - this is for importing questions saved in Blackboard's POOL format (BB version below 6)
  • Blackboard V6+ - zip file - import from questions exported from Blackboard version 6 and 7 (NOT WebCT version)
  • WebCT format - Text file - in development - supports importing questions saved in WebCT's text-based format (only for WebCT before Blackboard aquired it)
  • Course Test Manager - database/XML file - import questions from a Course Test Manager test bank, which is a MS Access database
  • Embedded answers (Cloze) - Text file - special purpose format that supports only one type of question, the Embedded Answers (known as Cloze)
  • Learwise format - XML file - supports importing multiple choice questions saved in Learnwise's XML format
  • Examview format - XML file (and others) - supports importing questions created in Examview 4 or higher

GIFT format
GIFT is the most comprehensive import format available for importing Moodle quiz questions from a text file. It was designed to be an easy method for teachers writing questions as a text file. It supports Multiple-Choice, True-False, Short Answer, Matching and Numerical questions, as well as insertion of a _____ for the "missing word" format. Various question-types can be mixed in a single text file, and the format also supports line comments, question names, feedback and percentage-weight grades. Here are some quick examples:
Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}

Grant is {~buried =entombed ~living} in Grant's tomb.

Grant is buried in Grant's tomb.{FALSE}

Who's buried in Grant's tomb?{=no one =nobody}

When was Ulysses S. Grant born?{#1822}

Basics
  • Each individual question in the GIFT file must not contain any blank lines.
  • Each question is delimited by at least one blank line.
  • There must be a blank line (double carriage return) separating questions.
  • If you need to represent a blank line in your question you can use the entity \n. (actually type the characters backslash n)
  • You can use comments wherever you wish but they must start with two forward slashes (//) at the start of the line.
  • Answers are placed inside of the { } brackets

Question Types
Multiple Choice and fill-in-the-blank ("Missing Word" format):
These questions have a section that contains the answers for the question as well as the question text.  The answer section is surrounded by the { } brackets.  Inside this answer section, wrong answers are prefixed with a tilde (~) and the correct answer is prefixed with an equal sign (=).  Multiple choice and Missing word formats are handled the same way, and which format is used is determined by where the answer section is located.  If it is before the closing punctuation mark, it is treated as a Missing word question.  Otherwise, it is a Multiple choice question.
Multiple choice:  Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}
Missing word:     Grant is {~buried =entombed ~living} in Grant's tomb.

The Missing Word format automatically inserts a fill-in-the-blank line (like this _____) where the answer section is located in the question text.  All question types can be written in the Missing Word format.

For clarity, the answers can be written on separate lines and even indented. For example:

The American holiday of Thanksgiving is celebrated on the {
    ~second
    ~third
    =fourth
} Thursday of November.

Japanese characters originally came from what country? {
    ~India
    =China
    ~Korea
    ~Egypt
}

Short Answer:
Answers in Short Answer question-type are all prefixed by an equal sign (=), indicating that they are all correct answers. The answers must not contain a tilde.
Who's buried in Grant's tomb?{=no one =nobody}
Two plus two equals {=four =4}.
If there is only one correct Short Answer, it may be written without the equal sign prefix, as long as it cannot be confused as True-False.
True-False:
In this question-type the answer indicates whether the statement is true or false. The answer should be written as {TRUE} or {FALSE}, or abbreviated to {T} or {F}.
Grant is buried in Grant's tomb.{F}
The sun rises in the east.{T}
Matching:
Matching pairs begin with an equal sign (=) and are separated by this symbol "->". There must be at least three matching pairs.
Matching Question. {
    =subquestion1 -> subanswer1
    =subquestion2 -> subanswer2
    =subquestion3 -> subanswer3
}

Match the following countries with their corresponding capitals. {
    =Canada -> Ottawa
    =Italy  -> Rome
    =Japan  -> Tokyo
    =India  -> New Delhi
}
Matching questions do not support feedback or percentage answer weights.
Numerical:
The answer section for Numerical questions must start with a number sign (#). Numerical answers can include an error margin, which is written following the correct answer, separated by a colon. So for example, if the correct answer is anything between 1.5 and 2.5, then it would be written as follows {#2:0.5}. This indicates that 2 with an error margin of 0.5 is correct (i.e., the span from 1.5 to 2.5). If no error margin is specified, it will be assumed to be zero.
When was Ulysses S. Grant born? {#1822}
What is the value of pi (to 3 decimal places)? {#3.1415:0.0005}.
Optionally, numerical answers can be written as a span in the following format {#MinimumValue..MaximumValue}.
What is the value of pi (to 3 decimal places)? {#3.141..3.142}.
You can specify multple numeric answers, and this is particularly usefully when combined with percentage weight grades.  There is a problem with this, however.  The Moodle web interface (the web page part itself) does not support this.  This means the only way to add numerical questions with multiple answers is to create them in the text file and then import the file.  To sum it up:  multiple numeric answers work, but you can't enter them in the web page, you have to import them.  Single answer numerical questions work fine through the web page.
When was Ulysses S. Grant born? {#
    =1822:0
    =%50%1822:2
}
This example will count 1822 as correct, and then give half credit to answers from 1820 to 1824 (1822 with margin of error of 2).
Essay:
An essay question is simply a question with an empty answer field. Nothing is permitted between the curly braces at all.
Write a short biography of Ulysses S. Grant {}
Description:
A description "question" has no answer part at all
The next set of questions will concern arithmatic

Options

In addition to these basic question types, you have the following options: line comments, question name, feedback and percentage answer weight.
Line Comments:
Comments that will not be imported into Moodle can be included in the text file. This can be used to provide headers or more information about questions. All lines that start with a double backslash (not counting tabs or spaces) will be ignored when the file is imported.
// Subheading: Numerical questions belowWhat's 2 plus 2? {#4}
Question Name:
A question name can be specified by placing it first and enclosing it within double colons.
::Kanji Origins::Japanese characters originally came from what country? {=China}
::Thanksgiving Date::The American holiday of Thanksgiving is celebrated on the {~second ~third =fourth} Thursday of November.
If no question name is specified, the entire question will be used as the name by default.
Feedback:
Feedback can be included for each answer by following the answer with a number sign (# also known as a hash mark) and the feedback.
What's the answer to this multiple-choice question? {
    ~wrong answer#feedback comment on the wrong answer
    ~another wrong answer#feedback comment on this wrong answer
    =right answer#Very good!
}

Who's buried in Grant's tomb? {
    =no one#excellent answer!
    =nobody#excellent answer!
}

Grant is buried in Grant's tomb.{FALSE#Wrong, No one is buried in Grant's tomb.#Right, well done.}
For Multiple Choice questions, feedback is displayed only for the answer the student selected. For short answer, feedback is shown only when students input the corresponding correct answer. For true-false questions, there can be one or two feedback strings. The first is shown if the student gives the wrong answer. The second if the student gives the right answer.
Percentage Answer Weights:
Percentage answer weights are available for both Multiple Choice and Short Answer questions. Percentage answer weights can be included by following the tilde (for Multiple Choice) or equal sign (for Short Answer) with the desired percent enclosed within percent signs (e.g., %50%). This option can be combined with feedback comments.
Difficult question.{~wrong answer ~%50%half credit answer =full credit answer}

::Jesus' hometown::Jesus Christ was from {
    ~Jerusalem#This was an important city, but the wrong answer.
    ~%25%Bethlehem#He was born here, but not raised here.
    ~%50%Galilee#You need to be more specific.
    =Nazareth#Yes! That's right!
}.

::Jesus' hometown:: Jesus Christ was from {
    =Nazareth#Yes! That's right!
    =%75%Nazereth#Right, but misspelled.
    =%25%Bethlehem#He was born here, but not raised here.
}
Note: The last two examples are essentially the same question, first as multiple choice and then as short answer.

Note: It is possible to specify percentage answer weights that are NOT available through the browser interface. The Match Grades drop-down on the import page determines how these are handled. You can either request that an error be reported or that the answer weight be adjusted to the nearest valid answer weight.
Specify text-formatting for the question
The question text (only) may have an optional text format specified. Currently the available formats are moodle (Moodle Auto-Format), html (HTML format), plain (Plain text format) and markdown (Markdown format). The format is specified in square brackets immediately before the question text. More information on text formats in Moodle.
[markdown]The *American holiday of Thanksgiving* is celebrated on the {
    ~second
    ~third
    =fourth
} Thursday of November.
Multiple Answers:
The Multiple Answers option is used for multiple choice questions when two or more answers must be selected in order to obtain full credit. The multiple answers option is enabled by assigning partial answer weight to multiple answers, while allowing no single answer to receive full credit.
What two people are entombed in Grant's tomb? {
    ~No one
    ~%50%Grant
    ~%50%Grant's wife
    ~Grant's father
}
Note: There is no equal sign (=) in any of these answers and the answers should total no more than 100%, otherwise Moodle will return an error. To avoid the problem of students automatically getting 100% by simply checking all of the answers, it is best to include negative answer weights for wrong answers.
What two people are entombed in Grant's tomb? {
    ~%-50%No one
    ~%50%Grant
    ~%50%Grant's wife
    ~%-50%Grant's father
}
Special Characters ~ = # { } :
These symbols ~ = # { } : control the operation of how the file is imported and cannot be used as normal text within questions. Since these symbols have a special role in determining the operation of this filter, they are called "control characters." But sometimes you may want to use one of these characters, for example to show a mathematical formula in a question. The way to get around this problem is "escaping" the control characters. This means simply putting a backslash (\) before a control character so that question import will know that you want to use it as a literal character instead of as a control character. For example:
Which answer equals 5? {
    ~ \= 2 + 2
    = \= 2 + 3
    ~ \= 2 + 4
}::GIFT Control Characters::
Which of the following is NOT a control character for the GIFT import format? {
   ~ \~     # \~ is a control character.
   ~ \=     # \= is a control character.
   ~ \#     # \# is a control character.
   ~ \{     # \{ is a control character.
   ~ \}     # \} is a control character.
   = \      # Correct! \ (backslash) is not a control character. BUT,
              it is used to escape the control characters.
}
When the question is processed, the backslash is removed and is not saved in Moodle.
Specifying Categories
It is possible to change the question category into which the questions are added within the GIFT file. You can change the category as many times as you wish within the file. All questions after the modifier up to the next modifier or the end of the file will be added to the specified category. Up to the first category modifier the category specified on the import screen will be used. Note that for this to work the from file: box must be ticked on the import screen.

To include a category modifier include a line like this (with a blank line before and after):
$CATEGORY: tom/dick/harry
or simply
$CATEGORY: mycategory
...the first example specifies a path of nested categories. In this cae the questions will go into harry. The categories are created if they do not exist.


Aiken Format

The Aiken format is a very simple way of creating multiple choice questions using a clear human-readable format. Here is an example of the format:
What is the correct answer to this question?
A. Is it this one?
B. Maybe this answer?
C. Possibly this one?
D. Must be this one!
ANSWER: D

Which LMS has the most quiz import formats?
A) Moodle
B) ATutor
C) Claroline
D) Blackboard
E) WebCT
F) Ilias
ANSWER: A
Rules:
  • The question must be all on one line.
  • Each answer must start with a single-letter character, followed by a period '.' or a bracket ')', then a space.
  • The answer line must immediately follow, starting with "ANSWER:" and then giving the appropriate letter.
  • Answer letters MUST be upper case, even in the ANSWER section.
  • The question and answers can NOT contain quotes of any kind (single or double).

Moodle XML format
This Moodle specific format imports quiz questions that have previously been exported in the same format. The format is straightforward and is best demonstrated by exporting a category in the Moodle XML format. The XML format is capabable of importing image files.
Category Switching
You can insert a special dummy question into the XML file to specify the category path into which the following questions will be inserted. If the category or categories do not exist they will be created. Note that the from file: option must be ticked on the option page or this code will be ignored completely. You can switch categories in the xml file as often as you wish.

An example of the format is as follows:
<question type="category">
    <category>
        tom/dick/harry
    </category>
</question>

Missing Word
This format only supports multiple choice questions and short answer question, depending on the number of answers. One answer generates a short answer question, two or more answers generate a multiple choice question. Each answer is separated with a tilde (~), and the correct answer is prefixed with an equals sign (=). Here is an example of a multiple choice question:
As soon as we begin to explore our body parts as infants we become students of {=anatomy and physiology ~reflexology ~science ~experiment}, and in a sense we remain students for life. 
Here is an example of a short answer question:
As soon as we begin to explore our body parts as infants we become students of {=anatomy and physiology}, and in a sense we remain students for life. 

Blackboard
This module can import questions saved in Blackboard's "POOL" type export format. It relies on XML functions being compiled into your PHP. Note that you must first unpack the exported zip file and provide Moodle with the appropriate .dat file. Note that this version does not work with Blackboard Version 6 and newer.
Blackboard V6+
This module can import questions saved in Blackboard's export format. It provides limited support for Blackboard Version 6 and 7. It relies on XML functions being compiled into your PHP. You must upload the zip file exported from Blackboard.
WebCT
This module can import questions saved in WebCT's text-based format.  The WebCT import function is in development and does not support all of the WebCT question types.  At the time of writing this, only Multiple Choice and Short answer questions are supported.  Here are some examples of these questions in a text file:
# Start of question: Short Answer Question
:TYPE:S:
:TITLE:Short Answer Question
:QUESTION:H
What is the name of the WebCT Learning Hub?

:IMAGE:dotcomLogoc.gif
:ANSWERS:1
:CASE:0
:ANSWER1:WebCT.com:100:0:20:0
:FEEDBACK1:H
Be sure to visit the Learning Hub\: www.WebCT.com
:CAT:Default
# End of question: Short Answer Question


# Start of question: Multiple Choice Question
:TYPE:MC:1:0:C
:TITLE:Multiple Choice Question
:FEEDBACK
Darwin invented the theory of evolution and created Darwinism.
:QUESTION:H
Where is the Darwin Research Center?
:IMAGE:
:LAYOUT:vertical
:ANSWER1:0:H
Menlo Park, California
:REASON1:H
Sorry!
:ANSWER2:0:H
Vancouver, Canada
:REASON2:H
Sorry!
:ANSWER3:100:H
Galapagos Islands, Ecuador
:REASON3:H
Correct Answer!
:ANSWER4:0:H
London, England
:REASON4:H
Sorry!
:ANSWER5:0:H
Sidney, Australia
:REASON5:H
Sorry!
:CAT:Default
# End of question: Multiple Choice Question

Course Test Manager
This module can import questions saved in a Course Test Manager test bank. It relies on different ways of accessing the test bank, which is in a Microsoft Access database, depending on whether Moodle is running on a Windows or Linux web server.  Course Test Manager is an "End of Lifetime" software package from Course Technology. It is no longer being actively developed by Course Technology. It has been replaced by a new test manager called ExamView.
Embedded answers (Cloze)
This very flexible question type is similar to a popular format known as the Cloze format.  Questions consist of a passage of text (in Moodle format) that has various sub-questions embedded within it, including:
  • short answers (SHORTANSWER or SA or MW),
  • numerical answers (NUMERICAL or NM),
  • multiple choice (MULTICHOICE or MC), represented as a dropdown menu in-line in the text
  • multiple choice (MULTICHOICE_V or MCV), represented a vertical column of radio buttons, or
  • multiple choice (MULTICHOICE_H or MCH), represented as a horizontal row of radio-buttons.
There is currently no graphical interface to create these questions - you need to specify the question format using the text box or by importing them from external files.  Here is an example of the input text used to specify such a question:
This question consists of some text with an answer embedded right here {1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} and right after that you will have to deal with this short answer {1:SHORTANSWER:Wrong answer#Feedback for this wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} and finally we have a floating point number {2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}.<br />
<br />
The  multichoice question can also be shown in the vertical display of the standard moodle multiple choice.<br />
<br />
{2:MCV:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}<br />
Or in an horizontal display that is included here in a table<br />
<br />
{2:MCH:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}<br />
Note that addresses like www.moodle.org and smileys :-) all work as normal:<br />
 a) How good is this? {:MULTICHOICE:=Yes#Correct~No#We have a different opinion}<br />
 b) What grade would you give it? {3:NUMERICAL:=3:2}<br />
<br />
Good luck!
This example will appear to students as:
1
Marks: --/12.00
This question consists of some text with an answer embedded right here and right after that you will have to deal with this short answer and finally we have a floating point number .

The multichoice question can also be shown in the vertical display of the standard moodle multiple choice

1. Wrong answer
2. Another wrong answer
3. Correct answer
4. Answer that gives half the credit

Or in an horizontal display that is included here in a table

1. Wrong answer2. Another wrong answer3. Correct answer4. Answer that gives half the credit


Note that addresses like www.moodle.org and smileys smile all work as normal:
a) How good is this?
b) What grade would you give it?

Good luck!

Learnwise format
This format can import multiple choice questions saved in Learnwise's XML format.
Examview format
This format can import from Examview 4 XML files. Note that the older versions of Examview are not supported.

Import and Export formats are a pluggable resource (added in as modules). Other optional formats may be available in the Modules and Plugins database.


A note about character encodings
If your file contains non-ascii characters then it must use UTF-8 encoding. You may be able to select or convert to UTF-8 using your favourite editor, or it may be an option in the exporting software. Be particularly cautious with files generated by Microsoft Office applications, as these commonly use special encoding which will not be handled correctly. XML based import formats will be handled automatically provided your Moodle server is running PHP 5.
Author: White, Shannon
Created: November 04, 2010 at 9:27 AM
Updated: July 08, 2011 at 9:36 AM