<p>GIFT is the most comprehensive import format available for importing
Moodle quiz questions from a text file. It supports Multiple-Choice,
- True-False, Short Answer and Numerical questions, as well as insertion
+ 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.</p>
The sun rises in the east.{T}</pre>
- <p><u>Numerical:</u><br>
+ <p><u>Matching:</u><br />
+ Matching pairs begin with an equal sign (=) and are seperated by this symbol "->". There must be at least three matching pairs.</p>
+
+<pre> 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
+ }</pre>
+<p>Matching questions do not support feedback or percentage answer weights.</p>
+ <p><u>Numerical:</u><br />
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, seperated 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 <u>{#2:0.5}</u>. 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.</p>
<pre> When was Ulysses S. Grant born? {#1822}
=%25%Bethlehem#He was born here, but not raised here.}</pre>
<p>Note that the last two examples are essentially the same question, first as multiple choice and then as short answer.</p>
-<p><small>Note that it is possible to specify percentage answer weights that are NOT available through the browser interface. Such answer-weights will calculate correctly (according to the value assigned when imported), and will appear normal to students taking the test. But such answer-weights will not display correctly to teachers when editing them through Moodle's Edit Question interface. The pull-down menu only allows certain fixed values, and if the answer-weight does not exactly match one of those predetermined values, then it will not display correctly. If you edit such a question through the browser interface, the answer weight will change to that displayed.</small></p>
+<p><font size="-1">Note that it is possible to specify percentage answer weights that are NOT available through the browser interface. Such answer-weights will calculate correctly (according to the value assigned when imported), and will appear normal to students taking the test. But such answer-weights will not display correctly to teachers when editing them through Moodle's Edit Question interface. The pull-down menu only allows certain fixed values, and if the answer-weight does not exactly match one of those predetermined values, then it will not display correctly. If you edit such a question through the browser interface, the answer weight will change to that displayed.</font></p>
<p><u>Multiple Answers:</u><br />
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.</p>
<p></p>
<h3>CREDITS</h3>
<p>This filter was written through the collaboration of numerous members of the Moodle community. It was originally based on the missingword format, which included code from Martin Dougiamas, Thomas Robb and others. Paul Tsuchido Shew wrote this filter in December 2003 incorporating community suggestions for a more robust question format. The name was conceived as an acronym for "General Import Format Technology" or something like that, but it's too long for a simple filter like this, so it just GIFT.</p>
- <p><small>GIFT documentation by Paul Tsuchido Shew, 10 Jan 2004.</small></p>
\ No newline at end of file
+ <p><font size="-1">GIFT documentation by Paul Tsuchido Shew, 13 Jan 2004.</font></p>
\ No newline at end of file
// ===Numerical===
+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
+ }
+
+// ===Numerical===
+
When was Ulysses S. Grant born? {#1822}
What is the value of pi (to 3 decimal places)? {#3.1415:0.0005}.
// EXAMPLES FROM gift/format.php
//-----------------------------------------//
+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:5}
+
+Match the following countries with their corresponding
+capitals.{=Canada->Ottawa =Italy->Rome =Japan->Tokyo}
+
+//-----------------------------------------//
+// MORE COMPLICATED EXAMPLES
+//-----------------------------------------//
+
::Grant's Tomb::Grant is {
~buried#No one is buried there.
=entombed#Right answer!
=1822:0 #Correct! 100% credit
=%50%1822:2 #He was born in 1822.
You get 50% credit for being close.
-}
\ No newline at end of file
+}
<?php // $Id$
//
///////////////////////////////////////////////////////////////
-// GIFT
-//
-// The GIFT import filter is an easy to use method for teachers
-// writing questions as a text file. It supports true-false,
-// short answer, multiple-choice and numerical questions, as well
-// as insertion of a blank line for the missing word format.
+// The GIFT import filter was designed as an easy to use method
+// for teachers writing questions as a text file. It supports most
+// question types and the missing word format.
//
// Multiple Choice / Missing Word
// Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}
// Who's buried in Grant's tomb?{=no one =nobody}
// Numerical
// When was Ulysses S. Grant born?{#1822:5}
+// Matching
+// Match the following countries with their corresponding
+// capitals.{=Canada->Ottawa =Italy->Rome =Japan->Tokyo}
//
// Comment lines start with a double backslash (//).
// Optional question names are enclosed in double colon(::).
// Answer feedback is indicated with hash mark (#).
// Percentage answer weights immediately follow the tilde (for
// multiple choice) or equal sign (for short answer and numerical),
-// and are enclosed in percent signs (% %). Below are more
-// complicated examples with various options and formatting styles.
-//
-// ::Grant's Tomb::Grant is {
-// ~buried#No one is buried there.
-// =entombed#Right answer!
-// ~living#We hope not!
-// } in Grant's tomb.
-//
-// Difficult multiple choice question.{
-// ~wrong answer #comment on wrong answer
-// ~%50%half credit answer #comment on answer
-// =full credit answer #well done!}
-//
-// ::Jesus' hometown (Short answer ex.):: Jesus Christ was from {
-// =Nazareth#Yes! That's right!
-// =%75%Nazereth#Right, but misspelled.
-// =%25%Bethlehem#He was born here, but not raised here.
-// }.
-//
-// //comment about questions below (this line ignored by filter)
-// ::Numerical example::
-// When was Ulysses S. Grant born? {#
-// =1822:0 #Correct! 100% credit
-// =%50%1822:2 #He was born in 1822.
-// You get 50% credit for being close.
-// }
+// and are enclosed in percent signs (% %). See docs and examples.txt for more.
//
// This filter was written through the collaboration of numerous
// members of the Moodle community. It was originally based on
if ($answertext{0} == "#"){
$question->qtype = NUMERICAL;
- } elseif (strstr($answertext, "~") !== false) {
+ } elseif (strpos($answertext, "~") !== false) {
// only Multiplechoice questions contain tilde ~
$question->qtype = MULTICHOICE;
+ } elseif (strpos($answertext, "=") !== false
+ AND strpos($answertext, "->") !== false) {
+ // only Matching contains both = and ->
+ $question->qtype = MATCH;
+
} else { // either TRUEFALSE or SHORTANSWER
// TRUEFALSE question check
$question->image = ""; // No images with this format
return $question;
break;
+
+ case MATCH:
+ $answers = explode("=", $answertext);
+ if (isset($answers[0])) {
+ $answers[0] = trim($answers[0]);
+ }
+ if (empty($answers[0])) {
+ array_shift($answers);
+ }
+
+ $countanswers = count($answers);
+ if ($countanswers < 3) {
+ if ($this->displayerrors) {
+ echo "<P>$text<P>Found markers for Matching format
+ (= and ->), but too few answers -- must be at least 3.<br />
+ Found <u>$countanswers</u> answers in answertext.";
+ }
+ return false;
+ break;
+ }
+
+ foreach ($answers as $key => $answer) {
+ $answer = trim($answer);
+ if (strpos($answer, "->") <= 0) {
+ if ($this->displayerrors) {
+ echo "<P>$text<P>Error processing Matching question.<br />
+ Improperly formatted answer: $answer";
+ }
+ return false;
+ break 2;
+ }
+
+ $marker = strpos($answer,"->");
+ $question->subquestions[$key] = addslashes(trim(substr($answer, 0, $marker)));
+ $question->subanswers[$key] = addslashes(trim(substr($answer, $marker+2)));
+
+ } // end foreach answer
+
+ $question->defaultgrade = 1;
+ $question->image = ""; // No images with this format
+ return $question;
+ break;
case TRUEFALSE:
$answer = $answertext;