Click here to Skip to main content
15,905,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir i make an online quiz project.

The question number is a primary key.

Sir/Madam
In the Quiz there is a set of 30 Questions.
And i schedule the quiz for 15 persons.


Sir/Madam
when i organize the quiz then all the participants have the question in the same order or in the same serial number.
I want to fetch the questions differently(Random Question) for all the participants.
How can i do it.

Please help me regarding this.
Posted

choose question id randomly ... use randon no for 1-30...

i.e....

C#
Random rand = new Random();
        int ra = rand.Next(1, 30);


and use use this ra .... this is a easy way ....
 
Share this answer
 
v2
Comments
ankur789 9-Feb-13 3:38am    
sir i am using vb as default language so please give me solution according to that
Avik Ghosh22 9-Feb-13 4:37am    
try this...

Dim rn As New Random

n =rn.Next(1, 4)

i have a little knowledge in vb.... bt try this code.. it may work....
HI,

checkout the following 2 solutions:

1:
VB
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Create a new Random class in VB.NET
        Dim RandomClass As New Random()

        Dim RandomNumber As Integer
        'Generate a random number between 1 and 2,147,483,647
        RandomNumber = RandomClass.Next()
        MessageBox.Show(RandomNumber, "www.interloper.nl", MessageBoxButtons.OK, MessageBoxIcon.Information)


        Dim RandomNumber2 As Integer
        'Generate a random number between 100 and 200
        RandomNumber2 = RandomClass.Next(100, 200)
        MessageBox.Show(RandomNumber2, "www.interloper.nl", MessageBoxButtons.OK, MessageBoxIcon.Information)

    End Sub

End Class


2.
Public Function GetRandomNum
Dim myRandom as New Random
dim RandomNumber as Integer = myRandom.Next('first value, 'sencond value) 'both as integers
Return RandomNumber
End Function


Thanks
 
Share this answer
 
Hello Ankur,

Random is a predefined class in .net so you can use Random class to generate random numbers.
Ex:

C#
Dim r As New Random
For i As Integer = 0 To 30
            Dim r As New Random
            r.Next()
        Next


use this 30 numbers to fetch the questions because Random class generate different values each time it will execute.

Hope this helps you.

Cheers with Prafulla
 
Share this answer
 
v2

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