|
'Matching list' basic example
(for more advanced information on matching lists, see Match.pm)
To obtain the problem:
WARNINGS µ¦å{h
{viewSource(setMAAtutorial/matchinglistexample.pg)}
- Since this is a matching questions, we do not usually wish to tell students which parts of the matching question have been answered correctly and which are incorrect. That is too easy. To accomplish this we set the following flag
$showPartialCorrectAnswers to 0 (line 11).
- Saying that
$ml$ml is a scalar variable which contains a pointer to the match list object, but you can think of the match list object as being shoe horned into the variable $ml. You need to remember that $ml Some people use the convention $o_ml to remind them that the variable contains an object, but for short problems that is probably not necessary.
An object contains both data (in this case the list of questions and answers) and subroutines (called methods) for manipulating that data.
- The construction
$ml ->qa(..list of alternating questions and matching answers ...). Asks the object $ml to store the matching questions and answers given in the argument in its private data (lines 35 and 45). Note that that you can call qa() more than once with a match list and it will add new questions. This is not true with all objects. Some objects will overwrite previous questions if qa() is used more than once.
- The construction
$ml->choose(3) asks the object to choose three question/answer pairs from its private data and
-
$out = $ml->print_q() asks the object to store a string of the formatted questions in the variable $out. Calling \{ $ml->print_q() \} within BEGIN_TEXT / END_TEXT statements will just append the formatted questions to the ouput text that the student sees (line 60).
-
$out = $ml->print_a() asks the object to store a string of the formatted answers in the variable $out. \{ $ml->print_a() \} can be used just like above to append a string of the formatted answers to the output text seen by the student (line 62).
-
ANS is needed to compare the students answers to the correct answers (line 66).
- The answer evaluator
str_cmp is just one of many possible answer evaluators from which to choose, each of which specifies a different method for comparing the correct answers to the students answers. str_cmp is almost always used with matching lists since the correct answers will always be a letter indicating one of the possible answers (line 66).
|