if you had an extra field, say worker_SortOrder that's a number, you can replace it with Random(), then sort by that field and omit all but the first ten records. (et al)
I'm not sure how to write that in a script. Do you think you can give me an example?
That worked perfect! But how can I make the selection of random questions from only one course or multiple ones that I select? I've tried to make a Find first but I can't get it to work.
the critical steps are:
go to layout (the one that's pertinent)
enter find mode
another version is:
go to layout
perform find (a stored one)
Pertinent for what? Selecting course?
you can do this without a script. So when you do script it, just follow the same steps you do when you find your records manually. You start in a layout, enter find mode, type something into a field and hit Enter (or click Find).
Yes I think I do that right but the problem is when I use the script that starts with "Enter Browse Mode" shows the 10 random questions it shows questions from all courses and not only the one I have selected. Do you understand how I mean?
I'm saying that you should start without the script - find your records manually, then recreate the manual steps in the script. Here's a really good reference:
(in fact, you can do what you want to do without a script at all - the script just makes it easily repeatable.)
I'm not fond of the Replace approach because it's not mutli-user, and modifies the modification date of records.
If you'd like to pick 10 random records among the found set (which means you already found records linked to the corresponding courses.
(not tested code, just to give an idea)
If [ Get ( Foundcount ) <= 10
# Get a list of random records
Set Variable [ $n ; Round ( Random * Get ( Foundcount ) ; 0 ) + 1 ]
Set Variable [ $id.list ; List ( $id.list ; GetNthRecord ( table::id ; $n )
Exit loop if [ Valuecount ( $id.list ) = 10 or not Get ( Foundcount ) ]
# Find records
Enter Find Mode [ Pause: off ]
Set Field [ table::id ; "==" & getvalue ( $id.list ; Get ( recordnumber ) ]
Exit Loop if [ Get ( RequestCount ) = 10
Round() should be Int() or Floor(). Using Round() you get 1 or 2 when Get(FoundCount)=1.
I like this for random positive integers (>=1) ...
Floor ( ( Random * n ) + 1 )
Yes but The found coût saoule not be 1 due to the first 3 limes.
Oh I hate the iPhone when he does this (switch language and auto-correct)
--> the found count should not be 1 due to the first 3 lines.