
Adam_Caudell wrote:I came across a demonstration that had code for a quiz generator, but cannot find it now. Does anyone have a template that they can share that is used to generate multiple versions of tests and quizzes?

x1=RandomInteger[{-9,9}];
y1=RandomInteger[{-9,9}];
x2=RandomInteger[{-9,9}];
y2=RandomInteger[{-9,9}];
marks=Table[j,{j,-10,10,1}];
If[x1==x2,x1=-9+RandomInteger[{1,4}];x2=RandomInteger[{1,4}]];
If[y1==y2,y1=-9+RandomInteger[{1,4}];y2=RandomInteger[{1,4}]];
mtop=y2-y1;
mbot=x2-x1;
g=GCD[Abs[mtop],Abs[mbot]];
mtop=mtop/g;
mbot=mbot/g;
m=mtop/mbot;
WrongChoices=Complement[{{mtop,-mbot,mtop x2-mbot y2},{mtop,mbot,mtop x2+mbot y2},{mtop,mbot,-(mtop x2-mbot y2)},{mtop,-mbot,-(mtop x2-mbot y2)},{mbot,mtop,mtop x2-mbot y2},{mbot,-mtop,mtop x2-mbot y2},{mbot,mtop,-(mtop x2-mbot y2)},{mbot,-mtop,-(mtop x2-mbot y2)},{mbot,mtop,mtop y2-mbot x2}},{mtop,mbot,mtop x2-mbot y2}];
Ch=Permutations[WrongChoices][[RandomInteger[{1,Length[Permutations[WrongChoices]]}]]];
f[x_]:=m x-m x2+y2;
FormattedAns={StringForm["`` x `` `` y = ``",mtop/.{1->"",-1->"-"},Positive[mbot]/.{True->"+",False->"-"},Abs[mbot]/.{1->"",-1->""},mtop x2-mbot y2],StringForm["`` x `` `` y = ``",Ch[[1,1]]/.{1->"",-1->"-"},Positive[Ch[[1,2]]]/.{True->"+",False->"-"},Abs[Ch[[1,2]]]/.{1->"",-1->""},Ch[[1,3]]],StringForm["`` x `` `` y = ``",Ch[[2,1]]/.{1->"",-1->"-"},Positive[Ch[[2,2]]]/.{True->"+",False->"-"},Abs[Ch[[2,2]]]/.{1->"",-1->""},Ch[[2,3]]],StringForm["`` x `` `` y = ``",Ch[[3,1]]/.{1->"",-1->"-"},Positive[Ch[[3,2]]]/.{True->"+",False->"-"},Abs[Ch[[3,2]]]/.{1->"",-1->""},Ch[[3,3]]]};
Choices=Permutations[FormattedAns][[RandomInteger[{1,Length[Permutations[FormattedAns]]}]]];
P=Plot[f[x],{x,-10,10},PlotRange->{-10,10},GridLines->{marks,marks},FrameTicks->{marks,marks,{},{}},
ImageSize->300,Frame->True];
P1=Graphics[{PointSize[.03],Point[{x1,y1}]}];
P2=Graphics[{PointSize[.03],Point[{x2,y2}]}];
L1=Graphics[{Thickness[.01],Line[{{0,-10},{0,10}}]}];
L2=Graphics[{Thickness[.01],Line[{{-10,0},{10,0}}]}];
DisplayForm[Grid[{{"1.) Find the equation of the line in standard form that passes through the given points and represents the line on the graph below.",SpanFromLeft},{Item[Show[P,P1,P2,L1,L2],Alignment->Center],SpanFromLeft},{StringForm["a.] `` ",Choices[[1]]],StringForm["b.] `` ",Choices[[2]]],StringForm["c.] `` ",Choices[[3]]],StringForm["d.] `` ",Choices[[4]]]}},Alignment->{Left},Spacings->{3,3},ItemSize->13]]Return to Mathematics and Statistics (Primary/Secondary)
Users browsing this forum: No registered users and 1 guest