<subsetOfRealsInput>
<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 theInputbase 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>viareferencesAreResponsesplus 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)
bindValueTosubsetOfReals. Two-way binding target for the input's value.
formatkeyword. Input format used for parsing entered subsets.
| Value | Description |
|---|---|
text (default) | Parse entered subsets as plain-text notation. |
latex | Parse entered subsets as LaTeX notation. |
text. Initial subset displayed in the input.
_variableName. Default value: . Variable name displayed on the number line.
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 <subsetOfRealsInput name="s">
Other (12)
$s.disabledboolean. Whether this component is disabled and cannot be interacted with.
$s.fixedboolean. Whether this component's value is fixed and cannot be modified.
$s.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$s.formattext. Input format used for parsing entered subsets.
$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.prefilltext. Initial subset displayed in the input.
$s.subsetValuesubsetOfReals. 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.doenetMLtext. The DoenetML source code that produced this component.
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. 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 to
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 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 ; 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.