# Introduction

This article will provide a step-by-step guide on building a **Symbolic Math** question.

# The Question

The following question is what will be used for this example. But rather than the bold values being set, we will make them variables.

Part 1 - Basic Numbers |

# Create a new Question

First we need to create a new question and add the question text itself.

- In Author, from Questions or within a Question Set, click ‘Create New’ and select Symbolic Math.
- Give the question a title
- Delete the placeholder text.
- In the man authoring area, write / paste the following Question Text:

Part 1 - Basic Numbers Given the parabolic formula y = [formula], solve for x = [x_value] [part1_answer] Part 2 - Symbolic Math Write the equation for the parabola that passes through the point ([x_coordinate],[y_coordinate]) but has the same shape as the previously given parabola. [part2_answer] |

# Create the Program Model for Part 1

The next step involves creating the Program Model. This is where we declare all variables and their parameters. The sake of this example we will do the two parts individually.

- Click Program Model from the menu on the left, followed by Edit Program Model
- Delete the placeholder text in the Program Model.

For Part 1, there are 3 variables that need to be declared.

`formula`

`x_value`

`part1_answer`

### Variable: formula

This is the starting formula for the question. For this question, it will always be the same but we need to add it to the Program Model as that’s what’s being used in the calculations. The format is always `variable: value;`

so in this instance, the first line of the Program Model will be:

`formula: 2*x^2 - 4*x + 1;`

### Variable: x_value

We want the value of x to change so we’ll use the ```
rand_with_step(lower, higher,
step)
```

function. The three values in parenthesis state the lowest possible value, the high possible value, and the steps between each number. As we only want x to be either 2, 3, 4, 5, 6, 7, or 8, we write the following:

`x_value: rand_with_step(2,8,1);`

### Variable: part1_answer

Finally, we need to set the answer. There are two options here. The long way would be to write the formula again but this time replacing x with x_value as that is the variable that will change each time based on the above parameters.

`part1_answer: 2*x_value^2 - 4*x_value + 1;`

A far more elegant solution is to use the function `ev(a,b)`

which does it all for us. With `ev(a,b)`

, a = the expression to evaluate, and b = the evaluation options. In this case, we can write the following:

`part1_answer: ev(formula, x=x_value);`

This evaluates the equation we have set as `formula`

and sets the value of x to be the value of `x_value`

.

The Program Model should now look like the following:

```
formula: 2*x^2 - 4*x + 1;
```

x_value: rand_with_step(2,8,1);

part1_answer: ev(formula, x=x_value);

Now click ‘Compile’ and see the example values in the right column to ensure it’s working as expected. Each time you click ‘Compile’, it will re-run the Program Module. In the example we’re using, the x_value will change but the formula will not. Click Save.

# Insert Variables to Part 1

Now it’s time to replace our placeholder text with the actual variable.

- Delete the [formula] text and with the cursor in its location, click + Insert followed by Program Variable.
- Click on this Program Variable box and in the menu on the right, select ‘formula’ from the dropdown.
- Repeat this process for the [x_value] placeholder text and insert the x_value variable.
- At the end of Part 1, delete [Candidate Response] and with the cursor in its location, click + Insert followed by Candidate Response. This is the area the candidates write their answer.

# Set the Response Outcome for Part 1

All that’s left now is to set-up the correct response outcome.

- Click the Candidate Response field. It will be called
*RESPONSE-n*. - Under Response Outcome on the right, click
**+ Add response outcome** - Select the Input Type as
**Basic numbers**as the answer to this question is a number, not a formula. - Click
**+Add outcome**. - As we’re setting the correct outcome, select the first dropdown as ‘Equal’
- The middle dropdown we select the variable we’re validating against. In this case, we named it
**part1_answer**. - Finally, we leave the final dropdown to Correct.
- Click Save.

Now click on the Preview icon and you’ll see Part 1 is complete. The formula itself is now showing as is a value for x. Try answering and clicking ‘Check answer’. Now refresh your browser and you’ll see the value of x has changed, as has the correct answer.

Part 1 is now done.

# Create the Program Model for Part 2

Return to the Program Model to declare the final variables. For Part 2 we need:

`x_coordinate`

`y_coordinate`

`part2_answer`

For `x_coordinate`

and `y_coordinate`

, the logic will be the same - a random integer between two values. For this we can again use the function `rand_with_step(lower, higher, step)`

.

`x_coordinate: rand_with_step(1,12,1);`

`y_coordinate: rand_with_step(1,12,1);`

Each coordinate will now be a random integer between 2 and 12.

Finally we need to set the `part2_answer`

. In the case of this question, we need to recreate the shape of y = \(2x^2 - 4x + 1\) but have it pass through our randomly generate x and y coordinates.

What the question is therefore asking is to first solve for z in the formula y = \(2x^2 - 4x + z\) and enter the full formula as the response.

To achieve this we need declare the value of z which is z = \(2x^2 - 4x - y\) and set it as a variable remembering to substitute x and y for the actual variable names as those are the values that are needed for the calculation.

`z: 2*x_coordinate^2 - 4*x_coordinate - y_coordinate;`

This variable won't be exposed to the candidate in the question text but it is a calculation that needs to happen within the Program Model in order for the correct answer to be calculated.

The correct answer for Part 2 can be set in a variable.

`part2_answer: 2*x^2 - 4*x + z;`

The Program Model in its entirety should now look like the following:

`formula: 2*x^2 - 4*x + 1;`

x_value: rand_with_step(2,8,1);

part1_answer: ev(formula, x=x_value);

x_coordinate: rand_with_step(1,12,1);

y_coordinate: rand_with_step(1,12,1);

z: 2*x_coordinate^2 - 4*x_coordinate - y_coordinate;

part2_answer: 2*x^2 - 4*x + z;

Click ‘Compile’ and see the example values in the right column to ensure it’s working as expected. Then click Save.

# Insert Variables to Part 2

Following the same process as before:

- Delete the [x_coordinate] and [y_coordinate] text and with the cursor in its location, click + Insert followed by Program Variable.
- Click on this Program Variable box and in the menu on the right, select ‘x_coordinate’ from the dropdown.
- Repeat this process for the [y_coordinate] placeholder text and insert the y_coordinate variable.
- At the end of Part 2, delete [Candidate Response] and with the cursor in its location, click + Insert followed by Candidate Response.

# Set the Response Outcome for Part 2

- Click the Candidate Response field. It will be called
*RESPONSE-n*. - Under Response Outcome on the right, click
**+ Add response outcome** - Select the Input Type as
**Symbolic Math**as the answer to this question is an equation and we want it to be treated as such. - Click
**+Add outcome**. - From the first dropdown, select
**Algebraic.**This will ensure that provided the equation is correct, it will be marked correctly.- Setting it as
*String Match*would mean that every character of the equation must be in the same position as set out in the Program Model.

- Setting it as
- The middle dropdown we select the variable we’re validating against. In this case, we named it
**part2_answer**. - Finally, we leave the final dropdown to Correct.
- Click Save.

Our question is now complete and with the 3 random variables included within the Program Model, there are 864 possible versions to be generated.

Click Preview Icon to view. As an author, each time you refresh the page, the variables will be recalculated.