Referencechoice

<choice>

A single choice within a `<choiceInput>` or an `<answer>`.

<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.

feedbackCodes

textList. 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)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. 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 (12)
$c.credit

number. Fraction of credit (0 to 1) granted when this choice is selected.

$c.disabled

boolean. Whether this choice is disabled (cannot be selected).

$c.feedbackCodes

textList. Codes that select reusable feedback messages when this choice is selected.

$c.feedbacks

feedbacktext. Feedback messages shown when this choice is selected.

$c.feedbackText

text. Custom feedback text shown when this choice is selected.

$c.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$c.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$c.hidden

boolean. Whether this component is hidden from the rendered output.

$c.math

math. The choice's content interpreted as a math expression.

boolean. Whether this choice is currently selected.

boolean. Whether this choice was selected at the most recent submission.

$c.text

text. The choice's content as a text string.

Common to all components (4)
$c.doenetML

text. The DoenetML source code that produced this component.

$c.hide

boolean. Whether to hide this component from the rendered output.

$c.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$c.styleNumber

integer. 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.