<choiceInput>
<choiceInput> is an Input
component that defines a block of code for multiple choice questions.
It serves as a container element for the individual
<choice> components that are nested within.
Attributes and Properties
Attributes for <choiceInput>
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (10)
text. Two-way binding target for the input's value.
forAnswerreference. References to <answer> elements that this input should submit to.
boolean. Default value: false. Whether to render the input inline (as a dropdown) rather than as a list of choices.
labelPositionkeyword. Position of the label relative to the input.
| Value | Description |
|---|---|
left (default) | Place the label to the left of the input. |
right | Place the label to the right of the input. |
boolean. Default value: false. Whether to award partial credit when only some correct choices are selected.
placeHoldertext. Placeholder text shown when no choice is selected.
number. Index of a choice to pre-select on initial render.
preserveLastChoiceboolean. Default value: false. Whether the last-rendered choice keeps its position when shuffling.
boolean. Default value: false. Whether multiple choices may be selected.
boolean. Default value: false. Whether to display the choices in randomized order.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <choiceInput name="c">
Labels (2)
$c.labellabel. The label rendered with this component.
$c.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (24)
$c.choiceMaths[ math ]. The math expressions of all choices in displayed order.
$c.choiceTexts[ text ]. The text contents of all choices in displayed order.
$c.disabledboolean. Whether this component is disabled and cannot be interacted with.
$c.feedbacks[ feedback ]. Feedback messages produced by selected choices.
$c.fixedboolean. Whether this component's value is fixed and cannot be modified.
$c.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$c.focusedboolean. Whether this input currently has keyboard focus.
$c.inlineboolean. Whether the input is rendered inline (as a dropdown).
$c.labelPositiontext. Position of the label relative to the input.
$c.matchPartialboolean. Whether to award partial credit when only some correct choices are selected.
$c.numChoicesnumber. The number of choices available in the input.
$c.numFeedbacksnumber. The number of feedback messages produced by selected choices.
$c.preserveLastChoiceboolean. Whether the last-rendered choice keeps its position when shuffling.
$c.selectedIndexnumber. The 1-based index of the first currently selected choice.
[ number ]. Indices (1-based) of the currently selected choices.
$c.selectedValueThe text value of the first currently selected choice.
Text values of the currently selected choices.
$c.selectMultipleboolean. Whether multiple choices may be selected.
$c.shortDescriptiontext. A short accessibility description of this input; it is visible to screen readers but not rendered visually.
$c.shuffleOrderboolean. Whether to display the choices in randomized order.
$c.valueChangedboolean. Whether the input's selection has been changed from its initial state.
$c.valuesThe text values of the currently selected choices.
$c.valueToRecordOnSubmit[ number ]. Indices of the currently selected choices (recorded when the answer is submitted).
Common to all components (4)
$c.doenetMLtext. The DoenetML source code that produced this component.
$c.hideboolean. Whether to hide this component from the rendered output.
$c.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$c.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: <choiceInput> for survey question
A <choiceInput> is used to collect user responses that do not require
validation. A nested <label> child supplies the prompt for the choices.
Example: <choiceInput> in <answer>
A <choiceInput> can be nested within an <answer> to
collect user responses with validation.
Example: <choiceInput> as a menu
A <choiceInput> can be used in combination
with <conditionalContent> to create a simple menu.
Attribute Examples
Attribute Example: selectMultiple
The selectMultiple allows users to select multiple <choice>
components in a <choiceInput>.
Attribute Example: matchPartial
If an <answer> requires more than one <choice> selection
for full credit, the matchPartial attribute can be used to
assign partial credit if one or more of the total number of correct
choices are selected within a <choiceInput>.
Attribute Example: inline
The inline attribute provides a pull-down menu for <choice>
selection rather than the default radio buttons.
Attribute Example: shuffleOrder
With the shuffleOrder attribute, the sequenceing of the choices is
different for each page variant.
Attribute Example: preselectChoice
The preselectChoice attributes takes the index of the choice to preselect.
Attribute Example: bindValueTo
The <bindValueTo> takes a named component as input. The
value of the <choiceInput> then becomes linked to that component’s value.
Property Examples
Property Example: numChoices
The numChoices property returns the number of nested <choice>
children in the named <choiceInput>.
Property Example: choiceTexts
The choiceTexts property renders the texts contained in the <choiceInput> in an array.
Property Example: choiceMaths
The choiceMaths property renders the maths contained in the <choiceInput> in an array.
Property Example: selectedIndices
The selectedIndices property renders an array of the indices of all choices selected by the user.
Property Example: selectedValues
The selectedValues property renders an array of the values contained
in all of the choices selected by the user.
Property Example: feedbacks
The feedbacks property should be copied in the document at the
location where feedback should appear based on the specified interactions.