online test repeating questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

online test repeating questions

Post by shafiq2626 »

Hi!
I have make an online examination application.
I have a hundreds of questions for one test. when i allocate test for the students then online test paper select 30 question one by one with ORDER BY Rand() after each 30 seconds.
Problem is that there are repeating some questions numbers of time.
How can i solve this problem my query is follow.

Code: Select all

$sqlQuery="select * from question where  qstatus = 'Active' AND testid =".$_SESSION['tid']." ORDER BY Rand() LIMIT $offset , $limit";
its primary key is qid

Please help if anyone can with thanks.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: online test repeating questions

Post by twinedev »

Try seeding the RAND() with the time stamp so that each time they will hopefully be different:

Code: Select all

SELECT * FROM tblWhatever ORDER BY RAND(NOW());
-GReg
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Re: online test repeating questions

Post by shafiq2626 »

Thanks
This has been solved by the method which you send.
thanks again
Post Reply