Online Quiz wanted to show questions in random order
-
Hi I have quiz project running online. and i am using sql server 2005 as backend. The controls i am using to show questions is detailsview. I need to show questions in random order. I don't know how to do it. If somebody knows pls tell me. I am in great trouble.
-
Hi I have quiz project running online. and i am using sql server 2005 as backend. The controls i am using to show questions is detailsview. I need to show questions in random order. I don't know how to do it. If somebody knows pls tell me. I am in great trouble.
-
to select the records in random order, you can use "order by NewId()" in the select statement. something like this select * from tblQuestions order by NewID() bind the resultant set to the grid view
Regards
John
-
Use , NewID()
Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
Another way to do that is to load the questions into a datatable. Create an integer array from 0 to datatable row count. Then use the Fisher-Yates algorithm to shuffle the array. Clone the original datatable and then load rows into the cloned datatable using the order of the shuffled array. Alternatively you could have a question order field in the question database and shuffle the numbers in the datatable. Finally bind the datatable to the detailsview grid. Cheers.
Mike Rehner IT Teacher Northeast Career Center Columbus OH 43219