WeBWorK Problems

MultiAnswer oddity

MultiAnswer oddity

by Peter Staab -
Number of replies: 2
I've been playing with compoundProblem5 and MultiAnswer within it.  I'm getting a strange result where I enter the correct expression  in the first ans_rule and I get the following in the entered column : "-\left(\sin\!\left(4x\right)\right)\tan\!\left(4x\right)/4x"  

and the warning: Unexpected character '\'

It appears that the tex version is being sent as the input.  

Here is the relevant code (the entire problem is about 300 lines, so I'll save you some headaches): 

$top3= Compute("-sin($b*x)*tan($b*x)");
$bottom3 = Compute("$b*x");

$dtop3 = $top3->D;
$dbottom3 = $bottom3->D;

$limit5 = MultiAnswer($top3, $bottom3)->with(
  singleResult => 0,
  allowBlankAnswers => 1,
  checker => sub {
    my ( $correct, $student, $self ) = @_;
    my ($studNum,$studDen) =@{$student};
    my $studentAns = Compute("$studNum/$studDen");
    my ($correctNum,$correntDen) = @{$correct};
    my $correctAns = Compute("$correctNum/$correntDen");
    my $denomLinear =  $studDen->D()->D() == Compute(0);
    $self->setMessage(2,"The denominator must be linear") unless $denomLinear;

    my $result = $studentAns == $correctAns && $denomLinear;

    return $result;

if ($displayMode eq 'TeX') {
  $showLimit =
  "\[ $limit  ".$limit5->ans_rule(10).$limit5->ans_rule(10)." \]";
} else {
  $showLimit =
  "\( \displaystyle $limit \)",
  indent => 0, separation => 10, valign => "MIDDLE"

{ name=>"5: Rewrite and apply L'Hopital's Rule Again", 
    canshow =>$scaffold->requireCorrect(7,8,9). " or $isInstructor",
},   <<'END_SECTION'); 

You found the limit in the previous section to be

\[ $limit \frac{$top2}{$bottom2} \]

Rewrite this into the form where the bottom is a linear function and the top has trigonometric functions.  (Note: do not apply L'Hopital's Rule)

In reply to Peter Staab

Re: MultiAnswer oddity

by Michael Gage -
This is not a direct reply to your post, but don't expect compoundProblems5/Scaffold and MultiAnswer to always work smoothly together.  They both change the names of answer blanks around and not always in ways that work together.  John Travis and I ran into this while working on some sample questions at Asheville.  The Scaffolding code needs some more work and possibly a new idea to work smoothly with multianswer.  So far compoundProblems5 has worked well with arrays.
In reply to Michael Gage

Re: MultiAnswer oddity

by Peter Staab -
Thanks Mike.  If I get a chance, I'll look at the code for the two of them.  I have a simple compoundProblem with multiAnswer that works, but the one I mentioned has 6 sections, and maybe something this large is the problem.