<choice>
<choice> is an Input
component that defines an individual choice when nested
within an <answer> block for multiple choice questions.
Attributes and Properties
Attributes for <choice>
Other (4)
number. Default value: 0. Fraction of credit (0 to 1) granted when this choice is selected. A value above 1 counts as 1, and a negative or non-numeric value as 0.
feedbackCodestextList. Codes that select reusable feedback messages when this choice is selected.
text. Custom feedback text shown when this choice is selected.
boolean. Default value: false. Whether this choice is pre-selected on initial render.
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 <choice name="c">
Other (8)
$c.creditnumber. Fraction of credit (0 to 1) granted when this choice is selected. A value above 1 counts as 1, and a negative or non-numeric value as 0.
$c.feedbackCodestextList. Codes that select reusable feedback messages when this choice is selected.
$c.feedbacksfeedbacktext. Feedback messages shown when this choice is selected.
$c.feedbackTexttext. Custom feedback text shown when this choice is selected.
$c.mathmath. The choice's content interpreted as a math expression.
$c.selectedboolean. Whether this choice is currently selected.
$c.submittedboolean. Whether this choice was selected at the most recent submission.
$c.texttext. The choice's content as a text string.
Common to all components (8)
$c.disabledboolean. Whether this choice is disabled (cannot be selected).
$c.doenetMLtext. The DoenetML source code that produced this component.
$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.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: <choice> inside a <choiceInput> block
The <choice> components can be nested inside a <choiceInput> block.
Example: <choice> inside an <answer>
The <choice> components can be nested inside an <answer> for
validation. Use the credit attribute to assign the correct <choice>.
Attribute Examples
Attribute Example: credit
Use the credit attribute to assign the correct <choice> in
an <answer>. Partial credit may also be assigned with the credit attribute.
Attribute Example: feedbackText
Use the feedbackText attribute to directly define short feedback
corresponding to individual <choice> selections within the <choice> definition.
To render the feedback to the student, copy the feedbacks property of the named <answer>.
Attribute Example: preSelect
The preSelect attribute causes the <choice> to appear
selected when the page is rendered.
Property Examples
Property Example: Attributes as properties
The credit and feedbackText attributes of a <choice>
are accessible as properties.
Property Example: text
The text property renders the text contained in the <choice>.
Property Example: math
The math property renders the math contained in the <choice>.
Property Example: selected
The selected property renders the boolean value corresponding to whether
a choice is currently selected.
Property Example: submitted
The submitted property renders the boolean value corresponding to
whether a choice has been submitted as a response.