"SelectCompletion" (Question Interface Type)
"SelectCompletion"
provides a fill-in-the-blank interface with choices for each blank.
Properties
- In QuestionInterface["SelectCompletion",props], props is an Association that supports the following keys:
-
"Prompt" None text asking the user a question "Template" (required) template object with slots to be filled "Choices" Automatic available choices for each slot "ChoiceOrdering" Automatic function for ordering choices "Labels" Automatic corresponding labels for each choice - The "Template" can be any content supported by TemplateObject or StringTemplate. When providing a string, template slots denoted by backticks `` define locations for blanks in the question interface.
- By default, the "Choices" are inherited from the AssessmentFunction and randomly sorted to avoid exposing the correct answer.
- When provided directly, "Choices" should have the form {{item1a,item1b,…},{item2a,item2b,…},…} where each sublist contains the available choices for a blank in the interface. By default, the order will be maintained as provided.
- When "ChoiceOrdering"f is specified, the items will be presented as {f[{item1a,item1b,…}],f[{item2a,item2b,…}],…}.
- Additionally, options for PopupMenu are supported including:
-
Background Automatic input field background color "DefaultLabel" Null expression to display when field is empty FieldSize {{{{5,Infinity},{1,Infinity}}}} the size of the input field - For a PopupMenu setting optvalue, the following forms of value are supported:
-
expr use expr for all fields {expr1, expr2, …} use the expri in order for each field, then use defaults {expr1, expr2,…,{c},exprm,…,exprn} use the sequence of expri, then repeatedly use c, then use the last sequence of expri at the end {i1->v1,i2->v2,…} specify what to use at positions ik {spec,rules} use rules to override specifications in spec
Corresponding AssessmentFunction
- "SelectCompletion" is not an automatically assigned interface type for any AssessmentFunction. It must be specified in QuestionInterface.
- The values vali in AssessmentFunction[{val1,…},…] should contain the answers for each slot in order.
- The assessment function should be structured as AssessmentFunction[{{elem1a, elem2a,…}scorea,{elem1b,elem2b}scoreb},…] where each list {elem1i,elem2i,…} is a value in the answer key defining a possible correct or incorrect answer.
Examples
open all close allBasic Examples (3)
Define a select completion question with assessment:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the countries", "Template" -> "Shanghai is in `` and London is in ``"|>], AssessmentFunction[{{"China", "England"} -> 1,
{"Japan", "France"} -> 0,
{"Austria", "Denmark"} -> 0
}]]Specify the choices directly instead of inheriting from the AssessmentFunction:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the countries", "Template" -> "Shanghai is in `` and London is in ``", "Choices" -> {{"China", "Japan", "Austria"}, {"England", "France", "Denmark", "Belgium"}}|>], AssessmentFunction[{{"China", "England"}}]]Create a select completion interface without assessment:
QuestionObject[QuestionInterface["SelectCompletion", <|"Template" -> "Handedness ``", "Choices" -> {{"Left", "Right", "Ambidextrous"}}|>]]Scope (3)
A question with multiple possible correct answers:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose a country", "Template" -> "`` is located in North America", "Choices" -> {{Entity["Country", "Canada"], Entity["Country", "Mexico"], Entity["Country", "Italy"]}}|>], AssessmentFunction[{{Entity["Country", "Canada"]}, {Entity["Country", "Mexico"]}}]]QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Complete the sentence using proper grammar", "Template" -> "I arrived `` Chicago `` Monday "|>], AssessmentFunction[{{"in", "on"} -> 1, {"to", "for"} -> 0, {"at", "next"} -> 0}]]Create a fill-in-the-blank question with labels:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose your pet", "Template" -> "My pet is ``", "Choices" -> {{"Cat", "Dog", "Fish", "Other", "None"}}, "Labels" -> {{Entity["TaxonomicSpecies", "FelisCatus::ddvt3"][EntityProperty["TaxonomicSpecies", "Image"]], Entity["TaxonomicSpecies", "CanisLupusFamiliaris::4t62p"][EntityProperty["TaxonomicSpecies", "Image"]], Entity["TaxonomicSpecies", "Actinopterygii::6qwyh"][EntityProperty["TaxonomicSpecies", "Image"]], "Other", "None, I don't have any pet"}}|>]]Generalizations & Extensions (3)
Specify the template using TemplateSlot:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blank", "Template" -> Row[{1, 1, 2, 3, 5, TemplateSlot[1], 13}, ", "], "Choices" -> Range[5, 11]|>], AssessmentFunction[{8} -> 1]]Provide a full TemplateObject:
template = StringTemplate["`` Newton and `` Einstein", InsertionFunction -> Identity, CombinerFunction -> Identity]QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blank", "Template" -> template, "Choices" -> {{"Isaac", "Andrew", "James"}, {"Edward", "Travis", "Albert"}}|>], AssessmentFunction[{{"Isaac", "Albert"}}]]Customize the menu color and font style:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the right words", "Template" -> "During the archery contest, `` Hood amazed the `` by ``
an `` with such precision that it `` the bullseye.",
"Choices" -> {{"Ronald", "Neighbor", "Robin"}, {"cat", "crowd", "king"}, {"shooting", "throwing", "firing"}, {"bullet", "arrow", "basketball"}, {"exploded", "missed", "struck"}}, Background -> {{Blue}, 1 -> Cyan, 3 -> Yellow, 5 -> Yellow}, FrameMargins -> 15, DefaultMenuStyle -> Directive[Bold, 14]|>], AssessmentFunction[{{"Robin", "crowd", "shooting", "arrow", "struck"}}]]Applications (2)
Create a question generator for a fill-in-the-blank question:
gen = QuestionGenerator[{"a" :> RandomInteger[{10, 20}], "b" :> RandomInteger[10]}, QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose the correct answer", "Template" -> StringTemplate["`a` plus `b` equals "][#] <> "``?"|>], AssessmentFunction[{{#a + #b} -> 1, {#a - #b}, {#b - #a}, {#a + #b + 1}}]]&]Create three instances of the question:
Table[gen[], {3}]Create a select completion question for an art assessment:
arttest = QuestionGenerator[{"c" :> RandomEntity[EntityValue[Entity["Person", "VincentVanGogh::9vq62"], EntityProperty["Person", "NotableArtworks"]], 4], "decoys" :> RandomEntity[EntityValue[Entity["Person", "DiegoVelazquez::jk6k2"], EntityProperty["Person", "NotableArtworks"]], 3]}, QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose the artwork from the same artist as the pieces shown", "Template" -> Grid[{Append[Image[EntityValue[Most@#c, "Image"]], TemplateSlot[1]]}], "Choices" -> {Append[#decoys, Last[#c]]}, "Labels" -> {DeleteDuplicates@Flatten@{Append[Image[EntityValue[#decoys, "Image"], ImageSize -> Tiny], Image[EntityValue[Last@#c, "Image"], ImageSize -> Tiny]]}}|>], AssessmentFunction[{{Last@#c} -> 1}]]&]Generate a question. Images for some artworks are unavailable and may cause failures:
arttest[]Properties & Relations (1)
Specify choice ordering on a fill-in-the-blank question:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Rate your experience", "Template" -> "Customer Service: ``", "Labels" -> {{"⭐⭐⭐", "⭐", "⭐⭐"}}, "Choices" -> {{"Good", "Bad", "Neutral"}}, "ChoiceOrdering" -> SortBy[StringLength]|>]]Possible Issues (2)
The values in the AssessmentFunction should be lists. Submitting an answer to this invalid assessment will fail:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose the color", "Template" -> "Apples are ``", "Choices" -> {{"red", "white", "blue"}}|>], AssessmentFunction["red" -> 1]]Specify the answer key values as a list instead:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Choose the color", "Template" -> "Apples are ``", "Choices" -> {{"red", "white", "blue"}}|>], AssessmentFunction[{{"red"} -> 1}]]The TemplateObject created by StringTemplate contains options incompatible with "SelectCompletion":
fromStringTemplate = StringTemplate["`` and Juliet"]Options[fromStringTemplate]Attempting to use this template will create a broken interface:
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blank",
"Choices" -> {"Romeo", "Hamlet", "Iago", "Othello"}, "Template" -> fromStringTemplate|>], AssessmentFunction[{{"Romeo"}}]]withoutOptions = TemplateObject[First@fromStringTemplate]Now the template works in "TextCompletion":
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blank",
"Choices" -> {"Romeo", "Hamlet", "Iago", "Othello"}, "Template" -> withoutOptions|>], AssessmentFunction[{{"Romeo"}}]]Alternatively, use TemplateObject directly instead of StringTemplate:
directTemplate = TemplateObject[{TemplateSlot[1], " and Juliet"}];This template does not have any options settings:
Options[directTemplate]It works in "SelectCompletion":
QuestionObject[QuestionInterface["SelectCompletion", <|"Prompt" -> "Fill in the blank",
"Choices" -> {"Romeo", "Hamlet", "Iago", "Othello"}, "Template" -> directTemplate|>], AssessmentFunction[{{"Romeo"}}]]See Also
QuestionInterface QuestionObject PopupMenu TemplateObject
Question Interface Types: TextCompletion DragCompletion SelectPair
Comparison Methods: Expression