I have a follow-up question. I want a notebook with multiple such 'question' forms in it. Students will have the notebook live in class, and the forms are not for a formal quiz, but for instructor feedback — some of you will know about 'iClicker' and other such tools for this. So, I set up one Databin for the notebook, and each form sends its responses to the Databin with a different key so they appear in different 'columns' when it's read back in as a Dataset. Then they can be displayed, graphed, etc as appropriate. Here is an example of setup code that is autoevaluated at the beginning of the notebook, identifying the Databin and defining three forms that send data to it:
(* Initialize clean databin to hold class responses (INSTRUCTOR \
NOTEBOOK ONLY) *)
(* dataBins=Databins[];
If[Length[Select[dataBins,#["Name"]==="popBin1"&]]>0,DeleteObject[\
Select[dataBins,#["Name"]==="popBin1"&]]];
popBin1=CreateDatabin[<|"Name"\[Rule]"popBin1"|>]; *)
(* Locate the databin for this notebook (STUDENT NOTEBOOKS) *)
popBin1 = Select[Databins[], #["Name"] === "popBin1" &][[1]];
(* Initialize forms for responses *)
form1 = FormFunction[<|
"Response" ->
"String"|>, (DatabinAdd[popBin1, <|"Q1" -> #Response|>];
Print["Thanks!"]) &,
AppearanceRules -> <|"Title" -> "Class Response 1",
"Description" ->
"Write a short interpretation of the results in the graph",
"ItemLayout" -> "Vertical"|>];
form2 = FormFunction[<|"Response" -> "String"|>,
DatabinAdd[popBin1, <|"Q2" -> #Response|>] &,
AppearanceRules -> <|"Title" -> "Class Response 2",
"Description" ->
"Write a short interpretation of the results in this other \
graph", "ItemLayout" -> "Vertical"|>];
form3 = FormFunction[
FormObject[<|
"Response" -> <|
"Interpreter" -> {"None at all." -> 1,
"Some stuff in high school." -> 2,
"I have taken one or two intro-level college classes." -> 3,
"I have written code for research in an Independent Study or \
similar." -> 4, "I have mad skillz and write my own apps." -> 5},
"Control" -> (RadioButtonBar[##, Appearance -> "Vertical"] &)|>|>,
AppearanceRules -> <|"Title" -> "Your Coding Experince",
"Description" ->
"Choose the answer that is closest to your experience level",
"ItemLayout" -> "Vertical"|>],
DatabinAdd[popBin1, <|"Q3" -> #Response|>] &];
All the functionality works great — that is not my problem. My problem is with how the forms deploy in the notebook, if I don't want students to have to Shift-Enter in a cell with form1[];
in it. I can't use auto-evaluating cells because each form interrupts evaluation until it is submitted or canceled. So I tried
Button["Question 1",form1[]]
but this displays nothing; it just changes to the 'pressed' appearance for the default timeout of 5 secs and then returns to 'unpressed.' No form appears. Any thoughts about how to make a form appear when a button is pressed?