QuestionObject[q,assess]
represents the question q and the corresponding assessment assess.
QuestionObject[assess]
derives a question from the assessment.
QuestionObject
List of interface types »QuestionObject[q,assess]
represents the question q and the corresponding assessment assess.
QuestionObject[assess]
derives a question from the assessment.
Details and Options
- A QuestionObject is displayed as an interactive form in which answers are submitted and assessed.
- A QuestionObject is commonly created in a Question Notebook, available with CreateNotebook["QuestionNotebook"].
- In QuestionObject[q,assess], q accepts the following form:
-
"question" text prompt asking a question QuestionInterface[type,specs] a QuestionInterface object - The assessment assess accepts the following forms:
-
AssessmentFunction[…] assessment function <|…|> Association defining a valid key for AssessmentFunction f test function - The test function f should be a function that takes the submitted answer returns an assessment, either as True, False or as an AssessmentResultObject.
- Supported interface types are listed Question Interface Types and include:
-
"ChooseMultiple" select any number of items from a defined list "ClickLocations" locate an item on a graphical interface "Code" enter code using an input field "DragCategorize" group items into categories using a drag-and-drop interface "DragCompletion" drag items from a pool to fill in blanks "MultipleShortAnswers" enter multiple answers into input fields "MultipleChoice" select a correct answer from a list "MultipleChoiceGrid" group items into categories using a table "NumericRange" choose a value from within a range "SelectPair" match an item with a category "SelectColor" choose a color "SelectCompletion" choose text to fill in a blank "ShortAnswer" enter an answer using an input field "Sort" order a list using a drag-and-drop interface "TextCompletion" type text to fill in a blank "TrueFalse" determine whether a question is true or false - QuestionObject supports the following options:
-
EpilogFunction None function applied to the assessment after submission ImageSize Automatic overall size of the QuestionObject
Examples
open all close allBasic Examples (2)
Scope (17)
Create a categorization question:
QuestionObject["Put an animal in the correct class:", AssessmentFunction[{
"Horse" -> <|"Category" -> "Mammal"|>,
"Seahorse" -> <|"Category" -> "Fish"|>,
"Platypus" -> <|"Category" -> "Mammal"|>,
"Orca" -> <|"Category" -> "Mammal"|>,
"Turtle" -> <|"Category" -> "Reptile"|>
}]]Specify a test function to assess the answer:
QuestionObject["Give a prime number", PrimeQ]Create a question where multiple answers may be chosen:
QuestionObject["SqrtBox[4]", AssessmentFunction[{-2 -> True, 0 -> False, 2 -> True, 1 -> False}, <|"ListAssessment" -> "SeparatelyScoreElements"|>, MaxItems -> 2]]Create a "ShortAnswer" question for assessing a free-form textual answer:
QuestionObject[QuestionInterface["ShortAnswer", <|"Prompt" -> "What sort of animal is Eeyore?",
"Interpreter" -> "Species"|>],
AssessmentFunction[Entity["TaxonomicSpecies", "EquusAsinus::8c9y9"]]]Create a "MultipleChoice" question for selecting a single correct answer from a list of choices:
QuestionObject[QuestionInterface["MultipleChoice", <|"Prompt" -> "Which function is linear?"|>],
AssessmentFunction[{ x ^ 2 -> 0, Sin[x] -> 0, 5x -> 1}]]Create a "MultipleShortAnswers" question to assess many free-form answers:
QuestionObject[QuestionInterface["MultipleShortAnswers", <|"Prompt" -> "Give divisors of 24?",
"FieldType" -> Number|>],
AssessmentFunction[{_ ? (Divisible[24, #]&)}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]Create a "TextCompletion" question to assess free-form fill-in-the-blank answers:
QuestionObject[QuestionInterface["TextCompletion", <|"Prompt" -> "Fill in the blanks",
"Template" -> "The quick brown `` jumped over the lazy ``."|>],
AssessmentFunction[{{"fox", "dog"}}]]Create a "SelectCompletion" question to select from a set of predefined answers for each blank:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blanks",
"Template" -> "The quick brown `` jumped over the lazy ``."|>],
AssessmentFunction[{{"fox", "dog"} -> 1, {"horse", "child"} -> 0, {"hare", "turtle"} -> 0}]]Create a "DragCompletion" question to fill blanks from a common pool of predefined answers:
QuestionObject[QuestionInterface["DragCompletion", <|"Prompt" -> "Fill in the blanks",
"Template" -> "The quick brown `` jumped over the lazy ``."|>],
AssessmentFunction[{{"fox", "dog"} -> 1, {"horse", "child"} -> 0, {"hare", "turtle"} -> 0}]]Create a "ClickLocations" question for locating items in a photo:
stoplights = [image];QuestionObject[QuestionInterface["ClickLocations", <|"Prompt" -> "Locate the stoplights", "Background" -> stoplights|>], AssessmentFunction[{ImageCases[stoplights, Entity["Concept", "TrafficLight::b4966"] -> "Position"]}, <|"ComparisonMethod" -> "Vector", "ListAssessment" -> "AllElementsOrderless"|>, Tolerance -> 80]]Create a "Sort" question for ordering items in a list:
QuestionObject[QuestionInterface["Sort", "Order the countries from earliest independence to latest" ],
AssessmentFunction[{SortBy[RandomEntity["Country", 4], #["IndependenceDate"]&]}]]Create a "NumericRange" question for choosing a value within an interval:
QuestionObject[QuestionInterface["NumericRange", <|"Prompt" -> "How many people live in New Zealand?",
"Range" -> {5*^5, 30*^6}|>], AssessmentFunction[
QuantityMagnitude@Entity["Country", "NewZealand"][EntityProperty["Country", "Population"]], Tolerance -> 5*^5
]]Create a "SelectPair" question for matching one item with a category:
QuestionObject[QuestionInterface["SelectPair", "Match an athelete with their sport:"], AssessmentFunction[{
"Tiger Woods" -> <|"Category" -> "Golf"|>,
"Serena Williams" -> <|"Category" -> "Tennis"|>,
"Lionel Messi" -> <|"Category" -> "Soccer"|>,
"Usain Bolt" -> <|"Category" -> "Track"|>
}]]Create a "SelectColor" question for assessing a color choice:
QuestionObject[QuestionInterface["SelectColor", "What color is a Cardinal"], AssessmentFunction[{
Interpreter["Color"]["Cardinal"]
}, Tolerance -> 0.5]]Create a "MultipleChoiceGrid" question for categorizing multiple items into common categories by selecting radio buttons:
QuestionObject[QuestionInterface["MultipleChoiceGrid", "Categorize the primates"], AssessmentFunction[{
"Chimpanzee" -> <|"Category" -> "Ape"|>, "Gibbon" -> <|"Category" -> "Ape"|>,
"Baboon" -> <|"Category" -> "Monkey"|>,
"Sifaka" -> <|"Category" -> "Lemur"|>}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]Create a "DragCategorize" question for categorizing multiple items into common categories by dragging the items:
QuestionObject[QuestionInterface["DragCategorize", "Categorize the primates"], AssessmentFunction[{
"Chimpanzee" -> <|"Category" -> "Ape"|>, "Gibbon" -> <|"Category" -> "Ape"|>,
"Baboon" -> <|"Category" -> "Monkey"|>,
"Sifaka" -> <|"Category" -> "Lemur"|>}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]Create a "Code" question for assessing whether submitted code is equivalent to the code in the answer key:
QuestionObject[QuestionInterface["Code", "Write code that flips the order of the string \"Hello World\""], AssessmentFunction[{
HoldPattern[StringReverse["Hello World"]]}, "CodeEquivalence"]]Generalizations & Extensions (1)
Create a test function that returns an AssessmentResultObject where the score is a function of the answer:
isItGreen[color_] := With[{dist = ColorDistance[color, Green]},
AssessmentResultObject[<|"Score" -> (0.3 - dist) * 10, "AnswerCorrect" -> dist < 0.3|>]
]QuestionObject[QuestionInterface["SelectColor", "Choose a green color"],
isItGreen]Options (2)
EpilogFunction (1)
Use EpilogFunction in QuestionObject to record the results to a file:
QuestionObject[QuestionInterface["MultipleChoice", <|"Prompt" -> "What is 4^3?"|>],
AssessmentFunction[{16, -64, 64 -> 1}], EpilogFunction -> (PutAppend[#Assessment, "assessmentresults"]&)]ReadList["assessmentresults"]DeleteFile["assessmentresults"]ImageSize (1)
Use ImageSize to set the width of a QuestionObject:
QuestionObject[QuestionInterface["TrueFalse", <|"Prompt" -> "Is it accurate to say that a whale belongs to the class of animals known as mammals? True or false?"|>], TrueQ, ImageSize -> 500]QuestionObject[QuestionInterface["TrueFalse", <|"Prompt" -> "Is it accurate to say that a whale belongs to the class of animals known as mammals? True or false?"|>], TrueQ, ImageSize -> {300, 300}]Applications (1)
Define a function that generates random versions of a question:
factorQuestion[] := With[{n = RandomInteger[{10, 100}]}, QuestionObject["What are the prime factors of " <> ToString[n, TraditionalForm],
AssessmentFunction[RandomSample[{{2, 3, 5} -> 0, (First /@ FactorInteger[n]) -> 1,
Prime /@ Sort[RandomInteger[{2, 10}, 3]] -> 0}]]]
]Generate two versions of the question:
factorQuestion[]factorQuestion[]Create an equivalent QuestionGenerator:
factorGenerator = QuestionGenerator[
{"n" :> RandomInteger[{10, 100}]},
QuestionObject["What are the prime factors of " <> ToString[#n, TraditionalForm],
AssessmentFunction[RandomSample[{{2, 3, 5} -> 0, (First /@ FactorInteger[#n]) -> 1,
Prime /@ Sort[RandomInteger[{2, 10}, 3]] -> 0}]]]&
]factorGenerator[2]Properties & Relations (2)
When an interface type cannot be inferred from the assessment, an input field is used:
QuestionObject["Approximately how many asteroids are in the asteroid belt?", Between[{1100000, 2000000}]]When no assessment is defined, the submit button is omitted:
QuestionObject[ QuestionInterface["MultipleChoiceGrid", <|"Prompt" -> "Rate these foods:", "Choices" -> {"Ice cream", "Pizza", "Watermelon", "Popcorn"}, "Categories" -> {1, 2, 3, 4, 5}|>]]See Also
AssessmentFunction AssessmentResultObject QuestionInterface FormObject Ask
Function Repository: QuestionDeploy GetQuestionAssessments RandomEntityQuestion
Text
Wolfram Research (2021), QuestionObject, Wolfram Language function, https://reference.wolfram.com/language/ref/QuestionObject.html (updated 2025).
CMS
Wolfram Language. 2021. "QuestionObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/QuestionObject.html.
APA
Wolfram Language. (2021). QuestionObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QuestionObject.html
BibTeX
@misc{reference.wolfram_2026_questionobject, author="Wolfram Research", title="{QuestionObject}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/QuestionObject.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_questionobject, organization={Wolfram Research}, title={QuestionObject}, year={2025}, url={https://reference.wolfram.com/language/ref/QuestionObject.html}, note=[Accessed: 13-June-2026]}