## WeBWorK Problems

### Re: matching problems

by Zak Zarychta -
Number of replies: 0

On reflection I managed to solve the problem.

To ensure that no two problems with the same matching option were selected, each different question that has an identical matching option was grouped into an array.

One question from each group was selected by assigning each group a random selector Hence, all the matching options were covered and none were duplicated. For example

$randG1=random(0,n-1,1)$matchoptG1 = “matching option for group 1”;

@QgroupG1 = (#

“question_1”,

“question_2”,

“question_3”,

,...

“question_n”];

$randG1=random(0,n-1,1)$matchoptG2 = “matching option for group 2”;

@QgroupG2 = (#

“question_1”,

“question_2”,

“question_3”,

,...

“question_n”];

...

$randG1=random(0,n-1,1)$matchoptGN = “matching option for group N”;

@QgroupGN = (#

“question_1”,

“question_2”,

“question_3”,

,...

“question_n”];

####### snip ######

#

$ml->qa( "$QgroupG1[$randGp1]",”$matchoptG1”,
"$QgroupG2[$randGp2]",”$matchoptG2”, "$QgroupGN[$randGpN]",”$matchoptGN”