WeBWorK Problems

How use formula as alternative in multiple-choice

Re: How use formula as alternative in multiple-choice

by Michael Gage -
Number of replies: 0
If I have understood your question correctly, you want to use perl's interpolation feature to create $alt1 in one step:

$num = random(1,5,1);
$alt1 = "\(E_i = h^$num\)";

Any dollar sign variable inside double quotes in perl is replaced by its value. Single quotes prevent variable interpolation. For a very quick start on perl see

http://webwork.maa.org/wiki/Basic_Perl_syntax

particularly the section on quotes.

For more details see the links on that page and for a book I highly recommend "Learning Perl" by Randal Schwartz and Tom Phoenix.