Did you know that if you are distributing ELearning Packaged Tests or using the LAN based testing components, you can create question text and choices that contain dynamic (changing) values?
Here is a simple example. Consider this Quiz Question:
Dave has 2 apples. Jane has 1 apple. How many apples do they have total?
Suppose we want to change the names each time. Suppose we want to change the TOTAL # apples each time. We can do both - so let’s get started.
First, go to the question wizard, and pick BASIC STYLES > MULTIPLE RESPONSE:

Click ADD QUESTION, and the Question entry wizard will appear. Enter the question text, and (for this example) 4 choices:

Click NEXT (to save the question), and then close the Question Wizard form. Your new question should be listed in the question list.
Now, if you want the names Dave and Jane to be dynamic (meaning, they will be different each time), first double-click the question to open it up in the Question Editor, click the VIEW CODE tab, and click APPLY. When you click APPLY, you will be able to enter some PowerScript code. This is where we will define the ‘pool’ of names we will use. Enter the following code:
' Set Up Name Choices and Variables
ExecuteGlobal("Dim name1, name2")
'
' Create Possible Names
name1_choices = Array("Bob", "Dave", "Steve", "Joe")
name2_choices = Array("Alice", "Jane", "Mary", "Lisa")
'
' Pick a Randon Name for Each One
For i = 0 To Second(Time)
name1 = name1_choices( int(rnd(1)*4) )
name2 = name2_choices( int(rnd(1)*4) )
Next

Now, click the QUESTION/CHOICES tab, and click the FULL EDITOR button. Highlight the word Dave in the editor, and then click the INSERT DYNAMIC VALUE button:

Enter name1 into the blank and click OK. Notice that the name Dave has been replaced with <%name1%>.

Follow the same steps for Jane (highlight Jane, click insert dynamic value) - this time enter in the phrase name2 and click OK. Your question should look as follows:

Click SAVE on the FULL EDITOR, and you will be returned back to the Question Wizard. Now click the PREVIEW QUESTION tab and then click COMPILED PREVIEW. If you do it a few times, you should see that the names change each time:

Changing the ANSWER is a bit more complex. The reason is, we need to make sure that each of the incorrect/detractor answers are never the same value as the correct answer. In our example, we have used the values 2, 5, and 7 as detractor values, so we never want those values to be the correct value.
Keeping that in mind, let’s go back to the code editor (VIEW CODE tab), and modify the code as follows:
' Set Up Name Choices and Variables
ExecuteGlobal("Dim name1, name2, value1, value2, correct_value")
'
' Create Possible Names
name1_choices = Array("Bob", "Dave", "Steve", "Joe")
name2_choices = Array("Alice", "Jane", "Mary", "Lisa")
value1_choices = Array(2,3,4,5)
value2_choices = Array(6,7,8,9)
'
' Pick a Randon Name for Each One
For i = 0 To Second(Time)
name1 = name1_choices( int(rnd(1)*4) )
name2 = name2_choices( int(rnd(1)*4) )
value1 = value1_choices( int(rnd(1)*4) )
value2 = value2_choices( int(rnd(1)*4) )
Next
'
' Set Correct Value
correct_value = value1 + value2
Next, go to the QUESTION/CHOICES tab. You can (if you want) go to the FULL EDITOR and replace the numbers using the INSERT DYNAMIC DATA button like I showed you previously when you did it for the names, or, you can just type it in. Either way the end result should look as follows:
<%name1%> has <%value1%> apples. <%name2%> has <%value2%> apples. How many apples do they have total?
Since we are changing the values, we also need to make the ‘correct answer‘ dynamic. To do this, click the CHOICES A-H tab, and change the correct answer from ‘3‘ to <%correct_value%>.

Our code will calculate the ‘correct-value’, and place it here.
Once again, click PREVIEW QUESTION and then COMPILED PREVIEW. Doing it several times will yield various names and values each time.