Skip to main content

Random seed per student

When working with random numbers, you may want every student always to have the same seed for the random number generation. This way, a question will always have the same random values, even if the quiz is re-started several times; or the student will have the same data in different examinations 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. It will always give the same number a.



This option is advantageous 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 PP , and two vectors uu, vv , and we will ask them some questions:

  • Does PP belong to a given line?

  • Is uu parallel to a given vector?

  • Give the equation of the plane with vectors uu and vv and passing through PP

  • Give a linearly independent vector concerning uu and vv

  • Give a vector orthogonal to uu and vv

We can use a multichoice question type; for the third, we can use a short answer question type with the Equivalent equations validation property selected. We should use a grading function for the last two questions 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 uu and vv 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 uu and vv are the same in both questions. Then, for instance, a student can answer the normal vector of the plane as the orthogonal vector.