Random seed per student

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

The following algorithm

will give always the same number a.


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 P and two vectors u, v and we will ask them some questions:

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

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 u and v are the same in the two questions.

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

The statement would look like

For the second question, the algorithm will be

A quiz with both questions will be shown as

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