5 Replies Latest reply on Feb 18, 2011 7:58 PM by denno

# setting up a question bank

### Title

setting up a question bank

### Post

[FMP11]

I need to set up a database of questions where a subset will be used for practice tests. The criterion for the subset is that it hasn't been used in the prior 6 months. 30 questions that meet the criterion would need to pulled into the subset and printed.

I know how to set it up so I can extract ones that haven't been used in the last 6 months but I don't know how to pull the subset of 30 random questions. From another post about a similar scenario, it seems like using the Random function would play a role but I'm not sure how to create a subset of only 30.

Thanks-

• ###### 1. Re: setting up a question bank

I assign kids participating in a Pinewood Derby style car race to random lanes and heats with the random number function.

You assign a random number to a field and then sort on that field to put the records in random order.

Now go to record 31 and use Omit Multiple Records to Omit 9999 records so that you take just a random selection of 30 records.

• ###### 2. Re: setting up a question bank

if each question in the bank has a unique ID number going from 1 to X (the total # of questions).  You could then

set \$var to 0

have a random number generated from 1 to X.

find ID = Int(Random*x-1)+1

If used date -current date > 6 months

set question# to \$var+1

set used date to current date

loop exit after var = 30

find used date = current date

Sort by var

• ###### 3. Re: setting up a question bank

Thanks for the help.Two other questions--

1. I am displaying the 30 selected questions on a new layout for printing. I'd like to also have a question number from 1-30 listed. I tried using Get RecordNumber and RecordID but those numbers are linked to the original record order, not the order in the found set.

2. I am having trouble with the script and finding questions that haven't been used in the last 6 months.

I have a Month Difference field that calcs: 12 * ( Year ( Get (CurrentDate) ) - Year ( Last Used ) ) + Month ( Get (CurrentDate) ) - Month ( Last Used )

The calculation is working properly.

My script is:

If Month Difference > 6

Loop/randomize

Sort & Omit

End If

If I disable the If statement, the script runs fine. With the IF enabled, nothing happens. My sample records have a Month Difference value of 9.

• ###### 4. Re: setting up a question bank

1) If you make the calculation field unstored, get ( RecordNumber ) refers to the current order. You can also just put @@ on your layout and that will be displayed as the record number.

2) The first line of your script just checks the first record. It doesn't find any records.

Enter Find Mode[] //clear the pause check box
Set Field [Questions::MonthDifference ; "> 6" ]
Set Error capture [on]
Perform Find[]
If [ Get ( FoundCount ) > 29 ]
Replace field contents [ Questions::randomOrder ; Random ]
Sort [no dialog ; restore ] //sort on RandomOrder field
If [Get (Foundcount ) > 30 ]
Go To Record [31]
Omit Multiple Records [9999]
End If
Else
Show Custom Dialog ["Not enough question records"]
End If

• ###### 5. Re: setting up a question bank

As usual, thanks again for the help PhilModJunk!

Not sure why I used the If and not a Find