Random unique quiz question for each student

Random unique quiz question for each student

by Martin Novák -
Number of replies: 2

I am looking for a way / plugin to do this:

Let’s say I want to create a quiz with few questions (let’s say 2 for simplicity). Each question is from a different Category in the question bank. Let’s say there are 25 questions in each category and 5 students in total. For each student I want to randomly generate one question from each category, but so that when some question was already used for one student, it will not be used again for a different student. In other words, the generated question should be used once.

Any ideas how to do this?


Average of ratings: -
In reply to Martin Novák

Re: Random unique quiz question for each student

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

The Moodle quiz does not support this feature. If it did you would need rather a large question bank for even a modest number of students.

In reply to Martin Novák

Re: Random unique quiz question for each student

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If I have done the calculation right, in the situation you give (25 questions, 5 students) there is a 65% chance that students won't see a repeat for one of the questions, just from randomisation. Even if they do, it will just be two of the students who have the same question as someone else, but they won't know who, so that won't make it very easy for them to cheat. (I assume this is what you are worried about.)

The only way to get what you want would be by altering the code, which is something that should not be done lightly. However, I don't think it would be hard. I have not tested this, but I think you would just need to change this line:

https://github.com/moodle/moodle/blob/cad8adccc796f40ab11b1236cd637e9b987c17c8/mod/quiz/locallib.php#L165

// Usages for this user's previous quiz attempts.
$qubaids = new \mod_quiz\question\qubaids_for_users_attempts(
        $quizobj->get_quizid(), $attempt->userid);

Change it to 

// WARNING: Change to standard Moodle code: All previous usages for this quiz attempts.
$qubaids = new qubaids_for_quiz(
        $quizobj->get_quizid(), false);