# [LON-CAPA-users] Custom Response is buggy on a particular problem

Seema Ali sali at vsb.bc.ca
Thu Nov 8 20:22:21 EST 2012

Sorry but I'm not sure how to test out the custom response, to be able to pin point why something isn't working.  I created a question and it works for most of the few test cases I went through, but it isn't working on one particular test case, which I put in the code.  Does anyone know why it isn't working?

The question randomly generates a binomial and divides it by a monomial.

I'm super stuck on this one and I don't know why.  I used similar custom response in other questions that seemed to be working.

Thanks.

>From Seema.

<problem>
<script type="loncapa/perl">
sub numbervariable
{
$expression = shift;$variable   = shift;
$temp = length($expression);
$expression =~ s/($variable)/~~/g;
return length($expression) -$temp;
}

$factor1 = &random(-1,1,2) * &random(2,12,1);$factor2 = &random(-1,1,2) * &random(2,12,1);
$factor3 = &random(-1,1,2) * &random(2,12,1);$product1 = $factor1 *$factor2;
$product2 =$factor1 * $factor3; #numerator exponents$e11 = &random(5,9,1);
$e12 = &random(5,9,1);$e21 = &random(5,9,1);
$e22 = &random(5,9,1); #denominator exponents$e31 = &random(0,5,1);
$e32 = &random(0,5,1); #testcase 1 not working$product1 = 24;
$e11 = 5;$e12 = 8;
$product2 = -72;$e21 = 7;
$e22 = 5;$factor1 = -6;
$e31=4;$e32=0;
#answer should be: 12*x^3*y^5-4*x*y^8, it worked once

$numerator = &cas('maxima', "$product1 * x^$e11 * y^$e12 + $product2 * x^$e21 * y^$e22");$denominator = &cas('maxima', "$factor1 * x^$e31 * y^$e32");$answer = &cas('maxima', "trigsimp(($numerator)/($denominator))");

$numerator =~ s/\*//g;$denominator =~ s/\*//g;</script><startouttext />Simpify.
<m eval='on'>
$\frac{numerator}{denominator}$
</m><br />

<customresponse answerdisplay="$answer"> <answer type="loncapa/perl">$userinput = $submission;$correct = $answer;$num_x = numbervariable($userinput,'x');$num_y = numbervariable($userinput,'y');$ans_x = numbervariable($correct,'x');$ans_y = numbervariable($correct,'y'); #$equivalent = &cas('maxima',"is(trigsimp(trigreduce($submission-$answer)=0))");
$equivalent = &cas('maxima',"is(trigsimp($submission=$answer))"); if(($num_x==$ans_x) && ($num_y==$ans_y) && ($equivalent eq "true")){ return 'EXACT_ANS'; }