variation1[ctr_]:=Module[{a0,b0,c0,sol1,index,eq},

Clear[a,b,c];
a0=RandomInteger[{-10,10}];If[a0==0, a0=1]; (*make sure a is not 0*)
b0=RandomInteger[{-10,10}];
c0=RandomInteger[{1,10}];

sol1=Reduce[(Abs[a*x+b]<c)/.{a->a0,b->b0,c->c0}, x, Reals];

index=RandomSample[Range@4,4];


(*special cases*)
Which[
b0==0, eq=StringReplace["|ax|<c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0>0, eq=StringReplace["|ax+b|<c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0≤0, eq=StringReplace["|ax-b|<c",{"a"->ToString@a0,"b"->ToString@Abs[b0],"c"->ToString@c0}]
];


(*place resutls in an association to make it easier to reuse*)
<|

"question"->RandomChoice[{Rasterize@Column[{ctr<>"Solve the inequality:",eq}], Rasterize@Column[{ctr<>"Find solutions to inequality:",eq}]}],

"algebra"->(Abs[a*x+b]<c)/.{a->a0,b->b0,c->c0},

"choices"->{Reduce[(Abs[a*x+b]<c)/.{a->(Abs[a0]+1),b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<c)/.{a->a0,b->(b0+1),c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<c)/.{a->a0,b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<c)/.{a->a0,b->b0,c->(c0+1)}, x, Reals]},


"index"->index

|>



];



variation2[ctr_]:=Module[{a0,b0,c0,sol1,index,eq},

Clear[a,b,c];
a0=RandomInteger[{-10,10}];If[a0==0, a0=1]; (*make sure a is not 0*)
b0=RandomInteger[{-10,10}];
c0=RandomInteger[{1,10}];

sol1=Reduce[(Abs[a*x+b]>c)/.{a->a0,b->b0,c->c0}, x, Reals];

index=RandomSample[Range@4,4];


(*special cases*)
Which[
b0==0, eq=StringReplace["|ax|>c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0>0, eq=StringReplace["|ax+b|>c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0≤0, eq=StringReplace["|ax-b|>c",{"a"->ToString@a0,"b"->ToString@Abs[b0],"c"->ToString@c0}]
];


(*place resutls in an association to make it easier to reuse*)
<|

"question"->RandomChoice[{Rasterize@Column[{ctr<>"Solve the inequality:",eq}], Rasterize@Column[{ctr<>"Find solutions to inequality:",eq}]}],

"algebra"->(Abs[a*x+b]>c)/.{a->a0,b->b0,c->c0},

"choices"->(StringReplace[#,{"||"->"∨"}]&/@(ToString[#,InputForm]&/@{Reduce[(Abs[a*x+b]>c)/.{a->(Abs[a0]+1),b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>c)/.{a->a0,b->(b0+1),c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>c)/.{a->a0,b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>c)/.{a->a0,b->b0,c->(c0+1)}, x, Reals]})),


"index"->index

|>



];



variation3[ctr_]:=Module[{a0,b0,c0,sol1,index,eq},

Clear[a,b,c];
a0=RandomInteger[{-10,10}];If[a0==0, a0=1]; (*make sure a is not 0*)
b0=RandomInteger[{-10,10}];
c0=RandomInteger[{1,10}];

sol1=Reduce[(Abs[a*x+b]<=c)/.{a->a0,b->b0,c->c0}, x, Reals];

index=RandomSample[Range@4,4];


(*special cases*)
Which[
b0==0, eq=StringReplace["|ax|⩽c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0>0, eq=StringReplace["|ax+b|⩽c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0≤0, eq=StringReplace["|ax-b|⩽c",{"a"->ToString@a0,"b"->ToString@Abs[b0],"c"->ToString@c0}]
];


(*place resutls in an association to make it easier to reuse*)
<|

"question"->RandomChoice[{Rasterize@Column[{ctr<>"Solve the inequality:",eq}], Rasterize@Column[{ctr<>"Find solutions to inequality:",eq}]}],

"algebra"->(Abs[a*x+b]<=c)/.{a->a0,b->b0,c->c0},

"choices"->{Reduce[(Abs[a*x+b]<=c)/.{a->(Abs[a0]+1),b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<=c)/.{a->a0,b->(b0+1),c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<=c)/.{a->a0,b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]<=c)/.{a->a0,b->b0,c->(c0+1)}, x, Reals]},


"index"->index

|>



];


variation4[ctr_]:=Module[{a0,b0,c0,sol1,index,eq},

Clear[a,b,c];
a0=RandomInteger[{-10,10}];If[a0==0, a0=1]; (*make sure a is not 0*)
b0=RandomInteger[{-10,10}];
c0=RandomInteger[{1,10}];

sol1=Reduce[(Abs[a*x+b]>=c)/.{a->a0,b->b0,c->c0}, x, Reals];

index=RandomSample[Range@4,4];


(*special cases*)
Which[
b0==0, eq=StringReplace["|ax|⩾c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0>0, eq=StringReplace["|ax+b|⩾c",{"a"->ToString@a0,"b"->ToString@b0,"c"->ToString@c0}],
b0≤0, eq=StringReplace["|ax-b|⩾c",{"a"->ToString@a0,"b"->ToString@Abs[b0],"c"->ToString@c0}]
];


(*place resutls in an association to make it easier to reuse*)
<|

"question"->RandomChoice[{Rasterize@Column[{ctr<>"Solve the inequality:",eq}], Rasterize@Column[{ctr<>"Find solutions to inequality:",eq}]}],

"algebra"->(Abs[a*x+b]>=c)/.{a->a0,b->b0,c->c0},

"choices"->(StringReplace[#,{"||"->"∨","<="->"⩽",">="->"⩾"}]&/@(ToString[#,InputForm]&/@{Reduce[(Abs[a*x+b]>=c)/.{a->(Abs[a0]+1),b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>=c)/.{a->a0,b->(b0+1),c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>=c)/.{a->a0,b->b0,c->c0}, x, Reals],
Reduce[(Abs[a*x+b]>=c)/.{a->a0,b->b0,c->(c0+1)}, x, Reals]})),


"index"->index

|>



];


format[key_,question_,choices_]:={key,question}-><|"Interpreter"->choices,"Control"->Function[RadioButtonBar[None,#2,Appearance->"Vertical"]]|>

send[res_]:=Module[{url,list,q1,q2,ans1,ans2,id,text1,text2,eq1,eq2,sol1,sol2,err1=0,err2=0,err3=0,err4=0,body},

id=res[[1]][[1]];

ans1=res[[1]][[2]];
ans2=res[[1]][[3]];
ans3=res[[1]][[4]];
ans4=res[[1]][[5]];

q1=res[[2]][[1]];
q2=res[[2]][[2]];
q3=res[[2]][[3]];
q4=res[[2]][[4]];
text1=(res[[2]][[1]])["question"];
text2=(res[[2]][[2]])["question"];
text3=(res[[2]][[3]])["question"];
text4=(res[[2]][[4]])["question"];
eq1=(res[[2]][[1]])["algebra"];
eq2=(res[[2]][[2]])["algebra"];
eq3=(res[[2]][[3]])["algebra"];
eq4=(res[[2]][[4]])["algebra"];

list={Image[,ImageSize->125],Spacer@100,
"Intervals Quiz\nJanuary 2016",
"Prof. Kelso",
Spacer@100,
"student ID:",
id,
" ",
" ",
If[q1[ans1][[2]]==3, err1=1;Column@{text1,Row[{"Correct:",q1[ans1][[1]]}]},Column@{text1,Row[{"Incorrect:", q1[ans1][[1]]}]}],
" ",
sol1=Reduce[eq1,x,Reals];
NumberLinePlot[{sol1},x,PlotTheme->"Detailed"], (*x has to be free variable do not add to local var list *)
\[SelectionPlaceholder],
" ",
" ",
If[q2[ans2][[2]]==3, err2=1;Column@{text2,Row[{ "Correct:", q2[ans2][[1]]}]},Column@{text2,Row[{"Incorrect:", q2[ans2][[1]]}]}],
sol2=Reduce[eq2,x,Reals];
NumberLinePlot[{sol2},x,PlotTheme->"Detailed"],
\[SelectionPlaceholder],

" ",
" ",
If[q3[ans3][[2]]==3, err3=1;Column@{text3,Row[{ "Correct:", q3[ans3][[1]]}]},Column@{text3,Row[{"Incorrect:", q3[ans3][[1]]}]}],
sol3=Reduce[eq3,x,Reals];
NumberLinePlot[{sol3},x,PlotTheme->"Detailed"],
\[SelectionPlaceholder],
" ",

" ",
If[q4[ans4][[2]]==3, err4=1;Column@{text4,Row[{ "Correct:", q4[ans4][[1]]}]},Column@{text4,Row[{"Incorrect:", q4[ans4][[1]]}]}],
sol4=Reduce[eq4,x,Reals];
NumberLinePlot[{sol4},x,PlotTheme->"Detailed"],
\[SelectionPlaceholder],
" "};

body={};
AppendTo[body,id];
AppendTo[body,err1];
AppendTo[body,err2];
AppendTo[body,err3];
AppendTo[body,err4];

AppendTo[body,"Interval Quiz"];
AppendTo[body,"Olympic_Precalcone_4225"];
AppendTo[body,"KELSO"];

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

AppendTo[body,ToString@url];

If[session==1,
DatabinAdd[Databin["anxL0g7s"],body],
DatabinAdd[Databin["aqACGvGV"],body]
];

HTTPRedirect@url




]

bin=CreateDatabin[<|"Name"->"Olympic, MATH 141, Fractions, Kelso"|>]
Options[bin]

genForm[res_]:=Module[{v1,v2,v3,v4,result,action,ans,questions},

HTTPRedirect@CloudDeploy[



FormFunction[

questions={};
(*Use ApptendTo to avoid large associations,and possible use from other places to mix*)
v1=variation1["1. "];
AppendTo[questions,
<|"key"->"Q1",
"question"->v1["question"],
"algebra"->v1["algebra"],
"choices"->(Rasterize[#]&/@(TraditionalForm[#]&/@((v1["choices"])[[v1["index"]]]))),
Table[Rasterize@(TraditionalForm[((v1["choices"])[[v1["index"]]])[[i]]])->{((v1["choices"])[[v1["index"]]])[[i]],(Range[4][[v1["index"]]])[[i]]},{i,1,Length@v1["index"]}]
|>];

v2=variation2["2. "];
AppendTo[questions,
<|"key"->"Q2",
"question"->v2["question"],
"algebra"->v2["algebra"],
"choices"->(Rasterize[#]&/@(TraditionalForm[#]&/@((v2["choices"])[[v2["index"]]]))),
Table[Rasterize@(TraditionalForm[((v2["choices"])[[v2["index"]]])[[i]]])->{((v2["choices"])[[v2["index"]]])[[i]],(Range[4][[v2["index"]]])[[i]]},{i,1,Length@v2["index"]}]

|>];


v3=variation3["3. "];
AppendTo[questions,
<|"key"->"Q3",
"question"->v3["question"],
"algebra"->v3["algebra"],
"choices"->(Rasterize[#]&/@(TraditionalForm[#]&/@((v3["choices"])[[v3["index"]]]))),
Table[Rasterize@(TraditionalForm[((v3["choices"])[[v3["index"]]])[[i]]])->{((v3["choices"])[[v3["index"]]])[[i]],(Range[4][[v3["index"]]])[[i]]},{i,1,Length@v3["index"]}]

|>];


v4=variation4["4. "];
AppendTo[questions,
<|"key"->"Q4",
"question"->v4["question"],
"algebra"->v4["algebra"],
"choices"->(Rasterize[#]&/@(TraditionalForm[#]&/@((v4["choices"])[[v4["index"]]]))),
Table[Rasterize@(TraditionalForm[((v4["choices"])[[v4["index"]]])[[i]]])->{((v4["choices"])[[v4["index"]]])[[i]],(Range[4][[v4["index"]]])[[i]]},{i,1,Length@v4["index"]}]

|>];

result=format[#["key"],#["question"],#["choices"]]&/@questions;
action=Map[Slot,questions[[All,"key"]]];
result=Join[{Style[" ","Title"],{"name","Student Name"}->"String",Delimiter},result];

action=Join[{Slot["name"]},action];


result,
With[{formaction=action,q=questions},
(send[{formaction}~Join~{q}])&
],

"PNG",
AppearanceRules-><|"ItemLayout"->"Vertical"|>,
FormTheme->"Blue"]


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

]

Deploy Area
Olympic_Precalcone_4225

session=1;
cc=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,
"Intervals Quiz\nJanuary 2016",
"Prof. Kelso",
Spacer@100,

"Press Start button to start the test"
}]


], FormTheme -> "White"], 

Permissions->"Public"]

DatabinRemove[Databin["anxL0g7s"],{1,37}]

Data Bin

Options[Databin["anxL0g7s"]]

Values@Databin["anxL0g7s"]

ON

$Permissions = "Public";
on[]:=Module[{},CloudSymbol["Olympic_Precalcone_4225"]=1;SetPermissions[CloudObject[MouseOver], "Public"]];
CloudDeploy[

APIFunction[{},on[]&],Permissions->"Public"]

Off

$Permissions = "Public";
off[]:=Module[{},CloudSymbol["Olympic_Precalcone_4225"]=0;SetPermissions[CloudObject[MouseOver], "Private"]];
CloudDeploy[

APIFunction[{},off[]&],Permissions->"Public"]

Status

CloudDeploy[
APIFunction[{},CloudSymbol["Olympic_Precalcone_4225"]&],Permissions->"Public"]

Statistics Report

f[date_]:=Module[{grades,mean},grades=Values[Databin["anxL0g7s"]][[All,2;;5]];

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

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

Deploy Area
Olympic_Precalcone_4228

session=2;
cc=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,
"Intervals Quiz\nJanuary 2016",
"Prof. Kelso",
Spacer@100,

"Press Start button to start the test"
}]


], FormTheme -> "White"], 

Permissions->"Public"]

Data Bin

bin=CreateDatabin[<|"Name"->"Olympic, MATH 141, Intervals, Kelso"|>]
Options[bin]

ON

$Permissions = "Public";
on[]:=Module[{},CloudSymbol["Olympic_Precalcone_4228"]=1;SetPermissions[CloudObject[MouseOver], "Public"]];
CloudDeploy[

APIFunction[{},on[]&],Permissions->"Public"]

Off

$Permissions = "Public";
off[]:=Module[{},CloudSymbol["Olympic_Precalcone_4228"]=0;SetPermissions[CloudObject[MouseOver], "Private"]];
CloudDeploy[

APIFunction[{},off[]&],Permissions->"Public"]

Status

CloudDeploy[
APIFunction[{},CloudSymbol["Olympic_Precalcone_4228"]&],Permissions->"Public"]

Statistics Report

f[date_]:=Module[{grades,mean},grades=Values[Databin["aqACGvGV"]][[All,2;;5]];

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

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