Click here to Skip to main content
15,916,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Fellow Programmers! please i want to develop an application that will be generating random science questions for the student to answer.

My problem is how do i generate the string random question and set the answers as objectives.

Please somebody should give me clue. I appreciate!

Thanks
Posted
Comments
BELGIUMsky 23-Apr-14 6:20am    
You can make a list of questions
shuffle the list like shown in: http://stackoverflow.com/questions/273313/randomize-a-listt-in-c-sharp
and then show them like you wish

I think a simple path would be storing the questions (and the relative solutions) in a database and then select randomly a row on the questions table (you may, for instance, assign a numeric id to each question and then choose the question having id equal to a random generated number).
 
Share this answer
 
use random function While you Select The Question From Table

Eg:
SQL
select top 1 user_Code from tbl_user_registration order by newid()



http://msdn.microsoft.com/en-us/library/cc441928.aspx[^]
 
Share this answer
 
Its easy make a table and add question,with three wrong and one right ans with serial no
Then in your form get max(serial no) table then

use this code

VB
'IN form load event 
 
dim n,i as integer


Dim num As New Random

for i = 1 to no_of_questions 'you want to load in form

	  
n =num.Next(1, max_serial_no)

'now your sql query

dim sqlqry = "select question,ans1,ans2,ans3,ans4,rightans from question_table where serial_no = " & n & "" 

'in your ans one ans must be same with right ans and get that in form
'use your datareader executequery command


next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900