https://webwork.maa.org/moodle/mod/forum/discuss.php?d=3884
I used the line
[$radio->buttons]* [@ WEIGHTED_ANS( $radio->cmp(), $button_mark ) @]
to change the weight of the radio button. I'm getting a weird 0 at the end of the buttons. Below, I've included code for a simpler problem to show the code I've used (no big truth table) and a screen shot to show the weird 0.
## DESCRIPTION
## changing the weight of the radio buttons
## ENDDESCRIPTION
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserRadioButtons.pl",
"weightedGrader.pl",
"PGML.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
############################
# Setup
install_weighted_grader();
$radio = RadioButtons(
["must be first",
["random1",
"random2",
"random3" ],
"must be last"
],
0, # correct answer
labels => "ABC"
);
$button_mark = 5; # weighted for radio buttons, all others weight 1
$entries = 3; # number of entries
$button_pc = sprintf("%0.0f",($button_mark/($entries+$button_mark))*100 );
#$showPartialCorrectAnswers = 0; # don't show which answer are wrong
############################
# Main Text
BEGIN_PGML
Some questions that have weight 1
Enter the number ten
[_]{10}{10}
Enter the number twenty
[_]{20}{20}
Enter the number thirty
[_]{30}{20}
and now the radio button question that has weight [$button_mark].
[$radio->buttons]* [@ WEIGHTED_ANS( $radio->cmp(), $button_mark ) @]
Note: The multiple choice question is worth [$button_pc ]% of your grade.
END_PGML
# If I include answer checker down here,
#don't get weird zero at the end of the radio buttons
#WEIGHTED_ANS( $radio->cmp(), $button_mark ) ;
##########################
# Solution
BEGIN_PGML_SOLUTION
[$radio->correct_ans()]
END_PGML_SOLUTION
ENDDOCUMENT();