New SelectFrom Parameter Type

We have added a new SelectFrom parameter type that simplifies the process of randomly selecting elements from a list or set.

$s=selectfrom($sourceparameter,number)

To use a SelectFrom parameter, you need to create a “source” parameter that contains the elements you wish to “select from”. The source parameter can be just about anything.

$r=range(1,100)
$n=data(“Albert”,”Barry”,”Cyril”,”Egbert”,”Francis”)
$e=explode(“MATHEMATICS”)

$d=deck()

Once we have our source parameter, we can create a SelectFrom parameter

$s=selectfrom($d,5)

This command will randomly select five elements from $d. In this case, we will get back 5 cards from a deck.

One Trick – List All Elements

The SelectFrom command will select from listed values. Some parameters do not list all values automatically. For example,

$s=selectfrom($r,3)

will not produce the results you expect, because range parameters do not “list all values” automatically. To use the selectfrom command with range parameters (and other parameters which do not list all values), you need to list the values using references. The easiest way to do this is to use the $r[] notation.

$s=selectfrom($r[],3)

The addition of the square brackets will cause the range parameter to list all values and $s will contain 3 values selected from this list. You could have also typed something like $s=selectfrom($r[12,54],3) which would select from the 12th element through to the 54th element of the range list.

The SelectFrom parameter is an advanced parameter type that can make the creation of some question types much simpler.


Discover more from Efofex News

Subscribe to get the latest posts sent to your email.

Unknown's avatar

About efofexsoftware

Efofex Software produces graphic production software designed specifically for secondary mathematics and science teachers.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment