But parserRadioButtons.pl
has the ability to assign alternative labels to the buttons. These are what are used for the student answer and preview, so in your case, you should use that mechanism to make something more meaningful for the labels.
One choice would be to add
labels => "ABC"to the
RadioButtons()
call, which would make the answers be labeled A, B, C, etc. These are what would show up for the student answers in the results table when they check their answers. It also prevents the math tags from being used as the values of the buttons, so you won't get the extra stuff on screen.
But you could be fancier and have them labeled by the actual expressions. Since these labels are actually used as the student answers, they have to be valid expressions that MathObjects would need to parse. One way would be to add things like "1 mi/5280 ft" as strings, and then use these as the labels.
Alternatively, you can add mi
and ft
to the context and set things up so that the quotients stringify nicely. Here's an example of that:
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserRadioButtons.pl",
);
#
# Set up context to have mi and ft, and make them print properly
#
Context("Numeric");
Context()->constants->add(mi => 1, ft => 1000);
Context()->constants->set(mi => {TeX => "\ \mathsf{mi}"}, ft => {TeX => "\ \mathsf{ft}"});
Context()->operators->set("*" => {string => " "}, "/" => {rightparens=>""});
#
# The MathObjects for the answer choices
#
@answers = (
Formula("(5280 ft)/(1 mi)"),
Formula("(5280 mi)/(1 ft)"),
Formula("(1 mi)/(5280 ft)"),
Formula("(1 ft)/(5280 mi)"),
);
#
# The radio button choices (the text next to the button)
# and labels (what is used for the student answers)
#
@choices = map {" \(".$_->TeX."\)"} @answers;
@labels = map {$_->string} @answers;
$radioQ_a = "Which of these is a flavor of 1 to change ft to miles?";
$radio_a = RadioButtons(
[@choices],
$choices[2],
separator => "$BR$BR",
labels=>[@labels],
);
BEGIN_TEXT
$radioQ_a $BR$BR
\{$radio_a->buttons\}
END_TEXT
ANS($radio_a->cmp);
Hope that helps.
Davide