0

I'm implementing a quizz and want to fetch questions from a Firestore.

How can I query questions one by one from the DB in a different order between players but being sure that I never show twice the same question to the same player.

Is it possible to give an array of IDs that I already fetched ? Or is there another solution that can help me ?

Gp2mv3
  • 1,435
  • 20
  • 33

1 Answers1

0

There is nothing built in to Firebase for that. The first approach that comes to mind would be to track what questions you've already asked, and find a next question at random with the approach described here. Then if you've already used that question, find another random one.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Yes, I had a similar approach in mind but if the player already played a lot, it's possible that we need to fetch a lot of questions before finding one that he didn't play before... – Gp2mv3 Jun 12 '19 at 21:00
  • I think I'll fetch questions by batches then randomly select questions in that batch locally. – Gp2mv3 Jun 12 '19 at 21:02
  • Sounds like it'd have the same problem, just at a different scale. But if that works for you, definitely go for it. – Frank van Puffelen Jun 13 '19 at 00:59