From: thetrinity Date: Tue, 13 Jan 2004 14:32:18 +0000 (+0000) Subject: Implemented Matching Questions. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a9981ba6194c438aace048e9fc3f8130a3155542;p=moodle.git Implemented Matching Questions. --- diff --git a/lang/en/help/quiz/formatgift.html b/lang/en/help/quiz/formatgift.html index 8b5873eba2..abeef4b1fc 100644 --- a/lang/en/help/quiz/formatgift.html +++ b/lang/en/help/quiz/formatgift.html @@ -2,7 +2,7 @@

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.

@@ -39,7 +39,23 @@ The sun rises in the east.{T} -

Numerical:
+

Matching:
+ Matching pairs begin with an equal sign (=) and are seperated 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, 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 {#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}
 
@@ -96,7 +112,7 @@ within percent signs (e.g., %50%). This option can be combined with feedback com
      =%25%Bethlehem#He was born here, but not raised here.}

Note that the last two examples are essentially the same question, first as multiple choice and then as short answer.

-

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.

+

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.

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.

@@ -123,4 +139,4 @@ The Multiple Answers option is used for multiple choice questions when two or mo

CREDITS

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.

-

GIFT documentation by Paul Tsuchido Shew, 10 Jan 2004.

\ No newline at end of file +

GIFT documentation by Paul Tsuchido Shew, 13 Jan 2004.

\ No newline at end of file diff --git a/mod/quiz/format/gift/examples.txt b/mod/quiz/format/gift/examples.txt index a917f8e682..39046868f3 100644 --- a/mod/quiz/format/gift/examples.txt +++ b/mod/quiz/format/gift/examples.txt @@ -52,6 +52,21 @@ The sun rises in the east.{T} // ===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}. @@ -123,6 +138,23 @@ What two people are entombed in Grant's tomb? { // 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! @@ -146,4 +178,4 @@ 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. -} \ No newline at end of file +} diff --git a/mod/quiz/format/gift/format.php b/mod/quiz/format/gift/format.php index 993a9a9b15..286e77d5a1 100755 --- a/mod/quiz/format/gift/format.php +++ b/mod/quiz/format/gift/format.php @@ -1,12 +1,9 @@ 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 @@ -164,10 +138,15 @@ class quiz_file_format extends quiz_default_format { 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 @@ -244,6 +223,48 @@ class quiz_file_format extends quiz_default_format { $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 "

$text

Found markers for Matching format + (= and ->), but too few answers -- must be at least 3.
+ Found $countanswers answers in answertext."; + } + return false; + break; + } + + foreach ($answers as $key => $answer) { + $answer = trim($answer); + if (strpos($answer, "->") <= 0) { + if ($this->displayerrors) { + echo "

$text

Error processing Matching question.
+ 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;