QuestionGenerator[<|"name1":>val1,"name2":>val2,…|>, genfunc]
represents a QuestionObject generated by applying genfunc to "name1":>val1,"name1":>val2,….
QuestionGenerator[CloudObject[…]]
represents a cloud-deployed question generator.
QuestionGenerator
QuestionGenerator[<|"name1":>val1,"name2":>val2,…|>, genfunc]
represents a QuestionObject generated by applying genfunc to "name1":>val1,"name1":>val2,….
QuestionGenerator[CloudObject[…]]
represents a cloud-deployed question generator.
Details and Options
- The generation function genfunc should be a function that returns a QuestionObject when applied to the parameter association <|"name1":>val1,"name2":>val2|>.
- QuestionGenerator[params,genfunc][] effectively generates a QuestionObject by evaluating genfunc[params].
- QuestionGenerator[params,genfunc][assessments] evaluates genfunc[params,assessments] to generate a QuestionObject based on the parameters params as well as the AssessmentResultObject assessments. By including previous results in assessments, a series of questions can adapt to the users performance.
- Typically, QuestionGenerator is used with a question notebook available via CreateNotebook["QuestionNotebook"] or from File ▶ New ▶ Programmatic Notebook ▶ Question Notebook.
- A QuestionGenerator may evaluate locally or in the cloud, in the case of a deployed assessment.
- Cloud-deployed question generators have the form QuestionGenerator[CloudObject[…]] for a cloud object containing only a single generator or QuestionGenerator[{CloudObject[…],"questionid"}] when the cloud object contains multiple generators, pools or question objects.
- QuestionGenerator[genfunc] is equivalent to QuestionGenerator[<||>,genfunc].
Examples
open all close allBasic Examples (4)
Create random questions using a generator:
primetest = QuestionGenerator[{"n" :> RandomInteger[1000]}, QuestionObject["True or False: " <> ToString[#n] <> " is Prime.", AssessmentFunction[PrimeQ[#n]]]&]primetest[]Create questions using RandomEntity:
gen = QuestionGenerator[{"p" :> RandomEntity["Person"]}, QuestionObject[QuestionInterface["ShortAnswer", <|"Prompt" -> Grid[ {{"In what year was this person born?"}, {#p["Image"]}, {CommonName[#p]}}]|>], AssessmentFunction[{DateValue[#p[EntityProperty["Person", "BirthDate"]], "Year"]}]]&
]gen[]Create random survey questions using a generator:
gen = QuestionGenerator[{"food" :> RandomChoice[{"Hot dog", "Taco", "Poptart"}]}, QuestionObject[QuestionInterface["TrueFalse", "Is a " <> #food <> " a sandwich?"]]&]gen[]Create a generator that produces unique questions each time it is evaluated:
gen = QuestionGenerator[
{"rand" :> RandomInteger[100]},
QuestionObject["What are the prime factors of " <> ToString[#rand],
AssessmentFunction[
{(First /@ FactorInteger[#rand]) -> 1,
(Prime /@ RandomInteger[{1, 10}, 3]) -> 0}]]&]gen[]Scope (2)
Create random geography questions:
gen = QuestionGenerator[{"c" :> RandomEntity["Country"]}, QuestionObject["What is the capital of " <> CommonName[#c] <> "?", AssessmentFunction[Append[RandomSample[EntityList@EntityClass["City", "Country" -> #c], 3], #c[EntityProperty["Country", "CapitalCity"]] -> 1]]]&]gen[]
| |
Create several instances of the question:
gen[6]Create a question generator and deploy it to the cloud:
deployed = ResourceFunction["QuestionDeploy"][QuestionGenerator[{"n" :> RandomInteger[1000]}, QuestionObject["True or False: " <> ToString[#n] <> " is Prime.", AssessmentFunction[PrimeQ[#n]]]&]]gen = deployed["QuestionGenerator"]question = gen[]The solution to the question is not contained in either the deployed generator or the generated question:
FreeQ[{gen, question}, PrimeQ]Applications (1)
Create a QuestionGenerator that generates calculus questions including plots:
qg = QuestionGenerator[{"trig" :> RandomChoice[{Sin, Cos}], "a" :> RandomInteger[{1, 4}]},
Module[{func, der, int},
func = #trig[x] ^ #a;
der = D[func, x];
int = Integrate[func, x];
plot = Plot[Evaluate[{Legended[func, f[x] == func], Legended[der, D[f[x], x]], Legended[int, Integrate[f[x], x]]}], ...];
QuestionObject[QuestionInterface["TextCompletion", <|"Prompt" -> plot, "Template" -> TemplateObject[
{HoldForm[D[f, x]] == TemplateSlot[1], "
", HoldForm[Integrate[f, x]] == TemplateSlot[2]}
], "Interpreter" -> "HeldMathExpression"|>], AssessmentFunction[{{der, int}}, <|"ComparisonMethod" -> "CalculusResult", "ListAssessment" -> "AllElementsOrdered"|>]]]&]qg[]Related Guides
History
Text
Wolfram Research (2022), QuestionGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/QuestionGenerator.html.
CMS
Wolfram Language. 2022. "QuestionGenerator." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/QuestionGenerator.html.
APA
Wolfram Language. (2022). QuestionGenerator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QuestionGenerator.html
BibTeX
@misc{reference.wolfram_2026_questiongenerator, author="Wolfram Research", title="{QuestionGenerator}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/QuestionGenerator.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_questiongenerator, organization={Wolfram Research}, title={QuestionGenerator}, year={2022}, url={https://reference.wolfram.com/language/ref/QuestionGenerator.html}, note=[Accessed: 12-June-2026]}