Am 03.03.2009 um 14:17 schrieb Curious Learn:
As I mentioned earlier, I am trying to use Context to make a multiple choice test. I have two questions.
(1) Suppose I want to get a list of answers to the the multiple choice questions. One way I can think of doing this is by assigning a label to the CORRECT answer as done in the following code and then referring to that label. Is there a way these labels can be generated automatically, instead of hardcoding them as I have done below?
defineenumeration[problem][text= ,location=inleft] \setupenumerations[problem][stopper=)]
\defineitemgroup[choices][levels=1] \setupitemgroup[choices][1][a,packed] \nextrandom
You don't need \nextrandom any longer, it's fixed with the last beta. \newcounter\choicecounter \define[1]\Rightitem {\doglobal\increment\choicecounter \startitem[\choicecounter]#1\stopitem} \define[1]\Wrongitem {\startitem#1\stopitem} \processbetween{rightitem}\Rightitem \processbetween{wrongitem}\Wrongitem
\starttext
\problem This is the first question. \startchoices \startitem This is incorrect answer 1. \stopitem \startitem This is a wrong answer too. \stopitem \startitem[1] This is the CORRECT answer. \stopitem \startitem Yet another wrong answer. \stopitem
\startrightitem This is the CORRECT answer. \stoprightitem \startwrongitem Yet another wrong answer. \stopwrongitem
\stopchoices
\problem This is the second question. \startchoices \startitem[2] This is the CORRECT answer. \stopitem \startitem This is a wrong answer too. \stopitem \startitem This is not a correct choice. \stopitem \startitem Yet another wrong answer. \stopitem \stopchoices
Answers to the questions
\in[1]
\in[2]
\stoptext
(2) When I add the option "random" to the itemgroup (\setupitemgroup[choices][1][a,packed,random]) then as expected the choices are listed in a random order. However, the label does not change with the choice listing. I want the reference to be attached to the CORRECT answer, which changes its position with random option. Is there a way to have the reference reflect the letter corresponding to the correct answer.
The labels change but they're always one run behind the current order. You can use a fixed random order for the items (the don't change after each new run) with '\setupsystem[random=3456]', you can change the order when you user another number. Wolfgang