(* ::Package:: *) BeginPackage["Symbexv2POG230`"]; (* Author Dara O Shayda, Nov 2012 - Present *) qPanel1::usage = "Sample question"; qPanel2::usage = "Sample question"; qPanel3::usage = "Sample question"; qPanel4::usage = "Sample question"; qPanel5::usage = "Sample question"; qPanel6::usage = "Sample question"; qPanel7::usage = "Sample question"; qPanel8::usage = "Sample question"; qSend::usage = "Send the clicks out"; qSendLocal::usage = "Send the clicks out"; readName::usage="read student ID"; readTitle::usage="read LOGO"; Begin["`Private`"]; examIDString = "\!\(\* StyleBox[\"POG230\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\",\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\" \",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\"Sept\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\" \",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\"2014\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\",\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\" \",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\"Prof\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\".\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\" \",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\"Daniel\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\" \",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\"Rubenson\",\nFontWeight->\"Bold\"]\)"; examIDString2 = "POG230, Sept 2014, Prof.Daniel Rubenson"; examName = "Probability Module"; examName2 = "Probability"; 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"}}; qNumList={{"one",1}, {"two",2}, {"three",3}, {"four",4}, {"five",5}, {"six",6}, {"seven",7}, {"eight",8}, {"nine",9}, {"ten",10}}; qColorList={"red", "green", "blue", "yellow", "black", "white", "pink", "brown", "purple"}; qRandList[list0_]:=list0[[RandomInteger[{1, Length[list0]}]]] qCaps[x0_]:=Module[{x=x0}, x=Characters[x]; StringJoin[Join[{ToUpperCase[x[[1]]]}, Drop[x,1]]] ] (* only counts the True click *) qClick[n0_]:=DynamicModule[{n=n0}, qClicks[[n]][[2]] = 1 ; ] qClickPlus[n0_]:=DynamicModule[{n=n0}, qClicks[[n]][[3]] = 1; ] qTryAgainNOT[n_]:="" qNum = 0; (* number of questions *) qFlush[text_,id_]:=Module[{s,fname}, (*fname=FileNameJoin[{$TemporaryDirectory,StringReplace[DateString[], {" "->"_", ":"->"_"}]<>"symbolix.txt"}];*) fname=FileNameJoin[{$UserDocumentsDirectory,id<>StringReplace[DateString[], {" "->"_", ":"->"_"}]<>"symbolix.txt"}]; s=OpenWrite[fname]; Write[s,text]; {Close[s], fname} ] qFlushLAN[text_]:=Module[{s,fname}, fname=FileNameJoin[{"\\\\trinity.arts.ryerson.ca\\artslabshare\\dropbox","symbolix.txt"}]; s=OpenWrite[fname]; Write[s,text]; Close[s] ] qFlush2[dir_, prefix_,text_]:=Module[{s,fname}, fname=FileNameJoin[{dir,prefix<>"symbolix.txt"}]; s=OpenWrite[fname]; Write[s,text]; Close[s] ] qSend[]:=DynamicModule[{status="",a, body,text,ret1,ret2,tmp="",msg,res=False, track,res2,arg,Gg2, Gg3}, Manipulate[ (*g2 = Refresh[CheckboxBar[Range[qNum]*qClicks[[1;;qNum,2]],Range[qNum], Appearance->"Vertical",Enabled->False],UpdateInterval->1];*) Refresh[Gg2=qClicks,UpdateInterval->1,TrackedSymbols:>{qClicks}]; Refresh[Gg3=qClicks[[1;;qNum,2]],UpdateInterval->1,TrackedSymbols:>{qClicks}]; text=Dynamic[If[studentID=="", "Student Unidentified", "ID="<>studentID]<>"\n"<>status]; body={{Dynamic[If[res==True,Text[Style["Checked Marks Indicate Correct Answers\n"<>"\nTo Track this test: email "<>ToString[track]<>", "<>IntegerString[Hash[ToString[Gg2]<>ToString[track]<>"Mehran1339","MD5"],16]<>" to Deidre Lam \n"<>"Test results stored in file: "<>res2[[2]],Red,Background->Yellow]], ""]],Dynamic[If[res==True,CheckboxBar[Range[qNum]*Gg3,Range[qNum], Appearance->"Vertical",Enabled->False], ""]], Dynamic[Which[(Mean[Gg3] >= 0.8)&& (res == True), "\n\!\(\* StyleBox[\"Congratulations\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"!\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"You\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"passed\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"the\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<> examName <>" \!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"..\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\".\",\nFontColor->RGBColor[1, 0, 0]]\)\n\!\(\* StyleBox[\"Grade\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<>ToString[Ceiling[qTrunc4[Mean[Gg3]]*100]],(Mean[Gg3] < 0.8)&& (res == True), "\n \!\(\* StyleBox[\"Please\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"study\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"the\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<> examName <>" \!\(\* StyleBox[\"and\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"write\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"this\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"test\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"again\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\".\",\nFontColor->RGBColor[1, 0, 0]]\)\n\!\(\* StyleBox[\"Grade\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]\) "<>ToString[Ceiling[qTrunc4[Mean[Gg3]]*100]],True,""]]},{"","",""}}; 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,""},Dynamic[ Button["Send Answers",res=True; arg=studentID<>" , "<>examName2<>" , "<>ToString[Ceiling[qTrunc4[Mean[Gg3]]*100]]<>" , "<>ToString[Gg2]<>" , "<>examIDString2<>" , "<>DateString[]<>" , "<>ToString[track]<>" , "<>IntegerString[Hash[ToString[Gg2]<>ToString[track]<>"gilan1339","MD5"],16];res2=qFlush[arg,studentID]; URLFetch["http://symbolicexams.lossofgenerality.com/wp-content/plugins/test-receiver/results.php","Parameters"->{"results"->studentID<>" , "<>examName2<>" , "<>ToString[Ceiling[qTrunc4[Mean[Gg3]]*100]]<>" , "<>ToString[Gg2]<>" , "<>examIDString2<>" , "<>DateString[]<>" , "<>ToString[track]<>" , "<>IntegerString[Hash[ToString[Gg2]<>ToString[track]<>"Mehran1339","MD5"],16]},"ReadTimeout"->10,"ConnectTimeout"->50,"Method"->"POST"]; status="Answers Sent, Good Luck!\n"(*<>ToString[res2[[1]]]*);Clear["Global`*"];ClearAll[qClickPlus,qClick,readName] ]] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,SynchronousUpdating->False,Initialization:>((*qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}};*)track=RandomInteger[{100000,900000}];)] ] 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->200],course, prof},ItemSize->{20,Automatic}],PopupMenu[Dynamic[CurrentValue[EvaluationNotebook[],"Magnification"]],Range[0.5,3,0.5]]},Spacer[5]]]],"DockedCell"]];),Paneled->False] ] qSendLocal[dir_]:=Module[{status="",a, body,text,ret1,ret2,tmp="",msg,g, res=False, track}, Manipulate[ g=qClicks; g2 = Refresh[CheckboxBar[Range[qNum]*qClicks[[1;;qNum,2]],Range[qNum], Appearance->"Vertical",Enabled->False],UpdateInterval->1]; text=Dynamic[If[TrueQ[studentID==""], "Student Unidentified", "ID="<>studentID]<>"\n"<>status]; body={{Dynamic[If[res==True,Text[Style["Checked Marks Indicate Correct Answers\n",Red]], ""]],Dynamic[If[res==True,g2, ""]], Dynamic[Which[(Mean[g[[1;;qNum,2]]] > 0.8)&& (res == True), "\n\!\(\* StyleBox[\"Congratulations\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"!\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"You\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"passed\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"the\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"Integers\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"module\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\".\",\nFontColor->RGBColor[1, 0, 0]]\)\n\!\(\* StyleBox[\"Grade\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<>ToString[Ceiling[qTrunc4[Mean[g[[1;;qNum,2]]]]*100]],(Mean[g[[1;;qNum,2]]] < 0.8)&& (res == True), "\n \!\(\* StyleBox[\"Please\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"study\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"the\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<> examName <>" \!\(\* StyleBox[\"and\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"write\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"this\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"test\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\" \",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\"again\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\".\",\nFontColor->RGBColor[1, 0, 0]]\)\n\!\(\* StyleBox[\"Grade\",\nFontColor->RGBColor[1, 0, 0]]\)\!\(\* StyleBox[\":\",\nFontColor->RGBColor[1, 0, 0]]\) "<>ToString[Ceiling[qTrunc4[Mean[g[[1;;qNum,2]]]]*100]],True,""]] },{"","",""}}; 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",res=True;res2=qFlush2[dir, studentID<> StringReplace[DateString[], {" "->"_", ":"->"_"}],studentID<>" , "<>examName2<>" , "<>ToString[Ceiling[qTrunc4[Mean[g[[1;;qNum,2]]]]*100]]<>" , "<>ToString[qClicks]<>" , "<>examIDString2<>" , "<>DateString[]];status="Answers Sent, Good Luck!\n"; Clear["Global`*"];ClearAll[qClickPlus,qClick,readName] ] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None,SynchronousUpdating->False,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] ] readName[]:=DynamicModule[{x="",a, body,inputs, text=Null,studentID2}, Manipulate[ (* If has to use TrueQ[]!!! *) text=Dynamic[If[TrueQ[x==Null], "", "ID Registered: "<>studentID2]]; inputs=InputField[Dynamic[x], String, FieldHint->"Enter your ID"]; body={{inputs,Text[Style[examName<>"\n"<>examIDString,Red]]},{"",""}}; Refresh[studentID=studentID2 ,UpdateInterval->2,TrackedSymbols:>{studentID2}]; 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", studentID2 = x;studentID=studentID2]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,SynchronousUpdating->False, Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}};qNum=0;studentID2="";studentID="")] ] 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] qTrunc5[a0_]:=N[Round[10*a0]/10] 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, ""] qSign3[a0_]:=Which[a0>0, "+"<>ToString[Abs[a0]], a0<0, "-"<>ToString[Abs[a0]], a0==0, "-0"] qSign4[a0_]:=Which[a0>0, "+"<>ToString[Abs[a0]], a0<0, "-"<>ToString[Abs[a0]], a0==0, "+0"] qSign5[a0_]:=Which[a0>0, "+"<>ToString[Abs[a0],StandardForm], a0<0, "-"<>ToString[Abs[a0],StandardForm], a0==0, ""] qSign6[a0_]:=Which[a0==1, "",a0>0, "+"<>ToString[Abs[a0],StandardForm], a0<0, "-"<>ToString[Abs[a0],StandardForm], a0==0, ""] not0[x_]:=If[x==0, 1, x] threeDifferent[list_]:=Module[{i,j,k}, i=1;j=1;k=1; While[i==j||j==k||i==k, i=RandomInteger[{1, Length[list]}];j=RandomInteger[{1, Length[list]}];k=RandomInteger[{1, Length[list]}];]; {list[[i]], list[[j]], list[[k]]} ] twoDifferent[list_]:=Module[{i,j}, i=1;j=1; While[i==j, i=RandomInteger[{1, Length[list]}];j=RandomInteger[{1, Length[list]}];]; {list[[i]], list[[j]]} ] qPanelsolution1[vars_]:=DynamicModule[{body,a,b,c,d,m,n,x,num1, num2, num3}, {num1, num2, num3, a,b,c, d}=vars; body={{ "# of prizes="<>ToString[num1[[2]]+num2[[2]]+num3[[2]]], "Total number of tickets="<>ToString[d[[2]]*100], "Probability of winning a prize="<>ToString[ToString[(num1[[2]]+num2[[2]]+num3[[2]])]/ToString[(d[[2]]*100)],TraditionalForm]<>If[Denominator[(num1[[2]]+num2[[2]]+num3[[2]])/(d[[2]]*100)]==(d[[2]]*100),"","="<>ToString[(num1[[2]]+num2[[2]]+num3[[2]])/(d[[2]]*100),TraditionalForm]] }, {Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation1[pn_, vars_]:=Module[{variations,a,b,c,d,m,n,x,num1, num2, num3}, {num1, num2, num3, a,b,c, d}=vars; variations={{"At an annual Christmas raffle, there are "<>num1[[1]]<>" top prizes of $"<>ToString[a]<>", "<>num2[[1]]<>" $"<>ToString[b]<>" prizes and "<>num3[[1]]<>" $"<>ToString[c]<>" prizes.If "<>d[[1]]<>" hundred tickets were sold, what is the probability of wining a prize?" } }; text=ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers1[vars_]:=Module[{a,b,c,d,m,n,lhs,rhs,nn,xx,sols,x,num1, num2, num3}, {num1, num2, num3, a,b,c, d}=vars; {ToString[(num1[[2]]+num2[[2]]+num3[[2]])/(d[[2]]*200),TraditionalForm],ToString[1/(d[[2]]*100),TraditionalForm],ToString[(num1[[2]]+num2[[2]]+num3[[2]])/(d[[2]]*100),TraditionalForm],ToString[(num2[[2]]+num3[[2]])/(d[[2]]*100),TraditionalForm]} ] qPanelTRYAGAIN1[]:=Module[{a,b,c,d,m,n,x,num1, num2, num3}, num1=qNumList[[RandomInteger[{1,Length[qNumList]}]]]; num2=qNumList[[RandomInteger[{1,Length[qNumList]}]]]; num3=qNumList[[RandomInteger[{1,Length[qNumList]}]]]; a=RandomInteger[{7,10}]*1000; b=a-RandomSample[{1000,2000,3000}][[1]]; c=b-RandomSample[{1000,2000,3000}][[1]]; d=qNumList[[RandomInteger[{1,Length[qNumList]-1}]]]; (* do not use 10 *) {num1, num2, num3, a,b,c, d} ] qPaneHint1[vars_]:=Module[{body}, body={{ "P(prizes)="<>ToString["number of prizes"/"total number of tickets", TraditionalForm], "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR1[]:="" qPanel1[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN1[]; text=qPanelVariation1[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers1[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR1[]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN1[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint1[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution1[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN1[]; text=qPanelVariation1[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers1[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR1[]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] qPanelsolution2[vars_]:=DynamicModule[{body,a,b,c,d,m,n,x,c1,c2,c3,c4,c5,p1,p2}, {a,b,c, c1,c2,c3,c4,c5}=vars; p1=Which[c4 == c1, a, c4==c2, b, c4==c3, c]; p2=Which[c5 == c1, a, c5==c2, b, c5==c3, c]; body={{ ToString[a]<>" "<>c1<>", "<>ToString[b]<>" "<>c2<>", "<>ToString[c]<>" "<>c3, "Total: "<>ToString[a+b+c]<>" balloons", "P(a "<>c4<>" balloon & "<>"a "<>c5<>" balloon) = P("<>c4<>" balloon)\[Cross]"<>"P("<>c5<>" balloon)", "="<>ToString[p1/ToString[a+b+c], TraditionalForm]<>"\[Cross]"<>ToString[p2/(ToString[a+b+c]-1), TraditionalForm]<>"="<>ToString[(p1*p2)/((a+b+c)*(a+b+c-1)), TraditionalForm] }, {Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation2[pn_, vars_]:=Module[{variations,a,b,c,d,m,n,x,c1,c2,c3,c4,c5}, {a,b,c, c1,c2,c3,c4,c5}=vars; variations={{"A row of inflated balloons sits along a wall. "<>ToString[a]<>" are "<>c1<>", "<>ToString[b]<>" are "<>c2<>" and "<>ToString[c]<>" are "<>c3<>". A person blind-folded and throws dart at the balloons. If two balloons are pierced consecutively, determine the probability that the first balloon hit is "<>c4<>" followed by a "<>c5<>" balloon." } }; text=ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers2[vars_]:=Module[{a,b,c,d,m,n,lhs,rhs,nn,xx,sols,x,c1,c2,c3,c4,c5,p1,p2}, {a,b,c, c1,c2,c3,c4,c5}=vars; p1=Which[c4 == c1, a, c4==c2, b, c4==c3, c]; p2=Which[c5 == c1, a, c5==c2, b, c5==c3, c]; {ToString[(p1*p2)/((a+b+c)*(a+b+c+1)), TraditionalForm],ToString[(p1*p2)/((a+b+c)*(a+b+c)), TraditionalForm],ToString[(p1*p2)/((a+b+c)*(a+b+c-1)), TraditionalForm],ToString[(p1)/((a+b+c)*(a+b+c-1)), TraditionalForm]} ] qPanelTRYAGAIN2[]:=Module[{a,b,c,d,m,n,x,c1,c2,c3,c4,c5,colors}, {c1, c2, c3}=threeDifferent[qColorList]; colors={c1, c2, c3}; {c4,c5}=twoDifferent[colors]; a=RandomInteger[{3,6}]; b=a+RandomInteger[{1,3}]; c=b+RandomInteger[{2,4}]; {a,b,c, c1,c2,c3,c4,c5} ] qPaneHint2[vars_]:=Module[{body}, body={{ "P(A and B) = P(A)\[Times]P(B)", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR2[]:="" qPanel2[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN2[]; text=qPanelVariation2[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers2[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR2[]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN2[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint2[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution2[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN2[]; text=qPanelVariation2[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers2[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR2[]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] qPanelsolution3[vars_]:=DynamicModule[{body,a,b,c,d,m,n,x,c1,c2,c3,c4,c5,p1,p2,list,sumTable,ctr=0}, {a,b}=vars; sumTable=Table[i+j,{i,1,6},{j,1,6}]; list=DeleteCases[Flatten[Table[If[a<=sumTable[[i]][[j]]<=b, ctr+=1;{i+1, j+1}->Pink],{i,1,6},{j,1,6}],1],Null]; body={{ "Sum table:", Grid[Table[If[ i==0&&j==0, "",i+j],{i,0,6},{j,0,6}],Frame->All,Background->{{LightBlue},{LightBlue}}], "Count the number of entries between "<>ToString[a]<>" and "<>ToString[b]<>":", Grid[Table[If[ i==0&&j==0, "",i+j],{i,0,6},{j,0,6}],Frame->All,Background->{{LightBlue},{LightBlue},list}], "Count="<>ToString[ctr]<>", total=36 sums", If[b==12, "P("<>ToString[a]<>" or above)="<>ToString[ToString[ctr]/"36",TraditionalForm]<>"="<>ToString[ctr/36,TraditionalForm], "P("<>ToString[a]<>"\[LessSlantEqual] sum \[LessSlantEqual] "<>ToString[b]<>")="<>ToString[ToString[ctr]/"36",TraditionalForm]<>"="<>ToString[ctr/36,TraditionalForm]] }, {Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation3[pn_, vars_]:=Module[{variations,a,b,c,d,m,n,x,c1,c2,c3,c4,c5}, {a,b}=vars; variations={{If[b==12, "In rolling two dice, what is the probability of rolling a sum of "<>ToString[a]<>" or more?","In rolling two dice, what is the probability of rolling a sum such that:\n"<>ToString[a]<>"\[LessSlantEqual] sum \[LessSlantEqual] "<>ToString[b]] } }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers3[vars_]:=Module[{a,b,c,d,m,n,lhs,rhs,nn,xx,sols,x,c1,c2,c3,c4,c5,p1,p2,ctr=0,sumTable,list}, {a,b}=vars; sumTable=Table[i+j,{i,1,6},{j,1,6}]; list=DeleteCases[Flatten[Table[If[a<=sumTable[[i]][[j]]<=b, ctr+=1;{i+1, j+1}->Pink],{i,1,6},{j,1,6}],1],Null]; {ToString[(ctr+1)/36,TraditionalForm],ToString[(ctr+2)/36,TraditionalForm],ToString[ctr/36,TraditionalForm],ToString[(ctr-1)/36,TraditionalForm]} ] qPanelTRYAGAIN3[]:=Module[{a,b,c,d,m,n,x,c1,c2,c3,c4,c5,colors}, {a,b}=Sort[twoDifferent[Range[2,12]]]; {a,b} ] qPaneHint3[vars_]:=Module[{body}, body={{ "Think \"Sum Table\"" }, {Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR3[]:="" qPanel3[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN3[]; text=qPanelVariation3[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers3[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR3[]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN3[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint3[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution3[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN3[]; text=qPanelVariation3[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers3[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR3[]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] qPanelsolution4[vars_]:=DynamicModule[{body,a,b,c,d,m,n,x}, {a}=vars; (* body is an array with a as index to shuffle the solutions *) body= { (*1*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many Head & Head \nHH = 1 \[DoubleLongRightArrow] P(2 Heads) = "<>ToString[1/4, TraditionalForm] }, {Null,Null}}, (*2*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many Boy & Girl \nBG & GB = 2 \[DoubleLongRightArrow] P(son and a daughter) = "<>ToString["2"/"4", TraditionalForm]<>"="<>ToString[1/2, TraditionalForm] }, {Null,Null}}, (*3*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many only Boys \nBB = 1 \[DoubleLongRightArrow] P(two sons) = "<>ToString[1/4, TraditionalForm] }, {Null,Null}}, (*4*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many Tail & Tail \nTT = 1 \[DoubleLongRightArrow] P(2 Tails) = "<>ToString[1/4, TraditionalForm] }, {Null,Null}}, (*5*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many Head & Tail \nHT & TH = 2 \[DoubleLongRightArrow] P(Head and Tail) = "<>ToString["2"/"4", TraditionalForm]<>"="<>ToString[1/2, TraditionalForm] }, {Null,Null}}, (*6*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many only Grils \nGG = 1 \[DoubleLongRightArrow] P(two daughters) = "<>ToString[1/4, TraditionalForm] }, {Null,Null}}, (*7*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many with exactly two tails \nTHH, HTH, THH = 3 \[DoubleLongRightArrow] P(two heads) = "<>ToString[3/8, TraditionalForm] }, {Null,Null}}, (*8*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many with exactly two tails \nTTH, THT, HTT = 3 \[DoubleLongRightArrow] P(two Tails) = "<>ToString[3/8, TraditionalForm] }, {Null,Null}}, (*9*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Only 1 HHH \[DoubleLongRightArrow] P(All Heads) = "<>ToString[1/8, TraditionalForm] }, {Null,Null}}, (*10*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Only 1 TTT \[DoubleLongRightArrow] P(All Tails) = "<>ToString[1/8, TraditionalForm] }, {Null,Null}}, (*11*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many first tosses are Head\nHTT, HTH, HHT, HHH \[DoubleLongRightArrow] P(First toss Head) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*12*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many first tosses are Tail\nTTT, TTH, THT, THH \[DoubleLongRightArrow] P(First toss Tail) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*13*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many possible Heads\nTTH, THT, THH, HTT, HTH, HHT, HHH \[DoubleLongRightArrow] P(at least one Head) = "<>ToString[7/8, TraditionalForm] }, {Null,Null}}, (*14*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many possible Tails\nTTT, TTH, THT, THH, HTT, HTH, HHT \[DoubleLongRightArrow] P(at least one Tail) = "<>ToString[7/8, TraditionalForm] }, {Null,Null}}, (*15*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count all the middle Head tosses\nTHT, THH, HHT, HHH \[DoubleLongRightArrow] P(middle toss Head) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*16*) {{ TreePlot[{""->"H",""->"T","H"->"HH","H"->"HT","T"->"TH","T"->"TT","TT"->"TTH","TT"->"TTT","TH"->"THH","TH"->"THT", "HT"->"HTH","HT"->"HTT", "HH"->"HHH","HH"->"HHT"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="HH","H", #2=="HT","T",#2=="TH","H",#2=="TT","T",#2=="TTT","T",#2=="TTH", "H",#2=="HTT","T",#2=="THT","T",#2=="HTH","H",#2=="THH","H",#2=="HHT","T",#2=="HHH","H",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count all the middle Tail tosses\nTTT, TTH, HTT, HTH \[DoubleLongRightArrow] P(middle toss Tail) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*17*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count how many first born Girls\nGBB, GBG, GGB, GGG \[DoubleLongRightArrow] P(First born Girl) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*18*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Only 1 all girls\n GGG \[DoubleLongRightArrow] P(All Girls) = "<>ToString[1/8, TraditionalForm] }, {Null,Null}}, (*19*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Only 1 all boys\n BBB \[DoubleLongRightArrow] P(All Boys) = "<>ToString[1/8, TraditionalForm] }, {Null,Null}}, (*20*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Tow boys and one girl count\nBBG, BGB, GBB \[DoubleLongRightArrow] P(Two boys and one girl) = "<>ToString[3/8, TraditionalForm] }, {Null,Null}}, (*21*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Tow girls and one boy count\nGBG, GGG, BGG \[DoubleLongRightArrow] P(Two girls and one boy) = "<>ToString[3/8, TraditionalForm] }, {Null,Null}}, (*22*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "At least one girl \[Congruent] No all boys = 8 - 1\n \[DoubleLongRightArrow] P(At least one girl) = "<>ToString[7/8, TraditionalForm] }, {Null,Null}}, (*23*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "At least one boy \[Congruent] No all girls = 8 - 1\n \[DoubleLongRightArrow] P(At least one boy) = "<>ToString[7/8, TraditionalForm] }, {Null,Null}}, (*24*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count all with middle child girl\nBGB, BGG, GGB, GGG \[DoubleLongRightArrow] P(Middle child girl) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}}, (*25*) {{ TreePlot[{""->"G",""->"B","G"->"GG","G"->"GB","B"->"BG","B"->"BB","BB"->"BBG","BB"->"BBB","BG"->"BGG","BG"->"BGB", "GB"->"GBG","GB"->"GBB", "GG"->"GGG","GG"->"GGB"},Left,VertexRenderingFunction->({Black,Text[Which[#2=="GG","G", #2=="GB","B",#2=="BG","G",#2=="BB","B",#2=="BBB","B",#2=="BBG", "G",#2=="GBB","B",#2=="BGB","B",#2=="GBG","G",#2=="BGG","G",#2=="GGB","B",#2=="GGG","G",True, #2],#1]}&),DirectedEdges->True,PlotStyle->{Cyan,Arrowheads[{{0.07,0.9}}],Thickness[0.007]}], "Count all with middle child boy\nBBB, BBG, GBB, GBG \[DoubleLongRightArrow] P(Middle child boy ) = "<>ToString[4/8, TraditionalForm] }, {Null,Null}} }; Panel[Grid[Transpose[body[[a]]]]] ] qPanelVariation4[pn_, vars_]:=Module[{variations,a,b,c,d,m,n,x}, {a}=vars; variations={{Which[a==1, "In tossing two coins, what is the probability of getting 2 Heads?", a==2, "A family has 2 children. What is the probability that this family has a son and a daughter?", a==3,"A family has 2 children. What is the probability that this family has two sons?", a==4, "In tossing two coins, what is the probability of getting 2 Tails?" ,a==5, "In tossing two coins, what is the probability of getting Head and Tail?",a==6,"A family has 2 children. What is the probability that this family has two daughters?", a==7, "In tossing three coins, what is the probability of getting exactly two Heads?",a==8, "In tossing three coins, what is the probability of getting exactly two Tails", a==9, "In tossing three coins, what is the probability of getting all Heads?",a==10, "In tossing three coins, what is the probability of getting all Tails", a==11, "In tossing three coins, what is the probability the first toss is a Head?",a==12, "In tossing three coins, what is the probability the first toss is a Tail?", a==13, "In tossing three coins, what is the probability of getting at least one Head?", a==14, "In tossing three coins, what is the probability of getting at least one Tail?", a==15, "In tossing three coins, what is the probability of getting Head for middle toss?",a==16, "In tossing three coins, what is the probability of getting Tail for middle toss?", a==17, "A family has 3 children. What is the probability that the first born is girl?",a==18, "A family has 3 children. What is the probability that all three children are girls?", a==19, "A family has 3 children. What is the probability that all three children are boys?",a==20, "A family has 3 children. What is the probability of two boys and one girl?", a==21, "A family has 3 children. What is the probability of two girls and one boy?", a==22, "A family has 3 children. What is the probability of at least one girl?", a==23, "A family has 3 children. What is the probability of at least one boy?", a==24, "A family has 3 children. What is the probability of middle child is a girl?",a==25, "A family has 3 children. What is the probability of middle child is a boy?" ]} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers4[vars_]:=Module[{a,b,c,d,m,n,lhs,rhs,nn,xx,sols,x}, {a}=vars; { Which[ a==1,ToString[1/5,TraditionalForm],a==2,ToString[1/3,TraditionalForm], a==3,ToString[1/5,TraditionalForm], a==4,ToString[1/5,TraditionalForm],a==5,ToString[1/3,TraditionalForm], a==6,ToString[1/5,TraditionalForm],a==7,ToString[3/9,TraditionalForm], a==8,ToString[3/9,TraditionalForm], a==9,ToString[1/9,TraditionalForm],a==10,ToString[1/9,TraditionalForm], a==11,ToString[1/3,TraditionalForm],a==12,ToString[1/3,TraditionalForm], a==13,ToString[7/9,TraditionalForm], a==14,ToString[7/9,TraditionalForm],a==15,ToString[1/3,TraditionalForm], a==16,ToString[1/3,TraditionalForm],a==17,ToString[1/3,TraditionalForm], a==18,ToString[1/9,TraditionalForm], a==19,ToString[1/9,TraditionalForm],a==20,ToString[3/9,TraditionalForm], a==21,ToString[3/9,TraditionalForm],a==22,ToString[7/9,TraditionalForm], a==23,ToString[7/9,TraditionalForm], a==24,ToString[1/3,TraditionalForm],a==25,ToString[1/3,TraditionalForm] ], Which[ a==1,ToString[2/4,TraditionalForm],a==2,ToString[2/3,TraditionalForm], a==3,ToString[2/4,TraditionalForm], a==4,ToString[2/4,TraditionalForm],a==5,ToString[2/3,TraditionalForm], a==6,ToString[2/4,TraditionalForm],a==7,ToString[4/8,TraditionalForm], a==8,ToString[4/8,TraditionalForm], a==9,ToString[2/8,TraditionalForm],a==10,ToString[2/8,TraditionalForm], a==11,ToString[2/3,TraditionalForm],a==12,ToString[2/3,TraditionalForm], a==13,ToString[8/9,TraditionalForm], a==14,ToString[8/9,TraditionalForm],a==15,ToString[2/3,TraditionalForm], a==16,ToString[2/3,TraditionalForm],a==17,ToString[2/3,TraditionalForm], a==18,ToString[2/8,TraditionalForm], a==19,ToString[2/8,TraditionalForm],a==20,ToString[4/8,TraditionalForm], a==21,ToString[4/8,TraditionalForm],a==22,ToString[8/9,TraditionalForm], a==23,ToString[8/9,TraditionalForm], a==24,ToString[2/3,TraditionalForm],a==25,ToString[2/3,TraditionalForm] ], Which[ a==1,ToString[1/4,TraditionalForm],a==2,ToString[1/2,TraditionalForm], a==3,ToString[1/4,TraditionalForm], a==4,ToString[1/4,TraditionalForm],a==5,ToString[1/2,TraditionalForm], a==6,ToString[1/4,TraditionalForm],a==7,ToString[3/8,TraditionalForm], a==8,ToString[3/8,TraditionalForm], a==9,ToString[1/8,TraditionalForm],a==10,ToString[1/8,TraditionalForm], a==11,ToString[1/2,TraditionalForm],a==12,ToString[1/2,TraditionalForm], a==13,ToString[7/8,TraditionalForm], a==14,ToString[7/8,TraditionalForm],a==15,ToString[1/2,TraditionalForm], a==16,ToString[1/2,TraditionalForm],a==17,ToString[1/2,TraditionalForm], a==18,ToString[1/8,TraditionalForm], a==19,ToString[1/8,TraditionalForm],a==20,ToString[3/8,TraditionalForm], a==21,ToString[3/8,TraditionalForm],a==22,ToString[7/8,TraditionalForm], a==23,ToString[7/8,TraditionalForm], a==24,ToString[1/2,TraditionalForm],a==25,ToString[1/2,TraditionalForm] ], Which[ a==1,ToString[3/4,TraditionalForm],a==2,ToString[3/5,TraditionalForm], a==3,ToString[3/4,TraditionalForm], a==4,ToString[3/4,TraditionalForm],a==5,ToString[3/5,TraditionalForm], a==6,ToString[3/4,TraditionalForm],a==7,ToString[5/8,TraditionalForm], a==8,ToString[5/8,TraditionalForm], a==9,ToString[3/10,TraditionalForm],a==10,ToString[3/10,TraditionalForm], a==11,ToString[3/4,TraditionalForm],a==12,ToString[3/4,TraditionalForm], a==13,ToString[9/10,TraditionalForm], a==14,ToString[9/10,TraditionalForm],a==15,ToString[3/4,TraditionalForm], a==16,ToString[3/4,TraditionalForm],a==17,ToString[3/4,TraditionalForm], a==18,ToString[3/10,TraditionalForm], a==19,ToString[3/10,TraditionalForm],a==20,ToString[3/10,TraditionalForm], a==21,ToString[3/10,TraditionalForm],a==22,ToString[9/10,TraditionalForm], a==23,ToString[9/10,TraditionalForm], a==24,ToString[3/4,TraditionalForm],a==25,ToString[3/4,TraditionalForm] ] } ] qPanelTRYAGAIN4[]:=Module[{a,b,c,d,m,n,x}, {RandomInteger[{1,25}]} ] qPaneHint4[vars_]:=Module[{body}, body={{ "Think \"Tree Diagram\"" }, {Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR4[]:="" qPanel4[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN4[]; text=qPanelVariation4[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers4[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR4[]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN4[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint4[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution4[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN4[]; text=qPanelVariation4[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers4[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR4[]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] qPanelsolution5[vars_]:=DynamicModule[{body,a,b,c,d,m,n,x,index,\[Mu],\[Sigma],t, tick1,tick2,p}, {index,\[Mu],\[Sigma],t,tick1,tick2,p}=vars; (* body is an array with a as index to shuffle the solutions *) body= { {{ "Reasoning: Based on the information provided, "<>ToString[Round[p]]<>"% of the scores lie between "<>ToString[tick1]<>" cm and "<>ToString[tick2]<>" cm of rainfall. Based on the symmetry of the graph, the remaining "<>ToString[100-p]<>"% are divided equally, so that half of them are above (more than) "<>ToString[tick2]<>" cm of rainfall. So this means \[TildeTilde]"<>ToString[Round[((100-p)/2)]]<>"%.", "" }, {Null,Null}}, {{ "Reasoning: Based on the information provided, "<>ToString[Round[p]]<>"% of the scores lie between "<>ToString[tick1]<>" cm and "<>ToString[tick2]<>" cm of rainfall. Based on the symmetry of the graph, the remaining "<>ToString[100-p]<>"% are divided equally, so that half of them are below (less than) "<>ToString[tick1]<>" cm of rainfall. So this means \[TildeTilde]"<>ToString[Round[((100-p)/2)]]<>"%.", "" }, {Null,Null}}, {{ "Reasoning: Based on the information provided, "<>ToString[Round[p]]<>"% of the scores lie between "<>ToString[tick1]<>" cm and "<>ToString[tick2]<>" cm of rainfall. So this means \[TildeTilde]"<>ToString[p]<>"%.", "" }, {Null,Null}} }; Panel[Grid[Transpose[body[[index]]]]] ] qPanelVariation5[pn_, vars_]:=Module[{variations,a,b,c,d,m,n,x,index,\[Mu],\[Sigma],t, tick1,tick2,p}, {index,\[Mu],\[Sigma],t,tick1,tick2,p}=vars; variations={{Which[index==1, "In the distribution shown below, the x-axis represents the monthly rainfall, measured in cm, during the month of November in Toronto. What is the probability that it rains more than "<>ToString[tick2]<>" cm in November?", index==2, "In the distribution shown below, the x-axis represents the monthly rainfall, measured in cm, during the month of November in Toronto. What is the probability that it rains less than "<>ToString[tick1]<>" cm in November?", index==3, "In the distribution shown below, the x-axis represents the monthly rainfall, measured in cm, during the month of November in Toronto. What is the probability that it rains either less than "<>ToString[tick2]<>" or more than "<>ToString[tick1]<>" cm?"]} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers5[vars_]:=Module[{a,b,c,d,m,n,lhs,rhs,nn,xx,sols,x,index,\[Mu],\[Sigma],t, tick1,tick2,p}, {index,\[Mu],\[Sigma],t,tick1,tick2,p}=vars; { Which[index==1,ToString[3+Round[((100-p)/2)]]<>"%.",index==2, ToString[3+Round[((100-p)/2)]]<>"%.", index==3, ToString[3+p]<>"%"], Which[index==1,ToString[-3+Round[((100-p)/2)]]<>"%.",index==2, ToString[-3+Round[((100-p)/2)]]<>"%.", index==3, ToString[-3+p]<>"%"], Which[index==1,ToString[Round[((100-p)/2)]]<>"%.",index==2, ToString[Round[((100-p)/2)]]<>"%.", index==3, ToString[p]<>"%."], Which[index==1,ToString[5+Round[((100-p)/2)]]<>"%.",index==2, ToString[5+Round[((100-p)/2)]]<>"%.", index==3, ToString[5+p]<>"%"] } ] qPanelTRYAGAIN5[]:=Module[{a,b,c,d,m,n,x,\[Mu],\[Sigma],t,index, tick1,tick2,p}, index=RandomInteger[{1,3}]; \[Mu]=RandomInteger[{3,10}]; \[Sigma]=RandomInteger[{1,2}]; t=RandomReal[{0.4,1.5}]; tick1=N[Round[(-t*\[Sigma]+\[Mu])*10]/10,3]; tick2=N[Round[(t*\[Sigma]+\[Mu])*10]/10,3]; p=N[CDF[NormalDistribution[\[Mu],\[Sigma]],t*\[Sigma]+\[Mu]]-CDF[NormalDistribution[\[Mu],\[Sigma]],-t*\[Sigma]+\[Mu]]]; p=Round[p*100]; {index,\[Mu],\[Sigma],t, tick1, tick2,p} ] qPaneHint5[vars_]:=Module[{body}, body={{ "Use the concept of symmetry and that the probability under the curve is 100%.", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR5[vars_]:=Module[{index,\[Mu],\[Sigma],t, tick1,tick2,p,g1,g2,g3,g4,g5}, {index,\[Mu],\[Sigma],t,tick1,tick2,p}=vars; g1=Plot[PDF[NormalDistribution[\[Mu],\[Sigma]],x],{x,-3*\[Sigma]+\[Mu],3*\[Sigma]+\[Mu]},PlotRange->All]; g2=Graphics[Yellow,Line[{{t*\[Sigma],1},{t*\[Sigma],-1}}]]; g3=Graphics[Yellow, Line[{{-t*\[Sigma],1},{-t*\[Sigma],-1}}]]; g4=RegionPlot[PDF[NormalDistribution[\[Mu],\[Sigma]],x]-y>=0 && ((t*\[Sigma])+\[Mu])>=x>=((-t*\[Sigma])+\[Mu])&&y>=0,{x,-3*\[Sigma]+\[Mu],3*\[Sigma]+\[Mu]},{y,0,PDF[NormalDistribution[\[Mu],\[Sigma]],\[Mu]]},Mesh->None,PlotPoints->15,MaxRecursion->4,Frame->None,PlotStyle->Orange,Ticks->{{tick1,\[Mu],tick2},{-1,1}}(*, PlotLabel->"\n\[Mu]="<>ToString[\[Mu]]<>", \[Sigma]="<>ToString[\[Sigma]] *)]; g5=Graphics[{Yellow,Text[Style[ToString[p]<>"%",Medium],{\[Mu],PDF[NormalDistribution[\[Mu],\[Sigma]],\[Mu]]/2}]}]; (* regionplot first *) Show[g4,g1,g2,g3,g5, PlotRange->All,Axes->{True,False}, AxesLabel->{"Rainfall", "Probability"}, ImageSize->300] ] qPanel5[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN5[]; text=qPanelVariation5[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers5[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR5[vars]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN5[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint5[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution5[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,SynchronousUpdating->False,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN5[]; text=qPanelVariation5[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers5[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR5[vars]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] qPanelsolution6[vars_]:=DynamicModule[{body,index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t}, {index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t}=vars; (* body is an array with a as index to shuffle the solutions *) body= { {{ "As "<>ToString[p1]<>"%+"<>ToString[p2]<>"%="<>ToString[p1+p2]<>"% of the population is accounted for by the graph, the remaining 100%-"<>ToString[p1+p2]<>"%="<>ToString[100-(p1+p2)]<>"% must grow between "<>ToString[x1]<>" cm and "<>ToString[x2]<>" cm shown in white.", "" }, {Null,Null}}, {{ "", "" }, {Null,Null}} }; Panel[Grid[Transpose[body[[index]]]]] ] qPanelVariation6[pn_, vars_]:=Module[{variations,index,a1,b1,a2,b2,c,h,x1,x2,p1,p2,med1,med2,\[Mu],\[Sigma],t}, {index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t}=vars; variations={{"Using the information in the graph shown based on a population of 17-year old females in Canada, determine the probability that a 17 year old female grows between "<>ToString[x1]<>" cm and "<>ToString[x2]<>" cm in one year."} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers6[vars_]:=Module[{index,a1,b1,a2,b2,c,h,x1,x2,p1,p2,med1,med2,\[Mu],\[Sigma],t}, {index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t}=vars; { ToString[100-(p1+p2)+5]<>"%", ToString[100-(p1)]<>"%", ToString[100-(p1+p2)]<>"%", ToString[100-(p1+p2)-5]<>"%" } ] qPanelTRYAGAIN6[]:=Module[{index,a1,b1,a2,b2,c,h,x1,x2,p1,p2,x,y,med1,med2, area,f,\[Mu],\[Sigma],t,R1,R2}, \[Mu]=RandomInteger[{3,10}]; \[Sigma]=RandomInteger[{1,2}]; t=RandomReal[{0.4,1.5}]; c=7; h=RandomReal[{0.25,0.45}]; a1=h/5; b1=-2*a1; a2=-h/3; b2=-10*a2; (*{x1,x2}=Sort[twoDifferent[Range[3,9]],Less];*) x1=c; x2=c; While[x1==x2,{x1,x2}={RandomInteger[{3,c}],RandomInteger[{c,9}]}]; area=h*8/2; area=h*8/2; f[x_]:=Piecewise[{{a1*x+b1,x=c}}]; (*p1=Area[R1=ImplicitRegion[f[x]-y>=0&& y>=0&&x1>=x , {x,y}]]/area; p2=Area[R2=ImplicitRegion[f[x]-y>=0&& y>=0&&x >=x2, {x,y}]]/area;*) p1=f[x1]*(x1-2)/2; p2=f[x2]*(10-x2)/2; p1=Round[p1*100/area]; p2=Round[p2*100/area]; {med1,med2} = {{(x1+x1+2),f[x1]},{(10+x2+x2),f[x2]}}/3; (*med1=RegionCentroid[R1]; med2=RegionCentroid[R2];*) index=1; {index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t} ] qPaneHint6[vars_]:=Module[{body}, body={{ "Use the concept of symmetry and that the probability under the curve is 100%.", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR6[vars_]:=Module[{index,a1,b1,a2,b2,c,h,x1,x2,p1,p2,med1,med2,g1,g2,g3,g4,g5,\[Mu],\[Sigma],t,f}, {index,a1,b1,a2,b2,c,h,x1,x2,p1,p2, med1,med2,\[Mu],\[Sigma],t}=vars; f[x_]:=Piecewise[{{a1*x+b1,xc}}]; g1=Plot[Piecewise[{{a1*x+b1,xc}}],{x,0,11}, PlotRange->{{0,11}, {0,0.5}}]; g2=RegionPlot[f[x]-y>=0&& y>=0&&(x1>=x ||x>=x2), {x,0,11},{y,0,0.5},Mesh->None,PlotPoints->25,MaxRecursion->4,Frame->None,PlotStyle->Orange]; g3=Graphics[{Black,Text[Style[ToString[p1]<>"%",Medium],med1]}]; g4=Graphics[{Black,Text[Style[ToString[p2]<>"%",Medium],med2]}]; Show[g2,g1,g3,g4,PlotRange->All,Axes->True,AxesOrigin->{0,0}, AxesLabel->{"Number of cm grown", "Probability"},Ticks->{Range[11],{0.1,0.2,0.3,0.4,0.5}},ImageSize->300] ] qPanel6[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,vars,answer,b,bb,c,cc,aa,a,d,dd,rem,m,n,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, state=False, stateH=False,diag=diag0,g }, qNum +=1; If[diag==False, (* this is diagnosis training test *) Style[Manipulate[ xxx=xxx; (* kludge *) vars=qPanelTRYAGAIN6[]; text=qPanelVariation6[pn, vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"\n\nAnswer Correct",B1,qClickPlus[pn];myEnabled=False;text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text<>"\n\nAnswer \!\(\* StyleBox[\"Incorrect\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text<>"\n\nAnswer ?"]]; answers=qPanelAnswers6[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR6[vars]}],ImageMargins->10]]], {{xxx,1,""}, (* initial value of xxx, xxx=RandomReal[0.5] has to be in the button or else the test would not repeat*) Grid[{ {OpenerView[{Button["New Question",qTryAgain[pn];xxx=RandomReal[0.5];vars=qPanelTRYAGAIN6[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint6[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution6[vars]},state]} ,{Null,Null,Null}}] &}, TrackedSymbols->Manipulate, SaveDefinitions->True,AppearanceElements->None,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] , (* Else if actual test *) Style[Manipulate[ vars=qPanelTRYAGAIN6[]; text=qPanelVariation6[pn,vars]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text<>"",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text<>"",B1,qClickPlus[pn];myEnabled=False;text<>"",D1, myEnabled=False;qClickPlus[pn];text<>"", True, text<>""]]; answers=qPanelAnswers6[vars]; 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[body],Alignment->Left],Column[{answerStudent,qPanelEXPR6[vars]}],ImageMargins->10]]], "", TrackedSymbols->Manipulate, SaveDefinitions->True, AppearanceElements->None,SynchronousUpdating->False(*,Initialization:>(qClicks = {{1, 0, 0, ""}, {2, 0, 0, ""}, {3, 0, 0, ""}, {4, 0, 0, ""}, {5, 0, 0, ""}, {6, 0, 0, ""},{7, 0, 0, ""},{8, 0, 0, ""},{9, 0, 0, ""},{10, 0, 0, ""}})*)] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] ] End[]; EndPackage[];