(* ::Package:: *) BeginPackage["SymbolicExams`"]; (* Author Dara O Shayda, Nov 2012 *) (* License http://www.apache.org/licenses/LICENSE-2.0.html *) qPanel1::usage = "Simplest possible calculation panel"; qPanel2::usage = "Simplest possible calculation panel"; qPanel3::usage = "Simplest possible calculation panel"; qPanel4::usage = "Simplest possible calculation panel"; qPanel5::usage = "Simplest possible calculation panel"; qPanel6::usage = "Simplest possible calculation panel"; qPanel7::usage = "Simplest possible calculation panel"; qPanel8::usage = "Simplest possible calculation panel"; qPlot1::usage = "Matching plots to line equations"; qPlot2::usage = "Matching plots to line equations"; qPanelExpr1::usage = "Input fields are placed for expressions, and the inputed expressions are tested for validity"; qPanelExpr2::usage = "Input fields are placed for expressions, and the inputed expressions are tested for validity"; qPanelExpr3::usage = "Input fields are placed for expressions, and the inputed expressions are tested for validity"; qPanelExpr4::usage = "Input fields are placed for expressions, and the inputed expressions are tested for validity"; qInit::usage = "init stats"; qStart::usage = "start exam"; qPrint::usage = "Print exam clicks"; qStats::usage = "stats for exam clicks"; (*qTrue::usage = "Number of True answers"; tryAgain::usage = "Control to avoid bumping qTrue inside the Manipulate loop";*) Begin["`Private`"]; (* Let's keep these couple of panels as templates *) (* types of problems *) qArith=1; qGraphLine=2; qGraphLine=3; qPercentages=4; qFractions=5; qRatios=6; qMagnification = 1.2; bigNumber = 1000102010004455; qNamesList={"Boza", "Dara", "Jack", "Ginger", "Wayne", "Spomenka", "George", "Kevin", "Tina", "Lucia"}; qRandList[list0_]:=list0[[RandomInteger[{1, Length[list0]}]]] qInit[]:= Module[{}, (* {clickNum, problemType, tryAgain, totalClicks} *) qClicks = {{0, qArith, True, 0}, {0, qGraphLine, True, 0}, {0, qGraphLine, True, 0}, {0, qPercentages, True, 0}, {0, qFractions, True, 0}, {0, qRatios, True, 0},{0, qRatios, True, 0},{0, qRatios, True, 0},{0, qRatios, True, 0}}; ] (* 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; ] qStart[]:= Button["Start", qInit[]] qPrint[]:=Button["Results",Print[FromDigits[ToCharacterCode[Compress[qClicks]],1000]]] qStats[]:=Module[{a}, Manipulate[ Deploy[ Style[Panel[ListPlot[qClicks[[All,{4,2}]]],"hi",ImageMargins->10]]], {{a,1,""}, Button["Results",Print[qClicks]]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2}] ] 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, ""] qPanelExpr1[pn0_,a0_,b0_,c0_,d0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A2=bigNumber,B2=bigNumber,C2=bigNumber,D2=bigNumber,A1=Null,B1=Null, C1=Null, D1=Null,answer,a=a0,b=b0,c=c0,d=d0,myEnabled=True,text2,body, expers, answers,answersShuffled,expersShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text2={ToString[pn]<>". "<>"Simplify each of the following"}; answer="?"; (* If for the Null testhing has to be inside the dynamic *) (* FIXME: RunScheduledTask does not work correctly if the DynamicModule used *) answerStudent= Dynamic[A2=If[TrueQ[A1==Null], bigNumber,A1];B2=If[TrueQ[B1==Null], bigNumber,B1];C2=If[TrueQ[C1==Null], bigNumber,C1];D2=If[TrueQ[D1==Null], bigNumber,D1]; Which [A2==((a-b)-(c+d))&&B2==(a-(b-(c-d)))&&C2==(-a-(-b))&&D2==((a-b)-c),myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"True\",\nFontColor->RGBColor[1, 0, 0]]\)", A2!=bigNumber&&B2!=bigNumber&&C2!=bigNumber&&D2!=bigNumber, RunScheduledTask[myEnabled=False,{1}];text2<>"\n\nAnswer False",True, text2<>"\n\nAnswer ?"]]; expers={"("<>ToString[a]<>" - "<>ToString[b]<>") - ("<>ToString[c]<>" + "<>ToString[d]<>")", "-"<>ToString[a]<>" - ( - "<>ToString[b]<>")","("<>ToString[a]<>" - "<>ToString[b]<>") - "<>ToString[c],"("<>ToString[a]<>"-("<>ToString[b]<>"-("<>ToString[c]<>"-"<>ToString[d]<>")))"}; answers = {InputField[Dynamic[A1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[C1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[D1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[B1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3]}; (* BEIGN: Problem independent Code *) (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; expersShuffled = Table[expers[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) {"A ","B ","C ","D "}, (* First row/colum the proposed answers key *) expersShuffled, (* First row/colum the answer check boxes*) answersShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{4,0.5}(*,ItemSize->20)*)],answerStudent,ImageMargins->1],DefaultOptions->{InputField->{ContinuousAction->True},FontSize->Large}]], (* END: Problem independant code *) {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{1,20}];b=RandomInteger[{1,20}];c=RandomInteger[{1,20}];d=RandomInteger[{1,20}];myEnabled=True;A2=bigNumber;B2=bigNumber;C2=bigNumber;D2=bigNumber;A1=Null;B1=Null; C1=Null; D1=Null;RunScheduledTask[myEnabled=True,{1}]], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) (* better setup: Style[Manipulator[0.5, Appearance -> {"Open", Tiny}], DefaultOptions -> {Dynamic -> {BaseStyle -> Magnification -> 3}}] *) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanelExpr2[pn0_,a0_,b0_,c0_,d0_,e0_,f0_,h0_,i0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A2=bigNumber,B2=bigNumber,C2=bigNumber,D2=bigNumber,A1=Null,B1=Null, C1=Null, D1=Null,answer,a=a0,b=b0,c=c0,d=d0,e=e0,f=f0,h=h0,i=i0,myEnabled=True,text2,body, expers, answers,answersShuffled,expersShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text2={ToString[pn]<>". Multiply each of the following"}; answer="?"; answerStudent= Dynamic[A2=If[TrueQ[A1==Null], bigNumber,A1];B2=If[TrueQ[B1==Null], bigNumber,B1];C2=If[TrueQ[C1==Null], bigNumber,C1];D2=If[TrueQ[D1==Null], bigNumber,D1]; Which [A2==(a*b)&&B2==(c*d)&&C2==(e*f)&&D2==(h*i),myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"True\",\nFontColor->RGBColor[1, 0, 0]]\)", A2!=bigNumber&&B2!=bigNumber&&C2!=bigNumber&&D2!=bigNumber, RunScheduledTask[myEnabled=False,{1}];text2<>"\n\nAnswer False",True, text2<>"\n\nAnswer ?"]]; expers={"("<>ToString[a]<>")\[Times]("<>ToString[b]<>")","("<>ToString[e]<>")\[Times]("<>ToString[f]<>")","("<>ToString[h]<>")\[Times]("<>ToString[i]<>")", "("<>ToString[c]<>")\[Times]("<>ToString[d]<>")"}; answers = {InputField[Dynamic[A1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[C1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[D1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[B1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3]}; (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; expersShuffled = Table[expers[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) {"A ","B ","C ","D "}, (* First row/colum the proposed answers key *) expersShuffled, (* First row/colum the answer check boxes*) answersShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{4,0.5}(*,ItemSize->20)*)],answerStudent,ImageMargins->60],DefaultOptions->{InputField->{ContinuousAction->True}}]], {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{-20,20}];b=RandomInteger[{-20,20}];c=RandomInteger[{-20,20}];d=RandomInteger[{-20,20}];e=RandomInteger[{-20,20}];f=RandomInteger[{-20,20}];h=RandomInteger[{-20,20}];i=RandomInteger[{-20,20}];myEnabled=True;A2=bigNumber;B2=bigNumber;C2=bigNumber;D2=bigNumber;A1=Null;B1=Null; C1=Null; D1=Null;RunScheduledTask[myEnabled=True,{1}]], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanelExpr3[pn0_,a0_,b0_,c0_,d0_,e0_,f0_,g0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A2=bigNumber,B2=bigNumber,C2=bigNumber,D2=bigNumber,A1=Null,B1=Null, C1=Null, D1=Null,answer,a=a0,b=b0,c=c0,d=d0,e=e0,f=f0,g=g0,myEnabled=True,text2,body, expers, answers,answersShuffled,expersShuffled,index,answerStudent,tryAgain=True }, Style[ Manipulate[ text2={ToString[pn]<>". "<>"Simplify each of the following"}; answer="?"; (* make sure a is not 0 *) answerStudent= Dynamic[A2=If[TrueQ[A1==Null], bigNumber,A1];B2=If[TrueQ[B1==Null], bigNumber,B1];C2=If[TrueQ[C1==Null], bigNumber,C1];D2=If[TrueQ[D1==Null], bigNumber,D1]; Which [A2==(a-b+c+d-e)&&B2==(a-((b*c)+d^2))&&C2==((-3*a*g/a)-(b+c))&&D2==((a-b)-(f-g)),myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"True\",\nFontColor->RGBColor[1, 0, 0]]\)", A2!=bigNumber&&B2!=bigNumber&&C2!=bigNumber&&D2!=bigNumber, RunScheduledTask[myEnabled=False,{1}];text2<>"\n\nAnswer False",True, text2<>"\n\nAnswer ?"]]; expers={"("<>qSign[a]<>")-("<>qSign[b]<> ")+("<>qSign[c]<>")+("<>qSign[d]<>")-("<>qSign[e]<>")",ToString[-3*a*g]<>"\[Divide]("<>qSign[a]<>")-("<>ToString[b]<>"+"<>ToString[c]<>")","("<>ToString[a]<>"-"<>ToString[b]<>") - ("<>ToString[f]<>"-"<>ToString[g]<>")",ToString[a]<>"-(("<>ToString[b]<>")\[Times]("<>ToString[c]<>") +"<>ToString[ToString[d]^2,StandardForm]<>")"}; answers = {InputField[Dynamic[A1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[C1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[D1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[B1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3]}; (* BEIGN: Problem independent Code *) (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; expersShuffled = Table[expers[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) (*{"A ","B ","C ","D "},*) (* First row/colum the proposed answers key *) expersShuffled, (* First row/colum the answer check boxes*) answersShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{4,0.5},ItemSize->15],answerStudent,ImageMargins->40],DefaultOptions->{InputField->{ContinuousAction->True},FontSize->Large}]], (* END: Problem independant code *) {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{1,20}];b=RandomInteger[{1,20}];c=RandomInteger[{1,20}];d=RandomInteger[{1,10}];e=RandomInteger[{1,10}];f=RandomInteger[{1,10}];g=RandomInteger[{1,10}];myEnabled=True;A2=bigNumber;B2=bigNumber;C2=bigNumber;D2=bigNumber;A1=Null;B1=Null; C1=Null; D1=Null;RunScheduledTask[myEnabled=True,{1}]], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) (* better setup: Style[Manipulator[0.5, Appearance -> {"Open", Tiny}], DefaultOptions -> {Dynamic -> {BaseStyle -> Magnification -> 3}}] *) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanelExpr4[pn0_,a0_,b0_,c0_,d0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A2=bigNumber,B2=bigNumber,C2=bigNumber,D2=bigNumber,A1=Null,B1=Null, C1=Null, D1=Null,answer,a=a0,b=b0,c=c0,d=d0,myEnabled=True,text2,body, expers, answers,answersShuffled,expersShuffled,index,answerStudent,tryAgain=True }, Style[ Manipulate[ text2={ToString[pn]<>". "<>"Simplify each of the following"}; answer="?"; (* make sure a is not 0 *) answerStudent= Dynamic[A2=If[TrueQ[A1==Null], bigNumber,A1];B2=If[TrueQ[B1==Null], bigNumber,B1];C2=If[TrueQ[C1==Null], bigNumber,C1];D2=If[TrueQ[D1==Null], bigNumber,D1]; Which [A2==((-1)^a+(-1)^b+(-1)^c+(-1)^d)&&B2==((-1)^(2*a))+((-1)^(b+1)+(-1)^c+((-1)^(2*d)))&&C2==((-1)^a-(-1)^b+(-1)^c-(-1)^d)&&D2==(((-1)^(2*a))-((-1)^(b+1)+(-1)^c-((-1)^(2*d)))),myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"True\",\nFontColor->RGBColor[1, 0, 0]]\)", A2!=bigNumber&&B2!=bigNumber&&C2!=bigNumber&&D2!=bigNumber, RunScheduledTask[myEnabled=False,{1}];text2<>"\n\nAnswer False",True, text2<>"\n\nAnswer ?"]]; expers={ToString["("<>ToString[-1]<>")"^a,StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^b,StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^c,StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^d,StandardForm], ToString["("<>ToString[-1]<>")"^a,StandardForm]<>"-"<>ToString["("<>ToString[-1]<>")"^b,StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^c,StandardForm]<>"-"<>ToString["("<>ToString[-1]<>")"^d,StandardForm], ToString["("<>ToString[-1]<>")"^(2*a),StandardForm]<>"-"<>ToString["("<>ToString[-1]<>")"^(b+1),StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^c,StandardForm]<>"-"<>ToString["("<>ToString[-1]<>")"^(2*d),StandardForm], ToString["("<>ToString[-1]<>")"^(2*a),StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^(b+1),StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^c,StandardForm]<>"+"<>ToString["("<>ToString[-1]<>")"^(2*d),StandardForm]}; answers = {InputField[Dynamic[A1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[C1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[D1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3],InputField[Dynamic[B1],Expression,Enabled->Dynamic[myEnabled],FieldSize->3]}; (* BEIGN: Problem independent Code *) (* Shuffle the answer keys *) index = RandomSample[Range[Length[answers]]]; answersShuffled = Table[answers[[index[[i]]]], {i, 1,Length[answers]}]; expersShuffled = Table[expers[[index[[i]]]], {i, 1,Length[answers]}]; body = { (* First row/colum the answer key *) (*{"A ","B ","C ","D "},*) (* First row/colum the proposed answers key *) expersShuffled, (* First row/colum the answer check boxes*) answersShuffled }; (* Kludge: answerStudent has problem with <>, so concatenated earlier*) Deploy[ Style[Panel[Grid[Transpose[body],Alignment->Left,Spacings->{0.5,0.5},ItemSize->20],answerStudent,ImageMargins->40],DefaultOptions->{InputField->{ContinuousAction->True},FontSize->Large}]], (* END: Problem independant code *) {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{1,20}];b=RandomInteger[{1,20}];c=RandomInteger[{1,20}];d=RandomInteger[{1,20}];myEnabled=True;A2=bigNumber;B2=bigNumber;C2=bigNumber;D2=bigNumber;A1=Null;B1=Null; C1=Null; D1=Null;RunScheduledTask[myEnabled=True,{1}]], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) (* better setup: Style[Manipulator[0.5, Appearance -> {"Open", Tiny}], DefaultOptions -> {Dynamic -> {BaseStyle -> Magnification -> 3}}] *) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel1[pn0_,a0_,b0_,aSym0_, bSym0_,hint0_]:= Module[{pn=pn0,text,aSym=aSym0,bSym=bSym0,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,a=a0,b=b0,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". X is ", aSym, " and Y is ", bSym,"\nCalculate X + Y"}; text2=text/.{aSym->a, bSym->b}; text2=StringJoin[ToString/@text2]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ToString[a+b+1],ToString[a+b-4],ToString[a+b],ToString[a+b+9]}; 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],answerStudent,ImageMargins->10]]], {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{1,5}];b=RandomInteger[{1,5}] ;myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel2[pn0_,a0_,b0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,a=a0,b=b0,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". An item in a store was priced at $", N[a,2], ". During a sale, its price is reduced by %", b,"\na) Determine is new price. \nb) If the H.S.T. is applied to the sale priced, determine the toal amount paid with tax included.(In Ontario H.S.T is 13%)"}; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={"a = $"<>ToString[N[a-a*0.7,2]]<>", b = $"<>ToString[N[1.13*(a-a*0.7),2]],"a = $"<>ToString[N[a-b,2]]<>", b = $"<>ToString[N[1.13*(a-b),2]],"a = $"<>ToString[N[a-a*b,2]]<>", b = $"<>ToString[N[1.13*(a-a*b),2]],"a = $"<>ToString[N[a-a*0.9,2]]<>", b = $"<>ToString[N[1.13*(a-a*0.9),2]]}; 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],answerStudent,ImageMargins->10]]], {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomReal[N[{100.00,300.00},2]];b=RandomReal[N[{0.05, 0.5},2]] ;myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel3[pn0_,a0_,b0_,c0_,d0_, p0_, hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,a=a0,b=b0,c=c0,d=d0, p=p0,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". Mrs. Johnson owned ", a,"/",b, " of a store. She sold ", c, "/",d," of her interest in the store for $",p, ". What was the total value of the store?" }; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ToString[(1*b*20000/(c*b))+1000],ToString[(d*1*20000/(c*a))+2000],ToString[d*b*20000/(c*a)],ToString[(d*b*20000/(1*a))+1000]}; 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],answerStudent,ImageMargins->10]]], {{a,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];a=RandomInteger[{1,10}];b=a+RandomInteger[{0,10}];c=RandomInteger[{1,10}];d=c+RandomInteger[{0,10}];p=RandomInteger[{30000,60000}] ;myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel4[pn0_,b0_, c0_, d0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,b=b0,c=c0,d=d0, myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". If ", "a:b = ",c,":",d," and it is known that ","b = ", b, ", find the value of a." }; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ToString[2*b*c/d],ToString[d/(b*c)],ToString[b*c/d],ToString[(b+c)/d]}; 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],answerStudent,ImageMargins->10]]], {{b,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];b=RandomInteger[{50,300}];c=RandomInteger[{1, 20}];d=RandomInteger[{1, 20}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel5[pn0_,deposit0_,prevBalance0_,cheque10_,cheque20_,cheque30_,cheque40_, cheque50_,cheque60_,anotherDeposit0_,fee0_, hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,deposit=deposit0,prevBalance=prevBalance0,cheque1=cheque10,cheque2=cheque20,cheque3=cheque30,cheque4=cheque40, cheque5=cheque50,cheque6=cheque60,anotherDeposit=anotherDeposit0,fee=fee0,myEnabled=True,text2,variations,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True,name }, Style[Manipulate[ name=qRandList[qNamesList]; variations={{ToString[pn]<>". "<>name<>" has a chequing account. At the frist day of the month, deposited $",deposit," to a previous balance of ",qSign2[prevBalance], "$", Abs[prevBalance],". Later on wrote six cheques for $",cheque1, ", $", cheque2, ", $", cheque3, ", $",cheque4, ", $", cheque5, ", $", cheque6,". Because of holliday shopping had to make another deposit of $", anotherDeposit, ". If the bank service charge was $", fee, ", what was "<>name<>"'s account balance at the end of the month?"}, {ToString[pn]<>". "<>name<>" has a chequing account. In the beginning of the month, made a $",deposit," deposit to a previous balance of ",qSign2[prevBalance], "$", Abs[prevBalance],". And then wrote 6 cheques for $",cheque1, ", $", cheque2, ", $", cheque3, ", $",cheque4, ", $", cheque5, ", $", cheque6,". To cover additional expenses, made second deposit of $", anotherDeposit, ". The bank monthly fee is $", fee, ", calculate "<>name<>"'s account balance at the end of the month?"}, {ToString[pn]<>". "<>name<>" uses a chequing account. Last month, made a $",deposit," deposit to an existing balance of ",qSign2[prevBalance], "$", Abs[prevBalance],". Six cheques were written for $",cheque1, ", $", cheque2, ", $", cheque3, ", $",cheque4, ", $", cheque5, ", $", cheque6,". To assure positive balance, another deposit of $", anotherDeposit, " was made. The bank charges monthly fee of $", fee, ", what was "<>name<>"'s chequing balance by the end of the month?"}, {ToString[pn]<>". "<>name<>" pays bills by cheques. During the past month of May, deposited $",deposit," on top of the previous balance of ",qSign2[prevBalance], "$", Abs[prevBalance],". Had six bills, therefore wrote cheques for $",cheque1, ", $", cheque2, ", $", cheque3, ", $",cheque4, ", $", cheque5, ", $", cheque6,". The Revenue department sent a tax refund, thus "<>name<>" deposited a refund cheque valued at $", anotherDeposit, ". The bank charges $", fee, " per month, what was "<>name<>"'s account balance at the end May?"} }; text = qRandList[variations]; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={deposit+prevBalance-(cheque1+cheque2+cheque3+cheque4+cheque5+cheque6)+anotherDeposit,deposit-(cheque1+cheque2+cheque3+cheque4+cheque5+cheque6)+anotherDeposit-fee,deposit+prevBalance-(cheque1+cheque2+cheque3+cheque4+cheque5+cheque6)+anotherDeposit-fee,deposit+prevBalance-(cheque1+cheque2+cheque3+cheque4+cheque5+cheque6)-fee}; 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],answerStudent,ImageMargins->10]]], {{deposit,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];deposit=RandomInteger[{400,700}];prevBalance=RandomInteger[{-50,100}];cheque1=RandomInteger[{20,100}];cheque2=RandomInteger[{20,100}];cheque3=RandomInteger[{20,100}];cheque4=RandomInteger[{20,100}];cheque5=RandomInteger[{20,100}];cheque6=RandomInteger[{20,100}];anotherDeposit=RandomInteger[{100,300}];fee=RandomInteger[{10,25}] ;myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qConstants={"zero", "one", "two", "three", "four", "five", "six", "seven"}; qPanel6[pn0_,b0_, c0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,b=b0,c=c0,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". John's cell phone bill for every month is $",b,". For ",qConstants[[c+1]]," months, he has not been able to make any payments and Cell Phone Company is threatening to assign debt to a collection agency. User your knownledge of integers to indicate how much John owes to the Cell Phone Company."}; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ToString[(b*c)-5],ToString[b*(c-1)],ToString[b*c],ToString[b*(c+1)]}; 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],answerStudent,ImageMargins->10]]], {{b,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];b=RandomInteger[{50,300}];c=RandomInteger[{1, Length[qConstants]-1}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qTrunc1[a0_]:=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] qPanel7[pn0_,money0_,weightChicken0_,priceChicken0_,weightOrange0_,priceOrange0_,weightBeef0_,priceBeef0_, volMilk0_,priceMilk0_,unitsMilk0_,containersYogurt0_, priceYogurt0_, unitsYogurt0_, loafBread0_, priceBread0_, canPasta0_, pricePasta0_,fare0_,hint0_]:= Module[{pn=pn0, fare=fare0,money=money0,weightChicken=weightChicken0,priceChicken=priceChicken0,weightOrange=weightOrange0,priceOrange=priceOrange0,weightBeef=weightBeef0,priceBeef=priceBeef0, volMilk=volMilk0,priceMilk=priceMilk0,unitsMilk=unitsMilk0,containersYogurt=containersYogurt0, priceYogurt=priceYogurt0, unitsYogurt=unitsYogurt0, loafBread=loafBread0, priceBread=priceBread0, canPasta=canPasta0, pricePasta=pricePasta0, text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True, correctAnswer,incorrectAnswer1,incorrectAnswer2,incorrectAnswer3}, Style[Manipulate[ text={ToString[pn]<>". Martina works in a group home as personal support worker. On Monday, she went grocery shopping with $",money," in her purse. She incurred the following expenses: ",weightChicken, " pounds of chicken breasts at $",priceChicken," per pound, ", weightOrange, "kg of orange at $",priceOrange, " per kg, ", weightBeef, " kg of lean ground beef at $",priceBeef, " per kg, ",volMilk, "L skim milk (2%) at $", priceMilk, " per ", unitsMilk, "L, ", containersYogurt, " containers of yogurt at $", priceYogurt, " for ", unitsYogurt, " containers, ", loafBread, " loaves of whole bread at 1 loaf for $",priceBread, " and ", canPasta, " cans of pasta sauce at $", pricePasta, " a can. ", "Martina spent $", fare, " on taxi fare. How much did she have after these expenses?" }; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; correctAnswer = money-((weightChicken*priceChicken)+(weightOrange*priceOrange)+(weightBeef*priceBeef)+(volMilk*priceMilk/unitsMilk)+(containersYogurt*priceYogurt/unitsYogurt)+(loafBread*priceBread)+(canPasta*pricePasta)+fare); incorrectAnswer1 = money-((weightChicken*priceChicken)+(weightOrange*priceOrange)+(weightBeef*priceBeef)+(volMilk*priceMilk/unitsMilk)+(containersYogurt*priceYogurt/(unitsYogurt+5))+(loafBread*priceBread)+(canPasta*pricePasta)+fare); incorrectAnswer2 = money-((weightChicken*priceChicken)+(weightOrange*priceOrange)+(weightBeef*priceBeef)+(volMilk*priceMilk/unitsMilk)+(containersYogurt*priceYogurt/unitsYogurt)+(loafBread*priceBread)+(canPasta*pricePasta)); incorrectAnswer3 = money-((weightChicken*priceChicken)+(weightOrange*priceOrange)+(weightBeef*priceBeef)+(volMilk*priceMilk/(unitsMilk+5))+(containersYogurt*priceYogurt/unitsYogurt)+(loafBread*priceBread)+(canPasta*pricePasta)+fare); answers={N[Ceiling[100*incorrectAnswer1]/100],N[Ceiling[100*incorrectAnswer2]/100],N[Ceiling[100*correctAnswer]/100],N[Ceiling[100*incorrectAnswer3]/100]}; 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],answerStudent,ImageMargins->10]]], {{money,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];money=qTrunc1[RandomInteger[{200,400}]];weightChicken=qTrunc3[RandomReal[{1,5}]];priceChicken=qTrunc2[RandomReal[{2,3}]];weightOrange=RandomInteger[{1,5}];priceOrange=qTrunc1[RandomReal[{1.5,2.5}]];weightBeef=qTrunc3[RandomReal[{1,7}]];priceBeef=qTrunc1[RandomReal[{1,3}]];volMilk=RandomInteger[{1,20}];priceMilk=qTrunc1[RandomReal[{1,4}]];unitsMilk=RandomInteger[{1,4}];containersYogurt=RandomInteger[{20,60}];priceYogurt=qTrunc2[RandomReal[{3,5}]];unitsYogurt=RandomInteger[{1,12}];loafBread=RandomInteger[{3,5}];priceBread=qTrunc2[RandomReal[{2,4}]];canPasta=RandomInteger[{3,9}];pricePasta=qTrunc2[RandomReal[{2,4}]];fare=qTrunc2[RandomReal[{12,40}]];myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPanel8[pn0_,b0_, c0_,hint0_]:= Module[{pn=pn0,text,hint=hint0,A1=False,B1=False,C1=False,D1=False,answer,b=b0,c=c0, myEnabled=True,text2,body, answers, checks,answersShuffled,checksShuffled,index,answerStudent,tryAgain=True }, Style[Manipulate[ text={ToString[pn]<>". The temperature on an airplane was ", b,"\[InvisiblePrefixScriptBase]C. When the plane landed in Sudbury, the temperature was ", c,"\[InvisiblePrefixScriptBase]C. What change in temperature did Madelaine experience as she exited from the plane directly onto the tarmac?" }; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",C1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",B1,qClickPlus[pn];myEnabled=False;text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={ToString[b-c-1]<>"\!\(\*SuperscriptBox[\(\[InvisiblePrefixScriptBase]\), \(\[EmptySmallCircle]\)]\)C",ToString[-c+b]<>"\!\(\*SuperscriptBox[\(\[InvisiblePrefixScriptBase]\), \(\[EmptySmallCircle]\)]\)C",ToString[c-b]<>"\!\(\*SuperscriptBox[\(\[InvisiblePrefixScriptBase]\), \(\[EmptySmallCircle]\)]\)C",ToString[c-b-1]<>"\!\(\*SuperscriptBox[\(\[InvisiblePrefixScriptBase]\), \(\[EmptySmallCircle]\)]\)C"}; 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],answerStudent,ImageMargins->10]]], {{b,1,""}, (* initial value of a*) OpenerView[{Button["Try Again",qTryAgain[pn];b=RandomInteger[{-10,30}];c=RandomInteger[{-10,30}];myEnabled=True;A1=False; B1=False;C1=False; D1= False], hint}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPlot1[pn0_,m0_,b0_,hint0_]:=Module[{pn=pn0,text,b=b0, m=m0, hint=hint0,x,A1,B1,C1,D1,answer ,myEnabled=True,answerStudent, text2,body,answersShuffled,checksShuffled , checks, index, answers,tryAgain=True}, Style[Manipulate[ text={ToString[pn]<>". Which one of the following lines has equation\n y = (",m,")x +(",b,")"}; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",B1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",C1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={Plot[(m^2+1)*x+(2*b+2), {x,-5,5},AxesLabel->{"x","y"}],Plot[m*x+b, {x,-5,5},AxesLabel->{"x","y"}],Plot[(m+1)*x+b+3, {x,-5,5},AxesLabel->{"x","y"}],Plot[-m*x+b-3, {x,-5,5},AxesLabel->{"x","y"}]}; 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],answerStudent,ImageMargins->10]]], {{b,2,""}, (* initial value of b *) {m,1,""}, OpenerView[{Button["Try Again",qTryAgain[pn];b=RandomInteger[{-5,5}];m=RandomInteger[{-5,5}];myEnabled=True;A1=False; B1=False;C1=False; D1= False],hint[m,b]}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] qPlot2[pn0_,m0_,b0_,hint0_]:=Module[{pn=pn0,b=b0, m=m0, hint=hint0,x,A1,B1,C1,D1,answer ,myEnabled=True,answerStudent, text2,body,answersShuffled,checksShuffled , checks, index, answers,tryAgain=True,text}, Style[Manipulate[ text={ToString[pn]<>". Which one of the following lines has slope ",m," and intercept \n",b}; text2=StringJoin[ToString/@text]; answer="?"; answerStudent=Dynamic[Which [A1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",B1,qClick[pn];qTryAgainNOT[pn];myEnabled=False;text2<>"\n\nAnswer True",C1,myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)",D1, myEnabled=False;qClickPlus[pn];text2<>"\n\nAnswer \!\(\* StyleBox[\"False\",\nFontColor->RGBColor[1, 0, 0]]\)", True, text2<>"\n\nAnswer ?"]]; answers={Plot[(m^2+1)*x+(2*b+2), {x,-5,5},AxesLabel->{"x","y"}],Plot[m*x+b, {x,-5,5},AxesLabel->{"x","y"}],Plot[(m+1)*x+b+3, {x,-5,5},AxesLabel->{"x","y"}],Plot[-m*x+b-3, {x,-5,5},AxesLabel->{"x","y"}]}; 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],answerStudent,ImageMargins->10]]], {{b,2,""}, (* initial value of b *) {m,1,""}, OpenerView[{Button["Try Again",qTryAgain[pn];b=RandomInteger[{-5,5}];m=RandomInteger[{-5,5}];myEnabled=True;A1=False; B1=False;C1=False; D1= False],hint[m,b]}]&}, TrackedSymbols->Manipulate, SaveDefinitions->True,AutorunSequencing->{1,2},AppearanceElements->None] (*Manipulate*) , DynamicBoxOptions -> {BaseStyle -> Magnification -> qMagnification}] ] End[]; EndPackage[];