Matching¶
Answer type: matching
The student pairs each item in one list with an item from another.
The minimum¶
$questions holds the left-hand items, $answers the right-hand ones. Pairing is by position: $questions[0] matches $answers[0].
Common Control:
$questions = array("`sin(0)`", "`cos(0)`", "`cos(pi)`")
$answers = array("`0`", "`1`", "`-1`")
No [matching] section
Earlier versions of this page showed a bracketed section with a pairs =
list. Neither exists. Both lists must be arrays; if either is missing the
question fails with Eeek! $questions or $answers is not defined or needs
to be an array.
Options¶
| Variable | Effect |
|---|---|
$questions |
left-hand items — required, must be an array |
$answers |
right-hand items, aligned by position — required, must be an array |
$matchlist |
overrides positional pairing: a comma-separated string with one entry per $questions item, each the 0-based index of its correct entry in $answers (e.g. "0,1,0" lets two questions share answer 0); an entry like 1 or 2 accepts either |
$questiontitle |
heading above the left column |
$answertitle |
heading above the right column |
$noshuffle |
"questions", "answers" or "all": which list keeps its listed order; values such as 1 or "yes" do nothing and both lists still shuffle |
$displayformat |
"select": each dropdown lists the answer text itself and the lettered right column is omitted (backticks are stripped, so math shows as plain text); "2columnselect" (any digit 1-9) does the same in N columns; "2columnstacked" splits both lists into N columns; "limwidth300" caps column width at 300 px |
Both lists are shuffled independently per student unless $noshuffle says otherwise. Answers are labelled a, b, c, … in the order the student sees them.
Distractors¶
$answers may be longer than $questions. The extra entries appear as options that pair with nothing — the usual way to stop a student solving the last pair by elimination.
Example¶
Common Control — setup:
$fn = array("`x^2`", "`x^3`", "`sqrt(x)`", "`1/x`")
$deriv = array("`2x`", "`3x^2`", "`1/(2 sqrt(x))`", "`-1/x^2`")
Question Text:
<p>Match each function with its derivative.</p>
Common Control, continued — answer and options:
$questions = $fn
$answers = $deriv
$questiontitle = "Function"
$answertitle = "Derivative"
See Also¶
- Multiple Choice — one correct option
- Multiple Answer — several correct options
- Common Options — hints and shared display options