Specify ranges, lists, and text
Updated 28 Aug 2023
When you are defining an algorithmic value in the Edit Algorithmic Values window, the simplest constraints are ranges, lists, and text.
When you create decimal or integer algorithmic values, you can specify a range of acceptable values. The player randomly assigns a number from the range to the algorithmic value when it displays in a question.
For example, if you want your algorithmic value to be greater than or equal to 0 and less than or equal to 30, not equal to 13, and less than ~A, you enter the following constraints in the Edit Algorithmic Value window:
The player must satisfy all constraints when it calculates the value of the algorithmic value, so you cannot enter discontinuous ranges in the form ~A < ~B < ~C.
You can convert a discontinuous range to a continuous range by creating three algorithmic value definitions. The first definition covers one end of the range, the second definition covers the other end of the range, and the third definition is equal to either the first or second definition. In the following example, V1 is the lower end of the range, V2 is the top end of the range, and V3 is equal to either V1 or V2:
~V1 |
> |
~W |
|
< |
~X |
~V2 |
> |
~Y |
|
< |
~Z |
~V3 |
= |
~V1 |
|
= |
~V2 |
See Work with algorithmic values and Convert static questions to algorithmic for other examples of how to create algorithmic values as ranges.
To define an algorithmic value using a list, you create a list of acceptable values. The player then randomly assigns one of the values from the list to the algorithmic value when it shows in a question.
For example, if you want your algorithmic value to be an even number between 1 and 11, enter the following constraints in the Edit Algorithmic Values window:
You can link one or more algorithmic values that were defined using lists as long as each list contains the same number of elements. To do so, you assign a link ID number to each list you want to link. Enter the link number in the Link ID box in Options tab of the Edit Algorithmic Values window.
For example, suppose you define the following algorithmic values by specifying a list of 5 numbers each:
~A = {1, 2, 3, 4, 5}
~B = {2, 5, 7, 3, 9}
~C = {1, 1, 3, 9, 5}
If you then synchronize the three lists, the Custom Question Builder chooses the values from the same relative position in each list. For example, if the program picks 3 from ~A (the 3rd value in the list), the program then picks 7 from ~B and 3 from ~C.
Synchronized lists are useful whenever you need to match up two algorithmic values and cannot use a formula to do so. Each list must have the same number of elements, and must be entered in the exact order you want for the synchronization.
See Using synchronized lists for an example of using link IDs in a question.
To define an algorithmic value using text (such as "yes"), select Text or Symbol as the value type in the Edit Algorithmic Values window. When you select this type, the only available relational operator is =.
When you enter the text as a constraint, type the text surrounded by single or double quotation marks - for example, "undefined" or 'yes'.
To create a list of text values, enter each value on a separate row under Constraint Value. You cannot enter a comma-delimited list of text values in the same row. For example, to create an algorithmic value, subj, which stands for a subject in high school, you might enter:
When used in a question, your algorithmic value subj randomly displays as one of the subjects listed in the Constraint Value column.