Variables to vary item content
Updated 30 Aug 2024
Variables provide a way for instructors to use randomized values in an item so that not all students receive the exact same question. You can use the Simple Editor to:
- Define numeric variables
Values can be a simple numeric, a range of values, an equation, function, or another variable. Numeric variables can also be used in calculations. How to define numeric variables - Define list variables to associate numeric or string values
A list variable is a group of numeric values or string values (letters, words, or expressions formatted with TeX or ChemTex). List variables can be combined in different ways when they share the same List ID. How to define list variables
In the Item Library, items that contain variables are flagged as randomizable in the Item Type column. When organizing content for an assignment, instructors can turn randomization on or off.
Watch a video: Add variables in Simple Editor to randomize question values
- Answer types —
You can use the Simple Editor to define, edit, and insert variables for chemical formula, labeling, multiple choice, multiselect, numeric value or symbolic expression, numeric value with unit, ranking, simple text , and sorting answer types. For tips on how to insert variables for correct or incorrect answers, see Enter variables in different answer types.For other answer types you can edit with the Simple Editor: You can add and edit variables in text fields, but you cannot edit existing variables authored in the Advanced Editor.
- Areas in an item —
Most likely you will add a variable into a Part question or as a correct or incorrect answer. You can also add a variable in the Introduction (learning goal and introduction) or in any other Part text box, except for its name. For instructions, see the section below “Insert variables into item content”.
- Variable names are usually a letter, number, an alphanumeric (A1, B2), or a word.
- Spaces are NOT allowed. For two or more words, separate them with an underscore.
- Variable names cannot include special characters (*, /, %, etc.) or characters that can be interpreted as a function or primes, such as f' or S'.
- Each variable name must be unique within the item.
General instructions for variables
- Open the Simple Editor so that the item you want to edit appears in the Edit Item window.
- Navigate to the text box where you want to insert the variable, such as in a part question. For information about where you can insert variables, see the earlier section “Where you can insert variables”.
- Use either of the following methods to insert a variable into any text field that provides the editing toolbar. For answers, see Enter variables in different answer types.
- Add a new variable at the insertion point
In the text box, enter a variable name (such as "salts"), select the name, and choose Add Variable from the editing toolbar. Select the variable name again so that a pop-up opens. Choose the define link (opens the Define Variable form) and define the variable, whether a numeric variable or a numeric list or string list variable. If needed , move the Define Variable window so you can refer to item information that would otherwise be hidden.
- Insert a defined variable for the item
This method requires that the numeric or list variable has already been defined in the item. Right-click in the text box and choose Insert variable. Or, from the editing toolbar menus, select Insert then Insert variable. Then, select the named variable you want.
Note: Currently you cannot use this method to insert a variable into a ranking or sorting answer type. Use the method above instead.
In either method, the inserted variable appears with its first value in a box, such as .
- Add a new variable at the insertion point
- To insert a variable into answers: See instructions for entering variables in answers.
- 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).
- 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. - If it is not already selected, choose View All to check the order of or to reorder variables. (Optional)
To define a new variable from this view —
Select Define New Variable, enter the appropriate values into the fields in the list, and then select Save. You can define only one variable from this view at a time. Variable order is important if a later numeric variable relies on the definition of an earlier numeric variable.To reorder or delete variables —
Choose Move Up, Move Down, or choose Delete.To view the values for a variable in this view —
By default, only the first value is shown. Select the arrow to the left of the variable name to show the rest of its defined values.To edit a variable definition, including its values —
Choose Edit to make changes to the value fields in the variable table. To reorder values (especially for list variables), either make edits in the value text boxes or add and delete values. - Choose View List to view and compare the order of values in associated list variables. (Optional)
You can edit variables from this view, but you cannot define a new variable. Switch to View All to define new variables. To reorder values, follow the instructions in step 3.
Value order is important for list variables that are combined in an item by sharing the same List ID. Each value to be associated between list variables must be in the same sequence.
To preview an item, either open it from the Item Library or choose the Save & Preview link (top right) from the Edit Item window. When you preview an item that contains one or more variables, choose from the following options in the “Manage this Item” menu.
Standard View is what students see. Solution View shows the correct answer(s).
- Standard View Randomized — This is the default for previewing an item that contains variables. The variable values shown in this view can vary randomly, similar to what different students might see.
- Standard View Non-Randomized — For an item that contains list variables, only the first value from each variable list appears. For numeric variables, a random value appears.
- Solution View Randomized — A random variable value (or set of values, if multiple variables are used) appears along with its corresponding answer.
- Solution View Non-Randomized — For an item that contains list variables, only the first value from each set of list variables appears. For numeric variables, the answer corresponds with a random value.
- Check how variables will look to students. In particular, check that variable values align with non-variable values in multiple choice and multiselect answer options. An extra space is automatically inserted before variable values, so you should add a space before the other answers.
- When a variable shows as a blank box or its name is bold red in the Edit Item window, the variable will not display to students because "Show value" has been deselected. To get the variable to display to students, select the variable at its insertion point and then select "Show value" in the pop-up that opens. The variable should then show a value.
- To see the exact variable value(s) that an individual student received in an assigned item, select the student’s assignment grade in the Gradebook.
See also: