Random Documents

Since there has been an influx of questions on how to make exams in Lotus Notes
with random questions..I figured I'd post my random document selector.

Things to note:
'total_questions' should be filled in programatically. It should reflect the
number of documents in your doc collection or view that you are going to select
docs from.

'how_many' is the number of random documents to select

Once you have run randomizer() the outlist array will contain the document
number to use in getnthdocument.
example usage:
forall x in outlist
doc = view.getnthdocument(x)

forall x in outlist
doc = collection.getnthdocument(x)

Any questions on this scripts can be sent to me at:
Custom test dbs can also be developed.. for a price of course ;-)
Option Public
Dim tarray() As Integer
Dim outlist() As Integer
Dim total_questions As Integer
Sub Initialize
Call randomizer()
End Sub
Function randomizer()
Dim anum As Integer
Dim how_many As Integer
Dim place As Integer

' Total number of questions to choose from
total_questions% = 50
' How many do you want?
how_many% = 10
Redim outlist(0 To (how_many%-1))
'Create number array
total_questions% = total_questions% -1
Redim tarray(0 To (total_questions%))
For x = 0 To (total_questions%)
tarray(x) = x+1
'Now shuffle the numbers
For place = 0 To (how_many%-1)
anum% = Round(Rnd()*total_questions%,0)
outlist(place) = tarray(anum%)
Call reorg(anum%)
End Function
Function reorg(place As Integer)
Dim x As Integer
'Remove selected and slide down rest
For x = place To (total_questions%-1)
tarray(x) = tarray(x+1)
'Take one from total_questions
total_questions% = total_questions% -1
Redim Preserve tarray(0 To total_questions%)
End Function

Dig Deeper on Domino Resources



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury