# Random seed per student

**temporarily out of service**in Moodle in versions prior to 3.78.1. Feel free to contact us via support@wiris.com if you experience related problems in other environments.

When working with random numbers, you may want that every student has always the same seed for the random numbers generation. This way a question will have always the same random values, even if the quiz is re-started several times; or the student will have the same data in different quizzes over the course.

To do so you need to call the parameter `user_id`

, which identifies every student by an ID; and fix the random seed.

parameter user_id = 0 random_seed(user_id)

The following algorithm

will give always the same number `a`

.

### Example

This option is extremely useful when, for instance, we want to ask different types of questions (like in Cloze question type) but we have to use a grading function.

As an example, we will give the students a point and two vectors , and we will ask them some questions:

- Does belong to a given line?
- Is parallel to a given vector?
- Give the equation of the plane with vectors and and passing through
- Give a linearly independent vector with respect to and
- Give a vector orthogonal to and

For the first two questions, we can use a multichoice question type; for the third, we can use a short answer question type with *Equivalent equations* validation property selected. For the last two questions, we should use a grading function because there are infinite solutions. Hence, we will create a Cloze question type for the first three questions and a short answer question type with a grading function for the last two. We will fix the random seed for each student so that the vectors and are the same in the two questions.

For the first question, select *Equivalent equations* on the Validation tab and write the following algorithm:

For the second question, the algorithm will be

A quiz with both questions will be shown as

Note that the vectors and are the same in both questions. Then, for instance, a student can answer the normal vector of the plane as the orthogonal vector.