Difference between revisions of "GIFT format"

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: GIFT format.

(Hints and Tips: guessing a little here about "precede" -- trying to err on safe side but flying a little blind)
(Format symbols: relatively unimportant question should not clutter here)
Line 48: Line 48:
| } || End answer(s)
| } || End answer(s)
| \character || Backslash escapes the special meaning of ~ = # { } and : (perhaps \//? -- see page comments)
| \character || Backslash escapes the special meaning of ~, =, #, {, }, and :
| \n || Places a newline in question text -- blank lines delimit questions
| \n || Places a newline in question text -- blank lines delimit questions

Revision as of 18:30, 5 February 2010

GIFT format allows someone to use a text editor to write multiple-choice, true-false, short answer, matching missing word and numerical questions in a simple format than can be imported. The GIFT format is also an export file format available in Question bank.

  • When creating a large numbers of questions, GIFT can provide a quick way of bulk loading questions either into a question category, or into a Lesson.
  • Sometimes it is easier proofing questions in a question category by viewing them in a GIFT file.

General instructions

At least one blank line must be left between each question.

In the simple form, the question comes first, then the answers are set in between brackets, with an equal sign indicating the correct answer(s) and tilde the wrong answers. A Number sign will insert a response. Questions can be weighted by placing percentage signs around the weight. Comments are preceded by double slashes and are not imported.

Here are some useful GIFT examples than can be imported or used as rough template. Many of the examples below used the questions in the file as a starting point.

TIP: Any GIFT file must be correctly encoded in UTF8. Beware of some of Microsoft's "fake" Unicode implementation which is not compatible and may result in strange characters appearing in your quizzes. When in doubt, save as a simple MS-DOS text file.

Format symbols

Here are some common GIFT symbols and their use.

Symbols Use
// text Comment until end of line (optional)
 ::title:: Question title (optional)
text Question text (becomes title if no title specified)
{ Start answer(s) -- without any answers, text is a description of following questions
{T} or {F} True or False answer; also {TRUE} and {FALSE}
{ ... =right ... } Correct answer for multiple choice, (multiple answer? -- see page comments) or fill-in-the-blank
{ ... ~wrong ... } Incorrect answer for multiple choice or multiple answer
{ ... =item -> match ... } Answer for matching questions
#feedback text Answer feedback for preceding multiple, fill-in-the-blank, or numeric answers
{# Start numeric answer(s)
answer:tolerance Numeric answer accepted within ± tolerance range
low..high Lower and upper range values of accepted numeric answer
=%n%answer:tolerance n percent credit for one of multiple numeric ranges within tolerance from answer
} End answer(s)
\character Backslash escapes the special meaning of ~, =, #, {, }, and :
\n Places a newline in question text -- blank lines delimit questions

Here are some quick examples:

// true/false
::Q1:: 1+1=2 {T}

// multiple choice with specified feedback for right and wrong answers
::Q2:: What's between orange and green in the spectrum? 
{ =yellow # right; good! ~red # wrong, it's yellow ~blue # wrong, it's yellow }

// fill-in-the-blank
::Q3:: Two plus {=two =2} equals four.

// matching
::Q4:: Which animal eats which food? { =cat -> cat food =dog -> dog food }

// math range question
::Q5:: What is a number from 1 to 5? {#3:2}

// math range specified with interval end points
::Q6:: What is a number from 1 to 5? {#1..5}
// translated on import to the same as Q5, but unavailable from Moodle question interface

// multiple numeric answers with partial credit and feedback
::Q7:: When was Ulysses S. Grant born? {#
         =1822:0      # Correct! Full credit.
         =%50%1822:2  # He was born in 1822. Half credit for being close.

// essay
::Q8:: How are you? {}

Format symbols explained

The multiple choice format below as a comment line // for the question, when Moodle exports it the question unique id number will appear here. The first set of  :: precedes the question title. The second :: precedes the actual question. The first { indicates the start of the answers. The correct answer is preceded by an = sign and wrong answers by a ~. Teacher responses have a # in front of them. The question ends with a } and then a blank line. NOTE it is { } not ( ) parenthesis! Usually these are gotten with help of the [AltGr] key.

//Comment line 
::Question title 
:: Question {
=A correct answer
~Wrong answer1
#A response to wrong answer1
~Wrong answer2
#A response to wrong answer2
~Wrong answer3
#A response to wrong answer3
~Wrong answer4
#A response to wrong answer4

The shortest format for a multiple choice question is:

Question{= A Correct Answer ~Wrong answer1 ~Wrong answer2 ~Wrong answer3 ~Wrong answer4 }
Tip: If you don't specify a question title the WHOLE question will be used as the title at the time of import into Moodle. There are pros and cons to allowing this to happen. Cons: This can add a lot of unnecessary words. This can include characters which might confuse the export GIFT process. Pros: On the other hand. if the start of each question is different, it can make finding a single question easier in a category list of questions. It will save you typing. Having the same title for every question is a very bad idea.

Question format examples

There are several ways to use a text editor to write a GIFT format. We will try to show the simple version for example and in some formats we will introduce some more complex features that can be imported into many Moodle Question formats.

Multiple choice

Here is a simple acceptable GIFT multiple choice format:

Who's buried in Grant's tomb?{=Grant ~no one ~Napoleon ~Churchill ~Mother Teresa }

Here is a longer format that uses most of the GIFT elements:

 // question: 1 name: Grants tomb
::Grants tomb::Who is buried in Grant's tomb in New York City? {
~No one
#Was true for 12 years, but Grant's remains were buried in the tomb in 1897
#He was buried in France
#He was buried in England
~Mother Teresa
#She was buried in India


// question: 0 name: TrueStatement
::TrueStatement about Grant::Grant was buried in a tomb in New York City.{T}

Short answer

Here are two examples using the simple method showing possible right answers for credit.

Who's buried in Grant's tomb?{=Grant =Ulysses S. Grant =Ulysses Grant}
Two plus two equals {=four =4}


The matching uses the equal sign before the list item with a -> (dash and greater than) before the correct match.

Match the following countries with their corresponding capitals. {
   =Canada -> Ottawa
   =Italy  -> Rome
   =Japan  -> Tokyo
   =India  -> New Delhi

Missing word

This is a simple missing word format

Grant {~is not buried =is buried ~might be buried} in Grant's tomb.

Numerical questions

Here is a simple numerical format question. It will accept a range of 5 years.

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

Here is a more complex numerical format with a ranged and partial credit given for 1 answer.

//this comment will be ignored in the import process 
::Numerical example::
When was Ulysses S. Grant born? {#
    =1822:0      #Correct!  you will get full credit for this answer
    =%50%1822:2  #He was born in 1822.
                 You get 50% credit for being close.

Hints and Tips

  • Use the ::title:: at the beginning of every question to organize your questions when Moodle presents a list or exports them as another GIFT file. When the title is left blank, Moodle will put the beginning of the question as the title. Some teachers want to see something like "001 LIT101 Poe ref Purloin Letter" or "The Purloin Letter was written by (AmLit pg 254)" in the title.
  • You can specify which question category the following questions will be in with
  $CATEGORY: myParentCat/myCategory 

(that line must be preceded and followed by an empty line. See more about this in the reference pdf below.

  • You can specify markup if you need to format the question by setting [html], [moodle], [plain] or [markdown] just before the question text. See more about this in the reference pdf below.
  • In the Lesson module, in a question page, correct answers jump by default to Next page and incorrect answers jump to This page (i.e. student has to "try again"). When importing from a GIFT format file, this is exactly the mechanism which is used.
  • If you want a student to be taken directly from one question to the next irrespective of their answer being correct or incorrect: in the Lesson Settings, set Maximum number of attempts: to 1.
    • Please note, however, that a message "correct / incorrect" will still be displayed to the student upon answering each question. If you do not want this (default) feedback message to be displayed then enter your own feedback message (i.e. "continue", "---", etc.)
    • In case you want no visible message displayed then enter a non-breaking space as feedback. Moodle will not put it's automatic response because it sees the blank space. To do this, put a # after the answer and write Nbsp.png (without spaces between these characters).
  • Need to use a special GIFT character in your question or answer? Put a \ in front of the GIFT character.
    • For example if you want to use curly braces, { or }, or equal sign, =, or # or ~ in a GIFT file (in a math question including TeX expressions) you must "escape" them by preceding them with a \ directly in front of each { or } or =. It is possible to use a replace program/macro/editor filter to do this conversion before importing to Moodle.
  • Want to change T/F type questions to multiple choice? Consider exporting the T/F questions as a GIFT file, then using a text editor to replace the (T) with (=True ~False). Perhaps change the title slightly so you will recognize the new questions.
  • Alphabetic case-sensitive comparison is disabled by default. If you need case-sensitive comparison for short answer questions (an unusual need), precede them with:
  $question->usecase = 1;

surrounded by blank lines.

Word processors and Spreadsheets tools that create GIFTs

Several contributors have used macros to generate GIFT files from a more familiar popular programs.

  • There are Word macros available for easily creating GIFT files. See this non-Moodle site for downloads and instructions for use.
  • There are several Excel spreadsheets for generating GIFT files. Several people have built upon other contributors work.
  • There are Open Office templates for generating GIFT files in Writer. These are located in the Quiz forum in theOOo template to write exams and convert to GIFT format thread.
    • The most recent for OO 2.x is "OOo2GIFT_Template_05.zip" postes 17 December 2005 by Enrique Castro.
    • An earlier version is "GIFT_template_OOo.zip" posted 22 March 2005 by Enrique Castro.
  • There is an easy to use on line multiple question generator at a4esl.org. Here you write your question(s) without formating marks, select Moodle and press the generate quiz button. This creates GIFT formatted text that can be pasted into a file for importing into Moodle.
    • The initial format requires fewer keystrokes (it uses line position and returns) than the GIFT format, so you should save time and be less likely to create invalid data.

See also