R
R
Roman Rakzin2015-06-25 10:49:01
SQL
Roman Rakzin, 2015-06-25 10:49:01

How to shuffle questions for each student (but not order by rand)?

Is there some random way to display data, but at the same time, so that they do not change every time?
For example, there is a table of questions for testing (contains, for example, questions 1,5,9,20), I need to randomly select data from the table for user id 5 - for example 20,5,1,9 and for user id 20 - another combination . But the bottom line is that if user id 5 asks for his questions, he should have a combination (1,5,9,20), and not a newly generated random one.
Of course, you can generate a sequence once for each and add it to the table, but how can you make sure that certain random sequences are displayed by user id, and not just random data? Is it possible somehow to mix the questions using a sinusoid or some other function?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2015-06-25
@opium

do not initialize rand in the programming language and it will always generate the same randoms in a row.

R
Roman, 2015-06-25
@yarosroman

Make a table
UserId, QuestId, fill it as we need, then SELECT * FROM Quest WHERE QuestID IN (SELECT QuestId WHERE UserId=1) ORDER BY RAND.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question