- Log in as a teacher in a course.
- Create a course
- Turn editing on.
- Create a quiz
- Edit the quiz and add a new True/false question under the course's default question category.
- Add a "random question" to the quiz using the course's default question category
- Go back to the course page
- Duplicate the quiz
- Duplicate the quiz again
- Duplicate the quiz yet again
- Check the question table on the database. (It's most likely mdl_question). You should see 9 questions on the table.
- Open a terminal, go to your Moodle instance's root directory and run
php admin/tool/task/cli/schedule_task.php --execute=\\qtype_random\\task\\remove_unused_questions
- Confirm that you see a message that 4 unused random questions have been cleaned up.
- Check the question table.
- Confirm that only 5 questions now remain.