-
MathType
-
Wiris Quizzes
-
Learning Lemur
-
CalcMe
-
MathPlayer
-
Store FAQ
-
VPAT for the electronic documentation
-
MathFlow
-
BF FAQ
Generating tables from lists
Reading time: 2minOften, the data we wish to supply for a problem statement is best displayed as the contents of a table. However, editing each cell individually can be tedious, especially if we want to use variables to create a random table. Luckily, WirisQuizzes can easily convert list variables into table cells, which cuts quite a bit of the workload. But more interestingly, this feature allows us to create tables of variable size (see the last section for details).
Basics
It's straightforward to use this functionality. In the simplest case, we need only place a list variable inside a single table cell (you can make a table either with the table wizard or by making a table yourself in HTML mode). Let's see how it turns out.
Writing the statement
Create a short answer question, and type a variable inside a 1x1 table:
Create a list
Define a
as a list in the Variables tab:
View the results
Now when we go to the question, we see that the numbers in the list have automatically expanded into individual cells in a row:
As we've seen in this example, the default behaviour for a list inside a table cell is to fill the table towards the right. However, we would like to have a list of numbers expanding downwards in many settings. This is achievable simply by placing a cell above the variable cell, as in the following example:
The above input, in the question statement, becomes:
Example
Let's put what we've seen to use in a real question. A typical exercise in entry-level probability is to answer questions on a discrete probability distribution, using a table to describe it.
By using variables to fill out the table, we can exploit the random capabilities at our disposal to create a question that is different each time it is opened. Let's input the following in the editor:
In the Random variables section, we have to declare the lists and calculate the answers:
Our question is actually a list of three questions, so firstly, we'll have to write them in the Correct answer field.
Then, we'll have to select Grade answer boxes separately in the Input options section, and the grade weight for each subquestion.
Finally, when we view the question we see the table expanded as so:
Randomly sized tables
It's possible to make the size of a table depend on a variable if we so wish. The actual work involved has to do more with knowing how to make a list of variable sizes since we've already seen how lists can automatically expand into tables. There are many options for defining such lists, but we'll go through the basic ones.
Example 1
Say we wanted the probability distribution in the previous example to have a random number of elements. We would then use the following command in the Define random variables and functions section:
As we see, N above could have been the result of any other previous computation (provided it produces a number). This lets us be quite creative in making random lists.
Example 2
Another common type of list is one with its elements evenly spaced between the endpoints, typically representing points in an interval of real numbers. Let's take a look at the following command:
This means, in plain English, "a list of numbers from 0 to 3, spaced by increments of 0.5".
To make lists of this style random, we have to replace the numbers in the definition with variables. In this example, we keep the start point and the increments the same, but we randomize the endpoint:
There are many other possibilities for defining random lists. Any parameter that one would use to create a list can be replaced with a variable, so our creativity can take us as far as we want.