List variables for numeric or string values
Updated 30 Aug 2024
A list variable contains either a list of numeric values or a list of string values (letters, words, or expressions formatted with TeX or ChemTeX). The value shown to students for the list variable is chosen randomly from the list of values you define. When you define a list variable, you enter a non-zero integer as its List ID.
To create a variable with string values, create it as a string list variable—even if you don't plan to associate with another list variable. Numeric list and string list variables with unique List IDs work independently.
You can use the same List ID to associate list variables of the same kind or a mix of numeric list and string list variables.
- The values to be associated across list variables must be in the same order in each list. This ensures that the associated values appear together in the student's view when the item is randomized.
- See below for examples of associating list variables to get different effects.
- Open the Simple Editor so that the item you want to edit appears in the Edit Item window.
- Open the Define Variable form using one of these methods.
Move the Define Variable window to refer to item information that would otherwise be hidden.Define variables for an item (without inserting them in a text box yet)- Select Variables from the top toolbar.
- Choose the Define New Variable link.
Define and insert a variable as you work in the item, such as in a part text boxPlace your cursor in a text box and follow one of these paths:
- Choose Insert variable from the right-click menu or choose Insert then Insert variable from the editing toolbar menus. Select New.
- Enter a name for your new variable in the text box and select the text. Choose Add Variable from the editing toolbar. The variable name appears in a box. Select the variable name and then choose the define link.
- Choose either Numeric List or String List for the variable type, depending on the kind of values you want for this list.
- Enter a number (non-zero integer) for the List ID, such as 1 or 2.
- In the Variable Name box, enter a meaningful name for the list of values you will enter. About variable names
- Enter values in the appropriate format (numeric or string) into the Values boxes. To add more value boxes, select add value.
- Optional settings for a numeric list variable
Enter information for one or more of the following settings. (These settings do not apply to string list variables, but are also available when defining a numeric variable.)Units Name
Enter TeX or ChemTeX coding, such as mol*h^(-1) for .Format
Enter a format for how numeric values should display in item text boxes. See Display format for numeric variables.Symbol
Enter a TeX or ChemTeX symbol to use for displaying the variable name, such as /gamma.Units Conversion
Enter a formula for converting this value to some other system of units as part of an answer.Radians instead of degrees
Because the argument of all trigonometric functions in Mastering by default must be in radians, not degrees, the most common units conversion is from degrees to radians. For example, if you define an angle "theta" in degrees, and an answer later in the item is "sin(theta)", you must provide the conversion "theta*pi/180" in this field. You can also change the default from radians to degrees for an item. - Select OK.
The list variable (and its associated information) appears in the list of variables for the item at the top of the page. - To save your edits, select Save (from the top toolbar) or the Save & Preview link (top right). Do NOT press Ctrl+S (Windows) or Command-S (Mac OS).
- To insert the variable in the appropriate text box for the item, see Insert variables into item content.
The example below shows the creation of a string list variable and a numeric list variable. The same List ID of 1 is applied to both.
- String list values: acetylene, methane, propane, butane
- Numeric list values: 26.04, 16.04, 44.10, 58.12
To correctly associate the values between the two lists, make sure that the order of the values correspond in each list. To reorder one or more values, see the section "Reorder values in list variables" below.
String list values for variable “gasses” defined with List ID of 1
Numeric list values for variable “mass” also defined with List ID of 1
For example, you might want to spell out the name of a chemical compound in a part question and require the student to enter the chemical formula in the correct answer. To do this, define two string list variables and apply the same List ID to both.
- Values for string list “gasses” — acetylene, methane, propane, butane
- Values for string list "formulae" — C2H2, CH4, C3H8, C4H10
To correctly associate the values between the two lists, make sure that the order of the values correspond in each list. To reorder one or more values, see the section "Reorder values in list variables" below.
String list values for variable “gasses” with List ID of 2
String list values for variable “formulae” with List ID of 2
To correctly associate values in list variables with the same List ID, the values must be in the same order in each list—first value to first value, second to second, and so on. As you define string list variables, the order is from top to bottom, for numeric list variables, the order is from left to right. How to reorder variables in an item
- Open the Simple Editor so that the item you want to edit appears in the Edit Item window.
- Select Variables from the top toolbar.
Defined variables for the item appear in a list at the top of the Edit Item window. - Choose View List from the dropdown menu on the right.
This view lets you check that the values for associated list variables are in corresponding order. (You cannot make edits from this view.) - Choose View All from the dropdown menu on the right.
- Choose the Edit link for the list variable whose values you want to reorder.
The Define Variable form opens. - Reorder values by making edits in the value text boxes. You can also choose Delete and add value if needed.
- Select OK to save the revised list of values.
- Choose View List again to check that the correct list variable values align with each other.
- To save your edits, select Save (from the top toolbar) or the Save & Preview link (top right). Do NOT press Ctrl+S (Windows) or Command-S (Mac OS).
After variables have been defined in an item, you can see and edit them in the Edit Item window. After variables have been inserted in item content, you can preview variable values in Mastering Standard (student) and Solution views.
See also: