QuestionObject[q,assess]
表示问题 q 及对应的评估 assess.
QuestionObject[assess]
根据评估推导出问题.
QuestionObject
界面类型列表 »QuestionObject[q,assess]
表示问题 q 及对应的评估 assess.
QuestionObject[assess]
根据评估推导出问题.
更多信息和选项
- QuestionObject 被显示为交互式表单,可在表单内提交答案并对其进行评估.
- QuestionObject 通常在 Question Notebook 中被创建,用 CreateNotebook["QuestionNotebook"] 即可得到 Question Notebook.
- 在 QuestionObject[q,assess] 中, q 接受以下形式:
-
"question" 文字提示,提出问题 QuestionInterface[type,specs] 一个 QuestionInterface 对象 - 评估 assess 接受以下形式:
-
AssessmentFunction[…] 评估函数 <|…|> 为 AssessmentFunction 定义有效的键的 Association f 测评函数 - 测评函数 f 应为一个接受提交的答案并返回评估的函数,结果为 True、False 或 AssessmentResultObject.
- 支持的界面类型被列在问题界面类型中,其中包括:
-
"ChooseMultiple" 从定义的列表中选择任意数量的项 "ClickLocations" 从图形界面中找出正确的答案 "Code" 在输入栏中输入代码 "DragCategorize" 使用拖放界面对各个项进行分组 "DragCompletion" 从给出的内容中选取合适的答案,完成填空 "MultipleShortAnswers" 在输入栏中输入多个答案 "MultipleChoice" 从列表中选择正确的答案 "MultipleChoiceGrid" 用表格对各个项进行分组 "NumericRange" 从一定范围内选择值 "SelectPair" 将项与类别相匹配 "SelectColor" 选择颜色 "SelectCompletion" 选择文字内容,完成填空 "ShortAnswer" 在输入栏中输入答案 "Sort" 使用拖放界面对列表进行排序 "TextCompletion" 自行输入内容,完成填空 "TrueFalse" 确定答案是 true 还是 false - QuestionObject 支持以下选项:
-
EpilogFunction None 提交后应用于评估结果的函数 ImageSize Automatic QuestionObject 的整体大小
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (17)
QuestionObject["Put an animal in the correct class:", AssessmentFunction[{
"Horse" -> <|"Category" -> "Mammal"|>,
"Seahorse" -> <|"Category" -> "Fish"|>,
"Platypus" -> <|"Category" -> "Mammal"|>,
"Orca" -> <|"Category" -> "Mammal"|>,
"Turtle" -> <|"Category" -> "Reptile"|>
}]]QuestionObject["Give a prime number", PrimeQ]QuestionObject["SqrtBox[4]", AssessmentFunction[{-2 -> True, 0 -> False, 2 -> True, 1 -> False}, <|"ListAssessment" -> "SeparatelyScoreElements"|>, MaxItems -> 2]]创建一个 "ShortAnswer" 问题,评估自由格式的文本答案:
QuestionObject[QuestionInterface["ShortAnswer", <|"Prompt" -> "What sort of animal is Eeyore?",
"Interpreter" -> "Species"|>],
AssessmentFunction[Entity["TaxonomicSpecies", "EquusAsinus::8c9y9"]]]创建一个 "MultipleChoice" 问题,从一组选项中选择正确的答案:
QuestionObject[QuestionInterface["MultipleChoice", <|"Prompt" -> "Which function is linear?"|>],
AssessmentFunction[{ x ^ 2 -> 0, Sin[x] -> 0, 5x -> 1}]]创建一个 "MultipleShortAnswers" 问题,评估多个自由格式的答案:
QuestionObject[QuestionInterface["MultipleShortAnswers", <|"Prompt" -> "Give divisors of 24?",
"FieldType" -> Number|>],
AssessmentFunction[{_ ? (Divisible[24, #]&)}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]创建一个 "TextCompletion" 问题,自行输入内容,完成填空:
QuestionObject[QuestionInterface["TextCompletion", <|"Prompt" -> "Fill in the blanks",
"Template" -> "The quick brown `` jumped over the lazy ``."|>],
AssessmentFunction[{{"fox", "dog"}}]]创建一个 "SelectCompletion" 问题,从一组预定义的答案中选择,完成多个填空:
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}]]创建一个 "DragCompletion" 问题,从预先给出的答案中选择,完成填空:
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}]]创建一个 "ClickLocations" 问题,从图片中找到正确答案:
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]]创建一个 "Sort" 问题,对列表进行排序:
QuestionObject[QuestionInterface["Sort", "Order the countries from earliest independence to latest" ],
AssessmentFunction[{SortBy[RandomEntity["Country", 4], #["IndependenceDate"]&]}]]创建一个 "NumericRange" 问题, 从区间内选择一个值:
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
]]创建一个 "SelectPair" 问题,将项与类别相匹配:
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"|>
}]]创建一个 "SelectColor" 问题,选择正确的颜色:
QuestionObject[QuestionInterface["SelectColor", "What color is a Cardinal"], AssessmentFunction[{
Interpreter["Color"]["Cardinal"]
}, Tolerance -> 0.5]]创建一个 "MultipleChoiceGrid" 问题,通过选择单选按钮对多个项进行分类:
QuestionObject[QuestionInterface["MultipleChoiceGrid", "Categorize the primates"], AssessmentFunction[{
"Chimpanzee" -> <|"Category" -> "Ape"|>, "Gibbon" -> <|"Category" -> "Ape"|>,
"Baboon" -> <|"Category" -> "Monkey"|>,
"Sifaka" -> <|"Category" -> "Lemur"|>}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]创建一个 "DragCategorize" 问题,通过拖动对多个项进行分类:
QuestionObject[QuestionInterface["DragCategorize", "Categorize the primates"], AssessmentFunction[{
"Chimpanzee" -> <|"Category" -> "Ape"|>, "Gibbon" -> <|"Category" -> "Ape"|>,
"Baboon" -> <|"Category" -> "Monkey"|>,
"Sifaka" -> <|"Category" -> "Lemur"|>}, <|"ListAssessment" -> "SeparatelyScoreElements"|>]]创建一个 "Code" 问题,评估提交的代码是否与答案中的代码等效:
QuestionObject[QuestionInterface["Code", "Write code that flips the order of the string \"Hello World\""], AssessmentFunction[{
HoldPattern[StringReverse["Hello World"]]}, "CodeEquivalence"]]推广和延伸 (1)
创建一个测评函数,返回一个 AssessmentResultObject,其中的分数为答案的函数:
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]选项 (2)
EpilogFunction (1)
用 QuestionObject 中的 EpilogFunction 将结果记录到文件中:
QuestionObject[QuestionInterface["MultipleChoice", <|"Prompt" -> "What is 4^3?"|>],
AssessmentFunction[{16, -64, 64 -> 1}], EpilogFunction -> (PutAppend[#Assessment, "assessmentresults"]&)]ReadList["assessmentresults"]DeleteFile["assessmentresults"]ImageSize (1)
用 ImageSize 设置 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}]应用 (1)
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}]]]
]factorQuestion[]factorQuestion[]创建一个等效的 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]属性和关系 (2)
QuestionObject["Approximately how many asteroids are in the asteroid belt?", Between[{1100000, 2000000}]]QuestionObject[ QuestionInterface["MultipleChoiceGrid", <|"Prompt" -> "Rate these foods:", "Choices" -> {"Ice cream", "Pizza", "Watermelon", "Popcorn"}, "Categories" -> {1, 2, 3, 4, 5}|>]]文本
Wolfram Research (2021),QuestionObject,Wolfram 语言函数,https://reference.wolfram.com/language/ref/QuestionObject.html (更新于 2025 年).
CMS
Wolfram 语言. 2021. "QuestionObject." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/QuestionObject.html.
APA
Wolfram 语言. (2021). QuestionObject. Wolfram 语言与系统参考资料中心. 追溯自 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: 14-July-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: 14-July-2026]}