0

how to display the randomly selsected questions from a database one at a time in jsp like in online quiz.please help me

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by jwenting
0

Solution depends on many things, but considering that for example you have situation where you have fixed numbers of question for quiz like 10 and larger number of questions to choose from I would query database for question IDs, run random generator between 0 and total-1 of question and pick 10 random IDs. Another query to database to retrieve all data related to selected IDs, store them in bean, pass it through session and job is done.

0

Solution depends on many things, but considering that for example you have situation where you have fixed numbers of question for quiz like 10 and larger number of questions to choose from I would query database for question IDs, run random generator between 0 and total-1 of question and pick 10 random IDs. Another query to database to retrieve all data related to selected IDs, store them in bean, pass it through session and job is done.

i didn't get you.actually i retrieved the random questions from the database.but the problem is they r displaying all at a time.i want to display one question at a time and when the user clicks the submit button next question is displayed and so on.can u please elaborate what u want me to do

0

so retrieve 1 question only, not all of them :)
1) get a random number to indicate the question to get
2) use that to retrieve the question and only the question
3) show the question

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.