Hi,

I'm modifying (well, fixing) an NPL problem on exact equations (Library/274/Exact/prob4.pg if you're curious), which first asks for the partials, then either asks for the solution, or the student to type "Not Exact" if the original equation isn't exact.

Here's the code snippet:

Context()->strings->add("Not Exact"=>{});

...

if($exact) {$ans = $f;}

else {$ans = Compute("Not Exact");}

ANS($ans->cmp());

When the equation is exact, everything works. The student can enter a function, or the string "Not Exact" (which is marked wrong with no error message).

The problem arises when the function is not exact. In this case the system expects a string. If a function is entered, the student gets the message "Your answer isn't a number (it looks like a formula that returns a number)".

So what I want to know is: Is there a way to have a string be the correct answer, but still allow functions to be submitted as answers (without an error message)?

http://webwork.maa.org/wiki/StringsInContext

I can't remember exactly where, but I thought I had seen something similar to this in another problem. This is what I found when I did a quick search.

- Brian

D. Brian Walton

James Madison University

The solution is

ANS($ans->cmp(typeMatch=>Formula("x*y")));

This way it still gives errors if the student answer isn't either an allowable string or a function of x and y.

Thanks.

This should turn off the error message:

ANS($answer ->cmp(showTypeWarnings=>0));

--rac