Example: Use algorithmic values in a math question
Updated 28 Aug 2023
This example guides you through the steps needed to create a simple algebraic subtraction question.
To begin, design your question and its algorithms on paper. Start with the static question and then convert the values to algorithmic.
Static question:
If a = 10
Then a - 4 = 6
Algorithmic question:
If a = ~a
Then a - ~sub = ~ans
The algorithmic values are defined in the following table:
Value | Type | Constraints | Notes |
---|---|---|---|
a | Integer | >=2, <=99 | The larger value |
sub | Integer | >=1, <=~a | A value smaller than or equal to ~a |
ans | Integer | ~a - ~sub | Calculates the answer |
Now that you have designed the question and the algorithms, you are ready to create your question and enter the algorithms.
- Open the Custom Question Builder.
- In the Create Custom Question wizard, select Start with an empty template and click Next.
- In the Choose Layout window, select Top/Bottom, and then click Next to open the Custom Question Builder with a blank problem.
- Click Show Algorithmic Values List to open the Algorithmic Values List window.
You use the Algorithmic Values List window with the Edit Algorithmic Values window to create the algorithmic values that you have defined. Use the table you created in the first section to help you enter the values.
To enter your algorithmic values:
- Click Add to bring up the Edit Algorithmic Values window, where you can enter your algorithmic values.
- Using the table of values, enter the value a and its constraints:
- In the Algorithmic Value Name box, replace the default name V1 with a.
- In the Select Type of Algorithmic Value section, select Integer.
- In the List Values or Set Up Constraints section, select the greater-than-or-equal-to symbol.
- In the Constraint Value box, enter the constraint
2
as the lowest value. - For the second constraint, select the less-than-or-equal-to symbol.
- Enter the constraint
99
as the highest value. - Click the Options tab and in the Authoring Notes box, enter the note:
The larger value
. - Click Save to enter your value in the Algorithmic Values List. Your entry looks like this:
The entry in the Value column of your version of the question might vary from this example because it is algorithmically generated.
- Click Add and enter the value sub and its constraints:
- In the Algorithmic
Value Name box, replace the default name with
sub
. - In the Select Type of Algorithmic Value section, select Integer.
- In the List Values or Set Up Constraints section, select the greater-than-or-equal-to symbol from the Relational Operator dropdown list.
- In the Constraint Value box, enter
1
as the lowest value. - For the second constraint, select the less-than-or-equal-to symbol from the Relational Operator dropdown list.
- Enter
~a
as the constraint value. Algorithmic values must be preceded by a tilde (~) when you enter them as constraints. - Click the Options tab and in the Authoring Notes box, enter the note:
A value smaller than or equal to ~a
. - Click Save to enter your value in the Algorithmic Values List.
- In the Algorithmic
Value Name box, replace the default name with
- Click Add and enter the value ans and its constraints:
- In the Algorithmic
Value Name box, replace the default name with
ans
. - In the Select Type of Algorithmic Value section, select Integer.
- In the List Values or Set Up Constraints section, select = from the Relational Operator dropdown list for the first constraint.
- In the Constraint Value box, enter
~a - ~sub
. - Click the Options tab and in the Authoring Notes box, enter the note:
Calculates the answer
. - Click Save to enter your value in the Algorithmic Values List. When you finish, your Algorithmic Values List looks like this:
The entries in the Value column of your version of the question might vary from this example because they are algorithmically generated.
- In the Algorithmic
Value Name box, replace the default name with
- Click Close in the Algorithmic Values List window to return to your question.
- In the Problem Statement area, remove the default text and type the problem statement:
If a =
- Highlight the letter
a
and click the italic icon () in the toolbar. - Enter a space after the equal sign and make sure your cursor is at the end of the line.
- Click the Algorithmic Values button in the left menu to view a list of algorithmic variables and their current values.
- Select the entry for a.
The current value of a is inserted in the problem statement highlighted in lavender to show that it's algorithmic. If you click Show Algorithmic Value Names in the Algorithmic Values toolbar, the algorithmic value name now shows instead of the current value. You can toggle between the value and name by clicking this button.
- In the answer area, replace the default text with:
Then a -
- Highlight the letter a and click the italic icon in the toolbar.
- Enter a space after the minus sign. With your cursor at the end of the line, click the Algorithmic Values button and select the entry for sub.
- Type a space, an equal sign, and a space after sub.
- With your cursor at the end of the line, click Short Answer under Student Interactions in the left menu. This option opens the Edit Answer Definition window, where you define your answer.
- In the Edit Answer Definition window, click on Step 1.
- Select Specify a subset of equivalent answers to accept and Accept integer or decimal equivalents only. Then click Next.
- On the Define Answers page, click the first row under Value box in the table. When your cursor is visible in the row, right-click and select Editing Options from the menu.
- Select Algorithmic Values from the menu.
- Select ~ans from the list of algorithmic values to insert it in the Value box. Click Next to go to Step 3.
- Leave these options as the defaults. Click Next to go to Step 4.
- Click Save to close the Edit Answer Definition window.
Your question looks like this when Show Algorithmic Value Names is selected:
- Click Regenerate Values several times to verify that your algorithms are working correctly.
- Click Preview Exercise and enter an incorrect answer.
- Check your answer to see the feedback message.
- Regenerate the question several times to make sure your algorithms work as intended.
You can regenerate the question by clicking Similar Exercise on the bottom right of your preview window.
- Close the Preview window.
- When you are sure that your question is working correctly, click Save.
- Give the question a name and select Algorithmic as the format.
- Optionally add a textbook association and keywords.
- Click OK to save your question.
After you save your question, you can add it to an assignment.