No randomization when querying multiple questions

Questions aren’t randomized properly when requesting more than 1 question.

Steps to reproduce the bug

  1. Enter the following API call into your browser: https://opentdb.com/api.php?amount=50&category=10
  2. Look at the first question.
  3. Refresh the page.

Expected behavior
A random question from the category is returned.

Bugged behavior
Some questions are returned much more often than others.

Question Times chosen
Which of the following authors was not born in England? 13
Who wrote Harry Potter? 5
Which of the following authors was not born in England? 5
Who wrote the A Song of Ice And Fire fantasy novel series? 3
Which author and poet famously wrote the line, The female of the species is more deadly than the male? 2
George Orwell wrote this book, which is often considered a statement on government oversight. 1
In the Beatrix Potter books, what type of animal is Tommy Brock? 1
Other 67 verified questions 0

Explanation
It seems like OpenTDB chooses 50 random questions, but always returns them in the same order.

Using an API token has no effect.

“Which of the following authors was not born in England?” is probably the first question in the ‘Entertainment: Books’ category. If it’s one of the 50 randomly chosen questions, it will be question one.

Questions are correctly randomized when changing amount=50 to amount=1.

Proposed fix
Randomize the question order when asking for more than 1 question.

1 Like