CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2006
    Posts
    28

    Question Online exam random Questions selection??

    Hi m a newbie doing a project in online exams in ASP.NET & MS ACCESS I have the following table containing Questions:
    QID(autono),Question,OptionA,OptionB,OptionC,OptionD

    and I have one more table Tests:
    TestID,QID,Question,OptionA,...OptionD,Duration

    Now m showing a form where I enter the number of Questions in the test & duration.I want a random function to pick up Questions from the Questions table(random enuf not to repeat Questions) and insert them to the Tests table(TestID will be provided while creating the test).

    Can sum1 help me out with both the above tasks.Its urgent pls help

  2. #2
    Join Date
    Aug 2002
    Location
    Kerala
    Posts
    1,183

    Re: Online exam random Questions selection??

    Use an array of booleans.

  3. #3
    Join Date
    Jan 2006
    Posts
    28

    Re: Online exam random Questions selection??

    Quote Originally Posted by Sahir
    Use an array of booleans.
    Could you perhaps elaborate a bit more or rather gimme a code snippet

  4. #4
    Join Date
    Aug 2002
    Location
    Kerala
    Posts
    1,183

    Re: Online exam random Questions selection??

    Suppose you have 100 questions, create a collection or array containing 100 boolean values, all set to false. Now generate a random number between 0 and 99. Suppose you got 37, check if the item at index 37 is true or false; if it's false display question 38 and set item 37 to true. If item 37 is true start iterating from 38 to 99 until you find one that's not used. When you find one, mark it as used and display the question number. Repeat until all elements are used. Suppose you iterate upwards hit 99 and still don't find an unused question then start from 36 and iterate downwards. You can also alternate the direction of iteration i.e. up then down then up etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured