If you simply generate a random number for use in a definition, the results can at times be unpredictable, but you can prevent such results if you specify conditions that randomly defined variables must meet. For example, you might set a condition that prevents a variable from being defined as 0 or a condition that prevents one variable from being greater than another.
When you use algorithms to state not only a question but also its
multiple-choice answers, you can use conditions to prevent the random
generation of duplicate or undefined answers. For example, a question that
involves two randomly generated variables a and b might have as possible
multiple-choice answers both
and
. If the
randomly generated values for the variables are the same, these answers will
be identical and will present a confusing choice to the student. You can
avoid the confusion by setting the condition that
(a≠b). You also want
to avoid the illegal situations of (a = 0) and (b = 0).
Like the definitions to which they refer, conditions can affect an entire exam or just a single question or question variant. Also like definitions, each condition must be stated on its own line in a Setup section. (Refer to Chapter 4EBfrontsection.tex and Chapter 5EBquestion.tex for more information about creating Setup sections.) Further, each condition must follow the definition to which it refers. You can use logical and (∧) and logical or (∨) to combine several conditions in a single statement.
Note that the conditions must be relatively easy to satisfy. If after several hundred attempts the Exam Builder can't find a random assignment to the variables that satisfies the conditions, it returns undefined results.