(* ::Package:: *) BeginPackage["Symbexv2MTH140`"]; (* 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"; Begin["`Private`"]; examIDString = "\!\(\* StyleBox[\"MTH140\",\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[\"Alvarez\",\nFontWeight->\"Bold\"]\)\!\(\* StyleBox[\".\",\nFontWeight->\"Bold\"]\)"; examIDString2 = "MTH140, Sept 2014, Prof. Alvarez"; examName = "Polynomials Module"; examName2 = "Polynomials"; qMagnification = 1.2; bigNumber = 1000102010004455; (* [[2]] told me, I told [[3]], [[4]] book, it is all [[5]] *) qNamesList={{"Boza", "he", "him", "his", "his"}, {"Dara", "he", "him", "his", "his"} , {"Jack", "he", "him", "his", "his"}, {"Ginger", "she", "her", "her", "hers"}, {"Wayne", "he", "him", "his", "his"}, {"Spomenka", "she", "her", "her", "hers"}, {"George", "he", "him", "his", "his"}, {"Kevin", "he", "him", "his", "his"}, {"Tina", "she", "her", "her", "hers"}, {"Lucia", "she", "her", "her", "hers"}, {"Ahmad", "he", "him", "his", "his"},{"Abaz", "he", "him", "his", "his"}}; qRandList[list0_]:=list0[[RandomInteger[{1, Length[list0]}]]] qCaps[x0_]:=Module[{x=x0}, x=Characters[x]; StringJoin[Join[{ToUpperCase[x[[1]]]}, Drop[x,1]]] ] (* only counts the True click *) qClick[n0_]:=Module[{n=n0}, qClicks[[n]][[2]] = 1; ] qClickPlus[n0_]:=Module[{n=n0}, qClicks[[n]][[3]] = 1; ] 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\\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,g2, res2}, Manipulate[ (*g2 = Refresh[CheckboxBar[Range[qNum]*qClicks[[1;;qNum,2]],Range[qNum], Appearance->"Vertical",Enabled->False],UpdateInterval->1];*) 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[qClicks]<>ToString[track]<>"gilan1339","MD5"],16]<>" to Deidre Lam \n"<>"Test results stored in file: "<>res2[[2]],Red,Background->Yellow]], ""]],Dynamic[If[res==True,CheckboxBar[Range[qNum]*qClicks[[1;;qNum,2]],Range[qNum], Appearance->"Vertical",Enabled->False], ""]], Dynamic[Which[(Mean[qClicks[[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[\" \",\nFontColor->RGBColor[1, 0, 0]]\)"<> examName <>" \!\(\* 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[qClicks[[1;;qNum,2]]]]*100]],(Mean[qClicks[[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[qClicks[[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=qFlush[studentID<>" , "<>examName2<>" , "<>ToString[Ceiling[qTrunc4[Mean[qClicks[[1;;qNum,2]]]]*100]]<>" , "<>ToString[qClicks]<>" , "<>examIDString2<>" , "<>DateString[]<>" , "<>ToString[track]<>" , "<>IntegerString[Hash[ToString[qClicks]<>ToString[track]<>"gilan1339","MD5"],16],studentID]; URLFetch["http://symbolicexams.lossofgenerality.com/wp-content/plugins/test-receiver/results.php","Parameters"->{"results"->studentID<>" , "<>examName2<>" , "<>ToString[Ceiling[qTrunc4[Mean[qClicks[[1;;qNum,2]]]]*100]]<>" , "<>ToString[qClicks]<>" , "<>examIDString2<>" , "<>DateString[]<>" , "<>ToString[track]<>" , "<>IntegerString[Hash[ToString[qClicks]<>ToString[track]<>"gilan1339","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,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}])] ] 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,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->1]; 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, 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="")] ] 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"] not0[x_]:=If[x==0, 1, x] qPanelsolution1[a_,b_,c_]:=DynamicModule[{body, z, d,x}, z=-b-c; d=b*c; body={{ "f(x) = a(x"<>qSign3[-b]<>")(x"<>qSign3[-c]<>") since the x intercepts are x ="<>ToString[b]<>", "<>ToString[c], "\nLet "<>ToString[a*b*c]<>"=a(0"<>qSign3[-b]<>")(0"<>qSign3[-c]<>")", "\nSolve for a: ", "\na="<>ToString[a], "\nf(x)="<>ToString[a]<>"(x"<>qSign3[-b]<>")(x"<>qSign3[-c]<>")", "\nf(x)="<>ToString[a]<>"("ToString[HoldForm["x"^2],StandardForm]<>qSign4[z]<>"x"<>qSign4[d]<>")", "\nf(x)="<>ToString[TraditionalForm[Expand[a*(x-b)*(x-c)],ParameterVariables:>{a,b,c}]/.{x->"x"},StandardForm] } , {Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation1[pn_]:=Module[{person,variations,text }, variations={{"Find the equation of the graph shown below. Answer in the form:\nf(x)="<>ToString[HoldForm["a"*"x"^2+"b"*"x"+"c"],StandardForm]}, {"What is the equation for the graph below. Answer in the form:\nf(x)="<>ToString[HoldForm["a"*"x"^2+"b"*"x"+"c"],StandardForm]} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers1[a_,b_,c_]:=Module[{}, {"f(x)="<>ToString[TraditionalForm[Expand[a*(x-b)*(x-c)+1],ParameterVariables:>{a,b,c}]/.{x->"x"},StandardForm],"f(x)="<>ToString[TraditionalForm[Expand[a*(x-b)*(x-c-1)],ParameterVariables:>{a,b,c}]/.{x->"x"},StandardForm],"f(x)="<>ToString[TraditionalForm[Expand[a*(x-b)*(x-c)],ParameterVariables:>{a,b,c}]/.{x->"x"},StandardForm],"f(x)="<>ToString[TraditionalForm[Expand[a*(x-b+1)*(x-c)],ParameterVariables:>{a,b,c}]/.{x->"x"},StandardForm]} ] qPanelTRYAGAIN1[]:={not0[RandomInteger[{-3,3}]],not0[RandomInteger[{-3,3}]],not0[RandomInteger[{-2,2}]]} qPaneHint1[a0_,b0_,c0_]:=Module[{body,a=a0,b=b0,c=c0}, body={{ "f(0) = c .\n", "At which x-values the curve intersects the x-axis?"<>"\n" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR1[a_,b_,c_]:=Plot[f1[x,a,b,c], {x,-4,4},AxesLabel->{"x", "f(x)"}, PlotRange->{{-4,4}, {-Abs[a*b*c]-1,Abs[a*b*c]+1}},ImageSize->400] f1[x_,a_,b_,c_]:=a*(x-b)*(x-c) qPanel1[pn0_,diag0_]:= DynamicModule[{xxx, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,answer,b,c,a, s,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 *) {a,b,c}=qPanelTRYAGAIN1[]; text=qPanelVariation1[pn]; 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[a,b,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],Column[{answerStudent,qPanelEXPR1[a,b,c]}],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];{a,b,c}=qPanelTRYAGAIN1[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint1[a,b,c]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution1[a,b,c]},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[ {a,b,c}=qPanelTRYAGAIN1[]; text=qPanelVariation1[pn]; 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[a,b,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],Column[{answerStudent,qPanelEXPR1[a,b,c]}],ImageMargins->10]]], "", 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}] ] ] qPanelsolution2[vars_]:=DynamicModule[{body, e,n,m,c,a,b,x, ctr=0}, {e,n,m,c,a,b}=vars; If[e*a-n ==0 && a^2+m ==0, ctr+=1]; If[e*b-n ==0 && b^2+m ==0, ctr+=1]; body={{ ToString[e*"x"-n,TraditionalForm]<>"="<>ToString[("x"^2+m)*ToString[c],TraditionalForm]<>" (multiply both sides by "<>ToString["x"^2+m,TraditionalForm]<>")", ToString[("x"^2+m)*c -(e*"x"-n),TraditionalForm]<>"=0", ToString[Factor[("x"^2+m)*c -(e*"x"-n)],TraditionalForm]<>"=0", "x="<>ToString[a]<>", "<>ToString[b], "Substitute the roots into the original equation, look for "<>ToString[HoldForm["0"/"0"], TraditionalForm], "When "<>ToString[a, TraditionalForm]<>": "<>If[e*a-n ==0 && a^2+m ==0, ToString[HoldForm["0"/"0"], TraditionalForm]<>" detected", "Clear"], "When "<>ToString[b, TraditionalForm]<>": "<>If[e*b-n ==0 && b^2+m ==0, ToString[HoldForm["0"/"0"], TraditionalForm]<>" detected","Clear"], If[ctr ==0, "Product of two roots="<>"("<>ToString[a]<>")"<>"("<>ToString[b]<>")"<>"="<>ToString[a*b], "Not possible to calculate as there is only one distinct root"] } , {Null,Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation2[pn_, vars_]:=Module[{e,n,m,c,a,b,variations,text}, {e,n,m,c,a,b}=vars; variations={{"Solve: "<>ToString[ToString[e*"x"-n,TraditionalForm]/ToString["x"^2+m,TraditionalForm],StandardForm]<>" = "<>ToString[c],". The product of the two roots is:" } }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers2[vars_]:=Module[{e,n,m,c,a,b,ctr=0}, {e,n,m,c,a,b}=vars; If[e*a-n ==0 && a^2+m ==0, ctr+=1]; If[e*b-n ==0 && b^2+m ==0, ctr+=1]; {ToString[a*b+1],ToString[a*b+2], If[ctr==0,ToString[a*b],"not possible to calculate as there is only one distinct root"], If[ctr!=0,ToString[a*b], "not possible to calculate as there is only one distinct root"] } ] qPanelTRYAGAIN2[]:=Module[{e,n,m,c,a,b}, {e,n,m,c,a,b}=makeVARS2[]; {e,n,m,c,a,b} ] qPaneHint2[vars_]:=Module[{body}, body={{ ToString[HoldForm["P(x)"/"Q(x)"],StandardForm]<>"=c \[DoubleLongRightArrow] P(x)=cQ(x)", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR2[vars_]:="" makeVARS2[]:=Module[{a,m,n,b,c,list}, list=DeleteDuplicates[DeleteCases[Flatten[Table[If[IntegerQ[(e-Sqrt[e^2-4 c^2 m-4 c n])/(2 c)]==True&&IntegerQ[(e+Sqrt[e^2-4 c^2 m-4 c n])/(2 c)]==True, {e,n,m,c,Simplify[(e-Sqrt[e^2-4 c^2 m-4 c n])/(2 c)],Simplify[(e+Sqrt[e^2-4 c^2 m-4 c n])/(2 c) ]}], {e, 1, 5}, {n, 1, 5}, {m, -4, 4}, {c, 1, 5}],3],Null]]; list[[RandomInteger[{1, Length[list]}]]]] qPanel2[pn0_,diag0_]:= DynamicModule[{xxx,vars, pn=pn0,text,person,variations,A1=False,B1=False,C1=False,D1=False,answer,b,c,a,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[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=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[vars]}],ImageMargins->10]]], "", 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}] ] ] qPanelsolution3[vars_]:=DynamicModule[{body, x,aa,bb,cc,dd,a,b,c,d,rem,f,aaa,bbb,sol}, {{dd,cc,bb,aa},{a,b,c,d,rem}}=vars; f[x_]:={1,x,x^2,x^3}.{dd,cc,bb,aa}; body={{ "From information above we know that:\n", "f("<>ToString[c]<>")="<>ToString[f[c]]<>" and f("<>ToString[a]<>")="<>ToString[f[a]]<>"\n", "f("<>ToString[c]<>")="<>ToString[TraditionalForm["a"*(x)^3+"b"*(x)^2+cc*(x)+dd,ParameterVariables:>{cc,dd}]/.{x->("("<>ToString[c]<>")")},TraditionalForm]<>"="<>ToString[rem]<>"\n", Framed[ToString[TraditionalForm["a"*x^3+"b"*x^2,ParameterVariables:>{"a","b"}]/.{x->c},TraditionalForm]<>"="<>ToString[rem-(cc*(c)+dd)]], "\n", "f("<>ToString[a]<>")="<>ToString[TraditionalForm["a"*(x)^3+"b"*(x)^2+cc*(x)+dd,ParameterVariables:>{cc,dd}]/.{x->("("<>ToString[a]<>")")},TraditionalForm]<>"="<>ToString[f[a]]<>"\n", Framed[ToString[TraditionalForm["a"*x^3+"b"*x^2,ParameterVariables:>{"a","b"}]/.{x->a},TraditionalForm]<>"="<>ToString[f[a]-(cc*(a)+dd)]], "\nFinally solve the above system of equations:\n", sol=Solve[(aaa*a^3+bbb*a^2==f[a]-(cc*(a)+dd))&&(aaa*c^3+bbb*c^2==rem-(cc*(c)+dd)),{aaa,bbb}];"a="<>ToString[(aaa/.sol)[[1]]]<>", "<>"b="<>ToString[(bbb/.sol)[[1]]]<>"\n" } , {Null,Null,Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation3[pn_, vars_]:=Module[{person,variations,text,aa,bb,cc,dd,a,b,c,d,rem}, {{dd,cc,bb,aa},{a,b,c,d,rem}}=vars; variations={{"The function f(x)="<> ToString[TraditionalForm["a"*x^3+"b"*x^2+cc*x+dd,ParameterVariables:>{cc,dd}]/.{x->"x"},StandardForm]<>" leaves a remainder of "<>ToString[rem]<>" when divided by x"<>qSign[-c]<>" and it is known that x"<>qSign[-a]<>" is a factor of f(x). Find a and b" } }; text=ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers3[vars_]:=Module[{aa,bb,cc,dd,a,b,c,d,rem,aaa,bbb}, {{dd,cc,bb,aa},{a,b,c,d,rem}}=vars; {"a="<>ToString[aa+1]<>",b="<>ToString[bb],"a="<>ToString[aa-1]<>",b="<>ToString[bb+1], "a="<>ToString[aa]<>",b="<>ToString[bb] , "a="<>ToString[aa+1]<>",b="<>ToString[bb-1]} ] qPanelTRYAGAIN3[]:=Module[{a,b,c,d,res}, (*f=(x-a)*(b*x^2+c*x+d)*) res=makePoly3[a=not0[RandomInteger[{-2,2}]],b=not0[RandomInteger[{-2,2}]],c=not0[RandomInteger[{-2,2}]], d=not0[RandomInteger[{-2,2}]]]; While[res[[2]][[5]]==0, res=makePoly3[a=not0[RandomInteger[{-2,2}]],b=not0[RandomInteger[{-2,2}]],c=not0[RandomInteger[{-2,2}]], d=not0[RandomInteger[{-2,2}]]]]; res ] qPaneHint3[vars_]:=Module[{body,aa,bb,cc,dd,a,b,c,d,rem,f}, {{dd,cc,bb,aa},{a,b,c,d,rem}}=vars; f[x_]:={1,x,x^2,x^3}.{dd,cc,bb,aa}; body={{ "Compute f("<>ToString[c]<>")="<>ToString[f[c]]<>" and f("<>ToString[a]<>")="<>ToString[f[a]]<>"\nby replacing corresponding x-values into f(x)", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR3[]:="" makePoly3[a_,b_,c_, d_]:=Module[{x,f,rem,rem1,sol}, f=(x-a)*(b*x^2+c*x+d); sol=Solve[PolynomialRemainder[f, x-c,x]==rem]; rem1=rem/.sol[[1]]; {CoefficientList[f,x], {a,b,c,d,rem1}} ] 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,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, x,aa,bb,cc,dd,a,b,c,d,f,f2,aaa,bbb,sols,sols2,c1,b1,a1}, {{c,b,a}, {aa,bb}}=vars; f2={1,x,x^2}.{c1,b1,a1}; sols2=Solve[f2==0,x]; f={1,x,x^2}.{c,b,a}; sols=Solve[f==0,x]; body={{ "Compute roots:\n", ToString["\!\(\*SubscriptBox[\(x\), \(1\)]\)", StandardForm]<>"="<>ToString[((x/.sols2[[2]])/.{a1->"a",b1->"b", c1->"c"}),StandardForm]<>"\n", ToString["\!\(\*SubscriptBox[\(x\), \(2\)]\)", StandardForm]<>"="<>ToString[(x/.sols2[[1]])/.{a1->"a",b1->"b", c1->"c"},StandardForm]<>"\n", ToString["\!\(\*SubscriptBox[\(x\), \(1\)]\)", StandardForm]<>"="<>ToString[(x/.sols2[[2]])/.{a1->"\[Cross]"<>ToString[a],b1->"("<>ToString[b]<>")", c1->"\[Cross]"<>ToString[c]},StandardForm]<>"\n", ToString["\!\(\*SubscriptBox[\(x\), \(2\)]\)", StandardForm]<>"="<>ToString[(x/.sols2[[1]])/.{a1->"\[Cross]"<>ToString[a],b1->"("<>ToString[b]<>")", c1->"\[Cross]"<>ToString[c]},StandardForm]<>"\n", ToString["\!\(\*SubscriptBox[\(x\), \(1\)]\)", StandardForm]<>"="<>ToString[(x/.sols[[2]]),StandardForm]<>"\n", ToString["\!\(\*SubscriptBox[\(x\), \(2\)]\)", StandardForm]<>"="<>ToString[(x/.sols[[1]]),StandardForm]<>"\n", ToString[ToString["("<>"\!\(\*SubscriptBox[\(x\), \(1\)]\)"<>")",StandardForm]^2, StandardForm]<>"+"<>ToString[ToString["("<>"\!\(\*SubscriptBox[\(x\), \(2\)]\)"<>")",StandardForm]^2, StandardForm]<>"="<>ToString[ToString["("<>ToString[x/.sols[[2]]]<>")",StandardForm]^2, StandardForm]<>"+"<>ToString[ToString["("<>ToString[x/.sols[[1]]]<>")",StandardForm]^2, StandardForm]<>"="<>ToString[aa^2+bb^2] } , {Null,Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation4[pn_, vars_]:=Module[{person,variations,text,aa,bb,cc,dd,a,b,c,d}, {{c,b,a}, {aa,bb}}=vars; variations={{"If "<>ToString["\!\(\*SubscriptBox[\(x\), \(1\)]\)",StandardForm]<>" and "<>ToString["\!\(\*SubscriptBox[\(x\), \(2\)]\)",StandardForm]<>" are the roots of the equation "<> ToString[TraditionalForm[a*"x"^2+b*"x"+c,ParameterVariables:>{a,b,c}],StandardForm]<>"=0 then the value of "<>ToString[ToString["("<>"\!\(\*SubscriptBox[\(x\), \(1\)]\)"<>")",StandardForm]^2, StandardForm]<>"+"<>ToString[ToString["("<>"\!\(\*SubscriptBox[\(x\), \(2\)]\)"<>")",StandardForm]^2, StandardForm]<>" is:" } }; text=ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers4[vars_]:=Module[{aa,bb,cc,dd,a,b,c,d,aaa,bbb}, {{c,b,a}, {aa,bb}}=vars; {ToString[aa^2+bb^2+2],ToString[aa^2+bb^2-1],ToString[aa^2+bb^2],ToString[aa^2+bb^2+1]} ] qPanelTRYAGAIN4[]:=Module[{a,b}, a=not0[RandomInteger[{-4,4}]]; b=not0[RandomInteger[{-4,4}]]; {CoefficientList[(x-a)*(x-b),x], {a,b}} ] qPaneHint4[vars_]:=Module[{body,aa,bb,cc,dd,a,b,c,d,f,x,sols}, f={1,x,x^2}.{c,b,a}; sols=Solve[f==0,x]; body={{ "Factor or compute roots:\n", "x="<>ToString[(x/.sols[[2]])/.{a->"a",b->"b", c->"c"},StandardForm]<>"\n", "x="<>ToString[(x/.sols[[1]])/.{a->"a",b->"b", c->"c"},StandardForm] }, {Null,Null,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,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,kval,up, down, q1,q2,q3,expr,x,ao,bo,co,kvalo, upo, downo, q1o,q2o,q3o,ko,k,expr2}, {a,b,c,kval,k, up, down, q1,q2,q3, expr,expr2}=vars; body={{ "Factor "<>ToString[Collect[Expand[down]/.{ko->k},"x"],TraditionalForm]<>"="<>"("<>ToString[q1/.{ko->k},TraditionalForm]<>")("<>ToString[q2/.{ko->k},TraditionalForm]<>")\n", ToString[(expr/.{ao->a,bo->b, co->c,kvalo->kval,ko->k,upo->up,downo->down,q1o->q1,q2o->q2,q3o->q3}),TraditionalForm]<>"\n", "="<>ToString[expr2/.{ko->k},TraditionalForm]<>"\n", "="<>ToString[Simplify[(up/down)/.{ko->k}],TraditionalForm]<>", x \[NotEqual] "<>ToString[c]<>", "<>ToString[kval*b] } , {Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation5[pn_, vars_]:=Module[{person,variations,text,aa,bb,cc,dd,a,b,c,d,kval,up, down, q1,q2,q3,expr,x,ao,bo,co,kvalo, upo, downo, q1o,q2o,q3o,ko,k,expr2}, {a,b,c,kval,k, up, down, q1,q2,q3, expr,expr2}=vars; (*ANNA*) variations={{"When simplified, the value of "<>ToString[(expr/.{ao->a,bo->b, co->c,kvalo->kval,ko->k,upo->up,downo->down,q1o->q1,q2o->q2,q3o->q3}),StandardForm]<>" is:"} (*ANNA*) }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers5[vars_]:=Module[{ a,b,c,d,kval,up, down, q1,q2,q3,expr,x,ao,bo,co,kvalo, upo, downo, q1o,q2o,q3o,ko,k,expr2}, {a,b,c,kval,k, up, down, q1,q2,q3, expr,expr2}=vars; { ToString[Simplify[("x"+(3*up+2)/down)/.{ko->k}],TraditionalForm]<>", x \[NotEqual] "<>ToString[c+2]<>", "<>ToString[kval*b-2], ToString[Simplify[("x"+(2*up+1)/down)/.{ko->k}],TraditionalForm]<>", x \[NotEqual] "<>ToString[c+3]<>", "<>ToString[kval*b-3], ToString[Simplify[(up/down)/.{ko->k}],TraditionalForm]<>", x \[NotEqual] "<>ToString[c]<>", "<>ToString[kval*b], ToString[Simplify[(up*2/down)/.{ko->k}],TraditionalForm]<>", x \[NotEqual] "<>ToString[c-1]<>", "<>ToString[kval*b-1]} ] qPanelTRYAGAIN5[]:=Module[{ao,bo,co,ko,upo, downo, q1o, q2o, q3o,kvalo,expr,expr2,x}, kvalo=not0[RandomInteger[{-2,2}]]; ao=not0[RandomInteger[{-2,2}]]; co=not0[RandomInteger[{-3,3}]]; bo=ao*co; upo=ao*("x"-co)-(ko*"x"-bo); downo=("x"-co)*("x"-ko*bo); q1o=("x"-co); q2o=("x"- ko*bo); q3o=(ko*"x"-bo); expr2=(ToString[Collect[Expand[ao/.{ko->kvalo}],"x"],TraditionalForm]/ToString[Collect[Expand[downo]/.{ko->kvalo},"x"],TraditionalForm])-"("<>ToString[ToString[Collect[Expand[(ko*"x"-bo)/.{ko->kvalo}],"x"],TraditionalForm]/ToString[Collect[Expand[downo]/.{ko->kvalo},"x"],TraditionalForm],TraditionalForm]<>")"*"("<>ToString[ToString[q1o/.{ko->kvalo},TraditionalForm]<>" "/ToString[q1o/.{ko->kvalo},TraditionalForm],TraditionalForm]<>")"; expr2=(ToString["("<>ToString[Collect[Expand[ao/.{ko->kvalo}],"x"],TraditionalForm]<>")"*ToString["("<>ToString[Collect[Expand[q1o/.{ko->kvalo}],"x"],TraditionalForm], TraditionalForm]<>")",TraditionalForm]/(ToString["("<>ToString[Collect[Expand[q2o]/.{ko->kvalo},"x"],TraditionalForm]<>")"*ToString["("<>ToString[Collect[Expand[q1o/.{ko->kvalo}],"x"],TraditionalForm], TraditionalForm]<>")",TraditionalForm]))-"("<>ToString[ToString[Collect[Expand[(ko*"x"-bo)/.{ko->kvalo}],"x"],TraditionalForm]/ToString[Factor[Expand[downo]/.{ko->kvalo}],TraditionalForm],TraditionalForm]<>")"; expr=(ToString[Collect[Expand[ao/.{ko->kvalo}],"x"],TraditionalForm]/ToString[Collect[Expand[q2o]/.{ko->kvalo},"x"],TraditionalForm])-(ToString[Collect[Expand[(ko*"x"-bo)/.{ko->kvalo}],"x"],TraditionalForm]/ToString[Collect[Expand[downo]/.{ko->kvalo},"x"],TraditionalForm]); {ao,bo,co,kvalo,ko, upo/.{ko->kvalo}, downo/.{ko->kvalo}, q1o/.{ko->kvalo},q2o/.{ko->kvalo},q3o/.{ko->kvalo}, expr,expr2} ] qPaneHint5[vars_]:=Module[{body,aa,bb,cc,dd,a,b,c,d,f,x,sols}, body={{ "Factor the denominator.", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR5[]:="" 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[]}],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,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[]}],ImageMargins->10]]], "", 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}] ] ] aMinusbEvenSQUARED[]:=Module[{evensquares, a,b,i,x,ablist,list,f,f2,f3}, evensquares={4,4*2^2}; a=not0[RandomInteger[{-10,10}]]; i=RandomInteger[{1,Length[evensquares]}]; ablist=Flatten[Table[ {evensquares[[i]]+a,a},{i,1 ,Length[evensquares]}, {a,-10,10}],1]; list=DeleteCases[Table[ {b,a}=ablist[[i]]; f=(x-a)*(x-b); f2=b^2+2b*x+x^2; f3=-f+f2; (* (-(a+b)\[NotEqual]2*b) necessary to have left over x factor *) If[(Max[Abs[CoefficientList[f3,x]]]<121)&&(-(a+b)!=2*b)&&((a>0 &&b<0)||(a<0 &&b>0)||(a>0 &&b>0)),Simplify[{f2,f3,{b,a}}]] ,{i, 1, Length[ablist]}],Null]; Simplify[list[[RandomInteger[{1,Length[list]}]]]/.{x->"x"}] ] qPanelsolution6[vars_]:=DynamicModule[{body, expr1,expr2,expr3,level,expr4,sols,xx,x}, {expr1,expr2,expr3}=vars; body={{ ToString[expr3,TraditionalForm]<>"="<>ToString[-expr1-expr2,TraditionalForm]<>"\n", ToString[ToString["("<>ToString[expr3,TraditionalForm]<>")",TraditionalForm]^"2",TraditionalForm]<>"="<>ToString[(-expr1-expr2)^2,TraditionalForm]<>"\n", ToString[Expand[expr3^2,TraditionalForm]]<>"="<>ToString[Simplify[Expand[(-expr1-expr2)^2]],TraditionalForm]<>"\n", level=Level[Collect[expr3^2-(-expr1-expr2)^2,"x"],1];expr4={level[[1]] +level[[2]],-level[[3]]}; ToString[expr4[[1]],TraditionalForm]<>"="<>ToString[expr4[[2]],TraditionalForm]<>"\n", ToString[expr4[[1]]^2,TraditionalForm]<>"="<>ToString[expr4[[2]]^2,TraditionalForm]<>"\n", ToString[expr4[[1]]^2-expr4[[2]]^2,TraditionalForm]<>"= 0"<>"\n", ToString[Expand[expr4[[1]]^2-expr4[[2]]^2],TraditionalForm]<>"= 0"<>"\n", ToString[Factor[Expand[expr4[[1]]^2-expr4[[2]]^2]],TraditionalForm]<>"= 0"<>"\n", sols=Solve[((expr4[[1]]^2-expr4[[2]]^2)/.{"x"->x})==0,x]; "Plug back into the original equation see if both solutions are valid:\n", xx=ToString[x/.sols[[1]]]; "Case x="<>xx<>": "<>ToString[expr2+expr3,TraditionalForm]<>"="<>ToString[Simplify[((expr2+expr3)/.{"x"->x})/.sols[[1]]],TraditionalForm]<>"\n", xx=ToString[x/.sols[[2]]]; "Case x="<>xx<>": "<>ToString[expr2+expr3,TraditionalForm]<>"="<>ToString[Simplify[((expr2+expr3)/.{"x"->x})/.sols[[2]]],TraditionalForm]<>"\n", If[Simplify[((expr2+expr3)/.{"x"->x})/.sols[[1]]]!=Simplify[((expr2+expr3)/.{"x"->x})/.sols[[2]]], "Only one valid solution", "Two valid solutions, sum="<>ToString[(x/.sols[[1]])+(x/.sols[[2]]),TraditionalForm]] }, {Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation6[pn_, vars_]:=Module[{variations,expr1,expr2,expr3}, {expr1,expr2,expr3}=vars; variations={{"Solve: "<>ToString[expr2+expr3,StandardForm]<>"="<>ToString[-expr1,StandardForm]<>". If two solutions, the sum of solutions is:"} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers6[vars_]:=Module[{expr1, expr2, expr3,sols}, {expr1,expr2,expr3}=vars; sols=Solve[((expr1+expr2+expr3)/.{"x"->x}) ==0,x]; {If[Length[sols]==2, ToString[1+(x/.sols[[1]])+(x/.sols[[2]])], ToString[2+(x/.sols[[1]])]] ,If[Length[sols]==2, ToString[2+(x/.sols[[1]])+(x/.sols[[2]])], ToString[1+(x/.sols[[1]])]] ,If[Length[sols]==2, ToString[(x/.sols[[1]])+(x/.sols[[2]])], "Only one solution"] ,If[Length[sols]==2, "Only one solution", ToString[4+(x/.sols[[1]])]]} ] qPanelTRYAGAIN6[]:=Module[{expr,expr2,x,c,c2,c3,c4,c5,c6,level}, c=aMinusbEvenSQUARED[]; c2=Sqrt[FactorTermsList[c[[2]]]]; c3=((c2[[1]]/2)+c2[[2]]); c4=Expand[((c2[[1]]/2)+c2[[2]])^2]; c5=Simplify[c4-Sqrt[c[[2]]]]; c6=PowerExpand[Simplify[Sqrt[c[[1]]]]]; Sqrt[c6+c5]-c3; level=Simplify[Level[Sqrt[c6+c5]-c3,1]] ] qPaneHint6[vars_]:=Module[{body,aa,bb,cc,dd,a,b,c,d,f,x,sols}, body={{ "Isolate the radical so that there is one radical on each side of the equation", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR6[]:="" 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[]}],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[]}],ImageMargins->10]]], "", 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}] ] ] makeABCD[]:=Module[{list,a,b,c,d,num,x,sols,res}, list=DeleteCases[Flatten[Table[If[IntegerQ[Sqrt[-4+a^2+4 b^2]]==True, {a,b}], {a,1, 10}, {b, 2,9}],1],Null]; {a,b}=list[[RandomInteger[{1,Length[list]}]]]; num=Numerator[Factor[((a*x-1)/(x^2-b^2))-1]]; sols=Solve[CoefficientList[Expand[-(x-c)*(x-d)]-num,x]==0,{c,d}]; res={c,d}/.sols[[1]]; {a,b,res[[1]],res[[2]]} ] intPlot[ss_,{s_,e_},ee_,sign_]:=intPlot[{{ss,{s,e},ee,sign}}] intPlot[ints:{{_String,{_?NumericQ,_?NumericQ},_String,_String}..}]:=Module[{i=-1,int}, With[{min=Min[ints[[All,2,1]]],max=Max[ints[[All,2,2]]],roots={Sort[ints[[All,2,1]],Less]}}, Graphics[Table[With[{ss=int[[1]],s=int[[2,1]],e=int[[2,2]],ee=int[[3]],sign=int[[4]]},{Thickness[.01],Gray,Text[Style[ss,Large,LightGray],{s,i*0}],Text[Style[ee,Large,LightGray],{e,i*0}],Text[Style[sign,Small,Black],{(e+s)/2,1/2}](*,Line[{{s,i*0},{e,i*0}}]*)}],{int,ints}], Axes->{True,False},AxesStyle->Directive[Thick,LightGray,12],Ticks->roots,TicksStyle->Directive[Red,8],PlotRange->{{min+1,max-1},{0,++i}},AspectRatio->.2]]] (* this version had graphics *) qPanelsolution7v2[vars_]:=DynamicModule[{body,a,b,c,d,f,f2,f3,ff,ff2,x,e,y,g1,g2,g3,gg0,gg1,gg2,gg3,gg4,fff,fff2,region,list={}}, {a,b,c,d,f,f2,f3,region}=vars; ff=-(x-c)*(x-d); ff2=Factor[(x^2-b^2)]; e=Max[Abs[{a,b,c,d}]]+2; g1=RegionPlot[ff<=0, {x,-e,e},{y,-1,1},PlotStyle->Directive[PointSize[Medium],LightGreen],BoundaryStyle->Dashed,PlotRange->{{-e,e},{-1,1}}]; g2=RegionPlot[ff2<=0, {x,-e,e},{y,-1,1},PlotStyle->Directive[PointSize[Medium],LightGreen],BoundaryStyle->Dashed,PlotRange->{{-e,e},{-1,1}}]; g3=RegionPlot[ff2*ff>0, {x,-e,e},{y,-1,1},PlotStyle->Directive[PointSize[Medium],LightRed],BoundaryStyle->Dashed,PlotRange->{{-e,e},{-1,1}}]; fff=f/.{"x"->x}; gg1=Plot[fff, {x,-e,e},PlotStyle->Directive[Black],PlotRange->{{-e,e},{-1,1}}]; gg2=RegionPlot[fff<=0, {x,-e,e},{y,-1,1},PlotStyle->Directive[PointSize[Small],LightGreen],BoundaryStyle->Dashed,PlotRange->{{-e,e},{-1,1}}]; gg3=ListPlot[{x,.0}/.FindInstance[fff<=0 &&-e<=x<=e, x,10],PlotMarkers->{"-"},PlotStyle->Directive[PointSize[Small],Orange],PlotRange->{{-e,e},{-1,1}}]; gg4=ListPlot[{x,.6}/.FindInstance[fff>0 &&-e<=x<=e, x,4],PlotMarkers->{"+"},PlotStyle->Directive[PointSize[Small],Red],PlotRange->{{-e,e},{-1,1}}]; body={{ "Move 1 to the lhs of inequality:\n"<>ToString[f,StandardForm]<>"="<>ToString[f3,StandardForm]<>"\n", "="<>ToString[f2,StandardForm]<>" \[LessEqual] 0\n", "Factored Numerator: -(x"<>qSign[-c]<>")(x"<>qSign[-d]<>")\n", g1, "Factored Denominator: (x"<>qSign[-b]<>")(x"<>qSign[b]<>")\n", g2, "Overlap: Positive\n", g3, ToString[region,StandardForm]<>": \n", Show[gg2,gg3,gg4,gg1] }, {Null,Null,Null,Null,Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelsolution7[vars_]:=DynamicModule[{body,a,b,c,d,f,f2,f3,ff,ff2,x,e,y,g1,g2,g3,gg0,gg1,gg2,gg3,gg4,fff,fff2,region,roots,max,min}, {a,b,c,d,f,f2,f3,region}=vars; ff=-(x-c)*(x-d); ff2=Factor[(x^2-b^2)]; e=Max[Abs[{a,b,c,d}]]+2; max=Max[{b,c,d,-b}]+3; min=Min[{b,c,d,-b}]-3; body={{ "Move 1 to the left hand side of inequality:\n"<>ToString[f,TraditionalForm]<>"="<>ToString[f3,TraditionalForm]<>" \[LessEqual] 0\n", "="<>ToString[f2,TraditionalForm]<>" \[LessEqual] 0\n", "Factored Numerator: -(x"<>qSign[-c]<>")(x"<>qSign[-d]<>")\n", "Factored Denominator: (x"<>qSign[-b]<>")(x"<>qSign[b]<>")\n", ToString[region,TraditionalForm]<>": \n", roots=Sort[{-b,b,c,d,max,min}];intPlot[{{"|",{roots[[1]],roots[[2]]},"|",qSign2[f/.{"x"->(roots[[1]]+roots[[2]])/2}]},{"|",{roots[[2]],roots[[3]]},"|",qSign2[f/.{"x"->(roots[[2]]+roots[[3]])/2}]},{"|",{roots[[3]],roots[[4]]},"|",qSign2[f/.{"x"->(roots[[3]]+roots[[4]])/2}]},{"|",{roots[[4]],roots[[5]]},"|",qSign2[f/.{"x"->(roots[[4]]+roots[[5]])/2}]},{"|",{roots[[5]],roots[[6]]},"|",qSign2[f/.{"x"->(roots[[5]]+roots[[6]])/2}]}}] }, {Null,Null,Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation7[pn_, vars_]:=Module[{a,b,c,d,f,f2,f3,region}, {a,b,c,d,f,f2,f3,region}=vars; variations={{"Solve: "<>ToString[f+1,TraditionalForm]<>" \[LessEqual] 1"} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers7[vars_]:=Module[{a,b,c,d,f,f2,f3,aA,bA,cA,dA,list={},regionA,aB,bB,cB,dB,regionB,aD,bD,cD,dD,regionD,region}, {a,b,c,d,f,f2,f3,region}=vars; (* {ToString[c]<>"\[LessEqual]x\[LessEqual]"<>ToString[c+2],ToString[b]<>"\[LessEqual]x",region,ToString[b]<>"\[LessEqual]x\[LessEqual]"<>ToString[b+3]} *) While [Length[DeleteDuplicates[list]] <4, {aA,bA,cA,dA}=makeABCD[]; regionA=Reduce[((aA*x-1)/(x^2-bA^2))-1<=0,x]; regionA=ToString[regionA/.{x->"x"}]; regionA=StringReplace[ToString[regionA, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; {aB,bB,cB,dB}=makeABCD[]; regionB=Reduce[((aB*x-1)/(x^2-bB^2))-1<=0,x]; regionB=ToString[regionB/.{x->"x"}]; regionB=StringReplace[ToString[regionB, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; {aD,bD,cD,dD}=makeABCD[]; regionD=Reduce[((aD*x-1)/(x^2-bD^2))-1<=0,x]; regionD=ToString[regionD/.{x->"x"}]; regionD=StringReplace[ToString[regionD, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; list={{aA,bA,cA,dA},{aB,bB,cB,dB},{aD,bD,cD,dD}, {a,b,c,d}}; ]; {regionA, regionB, region, regionD} ] qPanelTRYAGAIN7[]:=Module[{a,b,c,d,x,region}, {a,b,c,d}=makeABCD[]; region=Reduce[((a*x-1)/(x^2-b^2))-1<=0,x]; region=ToString[region/.{x->"x"}]; region=StringReplace[ToString[region, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; {a,b,c,d,((a*x-1)/(x^2-b^2))-1, (-(x-c)*(x-d)/(x^2-b^2)),(((a*x-1)-(x^2-b^2))/(x^2-b^2)) , region}/.{x->"x"} ] qPaneHint7[vars_]:=Module[{}, body={{ "Make the inequality be 0. Factor the expression and find a common denominator.", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR7[]:="" qPanel7[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=qPanelTRYAGAIN7[]; text=qPanelVariation7[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=qPanelAnswers7[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,qPanelEXPR7[]}],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=qPanelTRYAGAIN7[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint7[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution7[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=qPanelTRYAGAIN7[]; text=qPanelVariation7[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=qPanelAnswers7[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,qPanelEXPR7[]}],ImageMargins->10]]], "", 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}] ] ] makeAB2[]:=Module[{a,b,c,f,n,x}, a=1; b=1; While[a==b, a=not0[RandomInteger[{-4,4}]]; b=not0[RandomInteger[{-4,4}]]; c=not0[RandomInteger[{-2,2}]]; n=RandomInteger[{0,1}]; f=((-1)^n)*c*(x-a)*(x-b); ]; {a,b,c,n,Expand[f],Factor[f]}/.{x->"x"} ] qPanelsolution8v2[vars_]:=DynamicModule[{body,a,b,n,f,ff,region,g1,g2,g3,g4,x,fFactor,e,y}, {a,b,n,f,fFactor,region}=vars; ff=f/.{"x"->x}; e=Max[Abs[CoefficientList[ff,x]]]+2; g1=Plot[Sqrt[ff], {x,-e,e},PlotStyle->Directive[Black]]; g2=RegionPlot[ff>=0, {x,-e,e},{y,0,10},PlotStyle->Directive[PointSize[Medium],LightGreen],BoundaryStyle->Dashed]; g3=ListPlot[{x,5}/.FindInstance[ff>=0 &&-e<=x<=e, x,10],PlotMarkers->{"+"},PlotStyle->Directive[PointSize[Medium],Orange]]; g4=ListPlot[{x,7}/.FindInstance[ff<0 &&-e<=x<=e, x,4],PlotMarkers->{"-"},PlotStyle->Directive[PointSize[Medium],Red]]; body={{ "Factor the expression under the radical:\n", ToString[fFactor,StandardForm]<>"\n", "Plug sample numbers and check for + sign:\n", Show[g2,g1,g3,g4] }, {Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelsolution8[vars_]:=DynamicModule[{body,a,b,c,n,f,ff,region,g1,g2,g3,g4,x,fFactor,e,y,max,min,roots}, {a,b,c,n,f,fFactor,region}=vars; ff=f/.{"x"->x}; e=Max[Abs[CoefficientList[ff,x]]]+2; max=Max[{a,b}]+3; min=Min[{a,b}]-3; body={{ "Factor the expression under the radical:\n", ToString[fFactor,TraditionalForm]<>" \[GreaterSlantEqual] 0\n", "Plug sample numbers and check for + sign:\n", roots=Sort[{a,b,max,min}];intPlot[{{"|",{roots[[1]],roots[[2]]},"|",qSign2[f/.{"x"->(roots[[1]]+roots[[2]])/2}]},{"|",{roots[[2]],roots[[3]]},"|",qSign2[f/.{"x"->(roots[[2]]+roots[[3]])/2}]},{"|",{roots[[3]],roots[[4]]},"|",qSign2[f/.{"x"->(roots[[3]]+roots[[4]])/2}]}}] }, {Null,Null,Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelVariation8[pn_, vars_]:=Module[{a,b,c,n,d,f,f2,f3,region,fFactor,variations}, {a,b,c,n,f,fFactor,region}=vars; variations={{"The Domain of "<>ToString[Sqrt[f],TraditionalForm]<>" is:"} }; ToString[pn]<>". "<>qRandList[variations] ] qPanelAnswers8[vars_]:=Module[{a,b,c,n,d,f,f2,f3,region,regionA, regionB,regionC, regionD,fFactor,x,e}, {a,b,c,n,f,fFactor,regionC}=vars; regionA=regionB=regionD=0; While[regionA==regionB || regionB==regionD || regionD==regionA || (regionC==regionA || regionC==regionB ||regionC==regionD) , {a,b,c,n,f,fFactor}=makeAB2[]; f=f/.{"x"->x}; e=Max[Abs[CoefficientList[f,x]]]+2; region=Reduce[f>=0,x]; region=ToString[region/.{x->"x"}]; regionA=StringReplace[ToString[region, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; {a,b,c,n,f,fFactor}=makeAB2[]; f=f/.{"x"->x}; e=Max[Abs[CoefficientList[f,x]]]+2; region=Reduce[f>=0,x]; region=ToString[region/.{x->"x"}]; regionB=StringReplace[ToString[region, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; {a,b,c,n,f,fFactor}=makeAB2[]; f=f/.{"x"->x}; e=Max[Abs[CoefficientList[f,x]]]+2; region=Reduce[f>=0,x]; region=ToString[region/.{x->"x"}]; regionD=StringReplace[ToString[region, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; ]; (* FIXME use of region did not work *) {regionA,regionB,regionC,regionD} ] qPanelTRYAGAIN8[]:=Module[{a,b,c,n,d,x,region,f,fFactor,e}, {a,b,c,n,f,fFactor}=makeAB2[]; f=f/.{"x"->x}; e=Max[Abs[CoefficientList[f,x]]]+2; region=Reduce[f>=0,x]; region=ToString[region/.{x->"x"}]; region=StringReplace[ToString[region, TraditionalForm],{"||"->"\[Union]","<="->"\[LessEqual]", ">="->"\[GreaterSlantEqual]"(*,"<= x <="->"\[LessEqual]x \[Intersection] x\[LessEqual]","< x <="->""\[LessEqual]x \[Intersection] x<"*)}]; (*region=FunctionDomain[Sqrt[f],x]; did not work *) (*StringReplace[ToString[domain],{"||"\[Rule]"\[Union]","<= x <="\[Rule]"\[LessEqual]x \[Intersection] x\[LessEqual]"}]*) {a,b,c,n,f,fFactor,region}/.{x->"x"} ] qPaneHint8[vars_]:=Module[{}, body={{ "Set the expression inside the radical to be \[GreaterSlantEqual] 0. Factor the inequality and solve for x.", "" }, {Null,Null}}; Panel[Grid[Transpose[body]]] ] qPanelEXPR8[]:="" qPanel8[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=qPanelTRYAGAIN8[]; text=qPanelVariation8[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=qPanelAnswers8[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,qPanelEXPR8[]}],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=qPanelTRYAGAIN8[];myEnabled=True;A1=False; B1=False;C1=False; D1= False], "Try again"}], OpenerView[{Button["Hint",qTryAgain[pn];stateH=Not[stateH]],qPaneHint8[vars]},stateH], OpenerView[{Button["Solution",qTryAgain[pn];state=Not[state]],qPanelsolution8[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=qPanelTRYAGAIN8[]; text=qPanelVariation8[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=qPanelAnswers8[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,qPanelEXPR8[]}],ImageMargins->10]]], "", 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}] ] ] End[]; EndPackage[];