Thank you everyone, but I am after something a bit different. Arnoud, that was a useful hint. Thanks. I've put a bit more work into this:
My goal here is not to have students be quized on correct answers, but to make them read and understand before they can proceed. (n.b., I am finding students treat instructional workbooks like a video game, they click and go without thinking).
Here are some working examples that I hope illustrate what I am after.
This works, but still does not achieve my goal.
CreateDocument[
{
groupOpen = 1;
Cell["Tutorial", "Title"],
Cell["Words of wisdom...."],
Cell["Here is how to integrate in Mathematica", "Section"],
ExpressionCell[
Defer[InputForm[
Integrate[
Cos[4 Pi x/lambda] Cos[2 Pi x/lambda], {x, 0, lambda}]]],
"Input"],
ExpressionCell[Button["Continue",
CreateDialog[
Column[{
"Why is the integral above equal to zero?",
TabView[{"because the integrand is zero" ->
Tooltip["Wrong", "Oh you are just being silly"],
"because the integrand is odd about lambda/2" -> "Wrong",
"this is because of the orthogonality of cosines" ->
DefaultButton["Correct", DialogReturn[True]],
Cos[Pi/6] -> "Note quite"}, None]
}
],
Modal -> True]
]
],
CellGroup[
{
TextCell["Coding Challenge", "Subtitle"],
TextCell["Derive the grand unified theory with Mathematica",
"Subsubtitle"]
}, groupOpen
]
}
]
This also works, but doesn't achieve my goal.
CreateDocument[
{
groupOpen = All; (*the difference from above, All is not documented..*)
Cell["Tutorial", "Title"],
Cell["Words of wisdom...."],
Cell["Here is how to integrate in Mathematica", "Section"],
ExpressionCell[
Defer[InputForm[
Integrate[
Cos[4 Pi x/lambda] Cos[2 Pi x/lambda], {x, 0, lambda}]]],
"Input"],
ExpressionCell[Button["Continue",
CreateDialog[
Column[{
"Why is the integral above equal to zero?",
TabView[{"because the integrand is zero" ->
Tooltip["Wrong", "Oh you are just being silly"],
"because the integrand is odd about lambda/2" -> "Wrong",
"this is because of the orthogonality of cosines" ->
DefaultButton["Correct", DialogReturn[True]],
Cos[Pi/6] -> "Note quite"}, None]
}
],
Modal -> True]
]
],
CellGroup[
{
TextCell["Coding Challenge", "Subtitle"],
TextCell["Derive the grand unified theory with Mathematica",
"Subsubtitle"]
}, groupOpen
]
}
]
I would have expected this to work with Dynamic, but it doesn't and I don't know why....
CreateDocument[
{
groupOpen = 1;
Cell["Tutorial", "Title"],
Cell["Words of wisdom...."],
Cell["Here is how to integrate in Mathematica", "Section"],
ExpressionCell[
Defer[InputForm[
Integrate[
Cos[4 Pi x/lambda] Cos[2 Pi x/lambda], {x, 0, lambda}]]],
"Input"],
ExpressionCell[Button["Continue",
CreateDialog[
Column[{
"Why is the integral above equal to zero?",
TabView[{"because the integrand is zero" ->
Tooltip["Wrong", "Oh you are just being silly"],
"because the integrand is odd about lambda/2" -> "Wrong",
"this is because of the orthogonality of cosines" ->
DefaultButton["Correct",
DialogReturn[groupOpen = All; True]], (*changes value of groupOpen*)
Cos[Pi/6] -> "Note quite"}, None]
}
],
Modal -> True]
]
],
CellGroup[
{
TextCell["Coding Challenge", "Subtitle"],
TextCell["Derive the grand unified theory with Mathematica",
"Subsubtitle"]
}, Dynamic[groupOpen] (*second argument to CellGroup is Dynamic*)
]
}
]
I am going to try NotebookFind by CellTags next and then programmatically open cells that way, but I thought this method would have been easier.
Any insights welcome!