> For the complete documentation index, see [llms.txt](https://examind.gitbook.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://examind.gitbook.io/v1/examind-platform/build/question-builder/dynamic-questions/dynamic-engine/variables.md).

# Variables

This article shows you how to use the Variable blocks in our Dynamic Engine.

## What Is a Variable?

The term *variable* is the same term used in mathematics or computer science. It is a named value that can be changed - aka it "varies".

## The Variable Blocks

There are three kinds of variable blocks that you can use:

1. Set
2. Get
3. Change

### Variable: Set

The **set** block assigns a value to a variable, creating the variable if it doesn't already exist. For example, this sets the value of the variable named "age" to the number "18".

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2F2lSouJ1wQy0RJ9n8WSFo%2FScreenshot%202024-12-06%20at%204.22.46%E2%80%AFPM.png?alt=media&amp;token=2f0b937f-a2d6-4c16-80ed-c38f5dbe8942" alt=""><figcaption></figcaption></figure>

### Variable: Get

The **get** block provides the value of a variable. Continuing from the previous example, it would *get* the number "18".

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FgEqEoYHt9hygyCunulXb%2FScreenshot%202024-12-06%20at%204.23.08%E2%80%AFPM.png?alt=media&amp;token=a8ec4e03-fc59-42df-874c-24027b28de7a" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Without a corresponding **set** block, the engine does not know what you want to do with the number "18". Think of it like a floating puzzle piece that needs to be connected to something. Without a connection, it's just floating around the office looking for a fresh cup of coffee (like our hipster UX designer).
{% endhint %}

### Variable: Change

The **change** block adds a number to a variable. Continuing from the previous example, this would add the number "1" to the number "18".

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FhCX2ha0v2hmwOgvOWc5U%2FScreenshot%202024-12-06%20at%204.25.32%E2%80%AFPM.png?alt=media&amp;token=ff3b62eb-fb32-48ea-bebb-66febef2f66b" alt=""><figcaption></figcaption></figure>

The **change** block broken down into a calculation would look like this:

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FL4vxuoxUNRzGgR0HA94r%2FScreenshot%202024-12-06%20at%204.24.40%E2%80%AFPM.png?alt=media&amp;token=a3797fb1-beb9-4530-b86e-7a6147a20e88" alt=""><figcaption></figcaption></figure>

This is the equivalent of saying **set** the variable age to it's previous number (ie. 18) plus the number 1. So think of **change** like a shortcut.

### Variable: Menu

Click on the variable's dropdown symbol (light blue triangle) to get the following menu:

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FnVbPigZTzykeKCxd0phx%2FScreenshot%202024-12-06%20at%204.27.14%E2%80%AFPM.png?alt=media&amp;token=987eaa4d-8603-4148-95dc-4c2f894cd221" alt=""><figcaption></figcaption></figure>

The menu provides the following options:

* **Existing variables**: The names of all existing variables defined in the program. In this example, we only have one variable (age).
* **Rename variable...:** Change the name of the selected variable. Selecting this option opens a prompt to enter a new name.
* **Delete the 'selected' variable:** Deletes all blocks that reference this variable wherever it appears in the program.

***

## Example Question

Consider the following multiple-choice question. The goal of this question is to add randomness to the "too young" and "too old" distractors.

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2F8W5UBc1pMq2IxiafwXS4%2FScreenshot%202024-12-06%20at%204.32.50%E2%80%AFPM.png?alt=media&amp;token=b90c3125-8601-44eb-80fb-4eea0ec2e888" alt=""><figcaption></figcaption></figure>

Here is what the Dynamic Engine would look like:

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FMDx83TlpiNGTLuKBiDdR%2FScreenshot%202024-12-06%20at%204.33.40%E2%80%AFPM.png?alt=media&amp;token=d500c596-366c-4fd8-9e7e-c1b3bdea9b46" alt=""><figcaption></figcaption></figure>

Age is being **set** to make the correct answer "18" and the other answer options set to *Math* blocks that randomly choose numbers in a range.

Here is what a sample question would look like (values highlighted in blue for convenience):

<figure><img src="https://211323355-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfKsc0R4AcYm9kZgIT2X%2Fuploads%2FqSpiyDRfPsOtR1AEsvow%2FScreenshot%202024-12-06%20at%204.34.46%E2%80%AFPM.png?alt=media&amp;token=893ba7b9-e233-40a2-8384-849c4d3967f6" alt=""><figcaption></figcaption></figure>
