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"; (*Anna i added here slidingPlot for distributions*)

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. A sample of size n=#a is selected from the left-skewed population with \!\(\*OverscriptBox[\(\(X\)\(\\ \)\), \(_\)]\)= #b and S=#c. Is the following statement correct?\",TraditionalForm]"<>"}]"}
|>
,
"2"-><|

"2.1"->{"Column[{ToString[\"2. Is the parameter below an interest for this study? .\",TraditionalForm]"<>"}, Alignment->Left]"}
|>

,
"3"-><|
"3.1"->{"Column[{ToString[\"3. Is the sentence below present the null and alternative hypotheses to determine if the mean weight of the chocolate bars is greater than #b ounces?\"]}]"}

|>
,

"4"-><|
"4.1"->{"Column[{ToString[\"4. Decide if the statement below is true or false for (Subscript[H, 0]) at α = #a?\",TraditionalForm]"<>"}]"
}
|>
,
"5"-><|
"5.1"->{"Column[{ToString[\"5. Is the following conclusion correct?\"]"<>"}]"}
|>
,
"6"-><|
"6.1"->{"Column[{ToString[\"6.Is the statement below an approporiate null hypothesis?\"]"<>"}]"}
|>
,
"7"-><|
"7.1"->{"Column[{ToString[\"7. At the #c level of significance, what critical value should the company officials use to determine the rejection region?\"]"<>"}]"}
|>
,
"8"-><|
"8.1"->{"Column[{ToString[\"8. Is the following statement true or false?\"]"<>"}]"}
|>
,
"9"-><|
"9.1"->{"Column[{ToString[\"9. What will be the p-value if these data were used to perform a two-tail test?\"]"<>"}]"}
|>

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



data2="listfghjkl:="<>


ToString[{"",""


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

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



canvas1="\n"<>ToString[Hold[Module[{vars=ertyuiop,text,text2,text3,text4,text5,text6,text7,text8,text9,text10,answers, options,locs,data},


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

{Image[,ImageSize->125]},
{Image[]},   
{"Quiz 4,January 2016"},
{Image[]},
{"id"},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[2]]}}]},
{Image[]},
text2=vars["vars"][[1]][[5]];
{Grid[{{Rasterize@ToExpression@text2}}]},
{Image[]},
{Grid[{{"x2"}}]}, 
{Image[]},
{Image[]},
{Style["Use the following scenario for problems 2-5",Bold,21]},
{Image[]},
text8=vars["vars"][[2]][[6]];
{Grid[{{Rasterize@ToExpression@text8}}]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[3]]}}]},
{Image[]},
text7=vars["vars"][[2]][[5]];
{Grid[{{Rasterize@ToExpression@text7}}]},
{Image[]},
{Grid[{{"x4"}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[4]]}}]},
{Image[]},
text5=vars["vars"][[3]][[5]];
{Grid[{{Rasterize@ToExpression@text5}}]},
{Image[]},
{Grid[{{"x5"}}]},

{Image[]},
{Image[]},
text3=vars["vars"][[4]][[5]];
{Grid[{{Rasterize@ToExpression@text[[5]]}}]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text3}}]},
{Image[]},
{Grid[{{"x6"}}]},
{Image[]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[6]]}}]},
{Image[]},
text6=vars["vars"][[5]][[5]];
{Grid[{{Rasterize@ToExpression@text6}}]},
{Image[]},
{Grid[{{"x7"}}]},
{Image[]},
{Image[]},
{Style["Use the following scenario for problems 6-9",Bold,21]},
{Image[]},
text9=vars["vars"][[6]][[7]];
{Grid[{{Rasterize@ToExpression@text9}}]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[7]]}}]},

{Image[]},
text4=vars["vars"][[6]][[5]];
{Grid[{{Rasterize@ToExpression@text4}}]},
{Image[]},
{Grid[{{"x8"}}]},
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[8]]}}]},
{Image[]},
{Grid[{{Rasterize@" critical value = ","x9"}}]}, (*anna*)
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[9]]}}]},
{Image[]},
text10=vars["vars"][[8]][[5]];
{Grid[{{Rasterize@ToExpression@text10}}]},
{Image[]},
{Grid[{{"x10"}}]}, (*anna*)
{Image[]},
{Grid[{{Rasterize@ToExpression@text[[10]]}}]},
{Image[]},
{Grid[{{Rasterize@" p-value = ","x11"}}]}, (*anna*)
{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,a1,b1,c1,d1,aa,bb,cc,dd,ee, ff, gg, hh, ii, jj,pp,pp2,sd, vars,text,list,list0,list1,sol,aabbee,k, parta, partb, partc, partd,parte,partf,partg,parth,parti,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@(RandomInteger[{160,210}]);
b=ToString@RandomInteger[{100,110}];
c=ToString@RandomInteger[{20,26}];
d=ToString@(ToExpression@b+RandomInteger[{3,7}]);



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

{StringReplace["We cannot use the t-test to test the alternative hypothesis (Subscript[H, 0]) : μ = #d because the sample is too small.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["We cannot use the t-test to test the null hypothesis (Subscript[H, 0]) : μ = #d because the population is not normally distributed.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["We can use the Z-test to test the null hypothesis \!(Subscript[H, 0]) : μ = #d.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["We can use the t-test to test the null hypothesis \!(Subscript[H, 0]) : μ = #d.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"T\"","\"true\"","\"TRUE\""}}
};



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

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

];



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

Which[key=="2.1", 

a1=ToString@(N[RandomInteger[{6000,6200}]/1000]);
f=ToExpression@a1-0.09;
g=ToExpression@a1+0.09;
c=ToString/@(RandomSample[Range[f*1000,g*1000],18]/1000);
a=ToString@Mean[ToExpression/@c];
b=ToString@(N[Floor[(ToExpression@a - 0.01)*100]/100]);
sd=StandardDeviation[ToExpression/@c];
d=ToString@(N[(ToExpression@a-ToExpression@b)/(sd/Sqrt[18])]);

list0=StringReplace["A company that manufactures chocolate bars is particularly concerned about the mean weight of chocolate bars. A sample of 18 chocolate bars is selected, and their weights in ounces are summarized in the following list :#c. Assume normal distribution of weights of chocolate bars.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d}];

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

{StringReplace["σ", { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["π",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(OverBar[X])",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["μ",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"T\"","\"true\"","\"TRUE\""}}
};



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

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[{0.01,0.001,0.005}];
b=partb[[2]][[2]];
c=ToString@0;
d=ToString@0;


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

{StringReplace[" (Subscript[H, 0]) : μ ≥ #b and (Subscript[H, 1]) : μ < #b.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(Subscript[H, 0]) : (OverBar[X]) ≥ #b and (Subscript[H, 1]) : (OverBar[X]) < #b.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(Subscript[H, 0]) : (OverBar[X]) = #b and (Subscript[H, 1]) : (OverBar[X]) ≠ #b.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(Subscript[H, 0]) : μ ≤ #b and (Subscript[H, 1]) : μ > #b.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d}],{"\"T\"","\"true\"","\"TRUE\""}}
};



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

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



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

Which[key=="4.1", 

{a,b}=ToString/@RandomChoice[{{0.05,1.74},{0.1,1.33}}];


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

{StringReplace["Reject (Subscript[H, 0]) if (Subscript[t, STAT]) < -#b .", { "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["Reject (Subscript[H, 0]) if (Subscript[t, STAT]) > 1.98 or (Subscript[Z, STAT]) < -1.98",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["Reject (Subscript[H, 0]) if (Subscript[t, STAT]) > #b .",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}}
};

c=partb[[2]][[3]];
d=partb[[2]][[4]];
e=partb[[2]][[6]];


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

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

];

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



Which[key=="5.1", 

b=partb[[2]][[2]];
d=partb[[2]][[4]];

sol2=NSolve[CDF[StudentTDistribution[17],ToExpression@d]==1- (ToExpression@x),{x}, Reals];
t=x/.sol2[[1]];
a=ToString@(N[Ceiling[N[IntegerPart[t*10000]/100]+1]/100]);
c=ToString@(ToExpression@a - 0.05);
e=ToString@(ToExpression@c - 0.03);

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

{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is #b ounces.", { "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#c there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#e there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["At α=#a there is sufficient evidence to conclude that the population mean weight of the chocolate bars is greater than #b ounces.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}}
};



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

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


];

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


Which[key=="6.1", 

(*{a,b,c,d,pp,e}=partd[[2]];*)
a=ToString@(RandomSample[Range[80,88],1][[1]]);
{b,c}=ToString/@({100,RandomSample[Range[90,96],1][[1]]});

d=ToString@(N[(ToExpression@a )/100]);
e=ToString@0;


list1=StringReplace["A company that manufactures coffee vending machines has developed a new process ensuring that coffee cups are filled correctly. The previous process filled the cups  correctly #a % of the time. Based on a sample of #b orders, using the new process, #c were filled correctly. The company would like to know whether the new process has increased the proportion of orders filled correctly.",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}];

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

{StringReplace["(Subscript[H, 0]) : π ≥ #a .", { "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],
{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(Subscript[H, 0]) : π ≤ #a .",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},
{StringReplace["(Subscript[H, 0]) : π ≥ #d .",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}},

{StringReplace["(Subscript[H, 0]) : π ≤ #d .",{ "#a"->a,"#b"->b,"#c"->c,"#d"->d,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}}
};



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

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


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

Which[key=="7.1", 

(*{a,b,c,d,pp,e}=partd[[2]];*)

a=ToString@(RandomChoice@{99, 95,90,85});
b=ToString@N[(ToExpression@a)/100];
c=ToString@(N[1-ToExpression@b]);
d=ToString@0;
e=ToString@0;

vars={a,b,c,d,ToString[0,InputForm],e};
sol={x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-ToExpression@b),{x}, Reals][[1]]};

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

];


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

Which[key=="8.1", 

{a,b,c,d}=partf[[2]][[1;;4]];
z=N[((ToExpression@c/ToExpression@b)-ToExpression@d)/(Sqrt[(ToExpression@d*(1-ToExpression@d))/(ToExpression@b)])];
t=x/.NSolve[CDF[NormalDistribution[0,1],z]==1- (1-x),{x}, Reals][[1]];
t=1-t;
t=N[(IntegerPart[t*10000]/100)];
a1=ToString@N[(t-((1/2)*t))];
b1=ToString@(N[t+RandomChoice[{2,3}]]);
c1=ToString@(N[t+RandomChoice[{4,5,6}]]);
d1=ToString@(N[t+RandomChoice[{10,11,12}]]);
e=ToString@0;
(* For any String for sol we need to double quote or some confusing bug shows up*)
list=RandomChoice@{

{StringReplace["The null hypothesis would not be rejected if a #a% probability of committing a Type I error is allowed.", { "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],
{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #b% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #c% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"T\"","\"true\"","\"TRUE\""}},

{StringReplace["The null hypothesis would not be rejected if a #d% probability of committing a Type I error is allowed.",{ "#a"->a1,"#b"->b1,"#c"->c1,"#d"->d1,"#e"->e}],{"\"False\"","\"false\"","\"FALSE\"","\"F\""}}
};



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

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

];

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

Which[key=="9.1", 


{a,b,c,d}=partf[[2]][[1;;4]];

z=N[((ToExpression@c/ToExpression@b)-ToExpression@d)/(Sqrt[(ToExpression@d*(1-ToExpression@d))/(ToExpression@b)])];
t=x/.NSolve[CDF[NormalDistribution[0,1],z]==1- (1-x),{x}, Reals][[1]];
e=ToString[2*(1-t)];

vars={a,b,c,d,ToString[0,InputForm],e};
sol={e};

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

];

(*anna*)


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}],{question, parta[[1]],partb[[1]],partc[[1]],partd[[1]],parte[[1]],partf[[1]],partg[[1]],parth[[1]],parti[[1]]},{ 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 ";

Cloud Area

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

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

μ=0;σ=1;
{canvas,text,vars,sol}=ReleaseHold[ToExpression[a0["q"],InputForm]];
sol1=(ToExpression@sol)[[1]]; 
err=If[MemberQ[sol1[[1]],a0["x2" ]]==True, err1=1;"Correct",err1=0;"Incorrect"];

sol2=(ToExpression@sol)[[2]];
err=If[MemberQ[sol2[[1]],a0["x4" ]]==True, err2=1;"Correct",err2=0;"Incorrect"];
(*err2=If[Abs[ToExpression@(a0["x4"])-sol2[[1]]]<0.01, 1, 0];*)

AppendTo[body, err1];
AppendTo[body, err2];

col={

Image[,ImageSize->125],
" ",
"F16 QMS 202",
"Practice Questions for Lecture 4\nJanuary 2016",
Image[],
" ",
"Student ID:"<>a0["id"],
" ",
" ",
{a,b,c,d,string}=ToExpression@vars[[1]];
ToExpression@text[[1+1]],
string,
"Your answers:",a0["x2"],
If[MemberQ[sol1[[1]],a0["x2" ]]==True, err=1;"is Correct",err=0;"is Incorrect"],
(*slidingPLOT[15,a,c,b,d,5.4],*)
\[SelectionPlaceholder],
" ",
Style["Use the following scenario for problems 2-5",Bold],
" ",
{a,b,c,d,string,e}=ToExpression@vars[[2]];
e,
ToExpression@text[[1+2]],
string,
"Your answers:",a0["x4"],
If[MemberQ[sol2[[1]],a0["x4" ]]==True, err2=1;"is Correct",err2=0;"is Incorrect"],
(*If[err2==1, "Correct", Style["Incorrect",Red]],"Your answers:",Row@{a0["x4"]},"Solutions:",Row@{sol2[[1]]},*)

\[SelectionPlaceholder],

" ",

sol3=(ToExpression@sol)[[3]];
{a,b,c,d,string}=ToExpression@vars[[3]];
a1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-a))/2,{x}, Reals][[1]]);
ToExpression@text[[1+3]],
string,
"Your answers:",a0["x5"],
If[MemberQ[sol3[[1]],a0["x5" ]]==True, err3=1;"is Correct",err3=0;"is Incorrect"],
(*{e,f,g,h}=ToExpression@vars[[2]];*)
(*g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-a1},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,a1,7},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
(*Show[g1,g2,g3,Graphics[{PointSize[0.02],Point[{e,0},VertexColors->Red]}],ImageSize->400],*)
Show[g1,g2,g3,Graphics[{
PointSize[0.02],Point[{e,0},VertexColors->Blue],
Dashed,Red,Line[{{-a1,0.2},{a1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-a1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{a1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-a1,0},{-a1,0.3}}],
Black,Line[{{a1,0},{a1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{e,0.03}]
}],ImageSize->400],*)
\[SelectionPlaceholder],

" ",

sol4=(ToExpression@sol)[[4]];
{a,b,c,d,string,e}=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;Style["is Incorrect",Red]], 
\[SelectionPlaceholder],

" ",
sol5=(ToExpression@sol)[[5]];
{a,b,c,d,string,e}=ToExpression@vars[[5]];
f=N[(e-a)/(b/Sqrt[c*d])];
a1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-0.01))/2,{x}, Reals][[1]]);
b1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-0.05))/2,{x}, Reals][[1]]);
ToExpression@text[[1+5]],
string,
"Your answers:",a0["x7"],
If[MemberQ[sol5[[1]],a0["x7" ]]==True, err5=1;"is Correct",err5=0;"is Incorrect"],
(*g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-a1},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,a1,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
Show[g1,g2,g3,Graphics[{
PointSize[0.02],Point[{f,0},VertexColors->Blue],
Dashed,Red,Line[{{-a1,0.2},{a1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-a1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{a1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-a1,0},{-a1,0.3}}],
Black,Line[{{a1,0},{a1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{f,0.03}]
}],ImageSize->400],
g4=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0}];

g5=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-b1},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g6=Plot[PDF[NormalDistribution[μ,σ],x],{x,b1,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
Show[g4,g5,g6,Graphics[{
PointSize[0.02],Point[{f,0},VertexColors->Blue],
Dashed,Red,Line[{{-b1,0.2},{b1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-b1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{b1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-b1,0},{-b1,0.3}}],
Black,Line[{{b1,0},{b1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{f,0.03}]
}],ImageSize->400],*)

\[SelectionPlaceholder],
" ",
Style["Use the following scenario for problems 6-9",Bold],
" ",
sol6=(ToExpression@sol)[[6]];
{a,b,c,d,string,e,f}=ToExpression@vars[[6]];
f,
ToExpression@text[[1+6]],
string,
"Your answers:",a0["x8"],
If[MemberQ[sol6[[1]],a0["x8" ]]==True, err6=1;"is Correct",err6=0;"is Incorrect"],
\[SelectionPlaceholder],
" ",

sol7=(ToExpression@sol)[[7]];
err7=If[Abs[(ToExpression@(a0["x9"]))-sol7[[1]]]<0.01, 1, 0];
{a,b,c,d,string,e}=ToExpression@vars[[7]];
ToExpression@text[[1+7]],
(*string,*)
If[err7==1, "Correct", Style["Incorrect",Red]],"Your answers:",Row@{a0["x9"]},"Solutions:",Row@{sol7[[1]]},
(*"Your answers:",a0["x9"],
If[MemberQ[sol7[[1]],a0["x9" ]]==True, err7=1;"is Correct",err7=0;"is Incorrect"],*)
" ",
\[SelectionPlaceholder],
" ",

sol8=(ToExpression@sol)[[8]];
{a,b,c,d,string,e}=ToExpression@vars[[8]];
ToExpression@text[[1+8]],
string,
"Your answers:",a0["x10"],
If[MemberQ[sol8[[1]],a0["x10" ]]==True, err8=1;"is Correct",err8=0;"is Incorrect"],
" ",
\[SelectionPlaceholder],
" ",

sol9=(ToExpression@sol)[[9]];
err9=If[Abs[(ToExpression@(a0["x11"]))-sol9[[1]]]<0.01, 1, 0];
{a,b,c,d,string,e}=ToExpression@vars[[9]];
ToExpression@text[[1+9]],
(*string,*)
If[err9==1, "Correct", Style["Incorrect",Red]],"Your answers:",Row@{a0["x11"]},"Solutions:",Row@{sol9[[1]]},
(*"Your answers:",a0["x11"],
If[MemberQ[sol9[[1]],a0["x11" ]]==True, err9=1;"is Correct",err9=0;"is Incorrect"],*)
" "

 };
AppendTo[body,err3];
AppendTo[body,err4];
AppendTo[body,err5];
AppendTo[body,err6];
AppendTo[body,err7];
AppendTo[body,err8];
AppendTo[body,err9];

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


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

AppendTo[body,ToString@url];
resF=URLFetch["http://compclassnotes.com/trsm/qms202/api/ccnl/result","Parameters"->{"results"->(ToString@body)},"ReadTimeout"->10,"ConnectTimeout"->50,"Method"->"POST"];

      DatabinAdd[Databin["a8YmnpoA"],body];

HTTPRedirect@url
];


(* all err functions need to be called here since the Send is entirely happens in one unit *)
sendLOCAL[a0_]:=Module[{a,a1,b,b1,c,d,e,f,g,h,sol0,canvas0,err0,err,err1,err2,err3,err4,err5,err6,err7,err8,err9,err10,resF,canvas,vars,sol,sol1,sol2,sol3,sol4,sol5,sol6,sol7,sol8,sol9,sol10,μ,σ,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;
ToExpression@libGraphics;
body={a0["id"]};

μ=0;σ=1;
{canvas,text,vars,sol}=ReleaseHold[ToExpression[a0["q"],InputForm]];
sol1=(ToExpression@sol)[[1]]; 
err=If[MemberQ[sol1[[1]],a0["x2" ]]==True, err1=1;"Correct",err1=0;"Incorrect"];
sol2=(ToExpression@sol)[[2]];
err=If[MemberQ[sol2[[1]],a0["x4" ]]==True, err2=1;"Correct",err2=0;"Incorrect"];
(*err2=If[Abs[ToExpression@(a0["x4"])-sol2[[1]]]<0.01, 1, 0];*)

AppendTo[body, err1];
AppendTo[body, err2];

col={

Image[,ImageSize->125],
" ",
"F16 QMS 202",
"Practice Questions for Lecture 4\nJanuary 2016",
Image[],
" ",
"Student ID:"<>a0["id"],
" ",
" ",
{a,b,c,d,string}=ToExpression@vars[[1]];
ToExpression@text[[1+1]],
string,
"Your answers:",a0["x2"],
If[MemberQ[sol1[[1]],a0["x2" ]]==True, err=1;"is Correct",err=0;"is Incorrect"],
(*slidingPLOT[15,a,c,b,d,5.4],*)
\[SelectionPlaceholder],
"",
Style["Use the following scenario for problems 2-5",Bold],
" ",
{a,b,c,d,string,e}=ToExpression@vars[[2]];
e,
ToExpression@text[[1+2]],
string,
"Your answers:",a0["x4"],
If[MemberQ[sol2[[1]],a0["x4" ]]==True, err2=1;"is Correct",err2=0;"is Incorrect"],
(*If[err2==1, "Correct", "Incorrect"],"Your answers:",Row@{a0["x4"]},"Solutions:",Row@{sol2[[1]]},*)
\[SelectionPlaceholder],
" ",

sol3=(ToExpression@sol)[[3]];
{a,b,c,d,string}=ToExpression@vars[[3]];
a1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-a))/2,{x}, Reals][[1]]);
ToExpression@text[[1+3]],
string,
"Your answers:",a0["x5"],
If[MemberQ[sol3[[1]],a0["x5" ]]==True, err3=1;"is Correct",err3=0;"is Incorrect"],
(*{e,f,g,h}=ToExpression@vars[[2]];*)
(*g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-a1},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,a1,7},Filling->Axis,PlotLabel->"Normal Distribution", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
(*Show[g1,g2,g3,Graphics[{PointSize[0.02],Point[{e,0},VertexColors->Red]}],ImageSize->400],*)
Show[g1,g2,g3,Graphics[{
PointSize[0.02],Point[{e,0},VertexColors->Blue],
Dashed,Red,Line[{{-a1,0.2},{a1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-a1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{a1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-a1,0},{-a1,0.3}}],
Black,Line[{{a1,0},{a1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{e,0.03}]
}],ImageSize->400],*)
\[SelectionPlaceholder],
" ",

sol4=(ToExpression@sol)[[4]];
{a,b,c,d,string,e}=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"],

\[SelectionPlaceholder],
" ",
sol5=(ToExpression@sol)[[5]];
{a,b,c,d,string,e}=ToExpression@vars[[5]];
f=N[(e-a)/(b/Sqrt[c*d])];
a1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-0.01))/2,{x}, Reals][[1]]);
b1=(x/.NSolve[CDF[NormalDistribution[0,1],x]==1- (1-(1-0.05))/2,{x}, Reals][[1]]);
ToExpression@text[[1+5]],
string,
"Your answers:",a0["x7"],
If[MemberQ[sol5[[1]],a0["x7" ]]==True, err5=1;"is Correct",err5=0;"is Incorrect"],
(*g1=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0}];
g2=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-a1},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g3=Plot[PDF[NormalDistribution[μ,σ],x],{x,a1,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.01", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
Show[g1,g2,g3,Graphics[{
PointSize[0.02],Point[{f,0},VertexColors->Blue],
Dashed,Red,Line[{{-a1,0.2},{a1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-a1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{a1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-a1,0},{-a1,0.3}}],
Black,Line[{{a1,0},{a1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{f,0.03}]
}],ImageSize->400],
g4=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0}];

g5=Plot[PDF[NormalDistribution[μ,σ],x],{x,-7,-b1},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green,FillingStyle->{Green}];
g6=Plot[PDF[NormalDistribution[μ,σ],x],{x,b1,7},Filling->Axis,PlotLabel->"Normal Distribution\n"<>"α = 0.05", PlotRange->Full,AxesOrigin->{0,0},PlotStyle->Green, FillingStyle->{Green}];
Show[g4,g5,g6,Graphics[{
PointSize[0.02],Point[{f,0},VertexColors->Blue],
Dashed,Red,Line[{{-b1,0.2},{b1,0.2}}],Text[Style["Do not reject (Subscript[H, 0])",Medium,Bold],{0,0.22}],
Green,Line[{{-7,0.2},{-b1,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{-5,0.22}],
Green,Line[{{b1,0.2},{7,0.2}}],Text[Style["Reject (Subscript[H, 0])",Medium,Bold],{5,0.22}],
Black,Line[{{-b1,0},{-b1,0.3}}],
Black,Line[{{b1,0},{b1,0.3}}],
Text[Style["(Subscript[Z, STAT])",Medium,Bold],{f,0.03}]
}],ImageSize->400],*)
\[SelectionPlaceholder],
" ",
Style["Use the following scenario for problems 6-9",Bold],
" ",

sol6=(ToExpression@sol)[[6]];
{a,b,c,d,string,e,f}=ToExpression@vars[[6]];
f,
ToExpression@text[[1+6]],
string,
"Your answers:",a0["x8"],
If[MemberQ[sol6[[1]],a0["x8" ]]==True, err6=1;"is Correct",err6=0;"is Incorrect"],
" ",
\[SelectionPlaceholder],
" ",

sol7=(ToExpression@sol)[[7]];
err7=If[Abs[(ToExpression@(a0["x9"]))-sol7[[1]]]<0.01, 1, 0];
{a,b,c,d,string,e}=ToExpression@vars[[7]];
ToExpression@text[[1+7]],
(*string,*)
If[err7==1, "Correct", Style["Incorrect",Red]],"Your answers:",Row@{a0["x9"]},"Solutions:",Row@{sol7[[1]]},
(*"Your answers:",a0["x9"],
If[MemberQ[sol7[[1]],a0["x9" ]]==True, err7=1;"is Correct",err7=0;"is Incorrect"],*)
" ",
\[SelectionPlaceholder],
" ",

sol8=(ToExpression@sol)[[8]];
{a,b,c,d,string,e}=ToExpression@vars[[8]];
ToExpression@text[[1+8]],
string,
"Your answers:",a0["x10"],
If[MemberQ[sol8[[1]],a0["x10" ]]==True, err8=1;"is Correct",err8=0;"is Incorrect"],
" ",
\[SelectionPlaceholder],
" ",

sol9=(ToExpression@sol)[[9]];
err9=If[Abs[(ToExpression@(a0["x11"]))-sol9[[1]]]<0.01, 1, 0];
{a,b,c,d,string,e}=ToExpression@vars[[9]];
ToExpression@text[[1+9]],
(*string,*)
If[err9==1, "Correct", Style["Incorrect",Red]],"Your answers:",Row@{a0["x11"]},"Solutions:",Row@{sol9[[1]]},
(*"Your answers:",a0["x11"],
If[MemberQ[sol9[[1]],a0["x11" ]]==True, err9=1;"is Correct",err9=0;"is Incorrect"],*)
" "

 };

AppendTo[body,err3];
AppendTo[body,err4];
AppendTo[body,err5];
AppendTo[body,err6];
AppendTo[body,err7];
AppendTo[body,err8];
AppendTo[body,err9];




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={
{"x2",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F", "Help" -> ""|>,
{"x4",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x5",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x6",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x7",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x8",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>, 
{"x9",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "1.2345",  "Help" -> ""|>, 
{"x10",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>, 
{"x11",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "0.0117",  "Help" -> ""|>, 
{"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"],"x4"->#["x4"],"x5"->#["x5"],"x6"->#["x6"],"x7"->#["x7"],"x8"->#["x8"],"x9"->#["x9"],"x10"->#["x10"],"x11"->#["x11"],"id"->#["id"]}] 


], 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={

{"x2",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F", "Help" -> ""|>,
{"x4",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x5",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x6",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x7",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x8",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>,
{"x9",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "1.2345",  "Help" -> ""|>, 
{"x10",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "true, false, T, F",  "Help" -> ""|>, 
{"x11",""}-><|"Required"->True,"Interpreter"->"String","Hint" -> "0.0117",  "Help" -> ""|>, 
{"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"],"x4"->#["x4"],"x5"->#["x5"],"x6"->#["x6"],"x7"->#["x7"],"x8"->#["x8"],"x9"->#["x9"],"x10"->#["x10"],"x11"->#["x11"],"id"->#["id"]}]


], 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 4\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"->"Q3, QMS202, BOZA"|>]
Options[binQ1]

Databin["a8YmnpoA"]

DatabinRemove[Databin["a8YmnpoA"],{1,101}]

ARCHIVE DATA BIN

New Location

ON-Off

ON

$Permissions = "Public";
CloudDeploy[

APIFunction[{},SetPermissions[CloudObject[MouseOver], "Public"]&],Permissions->"Public"]

Off

$Permissions = "Public";
CloudDeploy[

APIFunction[{},SetPermissions[CloudObject[MouseOver], "Private"]&],Permissions->"Public"]

Statistics Report

f[date_]:=Module[{grades,mean},grades=Values[Databin["9UnJLEno"]][[All,2;;7]];

If[grades!={},
grades=Table[If[NumberQ[#]&/@grades[[i]]=={True,True,True,True,True,True},grades[[i]],Nothing], {i,1,Length@grades}],grades={{0,0,0,0,0,0}}];
mean=Mean@grades;
PieChart3D[N@mean, ChartLabels->Range[6],LabelingFunction->"VerticalCallout",PlotLabel->"QMS202, Quiz1\nProf Tasic\n"<>date,ImageSize->400]]

InputForm[CloudDeploy[Delayed[f[DateString[]]], Permissions->"Public"][[1]]]