(* ::Package:: *) BeginPackage["SymExamLIN`"]; (* Author Dara O Shayda, March 2013 *) (* License http://www.apache.org/licenses/LICENSE-2.0.html *) LINPanel1::usage = "Matrix multiplication calculation panel"; LINPanel2::usage = "Transpose calculation panel"; LINPanel3::usage = "Determinant calculation panel"; readTitle::usage = "init and logo"; qInit::usage = "init stats"; qStart::usage = "start exam"; qPrint::usage = "Print exam clicks"; qStats::usage = "stats for exam clicks"; qSend::usage = "Send the clicks out"; qWrite::usage= "File IO for clicks"; qFetch::usage = "FETCH URL SOLUTION by Wayne Allen"; qFetch2::usage = "FETCH URL SOLUTION by Wayne Allen"; readName::usage="Get student name" getClicks::usage="remove me"; Begin["`Private`"]; (* Specifications per exam *) (* FIXME: this is not working ????? *) examIDString = "Ryerson Math Department, Prof. Tasic, Linear Algebra, Mar 3, 2013"; (* types of problems *) qArith=1; qGraphLine=2; qGraphLine=3; qPercentages=4; qFractions=5; qRatios=6; LINmatrices = "Linear Algebra"; qClicks = {{0, LINmatrices, True, 0}, {0, LINmatrices, True, 0}, {0, LINmatrices, True, 0}, {0, LINmatrices, True, 0}, {0, LINmatrices, True, 0}, {0, LINmatrices, True, 0},{0, LINmatrices, True, 0},{0, LINmatrices, True, 0},{0, LINmatrices, True, 0}}; qMagnification = 1.2; bigNumber = 1000102010004455; (* [[2]] told me, I told [[3]], [[4]] book, it is all [[5]] *) qNamesList={{"Boza", "he", "him", "his", "his"}, {"Dara", "he", "him", "his", "his"} , {"Jack", "he", "him", "his", "his"}, {"Ginger", "she", "her", "her", "hers"}, {"Wayne", "he", "him", "his", "his"}, {"Spomenka", "she", "her", "her", "hers"}, {"George", "he", "him", "his", "his"}, {"Kevin", "he", "him", "his", "his"}, {"Tina", "she", "her", "her", "hers"}, {"Lucia", "she", "her", "her", "hers"}, {"Ahmad", "he", "him", "his", "his"},{"Abaz", "he", "him", "his", "his"}}; qRandList[list0_]:=list0[[RandomInteger[{1, Length[list0]}]]] qCaps[x0_]:=Module[{x=x0}, x=Characters[x]; StringJoin[Join[{ToUpperCase[x[[1]]]}, Drop[x,1]]] ] qInit[]:= Module[{}, (* {clickNum, problemType, tryAgain, totalClicks} *) Table[qClicks [[i]][[1]] = 0;qClicks [[i]][[4]]=0;qClicks [[i]][[3]]=True,{i , 1, Length[qClicks]}]; ] (* only counts the True click *) qClick[n0_]:=Module[{n=n0}, qClicks[[n]][[1]] = qClicks[[n]][[1]]+Boole[qClicks[[n]][[3]]]; qClicks[[n]][[4]] = qClicks[[n]][[4]]+Boole[qClicks[[n]][[3]]]; ] qClickPlus[n0_]:=Module[{n=n0}, qClicks[[n]][[4]] = qClicks[[n]][[4]]+Boole[qClicks[[n]][[3]]]; qTryAgainNOT[n]; ] (* best put this after making ABCD to FALSE *) qTryAgain[n0_]:= Module[{n=n0}, qClicks[[n]][[3]] = True; ] qTryAgainNOT[n0_]:= Module[{n=n0}, qClicks[[n]][[3]] = False; ] getClicks[]:=qClicks readTitle[logo_,course_,prof_]:=DynamicModule[{x="",a, body,inputs, text=Null,studentID}, Manipulate[ Pane@"", "", TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,SynchronousUpdating->False, Initialization:>(Off[Import::nffil];Off[DeleteFile::nffil];qClicks = {{1, 0, -1, ""}, {2, 0, -1, ""}, {3, 0, -1, ""}, {4, 0, -1, ""}, {5, 0, -1, ""}, {6, 0, -1, ""},{7, 0, -1, ""},{8, 0, -1, ""},{9, 0, -1, ""},{10, 0, -1, ""}};qNum=0;studentID=""; DeleteFile[FileNameJoin[{$UserDocumentsDirectory,"DARADARADARA"<>"symbolix.txt"}]];DeleteFile[FileNameJoin[{$UserDocumentsDirectory,"id"<>"symbolix.txt"}];qNum=0;](*If[DayCount[dateIssued, DateList[]] > experationInterval, Exit[]];*);SetOptions[EvaluationNotebook[],PrivateNotebookOptions->{"PluginToolbarEnabled"->False}, DockedCells->Cell[BoxData[ToBoxes[Row[{Column[{Image[logo,ImageSize->100],course, prof},ItemSize->{20,Automatic}],PopupMenu[Dynamic[CurrentValue[EvaluationNotebook[],"Magnification"]],Range[0.5,3,0.5]]},Spacer[5]]]],"DockedCell"]];),Paneled->False] ] qStart[]:= Button["Start", qInit[]] qPrint[]:=Button["Results",Print[FromDigits[ToCharacterCode[Compress[qClicks]],1000]]] qStats[]:=Module[{body}, OpenerView[Button["Grade", Panel[Grid[Transpose[body],Alignment->Left]]], True] ] (* Currently there is a problem with SendMail[] in Mathematica 9.0 *) qSend[]:=Button["Send Answers",SendMail["To"->"dara@lossofgenerality.com","Subject"->"Example Message from CDF","Body"->ToString[qClicks],"UserName"->"symbolicexams@gmail.com","Server"->"smtp.gmail.com","Password"->"gilangilangilan", "PortNumber"->465,"EncryptionProtocol"->"SSL"]] (* Export works only if the CDF player is Enterprise type *) qWrite[]:= Button["Save Answers",Export["test.txt",qClicks]] qFetch[]:=Module[{status="",a, body,text}, Manipulate[ text=Dynamic[If[TrueQ[status==""], "", status]]; body={{Text[Style["Check your student ID",Red]],""},{"",""}}; Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{4,0.5}(*,ItemSize->20)*)],text,ImageMargins->1],DefaultOptions->{InputField->{ContinuousAction->True},FontSize->Large}]], {{a, 0,""}, Button["Send Answers",status="Answers Sent, Good Luck!";URLFetch["mathematica.lossofgenerality.com/test.php","Parameters"->{"Student"->ToString[studentID],"Exam"->examIDString,"Clicks"->ToString[qClicks]}]] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] ] qFetch2[]:= Button["Send Answers",URLFetch["mathematica.lossofgenerality.com/test.php","Parameters"->{"Student"->ToString[studentID],"Exam"->examIDString,"Clicks"->ToString[qClicks]}]] readName[]:=Module[{x=Null,a, body,inputs, text=Null}, Manipulate[ (* If has to use TrueQ[]!!! *) text=Dynamic[If[TrueQ[x==Null], "", "ID Registered: "<>ToString[x]]]; inputs=InputField[Dynamic[x], Expression, FieldHint->"Enter your ID"]; body={{inputs,Text[Style[examIDString,Red]]},{"",""}}; Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{4,0.5}(*,ItemSize->20)*)],text,ImageMargins->1],DefaultOptions->{InputField->{ContinuousAction->True},FontSize->Large}]], {{a, 0,""}, Button["Press To Register ID", studentID = x]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] ] qSign[a0_]:=Which[a0>0, "+"<>ToString[Abs[a0]], a0<0, "-"<>ToString[Abs[a0]], a0==0, "0"] qSign2[a0_]:=Which[a0>0, "+", a0<0, "-", a0==0, ""] qTrunc1[a0_]:=If[IntegerQ[Ceiling[100*a0]/100], Ceiling[100*a0]/100, N[Ceiling[100*a0]/100]] qTrunc2[a0_]:=N[Floor[100*a0]/100] qTrunc3[a0_]:=N[Ceiling[10*a0]/10] qTrunc4[a0_]:=N[Floor[10*a0]/10] (* It has to be DynamicModule or a b won't work *) solutionLINPanel1[a0_,b0_]:=DynamicModule[{a=a0,b=b0,col,row,Arows,Acols,Bcols,Brows,matA,matB,rowclr,colclr,A1,B1,a1,b1}, (* some code borrowed from Aby Brown *) Style[Manipulate[ If[col>Bcols,col=1;col=col]; If[row>Arows,row=1;row=row]; Arows = Dimensions[a][[1]]; Acols=Dimensions[a][[2]]; Bcols=Dimensions[b][[2]]; If[col>Bcols,col=1;col=col]; If[row>Arows,row=1;row=row]; Brows=Acols; matA=a; matB=b; rowclr=Lighter[Green,0.7]; colclr=Lighter[Blue,0.7]; Pane[ Text@Column[{ Item[Row[{Column[{Text@Style["X",Italic,18],MatrixForm[{Style[Grid[matA,Alignment->{Right,Bottom},Spacings->{1,0.5},Background->{None,row->rowclr}],16]}]},Alignment->Center], Column[{Text@Style["Y",Italic,18], MatrixForm[{Style[Grid[matB,Alignment->{Right,Bottom},Spacings->{1,0.5},Background->{col->colclr,None}],16]}]},Alignment->Center]}],ItemSize->{Automatic,7},Alignment->Center], Item[Row[{Text@Style["XY = ",Italic,18],MatrixForm[{Style[Grid[matA.matB,Alignment->{Right,Bottom},Spacings->{1,0.5},Background->{None,None,{{row,col}->Blend[{rowclr,colclr}]}},Frame->{col->colclr,row->rowclr}],16]}]}],ItemSize->{Automatic,10},Alignment->Center], Style[Column[{ Grid[{Prepend[Append[Riffle[Riffle[matA[[row]],Transpose[matB][[col]]],If[Acols==1,")(",{")(",") + ("}]],")"],"("]},Spacings->0,ItemSize->{Riffle[Table[Automatic,{Acols*2+1}],1.5],1.2},Alignment->Center,Background->{Prepend[Append[Riffle[Flatten[Table[{rowclr,colclr},{Acols}]],None],None],None]}]," = ", Grid[{Riffle[Map[Apply[Times,#]&,Partition[Riffle[matA[[row]],Transpose[matB][[col]]],2]]," + "]}]," = ", Grid[{{matA[[row]].Transpose[matB][[col]]}},ItemSize->{2.5,1.2},Background->Blend[{rowclr,colclr}]] },Alignment->Center],16] },Alignment->Center,Spacings->1,Frame->{{},True},FrameStyle->Lighter[Gray,0.5] ], ImageSize->{400,400}, Alignment->{Center,Center}], {{row,1,"row"},1,Dimensions[a][[1]],1,ImageSize->Tiny}, {{col,1,"column"},1,Dimensions[b][[2]],1,ImageSize->Tiny},"", ControlPlacement->Left, TrackedSymbols:>Manipulate, AutorunSequencing->{1,2,3,4,5}] , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification/1.5}] ] matrixstyle[mat_]:=Text[Style[NumberForm[Chop[MatrixForm[mat, TableSpacing->1.5, TableAlignments->{Center, Center}],.01],{3,2}],12]] LINPanel1[pn0_]:= Module[{pn=pn0,text,dima,a,b, matrices,A1=False,B1=False,C1=False,D1=False,answer, myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False }, dima=RandomInteger[{2,4}]; a = RandomInteger[{-5,5},{RandomInteger[{2,4}], dima}]; b = RandomInteger[{-5,5},{dima,RandomInteger[{2,4}]}]; Style[Manipulate[ text={ToString[pn]<>". Compute XY.\n"}; text2=StringJoin[ToString/@text]; answer="?"; matrices={{"\!\(\* StyleBox[\"X\",\nFontWeight->\"Bold\"]\)","\!\(\* StyleBox[\"Y\",\nFontWeight->\"Bold\"]\)"},{Text[Style[MatrixForm[a,TableSpacing->1.5, TableAlignments->{Center, Center}],12]],Text[Style[MatrixForm[b,TableSpacing->1.5, TableAlignments->{Center, Center}],12]]}}; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ Text[Style[MatrixForm[a.b*2,TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[RandomInteger[{-5,5},Dimensions[a.b]],TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[a.b,TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[a*2,TableSpacing->1.5, TableAlignments->{Center, Center}],12]] }; checks = {Checkbox[Dynamic[A1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[B1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[C1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[D1],Enabled->Dynamic[myEnabled]]}; (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; checksShuffled = Table[checks[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) {"A","B","C","D"}, (* First row/colum the proposed answers key *) answersShuffled, (* First row/colum the answer check boxes*) checksShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[{{Grid[matrices],Grid[Transpose[body],Alignment->Left,Spacings->{1,2}]},{Null,Null}}],Spacings->{Automatic,4}],answerStudent,ImageMargins->10]]], {{b,1,""}, (* initial value of a*) Grid[{{OpenerView[{Button["Try Again",qTryAgain[pn];dima=RandomInteger[{2,4}]; a = RandomInteger[{-5,5},{RandomInteger[{2,4}], dima}]; b = RandomInteger[{-5,5},{dima,RandomInteger[{2,4}]}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], ""}], OpenerView[{Button["Full Solution",qTryAgain[pn];state=Not[state]],solutionLINPanel1[a,b]},state]},{Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] solutionLINPanel2[a0_]:= DynamicModule[{MatrixA=a0,RowColor,ColumnColor,CellColor,NumberOfRows,NumberOfColumns,CurrentColumn,CurrentRow}, (* borrowed some code from Udo Lorz *) Style[Manipulate[ NumberOfRows=Dimensions[MatrixA][[1]]; NumberOfColumns=Dimensions[MatrixA][[1]]; With[{ RowColor=Lighter[Green,0.7],ColumnColor=Lighter[Blue,0.7],CellColor=Lighter[Red,0.7]}, Pane[ Text@Grid[{ {Row[{Style["X",Italic]," = "}], MatrixForm[{Grid[MatrixA,Alignment->{Right,Bottom},Spacings->{1,1}, Background->{CurrentColumn->ColumnColor,CurrentRow->RowColor,{{CurrentRow,CurrentColumn}->CellColor}}]}]}, {"",""}, {Row[{Superscript[Style["X",Italic],"T"]," = "}],MatrixForm[{Grid[Transpose[MatrixA],Alignment->{Right,Bottom},Spacings->{1,1},Background->{CurrentRow->RowColor,CurrentColumn->ColumnColor,{{CurrentColumn,CurrentRow}->CellColor}}]}]} },Alignment->{{Right,Left},{Center,Center}}], ImageSize->{350,450},Alignment->{Center,Center},BaseStyle->{FontSize->16}]], "", Grid[{ {}, {"current row",Dynamic@SetterBar[Dynamic@CurrentRow,Range[1,NumberOfRows]]}, {"current column",Dynamic@SetterBar[Dynamic@CurrentColumn,Range[1,NumberOfColumns]]} },Alignment->{{Right,Left},{Center,Center}},BaseStyle->11], {{CurrentRow,2},ControlType->None}, {{CurrentColumn,2},ControlType->None}, ControlPlacement->Left,TrackedSymbols:>{NumberOfRows,NumberOfColumns,CurrentRow,CurrentColumn}] , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification/1.5}] ] LINPanel2[pn0_]:= Module[{pn=pn0,text,dima,a,b, matrices,A1=False,B1=False,C1=False,D1=False,answer, myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False }, a = RandomInteger[{-9,9},{RandomInteger[{2,4}], RandomInteger[{2,4}]}]; Style[Manipulate[ text={ToString[pn]<>". Find the Transpose of X.\n"}; text2=StringJoin[ToString/@text]; answer="?"; matrices={{"\!\(\* StyleBox[\"X\",\nFontWeight->\"Bold\"]\)",Null},{Text[Style[MatrixForm[a,TableSpacing->1.5, TableAlignments->{Center, Center}],12]],""}}; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ Text[Style[MatrixForm[a*2,TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[RandomInteger[{-9,9},Dimensions[a]],TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[Transpose[a],TableSpacing->1.5, TableAlignments->{Center, Center}],12]], Text[Style[MatrixForm[a+1,TableSpacing->1.5, TableAlignments->{Center, Center}],12]] }; checks = {Checkbox[Dynamic[A1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[B1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[C1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[D1],Enabled->Dynamic[myEnabled]]}; (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; checksShuffled = Table[checks[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) {"A","B","C","D"}, (* First row/colum the proposed answers key *) answersShuffled, (* First row/colum the answer check boxes*) checksShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[{{Grid[matrices],Grid[Transpose[body],Alignment->Left,Spacings->{1,2}]},{Null,Null}}],Spacings->{Automatic,4}],answerStudent,ImageMargins->10]]], {{a,1,""}, (* initial value of a*) Grid[{{OpenerView[{Button["Try Again",qTryAgain[pn];dima=RandomInteger[{2,4}]; a = RandomInteger[{-9,9},{RandomInteger[{2,4}], RandomInteger[{2,4}]}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], ""}], OpenerView[{Button["Full Solution",qTryAgain[pn];state=Not[state]],solutionLINPanel2[a]},state]},{Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] solutionLINPanel3[a0_]:=DynamicModule[{matrix=a0, a,b,c,d,choose,A}, Manipulate[ matrixFromMinor=a_ b_-c_ d_->{{a,c},{d,b}}; array=Array[Subscript[A, ##]&,{3,3}]; minors=Map[Reverse,Minors[array],{0,1}]; getnumbers=Thread[Flatten[array]->Flatten[matrix]]; dividers=Dividers->{{True,False,True},False}; plusminus=If[choose==2||choose==5,-1,1]; {{x,y,z},{X,Y,Z}}=If[ choose<=3, {array[[choose]],minors[[choose]]}, {(Transpose@array)[[choose-3]],(Transpose@minors)[[choose-3]]} ]; Pane[ Text@Column[{ "\n", Text@Row[{"Expand along ",If[choose<4,"row ","column "], If[choose<4,choose,choose-3],":"}], "\n", Row[{Grid[array/.getnumbers,Dividers->{{True,False,False,True},False}]," = \n"}], Row[{ signchoice[choose,x],Abs[x],Grid[(X/.matrixFromMinor),dividers], signchoice[choose,-y],Abs[y],Grid[(Y/.matrixFromMinor),dividers], signchoice[choose,z],Abs[z],Grid[(Z/.matrixFromMinor),dividers], " = \n" }]/.getnumbers, Row[{ signchoice[choose,x],Abs[x],"(",X ,")", signchoice[choose,-y],Abs[y],"(",Y,")", signchoice[choose,z],Abs[z],"(",Z,")", " = \n" }]/.getnumbers, Row[{ plusminus x X,If[-plusminus y Y<0," - "," + "],Abs[-plusminus y Y],If[plusminus z Z<0," - "," + "],Abs[plusminus z Z], " = \n" }]/.getnumbers, Row[{ plusminus( x X - y Y+ z Z) }]/.getnumbers }],ImageSize->{400,400}], "expand along:", {{choose,1,"row"},{1->"1",2->"2",3->"3"},ControlType->SetterBar}, {{choose,4,"column"},{4->"1",5->"2",6->"3"},ControlType->SetterBar}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2} ] ] (* some code borrowed from George Beck *) signchoice[choose_,var_]:=If[ choose==2||choose==5, Switch[Sign[var],-1," + ", 1," - ", 0," + "], Switch[Sign[var],-1," - ", 1," + ", 0," + "] ] LINPanel3[pn0_]:= Module[{pn=pn0,text,dima,a,b, matrices,A1=False,B1=False,C1=False,D1=False,answer, myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False }, a = RandomInteger[{-5,5},{3, 3}]; Style[Manipulate[ text={ToString[pn]<>". Find the Determinant of X.\n"}; text2=StringJoin[ToString/@text]; answer="?"; matrices={{"\!\(\* StyleBox[\"X\",\nFontWeight->\"Bold\"]\)",Null},{Text[Style[MatrixForm[a,TableSpacing->1.5, TableAlignments->{Center, Center}],12]],""}}; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ Det[a]*2, Det[a]-5, Det[a], Det[a]+5 }; checks = {Checkbox[Dynamic[A1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[B1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[C1],Enabled->Dynamic[myEnabled]],Checkbox[Dynamic[D1],Enabled->Dynamic[myEnabled]]}; (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; checksShuffled = Table[checks[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) {"A","B","C","D"}, (* First row/colum the proposed answers key *) answersShuffled, (* First row/colum the answer check boxes*) checksShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[{{Grid[matrices],Grid[Transpose[body],Alignment->Left,Spacings->{1,2}]},{Null,Null}}],Spacings->{Automatic,4}],answerStudent,ImageMargins->10]]], {{a,1,""}, (* initial value of a*) Grid[{{OpenerView[{Button["Try Again",qTryAgain[pn];dima=RandomInteger[{2,4}]; a = RandomInteger[{-5,5},{3, 3}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], ""}], OpenerView[{Button["Full Solution",qTryAgain[pn];state=Not[state]],solutionLINPanel3[a]},state]},{Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] End[]; EndPackage[];