\label{Authoring_Daxe_Variables} \textbf{Creating a Problem with Randomized Values} Some randomization can easily be achieved with a radio button response, by setting thei\texttt{randomize} attribute to 'yes', setting the \texttt{max} attribute to a maximum number of displayed foils, and creating more foils than will be displayed. With a numerical response, it is necessary to create variables with random values. This can be done with a Perl script. Such a script is created by inserting a \texttt{script} element (in the \textit{Block} menu) and setting its \texttt{type} attribute to '\texttt{loncapa/perl}'. Here is a little cookbook for randomizing values with a Perl script: \begin{itemize} \item To set variable a to the value 1: \texttt{\$a = 1;} \item To set variable a to the value 'text': \texttt{\$a = 'text';} Note that single quotes take the value literally, while double quotes replace variables by their values. \item To pick a random number between 1 and 5 (included), with a step of 0.5: \texttt{\$a = random(1, 5, 0.5);} (the step can be omitted to use a step of 1) \item To chose a value randomly in a list of text entries: \begin{verbatim} @list = ('one', 'two', 'three'); $n = random(1, scalar(@list)); $a = choose($n, @list);\end{verbatim} \item Math operators: \texttt{+, -, *, /, **, \%} \item Math functions: \texttt{sin, cos, tan, asin, acos, atan, atan2, log, log10, exp, pow, sqrt, abs, sgn, erf, erfc, ceil, floor, min, max, factorial, sinh, cosh, tanh, asinh, acosh, atanh} \item Comments: \texttt{\# This is a comment.} \end{itemize} Once created in a script, variables can be used anywhere afterwards, still prefixed with \texttt{\$}. In particular, a numerical response answer can be set to a variable.