## WeBWorK Problems

### Re: Multiple Choice problems with Mathobjects answers and extras

by David Gilliam -
Number of replies: 0
Danny

I fear that my main problem is a lack of understanding of basic things involving MathObjects. I was hoping to compute answers and wrong answers using things like $F><$G and $F.$G where $F and$G are Vector functions. But they don't seem to work for me. Using your suggestion to move Context()->texStrings; to before the $mc definition I am now okay but don't understand why I can't display things like$F><$G. I'm reluctant to post an example due to making public my poor programming skills -- but I will go ahead and post an example that does not work for me and hopefully gain some insight into what is wrong with my thinking. I expect it has to do with executing and displaying things like$F><$G and$F.$G. Also, concerning my thought of finding an alternative to using Multiple Choice, I wish I could have a little more control over the display of the multiple choice questions. For example, I would like to have more space between the rows and so on. Thanks to all who have responded to my post. David Gilliam %%%%%%%%%%%%%%%%%%%%%%%% DOCUMENT(); loadMacros( "PGstandard.pl", "PGML.pl", "PGgraphmacros.pl", "MathObjects.pl", "PGcourse.pl", "PGchoicemacros.pl", "PGbasicmacros.pl", ); TEXT(beginproblem());$showPartialCorrectAnswers = 1;

######################################################################

Context("Vector");
$context = Context();$context->flags->set(ijk=>1);
$context->variables->add( t=>'Real');$a= random(2,5,1);
$b= random(2,4,1); while ($a == $b) {$b = non_zero_random(2,4,1); }

$a1 = non_zero_random(2,4,1);$a2 = non_zero_random(-3,3,1);
$a3 = non_zero_random(-1,1,1); do {$a3 = non_zero_random(-1,1,1); } until ($a3 !=$a1 || $a3 !=$a2);

$b1 = non_zero_random(-3,3,1);$b2 = random(-1,1,1);
$b3 = non_zero_random(-5,5,1); do {$b3 = non_zero_random(-5,5,1); } until ($a1 *$b1 + $a2 *$b2 + $a3 *$b3 != $a1*$b3 + $a2*$b2 + $a3*$b1);

$n= random(1,4,1);$m= random(1,6,1);

$f1= Formula( "$a1 t^$n" )->reduce ;$f2= Formula(" $a2 sin($a t) ")->reduce ;
$f3= Formula("$a3 " )->reduce;

$F = Compute( "<$f1 , $f2,$f3>" ) ;

$g1= Formula("$b1 cos($b t)")->reduce ;$g2= Formula(" $b2 ")->reduce ;$g3= Formula( "$b3 e^{$m t}")->reduce ;

$G = Compute("<$g1 , $g2,$g3>" );

# Rather than computing FxG by hand like this (which does work well)
$FxG = Compute(" <$a3 $b3 e^{$m t} - $a3$b2 , -($a1$b3 t^$n e^{$m t} - $a3$b1 cos($b t)),$a1 $b2 t^{$n} - $a2$b1 sin($a t) cos($b t)> ")->reduce;

# I had hoped to simply compute

$FprodG = Formula("$F >< $G")->reduce; # and then compute extra wrong answers using things like$GprodF = Compute("$G ><$F");

$FdotG = Compute("$F . $G"); Context()->texStrings;$mc = new_checkbox_multiple_choice();

$mc -> qa (" "," $$FprodG$$ ");$mc -> extra( " $$GprodF$$ ", "$$FdotG$$ " );
$mc -> makeLast("None of the above"); BEGIN_PGML Let [ \mathbf{F}(t) = \displaystyle [$F] ] and [ \mathbf{G}(t) = \displaystyle [$G] ] and find [ \mathbf{F}(t) \times \mathbf{G}(t) ]. [@$mc -> print_q() @]***
[@ $mc -> print_a() @]*** END_PGML Context()->normalStrings;$showPartialCorrectAnswers = 1;

ANS( checkbox_cmp( \$mc->correct_ans() ) );

COMMENT('PGML version');
######################################################################

ENDDOCUMENT(); # This should be the last executable line in the problem.