libLIST=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libLIST.m"]<>"\n";
libNAMES=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libNAMES.m"]<>"\n";
libIO=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libIO.m"]<>"\n";
libERR=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libERR.m"]<>"\n";
libGUI=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libGUI.m"]<>"\n";
libML=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libML.m"]<>"\n";
libMISC=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libMISC.m"]<>"\n";
libGraphics=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libGraphics.m"]<>"\n";
libFUNC=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libFUNC.m"]<>"\n";
libRELATION=ReadString["C:/mathematica/Work/lossofgenerality/MET-CS/HomeWorks/libRELATION.m"]<>"\n";

libLIST=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libLIST.m"]<>"\n";
libNAMES=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libNAMES.m"]<>"\n";
libIO=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libIO.m"]<>"\n";
libERR=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libERR.m"]<>"\n";
libGUI=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libGUI.m"]<>"\n";
libML=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libML.m"]<>"\n";
libMISC=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libMISC.m"]<>"\n";
libGraphics=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libGraphics.m"]<>"\n";
libFUNC=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libFUNC.m"]<>"\n";
libRELATION=ReadString["/Users/darashayda1xfer/Desktop/MODULES/BU/libs/libRELATION.m"]<>"\n";

data1="\n"<>"textfghjkl:="<>ToString[<|

"0"->{"Column[{ToString[\"fghjkl. Answer the following:\",TraditionalForm]"<>","<>"ToString[\"(Yes, No, True, False...) \"]"<>"}]","Column[{ToString[\"fghjkl. Answer with Y or N for yes and no:\",TraditionalForm]"<>","<>"ToString[\" \"]"<>"}]"},



"1"-><|
"1.1"->{"Column[{ToString[\" Is this Relation Symmetric:\"]"<>"}]",
"Column[{ToString[\" Verify if Symmetric:\"]"<>"}]"}
|>,

"2"-><|

"2.1"->{"Column[{ToString[\" Is this Relation Reflexive:\"]"<>"}]",
"Column[{ToString[\" Verify if Reflexive:\"]"<>"}]"}

|>,


"3"-><|

"3.1"->{"Column[{ToString[\" Is this Relation Transitive:\"]"<>"}]",
"Column[{ToString[\" Verify if Transitive:\"]"<>"}]"}

|>,


"4"-><|

"4.1"->{"Column[{ToString[\" Is this a Binary Relation:\"]"<>"}]",
"Column[{ToString[\" Verify if Binary Relation:\"]"<>"}]"}

|>,

"5"-><|

"5.1"->{"Column[{ToString[\" Is this an Equivalence Relation:\"]"<>"}]",
"Column[{ToString[\" Verify if Equivalence Relation:\"]"<>"}]"}

|>



|>,InputForm]<>";\n ";



data2="listfghjkl:="<>


ToString[

""

,InputForm]<>";\n ";

data=ToString[{data1, data2}, InputForm];

canvas1="\n"<>ToString[Hold[canvasFunc1[s_]:=Module[{vars=ertyuiop,text,answers, options,locs,data},

{answers,options}=s;

text=vars["text"];

Column[{ToExpression@text[[1]],



Column[{
Row[{Row[{Column[{options[[1]]<>")"}],ToExpression@text[[2]]}],Pane[answers[[1]],BaselinePosition->Scaled[0.2]]}] 
,

ToExpression@vars["vars"][[1]][[1]]

}],

(*Spacer@100,*)

Column[{Row[{Row[{Column[{options[[2]]<>")"}],ToExpression@text[[3]]}],Pane[answers[[2]],BaselinePosition->Scaled[0.2]]}] ,

ToExpression@vars["vars"][[2]][[1]]
}],

(*Spacer@100,*)
Column[{Row[{Row[{Column[{options[[3]]<>")"}],ToExpression@text[[4]]}],Pane[answers[[3]],BaselinePosition->Scaled[0.2]]}] ,

ToExpression@vars["vars"][[3]][[1]],

}],

(*Spacer@100,*)
Column[{Row[{Row[{Column[{options[[4]]<>")"}],ToExpression@text[[5]]}],Pane[answers[[4]],BaselinePosition->Scaled[0.2]]}] ,

ToExpression@vars["vars"][[4]][[1]]


}]
,

Spacer@100,
Column[{Row[{Row[{Column[{"2. "}],ToExpression@text[[6]]}],Pane[answers[[5]],BaselinePosition->Scaled[0.2]]}] ,

ToExpression@vars["vars"][[5]][[1]]


}]






}]]]

,InputForm]<>"\n ";




variation1=ToExpression[data][[1]]<>ToExpression[data][[2]]<>ToString[Hold[Module[{key,p,a,b,c,d,e,f,g,h,i,j,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,pp, vars,text,list,sol,aabbee,k, parta, partb, partc, partd,parte,partf,partg,parth,parti,question,list12,teste,n},


question=RandomChoice[textfghjkl["0"]];

(*a*)

key=RandomChoice[Keys[textfghjkl["1"]]];
text=RandomChoice[textfghjkl["1"][key]];

Which[

key=="1.1", 

a=RandomChoice@{{makeRelation[]["symmetric"],True},{makeRelation[]["symmetricNOT"],False}};
vars={ToString[((a[[1]])[RandomChoice@Keys@a[[1]]]),InputForm]};

sol=If[a[[2]]==True, {"Y","y","yes","Yes","YES","True","T","true","t"},{"N","n","No","NO","no","false","False","F","f"}];

parta={StringReplace[text, { "#a"->""}],vars,sol} ;];


key=RandomChoice[Keys[textfghjkl["2"]]];
text=RandomChoice[textfghjkl["2"][key]];

Which[

key=="2.1", 

a=RandomChoice@{{makeRelation[]["reflexive"],True},{makeRelation[]["reflexiveNOT"],False}};
vars={ToString[((a[[1]])[RandomChoice@Keys@a[[1]]]),InputForm]};

sol=If[a[[2]]==True, {"Y","y","yes","Yes","YES","True","T","true","t"},{"N","n","No","NO","no","false","False","F","f"}];

partb={StringReplace[text, { "#a"->""}],vars,sol} ;];

key=RandomChoice[Keys[textfghjkl["3"]]];
text=RandomChoice[textfghjkl["3"][key]];

Which[

key=="3.1", 

a=RandomChoice@{{makeRelation[]["transitive"],True},{makeRelation[]["transitiveNOT"],False}};
vars={ToString[((a[[1]])[RandomChoice@Keys@a[[1]]]),InputForm]};

sol=If[a[[2]]==True, {"Y","y","yes","Yes","YES","True","T","true","t"},{"N","n","No","NO","no","false","False","F","f"}];

partc={StringReplace[text, { "#a"->""}],vars,sol} ;];


key=RandomChoice[Keys[textfghjkl["4"]]];
text=RandomChoice[textfghjkl["4"][key]];

Which[

key=="4.1", 

a=RandomChoice@{{makeRelation[]["transitive"],True},{makeRelation[]["transitiveNOT"],True},{notRelation[],False}};
vars={ToString[((a[[1]])[RandomChoice@Keys@a[[1]]]),InputForm]};

sol=If[a[[2]]==True, {"Y","y","yes","Yes","YES","True","T","true","t"},{"N","n","No","NO","no","false","False","F","f"}];

partd={StringReplace[text, { "#a"->""}],vars,sol} ;];


key=RandomChoice[Keys[textfghjkl["5"]]];
text=RandomChoice[textfghjkl["5"][key]];

Which[

key=="5.1", 

a=RandomChoice@{{makeRelation[]["equivalence"],True},{makeRelation[]["equivalenceNOT"],False}};
vars={ToString[((a[[1]])[RandomChoice@Keys@a[[1]]]),InputForm]};

sol=If[a[[2]]==True, {"Y","y","yes","Yes","YES","True","T","true","t"},{"N","n","No","NO","no","false","False","F","f"}];

parte={StringReplace[text, { "#a"->""}],vars,sol} ;];







vars=ToString[<|"text"->{question, parta[[1]],partb[[1]],partc[[1]],partd[[1]],parte[[1]](*,partf[[1]],partg[[1]],parth[[1]],parti[[1]]*)},"vars"->{ parta[[2]],partb[[2]],partc[[2]],partd[[2]],parte[[2]](*,partf[[2]],partg[[2]],parth[[2]],parti[[2]]*)}, "sol"->{ parta[[3]],partb[[3]],partc[[3]],partd[[3]],parte[[3]](*,partf[[3]],partg[[3]],parth[[3]],parti[[3]]*)}|>,InputForm];

{StringReplace[ToString[canvasZ,InputForm],{"ertyuiop"->vars}],{ parta[[2]],partb[[2]],partc[[2]],partd[[2]],parte[[2]](*,partf[[2]],partg[[2]],parth[[2]],parti[[2]]*)}, { parta[[3]],partb[[3]],partc[[3]],partd[[3]],parte[[3]](*,partf[[3]],partg[[3]],parth[[3]],parti[[3]]*)}}


(* it has to be InputForm or ToExpression fails *)
]],InputForm]<>"\n ";


solution1=data1<>data2<>ToString[Hold[Module[{x, a,b,c,d,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP, varsa, varsb, varsc,varsd,varse,varsf,g,h,pp,teste,bb1,list123,pos1,t11,t12,t21,t22,s1,s2,sum1,sum2,k},





(*varsa=vars[[1]];
varsb=vars[[2]];*)



(*{aa,bb,cc,dd,ee,gg,pp}=varsa;
sol=Solve[ToExpression[bb]*x-ToExpression[cc]*(x-ToExpression[dd])==ToExpression[ee]-ToExpression[gg]*x,x];
*)


body={
{"",""

}, 
{Null ,Null} 
};


Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";


hint1=ToString[Hold[Module[{aa,bb,cc,dd,ee, ff, gg, hh, ii, jj, text,list,sol, body={},vars=ertyuiop,options=ERTYUIOP},  


body={ 
{""
},
{Null}
};

Panel[Grid[Transpose[body]]]

]],InputForm]<>"\n ";

PRACTICE

proc1=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation1,hint1,solution1,canvas1},InputForm]<>";\n";

ToExpression@libGUI;
ToExpression@libRELATION;
panelsMIX={ StringReplace[qCanvas0,{"pn0"->ToString[1],"proc0"->proc1,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libRELATION),"err0"->"{errNO4,errNO4,errNO4,errNO4,errNO4}","inputsize0"->"{5,5,5,5,5}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"5","diag00"->"0","IO00"->"qClick","logo"->ToString[,InputForm]}]

};

TEST

proc1=ToString[{ToString[Hold[Module[{},"level"]],InputForm],variation1,hint1,solution1,canvas1},InputForm]<>";\n";




ToExpression@libGUI;
ToExpression@libIO;
ToExpression@libRELATION;

panelsMIXTEST={ 

StringReplace[qCanvas0,{"pn0"->ToString[1],"proc0"->proc1,"libs"->(libLIST<>"\n"<>libNAMES<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libRELATION),"err0"->"{errNO4,errNO4,errNO4,errNO4,errNO4}","inputsize0"->"{5,5,5,5,5}","level00"->ToString[{1,1,{}}],"max0"->"3","mult0"->"5","diag00"->"1","IO00"->"qClick","logo"->ToString[,InputForm]}],



StringReplace[qSendLocal,{"libs"->(libLIST<>"\n"<>libIO<>"\n"<>libERR<>"\n"<>libMISC<>"\n"<>libRELATION),"path0"->"\"\"","examName0"->"\"MET CS248, Homework 4\"","examName20"->"\"MET CS248, Homework 4\"","examIDString20"->"\"MET CS248, Homework 4\"","logo"->ToString[,InputForm],"weights0"->"{1,1,1,1,1}"}]


};

HOMEWORK_CDF

CDFDeploy[ToFileName[{$UserDocumentsDirectory},"cs248_homework4_relations_PRAC.cdf"],Column[Table[ReleaseHold[ToExpression[panelsMIX[[i]]]],{i,1,Length[panelsMIX]}]],
"Method"->"Standalone"];

CDFDeploy[ToFileName[{$UserDocumentsDirectory},"cs248_homework4_Relations.cdf"],Column[Table[ReleaseHold[ToExpression[panelsMIXTEST[[i]]]],{i,1,Length[panelsMIXTEST]}]],
"Method"->"Standalone"];

TEST AREA

Column[Table[ReleaseHold[ToExpression[panelsMIXTEST[[i]]]],{i,1,Length[panelsMIXTEST]}]]

ReleaseHold[ToExpression[panelsMIX[[3]]]]

Column[Table[ReleaseHold[ToExpression[panelsMIX[[i]]]],{i,1,Length[panelsMIX]}]]