LIBS

libLIST=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libLIST.m"]<>"\n";
libNAMES=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libNAMES.m"]<>"\n";
libIO=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libIO.m"]<>"\n";
libERR=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libERR.m"]<>"\n";
libGUI=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libGUI.m"]<>"\n";
libML=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libML.m"]<>"\n";
libMISC=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libMISC.m"]<>"\n";
libGraphics=ReadString["/Users/darashayda1xfer/Desktop/MODULES/Ryerson 2016/TRSM/QMS202/libs/libGraphics.m"]<>"\n";

libLIST=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libLIST.m"]<>"\n";
libNAMES=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libNAMES.m"]<>"\n";
libIO=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libIO.m"]<>"\n";
libERR=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libERR.m"]<>"\n";
libGUI=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libGUI.m"]<>"\n";
libML=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libML.m"]<>"\n";
libMISC=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libMISC.m"]<>"\n";
libGraphics=ReadString["C:/mathematica/Work/lossofgenerality/QMS202/QUIZES/libGraphics.m"]<>"\n";

Module Area

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

(*fghjkl. removed*)


"0"-><|
"1.1"->{"Column[{ToString[\" \"]"<>"}]"}
|>
,
(* let's use key as the option *)
"1"-><|
"1.1"->{"Column[{ToString[\"1. The Z-values associated with #a% confidence (i.e. probability #b) are\"]"<>"}]",
"Column[{ToString[\"1. If #a% confidence (i.e. probability #b), then what are the associated Z-values\"]"<>"}]"}
|>
,
"2"-><|
"2.1"->{"Column[{ToString[\"2. If (OverBar[X])=#a, σ=#b and n=#c, the #d% confidence interval estimate for the population mean μ is:\",TraditionalForm]"<>"}, Alignment->Left]"}
|>

,
"3"-><|
"3.1"->{"Column[{ToString[\"3. Determine the critical value of t in the following circumstances:\"]"<>","<>"ToString[\"          1-α = #a, n=#b.\",TraditionalForm]"<>","<>"ToString[\"Round your answer to 4 decimal places.\"]}]"}

|>
,

"4"-><|
"4.1"->{"Column[{ToString[\"4. It is desired to estimate the mean total compensation of CEOs in the Service industry. Data were randomly collected from #a CEOs and the #b% confidence interval was calculated to be ($#c, $#d). Is the following statement correct?\",TraditionalForm]"<>"}, Alignment->Left]"} (*Anna*)
|>
,
"5"-><|
"5.1"->{"Column[{ToString[\"5. An economist is interested in studing the incomes of consumers in a particular country. The population standard deviation is known to be $#c. A random sample of #d individuals resulted in a mean income of $#e. What is the width of #a% confidence interval rounded to two decimal places? Remark: The width (length) of an interval (a,b) is b-a.\"]}]"}

|>
,
"6"-><|
"6.1"->{"Column[{ToString[\"6. The head librarian at Library of Congres has asked her assistant for an interval estimate of the mean number of books checked out each day. The assistant provides the following interval estimate: from #a to #b books per day. If the head librarian knows that the population standard deviation is #c books checked out per day, and she asked her assistant to use #d days of data to construct the interval estimate, what confidence level can she attach to the interval estimate?\"]}]"}

|>


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



data2="listfghjkl:="<>


ToString[{"",""


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

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



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


text=vars["text"];
Grid[{

{Image[,ImageSize->125]},
{Image[]},   
{"Quiz 1,January 2016"},
{Image[]},
{"id"},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[2]]}}]},
{Grid[{{Rasterize@" Z = ±","x2"}}]}, (*Anna*)
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[3]]}}]},
{Grid[{{"x3",Rasterize@" ⩽μ⩽ ","x4"}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[4]]}}]},
{Grid[{{Rasterize@ToString["t=±",TraditionalForm],"x5"}}]},

text2=vars["vars"][[4]][[5]];
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[5]]}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@text2}}]},
{Grid[{{"x6"}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[6]]}}]},
{Grid[{{Rasterize@"b-a = ","x7"}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[7]]}}]},
{Grid[{{"x8",Rasterize@"%"}}]},
{Image[]}

},Spacings->{0,3}]


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





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


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

(*a*)

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


Which[key=="1.1", 
a=ToString@(RandomChoice@{99, 95,90,85,80,75,70,65,60});
b=ToString@N[(ToExpression@a)/100];
vars={a,b};
sol={x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-ToExpression@b)/2,{x}, Reals][[1]]};(*Anna*)
parta={StringReplace[text, { "#a"->a,"#b"->b}],vars,sol} ;

];



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

Which[key=="2.1", 

a=ToString@RandomInteger[{50,150}];
b=ToString@RandomInteger[{10,30}];
c=ToString@RandomChoice@{25,36,49,64};

dd=(RandomChoice@{{99,2.5758}, {98,2.3263},{96,2.0537},{95,1.9600},{92,1.7507},{90, 1.6449},{85,1.4395},{80, 1.2816}, {75,1.1503},{70, 1.0364}});

d=ToString@dd[[1]];

vars={a,b,c,d};
(*distance e: from mean value to the border of cofidance interval*)
e=((ToExpression@b)*dd[[2]])/Sqrt[ToExpression@c];
(*confidence interval a*)
sol={N[(ToExpression@a-e)],N[(ToExpression@a+e)]};

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

];


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

Which[key=="3.1", 

a=ToString@RandomChoice[{1-0.90, 1-0.95, 1-0.975, 1-0.99, 1-0.995, 1-0.999}];
b=ToString@RandomInteger[{5,30}];

vars={a,b};
sol2=NSolve[CDF[StudentTDistribution[(ToExpression[b]-1)],x]==1- (ToExpression@a)/2,{x}, Reals];
t=x/.sol2[[1]];
t2=N[IntegerPart[t*10000]/10000]; 
If[(IntegerPart[t*100000]-(IntegerPart[t*10000]*10))≥ 5,t2=t2+0.0001,t2=t2];

sol={t2};


partc={StringReplace[text, { "#a"->(ToString@(1-ToExpression@a)),"#b"->b}], vars,sol} ;

];


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

Which[key=="4.1", 

a=ToString@RandomInteger[{10,20}];
b=ToString@RandomInteger[{75,99}];
c=ToString@RandomInteger[{1000000,5000000}];
d=ToString@(ToExpression[c]+RandomInteger[{100000,500000}]);


(* For any String for sol we need to double quote or some confusing bug shows up*)
list=RandomChoice@{

{StringReplace["#b% of the sampled total compensation values fall between $#c and $#d.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["We are #b% confident that the mean of the sampled CEOs falls in the interval $#c to $#d.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["In the population of Service industy CEOs, #b% of them will have total compensations that fall in the interval $#c to $#d.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["We are #b% confident that the mean total compensation of all CEOs in the Service industry falls in the interval $#c to $#d.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"T\"","\"true\"","\"TRUE\""}}
};



vars={a,b,c,d,ToString[list[[1]],InputForm]};
sol={list[[2]]};

partd={StringReplace[text, { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],vars,sol} ;
(*Anna -removed key 4.2 and 4.3*)
];

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

Which[key=="5.1", 

a=ToString@(RandomChoice@{99, 95,90,85,80,75,70,65,60});
b=ToString@N[(ToExpression@a)/100];
c=ToString@(RandomSample[Range[1,5],1][[1]]*1000);
d=ToString@(RandomSample[Range[5,9],1][[1]]*10);
e=ToString@(RandomSample[Range[11,17],1][[1]]*1000);
vars={a,e,c,d};
r=x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-ToExpression@b)/2,{x}, Reals][[1]];
(*r2=N[IntegerPart[r*10000]/10000]; 
If[(IntegerPart[r*100000]-(IntegerPart[r*10000]*10))≥ 5,r2=r2+0.0001,r2=r2];*)
sol={N[(2*r(*r2*)*ToExpression@c)/Sqrt[ToExpression@d]]}; (*Anna*)

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

];

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

Which[key=="6.1", 
d=ToString@RandomChoice@{9,16,25,36};
(*x=RandomSample[Range[50,100],1][[1]];*)
x=RandomSample[Range[5,10],1][[1]]*100;
y=RandomChoice@{1.15,1.28,1.44,1.64,1.96,2.58};
(*y=RandomChoice@{1.28155,1.43953,1.64485,1.95996,2.57583,3.29053};*)
e=x*y;
c=ToString@(Sqrt[ToExpression@d]*x);
a=ToString@(IntegerPart[RandomSample[Range[650,850],1][[1]]*10+e]);
b=ToString@(IntegerPart[ToExpression@a+2*e]);
vars={a,b,c,d};
f=N@(ToExpression@e*Sqrt[ToExpression@d]/ToExpression@c);

sol2=z/.NSolve[CDF[NormalDistribution[0,1],f]==1- (1-ToExpression@z)/2,{z}, Reals][[1]];
(*g=ToString@PDF[NormalDistribution[0,1],f]; (*Anna*)
sol2=(1-ToExpression@g)*100;*)
sol={sol2};

partf={StringReplace[text, { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],vars,sol} ;

];



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

{StringReplace[ToString[canvasZ,InputForm],{"ertyuiop"->vars}],{question, parta[[1]],partb[[1]],partc[[1]],partd[[1]],parte[[1]],partf[[1]]},{ parta[[2]],partb[[2]],partc[[2]],partd[[2]],parte[[2]],partf[[2]]}, { parta[[3]],partb[[3]],partc[[3]],partd[[3]],parte[[3]],partf[[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 ";

Cloud Area

(* all err functions need to be called here since the Send is entirely happens in one unit *)
send[a0_]:=Module[{a,b,c,d,sol0,canvas0,err,err2,err3,err4,err5,err6,resF,canvas,vars,sol,sol1,sol2,sol3,sol4,sol5,sol6,μ,σ,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,n,xbar,d1,d2,x,df,col, body={},text,string,url},

ToExpression@libLIST; (*these have to be here *)
ToExpression@libERR;
body={a0["id"]};

μ=0;σ=1;
{canvas,text,vars,sol}=ReleaseHold[ToExpression[a0["q"],InputForm]];
sol1=(ToExpression@sol)[[1]]; (*Anna*)
err=If[Abs[ToExpression@(a0["x2"])-sol1[[1]]]<0.01, 1, 0]; (*Anna*)

g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"μ="<>ToString[μ]<>", σ="<>ToString[σ], PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-sol1[[1]],sol1[[1]]},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"μ="<>ToString[μ]<>", σ="<>ToString[σ], PlotRange->Full,AxesOrigin->{0,0},FillingStyle->{Red}]; (*Anna*)



sol2=Sort[(ToExpression@sol)[[2]],Less];
err2=If[Norm[{ToExpression@(a0["x3"]),ToExpression@(a0["x4"])}-sol2]<0.01, 1, 0];

AppendTo[body, err];
AppendTo[body, err2];

col={

Image[,ImageSize->125],
" ",
"F16 QMS 202",
"Practice Questions for Lecture 1\nJanuary 2016",
Image[],
" ",
"Student ID:"<>a0["id"],
" ",
" ",
ToExpression@text[[1+1]],
(*Anna*)
If[err==1, "Correct","Incorrect"],"Your answers:",a0["x2"],"Solutions:",sol1[[1]], Show[g1,g2,ImageSize->400], (*Anna*)
" ",
ToExpression@text[[1+2]],

If[err2==1, "Correct", "Incorrect"],"Your answers:",Row@{a0["x3"],", ",a0["x4"]},"Solutions:",Row@{sol2[[1]],", ",sol2[[2]]},

" ",

sol3=(ToExpression@sol)[[3]];
err3=If[Abs[ToExpression@(a0["x5"])-sol3[[1]]]<0.01, 1, 0];  (* ANNA changed the place for Abs *)
{a,b}=ToExpression@vars[[3]];
df=b;
g8=Plot[PDF[StudentTDistribution[df],x],{x,-8,8},Filling->Axis,PlotRange->All];
g9=Plot[PDF[StudentTDistribution[df],x],{x,sol3[[1]],8},Filling->Axis,PlotStyle->Red, AxesOrigin->{0,0},PlotRange->All];
g10=Plot[PDF[StudentTDistribution[df],x],{x,-8,-sol3[[1]]},Filling->Axis,PlotStyle->Red, AxesOrigin->{0,0},PlotRange->All];
ToExpression@text[[1+3]],
If[err3==1, "Correct","Incorrect"]
,
"Your answers:",a0["x5"],"Solutions:",Row@{"±",sol3[[1]]},
Show[g8,g9,g10, ImageSize->400],

" ",

sol4=(ToExpression@sol)[[4]];
{a,b,c,d,string}=ToExpression@vars[[4]];
ToExpression@text[[1+4]],
string,
"Your answers:",a0["x6"],
If[MemberQ[sol4[[1]],a0["x6" ]]==True, err4=1;"is Correct",err4=0;"is Incorrect"], (*Added "is..."*)

" ",
sol5=(ToExpression@sol)[[5]];
err5=If[Abs[(ToExpression@(a0["x7"]))-sol5[[1]]]<0.01, 1, 0];
ToExpression@text[[1+5]],
If[err5==1, "Correct","Incorrect"],
"Your answers:",a0["x7"],"Solutions:",Row@{sol5[[1]]},
" ",
sol6=(ToExpression@sol)[[6]];
err6=If[Abs[(ToExpression@(a0["x8"]))-sol6[[1]]]<1(*0.01*), 1, 0];
ToExpression@text[[1+6]],
If[err6==1, "Correct","Incorrect"],
"Your answers:",a0["x8"],"Solutions:",Row@{sol6[[1]]},
" "

 };

AppendTo[body,err3];
AppendTo[body,err4];
AppendTo[body,err5];
AppendTo[body,err6];

AppendTo[body,"Q1"];
AppendTo[body,"QMS202"];
AppendTo[body,"BOZA"];


url=CloudExport[Column@col,"PNG",Permissions->"Public"][[1]];

AppendTo[body,ToString@url];

resF=URLFetch["http://symbolicexams.lossofgenerality.com/wp-content/plugins/test-receiver/results.php","Parameters"->{"results"->(ToString@body)},"ReadTimeout"->10,"ConnectTimeout"->50,"Method"->"POST"];

        DatabinAdd[Databin["9UnJLEno"],body];
(*HTTPRedirect@CloudExport[Column@col,"PNG",Permissions->"Public"][[1]]*)
HTTPRedirect@url
];


(* all err functions need to be called here since the Send is entirely happens in one unit *)
sendLOCAL[a0_]:=Module[{a,b,c,d,sol0,canvas0,err,err2,err3,err4,err5,err6,resF,canvas,vars,sol,sol1,sol2,sol3,sol4,sol5,sol6,μ,σ,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,n,xbar,d1,d2,x,df,col, body={},text,string},

ToExpression@libLIST; (*these have to be here *)
ToExpression@libERR;
body={a0["id"]};

μ=0;σ=1;
{canvas,text,vars,sol}=ReleaseHold[ToExpression[a0["q"],InputForm]];
sol1=(ToExpression@sol)[[1]]; (*Anna*)
err=If[Abs[ToExpression@(a0["x2"])-sol1[[1]]]<0.01, 1, 0]; (*Anna*)

g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"μ="<>ToString[μ]<>", σ="<>ToString[σ], PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-sol1[[1]],sol1[[1]]},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"μ="<>ToString[μ]<>", σ="<>ToString[σ], PlotRange->Full,AxesOrigin->{0,0},FillingStyle->{Red}];(*Anna*)



sol2=Sort[(ToExpression@sol)[[2]],Less];
err2=If[Norm[{ToExpression@(a0["x3"]),ToExpression@(a0["x4"])}-sol2]<0.01, 1, 0];

AppendTo[body, err];
AppendTo[body, err2];

col={

Image[,ImageSize->125],
" ",
"F16 QMS 202",
"Practice Questions for Lecture 1\nJanuary 2016",
Image[],
" ",
"Student ID:"<>a0["id"],
" ",
" ",
ToExpression@text[[1+1]],
If[err==1, "Correct","Incorrect"],"Your answers:",a0["x2"],"Solutions:",sol1[[1]],Show[g1,g2,ImageSize->400], (*Anna*)
" ",
ToExpression@text[[1+2]],

If[err2==1, "Correct", "Incorrect"],"Your answers:",Row@{a0["x3"],", ",a0["x4"]},"Solutions:",Row@{sol2[[1]],", ",sol2[[2]]},

" ",

sol3=(ToExpression@sol)[[3]];
err3=If[Abs[ToExpression@(a0["x5"])-sol3[[1]]]<0.01, 1, 0];  
{a,b}=ToExpression@vars[[3]];
df=b;
g8=Plot[PDF[StudentTDistribution[df],x],{x,-8,8},Filling->Axis,PlotRange->All];
g9=Plot[PDF[StudentTDistribution[df],x],{x,sol3[[1]],8},Filling->Axis,PlotStyle->Red, AxesOrigin->{0,0},PlotRange->All];
g10=Plot[PDF[StudentTDistribution[df],x],{x,-8,-sol3[[1]]},Filling->Axis,PlotStyle->Red, AxesOrigin->{0,0},PlotRange->All];
ToExpression@text[[1+3]],
If[err3==1, "Correct","Incorrect"]
,
"Your answers:",a0["x5"],"Solutions:",Row@{"±",sol3[[1]]},
Show[g8,g9,g10, ImageSize->400],

" ",

sol4=(ToExpression@sol)[[4]];
{a,b,c,d,string}=ToExpression@vars[[4]];(*Anna , replaced for ;*)
ToExpression@text[[1+4]],
string,
"Your answers:",a0["x6"],
If[MemberQ[sol4[[1]],a0["x6" ]]==True, err4=1;"is Correct",err4=0;"is Incorrect"],(*Anna added "is..."*)

" ",
sol5=(ToExpression@sol)[[5]];
err5=If[Abs[(ToExpression@(a0["x7"]))-sol5[[1]]]<0.01, 1, 0];
ToExpression@text[[1+5]],
If[err5==1, "Correct","Incorrect"],
"Your answers:",a0["x7"],"Solutions:",Row@{sol5[[1]]},
" ",
sol6=(ToExpression@sol)[[6]];
err6=If[Abs[(ToExpression@(a0["x8"]))-sol6[[1]]]<1(*0.01*), 1, 0];
ToExpression@text[[1+6]],
If[err6==1, "Correct","Incorrect"],
"Your answers:",a0["x8"],"Solutions:",Row@{sol6[[1]]},
" "

 };

AppendTo[body,err3];
AppendTo[body,err4];
AppendTo[body,err5];
AppendTo[body,err6];




local`body=Column@{body,col}
];





genFormLOCAL[]:=Module[{a,sol0,canvas0,err,resF,canvas,vars,sol,f,ans,text},

ToExpression@libLIST; (*these have to be here *)
ToExpression@libERR;
f[]:=(ToString[ReleaseHold[ToExpression[StringReplace[variation1,{"canvasZ"->canvas1,"fghjkl"->ToString[1]}]]],InputForm]); (* InputForm must be here or some problems occurs in ToExpression@variation *)
ans={(*Anna removed x1*)
{"x2",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "", "Help" -> ""|>,
{"x3",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "", "Help" -> ""|>,
{"x4",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x5",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x6",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x7",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x8",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "83.8791",  "Help" -> ""|>, (*Anna*)
{"id",""}-><|"Interpreter"->"String","Help" -> "","Hint"->"Enter Student ID"|>,
"q"->"String"};

FormFunction[ans,sendLOCAL,  AppearanceRules-><|"SubmitLabel" -> "Send Answers"|>,

FormLayoutFunction->Function[


(* we need to use sol in send[] in order to see if the student input is correct or not?*)

{canvas,text,vars,sol}=ReleaseHold[ToExpression[Setting@#["q"][[1]][[1]][[2]][[1]]]];

ReleaseHold[ToExpression[canvas,InputForm]/.{"x2"->#["x2"],"x3"->#["x3"],"x4"->#["x4"],"x5"->#["x5"],"x6"->#["x6"],"x7"->#["x7"],"x8"->#["x8"],"id"->#["id"]}] (*Anna: removed x1*)


], FormTheme -> "Blue"]["q"->f[]]






];

genForm[a0_]:=Module[{a,sol0,canvas0,err,resF,canvas,vars,sol,f,ans,text},

ToExpression@libLIST; (*these have to be here *)
ToExpression@libERR;
f[]:=(ToString[ReleaseHold[ToExpression[StringReplace[variation1,{"canvasZ"->canvas1,"fghjkl"->ToString[1]}]]],InputForm]); (* InputForm must be here or some problems occurs in ToExpression@variation *)
ans={(*Anna removed x1*)

{"x2",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "", "Help" -> ""|>,
{"x3",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "", "Help" -> ""|>,
{"x4",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x5",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x6",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x7",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "",  "Help" -> ""|>,
{"x8",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "83.8791",  "Help" -> ""|>, (*Anna*)
{"id",""}-><|"Interpreter"->"String","Help" -> "","Hint"->"Enter Student ID"|>,
"q"->"String"};

HTTPRedirect@CloudDeploy[FormFunction[ans,send,  AppearanceRules-><|"SubmitLabel" -> "Send Answers"|>,

FormLayoutFunction->Function[


(* we need to use sol in send[] in order to see if the student input is correct or not?*)

{canvas,text,vars,sol}=ReleaseHold[ToExpression[Setting@#["q"][[1]][[1]][[2]][[1]]]];

ReleaseHold[ToExpression[canvas,InputForm]/.{"x2"->#["x2"],"x3"->#["x3"],"x4"->#["x4"],"x5"->#["x5"],"x6"->#["x6"],"x7"->#["x7"],"x8"->#["x8"],"id"->#["id"]}](*Anna*)


], FormTheme -> "Blue"]["q"->f[]], 

Permissions->"Public"][[1]]







];

Deploy Area

DeleteFile[c];
c=CloudDeploy[FormFunction[{},
genForm,  AppearanceRules-><|"SubmitLabel" -> "Start"|>,

FormLayoutFunction->Function[


(* we need to use sol in send[] in order to see if the student input is correct or not?*)

Column[{Image[,ImageSize->125],
Spacer@100,
"F16 QMS 202",
"Practice Questions for Lecture 1\nJanuary 2016",
Image[,ImageSize->5],
Spacer@100,

"Press Start button to start the test"
}]


], FormTheme -> "White"], 

Permissions->"Public"]

LOCAL TEST AREA

The local form is slow, take a second to refresh the input fields. Also the Send Answer Button might not chave colour properly.

genFormLOCAL[]

local`body

DATA BIN  AREA

$Permissions = "Public"

Date of Creation

DateString[]

binQ1=CreateDatabin[<|"Name"->"Q1, QMS202, BOZA"|>]
Options[binQ1]

DatabinRemove[Databin["9UnJLEno"],{1,100}]