WeBWorK Problems

MathObjects and change of variables

Re: MathObjects and change of variables

by Chrissy Safranski -
Number of replies: 0
I kept trying and found a workaround for my chief question, (last line of my code below), but it seems to me like something that ought to be fixed with the FormulaUpToConstant answer checker.  

I also figured out that I could get my "Test Message" when I typed 5u+C, which makes sense, because FormulaUpToConstant adds the +C if you don't type it.  I tried using a subroutine instead, and got an error because it was trying to compare a formula with a FormulaUpToConstant, which also makes sense.  Ideally, I'd be able to check if the only difference between the student answer and the correct answer was the +C, but the FormulaUpToConstant answer checker seems to check for +C first, and I don't know enough about it to mess with it any more.  

Of course, if students are persistent and observant, the checker already tells them that.  From my experimentation, it seems that if the submitted answer is wrong and without a +C then the message is "Note: there is always more than one possibility." However, if their submitted answer is correct except for no +C then the message is "Your answer is not the most general solution."

-----------------------------------
ANS($intg->cmp(limits=>[9,10],showLinearityHints => 0)-> withPostFilter(AnswerHints(
 sub {
    my ($correct,$student,$ans) = @_;
    return Value::isFormula($student) && ($student->{variables}{x} || $student->{variables}{dx} || $student->{variables}{du});
  } => [
    "This is after integrating with respect to 'u', so your answer here should be in terms of 'u' and should not include 'du' (or 'x' or 'dx').",
    checkCorrect => 1, score => 0
  ], 
 sub {
    my ($correct,$student,$ans) = @_;
    return Value::isFormula($student) && not($student->{variables}{u});
  } => [
    "Your answer needs to include 'u' in it.",
    checkCorrect => 1, score => 0
  ],
 $intg=>["", checkCorrect => 1, score => 1, replaceMessage=>1],
)));

------------------------------------