ReferencesubsetOfRealsInput

<subsetOfRealsInput>

An interactive number-line widget for entering a subset of real numbers (block-level; does not inherit from Input)

<subsetOfRealsInput> is a block-level interactive widget that renders a number line on which the learner builds a subset of the real numbers. The learner can click to add or remove points, drag to extend intervals, and toggle endpoints between open and closed.

The value of the widget is a <subsetOfReals> — so it compares equal to another subset when the two represent the same set, and can be plugged into a <when> condition for answer validation.

A few caveats unusual among Doenet’s input-shaped components:

  • Despite its name, <subsetOfRealsInput> does not inherit from the Input base class. As a result it cannot be placed inside an <answer>; for answer validation, name it, leave it outside the <answer>, and reference it from an <award> via referencesAreResponses plus a <when> check.
  • It is block-level, so it cannot sit inside a <p>.
  • It currently accepts no children — including no <label> or <shortDescription>. Place any prompt text in a sibling <p> above the widget. See Doenet/DoenetML#1167 for the accessibility follow-up.

Attributes and Properties

Attributes for <subsetOfRealsInput>

Other (4)
bindValueTo

subsetOfReals. Two-way binding target for the input's value.

format

keyword. Input format used for parsing entered subsets.

ValueDescription
text (default)Parse entered subsets as plain-text notation.
latexParse entered subsets as LaTeX notation.

text. Initial subset displayed in the input.

_variableName. Default value: \(x\). Variable name displayed on the number line.

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 <subsetOfRealsInput name="s">

Other (12)
$s.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$s.fixed

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

$s.fixLocation

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

$s.format

text. Input format used for parsing entered subsets.

$s.hidden

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

$s.intervals

[ math ]. The intervals (non-degenerate components) of the subset.

$s.isolatedPoints

[ math ]. The isolated (non-interval) points of the subset.

$s.points

[ math ]. The boundary points that delimit the subset.

$s.pointsClosed

[ boolean ]. Whether each boundary point of the subset is a closed (included) endpoint.

$s.prefill

text. Initial subset displayed in the input.

$s.subsetValue

subsetOfReals. The current subset of the reals entered by the user.

$s.variable

_variableName. Variable name displayed on the number line.

Common to all components (4)
$s.doenetML

text. The DoenetML source code that produced this component.

$s.hide

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

$s.isResponse

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

$s.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: A simple subset input

The default <subsetOfRealsInput> shows a number line from 10-10 to 1010 on which the learner can build a subset. The current value is referenced with $S, returning a <subsetOfReals>.


Example: Use in answer validation

The widget itself sits outside the <answer> (placing it inside would render nothing — see the caveat above). The <award> names $userSet as a response via referencesAreResponses, then a <when> child compares the referenced subset against the expected [-2, 2]. Any equivalent representation of [2,2][-2, 2] is accepted because = on subsets compares the sets, not their syntactic form.

Attribute Examples

Attribute Example: prefill

prefill provides an initial subset (in the input’s format). The learner sees the prefilled subset and can edit it from there.


Attribute Example: variable

variable does two things. It names the symbol the input expects when parsing a prefill string — with variable="t" set, prefill="t > 0" parses to the set t:t>0=(0,)\\{t : t > 0\\} = (0, \infty); with the default x it would fail because t would be an unknown symbol. And it propagates through extend to a <subsetOfReals>, so rendering the same subset with displayMode="inequalities" uses t for the variable in the inequality.