WeBWorK Main Forum

undefined answers incorrectly marked correct

undefined answers incorrectly marked correct

by Gavin LaRose -
Number of replies: 2
Hi all,

This is with a WeBWorK installation that self-identifies as "Version 2.5.0+," but the behavior also appears to exist in 2.5.0beta. It appears that a student answer that evaluates to an undefined value on all points of the evaluation domain is marked correct regardless of the correct answer's value. My test problem is the following.

DOCUMENT();
loadMacros( "PG.pl", "PGbasicmacros.pl", "MathObjects.pl" );

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
Context("Numeric");
my $ans = "e^x";
my $fun = Compute($ans);

BEGIN_TEXT
Enter \($ans\): \{ ans_rule(25) \}
END_TEXT

ANS( $fun->cmp(diagnostics=>1) );

ENDDOCUMENT();

I submitted the answer (-e^2 + e^(x))^(1/2), which is everywhere undefined on the default domain [-2,2], and it is marked correct.

So: (1) It seems to me that this is undesirable behavior. Is there a flag to set somewhere that will work around this? And (2) Is it patched in later versions of WeBWorK? This isn't completely useful for me, in that later versions appear to be broken for my purposes, but if I can get a patched version of the appropriate code I can kludge together my production service for now.

Thanks,
Gavin

In reply to Gavin LaRose

Re: undefined answers incorrectly marked correct

by Davide Cervone -
Gavin:

It looks like the NAN results are getting past the MathObject check for not a number. It seems from the diagnostics that they are in upper case rather than the expected lower case, so perhaps changing the line

  return $self->inherit($other)->make($x) unless $x eq 'nan';
to
  return $self->inherit($other)->make($x) unless lc($x) eq 'nan';
in pg/lib/Value/Real.pm in the sub power function (around line 98) would resolve the problem. It doesn't occur for me, so it may be hardware or perl version dependent (I'm a little out of date with my installation at the moment).

You should probably also change the one in sub make around line 39. And the one in pg/lib/Parser/BOP/power.pm at around line 34.

Let me know if that does it.

Davide

In reply to Davide Cervone

Re: undefined answers incorrectly marked correct

by Gavin LaRose -
Hi Davide,

Thanks—I think that's the root of the problem. It appears to be resolved, in the sense of marking the answer correctly, with your fix plus the possibility lc($x) eq '-nan'.

That said, it marks the answer wrong without reporting an error, which seems odd. The only reason I can think this would happen is if the value being evaluated is raising an unreported error in the answer processing.

Thanks,
Gavin

p.s.: thus, my corrected code reads

  return $self->inherit($other)->make($x) unless lc($x) eq 'nan' || lc($x) eq '-nan';

in pg/lib/Value/Real.pm, lines around 98 and 39, and pg/lib/Parser/BOP/power.pm around line 34.