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



  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...