Basic use of random variables

On this page, we will see how to randomize WirisQuizzes questions using the Basic Mode. With this new procedure, it's possible to generate random variables quickly without accessing CalcMe, the advanced computer algebra system (CAS).

Notice

The variables you want to involve must be all integers and independent. If they are not, we recommend you to see its dedicated page.

Declaring variables

Variables are defined by writing a name for a variable next to the pound symbol # and the minimum and maximum value between which it's comprised.

There are two details to note:

• The variable's name can be any letter or word without spaces, excluding reserved words (e.g. `sin`, `cos`).

• The minimum and maximum values can be any integer value such that the first one is less or equal than the second one.

Inserting variables

Those are the basics of how variables function inside of WirisQuizzes Studio works. What's very important, though, is to know how to use these variables outside of Studio.

To include a variable anywhere within a question type, write a pound symbol # followed by the name of the variable (e.g. `#a`). So we could include the above values in a question just like this:

This would appear to the student as:

Tip

It's also possible to insert these variables in the question's feedback. Furthermore, you can use the student's answer there. Learn how to do it here.

Variables evaluation

When defining the question's correct answer, we can expect the corresponding expression to be displayed as we have written it, or we want to evaluate it before showing the result to the students. To do so, we need to use the `evaluate()` command and insert the variables to be simplified as its argument.

If we don't use the command mentioned above and just type $\sqrt{#{a}^{2}+#{b}^{2}}$, the correct answer will be displayed, as you can see below.

It won't suppose any validation problem, as the student's answer will be compared following the corresponding assertions as usual. We only recommend using the `evaluate()` command to display the correct answer in a more compact way.

Transferring variables to CalcMe

You can automatically convert these basic random variables to the advanced mode if you wish. Thus, you will be able to add more variables and restrictions using all CalcMe resources.

Tip

The same happens if you delete a random variable from the quick edition mode, it will disappear from the advanced mode automatically.

Example: Volume of a cylinder

Let us create an essential question asking to calculate a cylinder's volume given its base's radius and height.

The Basic Mode allows us to retrieve a random integer number in a given interval. We need two random numbers: on for the base's radius and one for the cylinder's height, which we will call `r`, and `h` (the name of the variables is essential, as we will see later on). We need to click on the Add variable button to add them.

Now, we need to define the correct answer in the corresponding input field, considering that it's not a number. As you may see, the `evaluate()` command will be automatically displayed there to be used if we want our solution to be computed.

If we directly write the correct answer without the `evaluate()` command, the result showed to the student as the expected answer will appear without any performed calculus. Both options are valid, but we prefer to display the final fraction when the students answer the question in this example. Conversely, that's what it would be displayed.

Finally, we can test the question's behaviour in the Test the question section. There, we can try some possible answers and check everything works as expected.