ReferenceselectFromSequence

<selectFromSequence>

Randomly selects values from a sequence of numbers, math expressions, or letters to create document variants

<selectFromSequence> is a Math component that randomly selects values from a user-defined sequence of numbers, math expressions, or letters. Selections generate variants of the document.

Attributes and Properties

Attributes for <selectFromSequence>

Other (17)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

avoidScientificNotation

Whether to render numbers in full decimal form rather than scientific notation.

coprime

boolean. Default value: false. Require the selected numbers to be pairwise coprime (numbers only).

displayDecimals

Number of decimal places to display when rendering this number.

displayDigits

Number of significant digits to display when rendering this number.

displaySmallAsZero

Threshold below which numbers are displayed as zero.

_componentListWithSelectableType. Values to exclude from the sequence.

_componentListOfListsWithSelectableType. Lists of value combinations to exclude from the selection.

_componentWithSelectableType. The first value in the sequence.

length

integer. The number of values in the sequence.

integer. Default value: 1. How many values to select from the sequence.

padZeros

Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

keyword. Whether and how to sort the selected values.

ValueDescription
unsorted (default)Preserve the random selection order.
increasingSort the selected values in increasing order.
decreasingSort the selected values in decreasing order.

math. The increment between successive values in the sequence.

_componentWithSelectableType. The last value in the sequence. Used together with from to determine length when length is not specified.

keyword. The kind of values in the sequence.

ValueDescription
numberA sequence of numeric values.
mathA sequence of math expressions (allows symbolic from/to/step).
lettersA sequence of letters (single-letter or multi-letter labels).

boolean. Default value: false. Whether the same value can be selected more than once.

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

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

Other (4)
$s.coprime

boolean. Require the selected numbers to be pairwise coprime (numbers only).

$s.numToSelect

integer. How many values to select from the sequence.

$s.sort

text. Whether and how to sort the selected values.

$s.withReplacement

boolean. Whether the same value can be selected more than once.

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: Default <selectFromSequence>

The default <selectFromSequence> has a sequence range from 11 to 1010.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Example: Generate multiple selections

Three numbers are selected between -5 and 5 (stepping in increments of 0.5). Individual selections can be accessed using array notation.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.

Example: Assign descriptive names to selections

Three numbers are selected between -5 and 5 (stepping in increments of 0.5). Selections can be assigned more descriptive names by defining individual components which reference the selected values.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.

Attribute Examples

Attribute Example: numToSelect

The numToSelect attribute allows for selection of multiple values within the range of a single <selectFromSequence> component. Multiple selections are made without replacement, unless the withReplacement attribute is also specified.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: sort

The sort attribute determines how selected results are sorted. It accepts three values:

  • "unsorted" (default) - results are in the order they were selected
  • "increasing" - results are sorted in increasing order
  • "decreasing" - results are sorted in decreasing order

Alternatively, sort and sort="true" are equivalent to sort="increasing", and sort="false" is equivalent to sort="unsorted".

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: from, to

The from and to attributes specify the endpoints of the selection interval.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: step

The step attribute specifies the size of each increment in the sequence. The default step is 11

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: exclude

The exclude attribute specifies values to exclude in the selection.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: withReplacement

If selection with replacement is the desired behavior, use the withReplacement attribute.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: excludeCombinations

The excludeCombinations attribute can be used to exclude unfavorable combinations of parameters. In this example, the exclusions have been designed to prevent the condition that the coefficients in the expression result in a sum of 00.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: type

The type attribute takes either letters or number as a text input. If unspecified, the default type is number.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.