WeBWorK Problems

Empty answer for GraphTool objects

Empty answer for GraphTool objects

by Nathan Warkentin -
Number of replies: 5

Good day!

I am trying to implement the new GraphTool MathObject in questions, and I would like to allow an empty graph as an answer. The current question that I am asking is "draw a parabola which is an odd function, if that's impossible then leave the graph blank."

In an archived thread - str_cmp no longer accepts an empty string as an answer. - it was discussed that that there's no viable use case for not differentiating between a blank answer and no attempt whatsoever. However, I think that GraphTools present exactly this case. There's no way to instruct the student to enter "none" in the answer blank because there isn't an answer blank.

I hope that, moving forward, the parser for GraphTools will allow blank answers, but in the meantime, is there a way for me to disable the prefilters for this answer checker? I tried the following line from the archived thread, but it did not work.

$cmp->install_pre_filter('erase');
Thank you in advance!
In reply to Nathan Warkentin

Re: Empty answer for GraphTool objects

by Glenn Rice -
You also need to do the grading in a post filter. I have attached an example of how this can be done.
In reply to Glenn Rice

Re: Empty answer for GraphTool objects

by Nathan Warkentin -
Thanks for the answer Glenn! Unfortunately, I copy-pasted your code into the relevant parts of my problem, and the grader seems to think there's no answer checker associated with the object. I am afraid that I am not knowledgeable enough about the underlying mechanics of filters and answer checking to troubleshoot this.

I will add that your code works when it's isolated in its own problem, but I cannot fathom what about my implementation represents a substantial deviation. I apologize for not being savvy enough to figure this out myself.

Here is the code I tried (I left out the $oddChecker and $neitherChecker subs because they're irrelevant and work as intended). I believe that the relevant portions are identical to your example, but I still get the "No answer evaluator for the question labeled: AnSwEr0003" error when viewing the problem. In case it matters, the server is running version 2.16, not 2.17.
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"PGcourse.pl",
"parserGraphTool.pl", # use custom answer checker to mark diff point choices
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

Context("Numeric");

$graph0 = GraphTool("{parabola,solid,vertical,(0,0),(1,1)}")->with(cmpOptions => { checker => $evenChecker });
$graph2 = GraphTool("{parabola,solid,vertical,(1,0),(2,1)}")->with(cmpOptions => { checker => $neitherChecker });

# Some shenanigans are required in order to allow a blank graph to be marked correct
$gt = GraphTool()->with(
     bBox => [-20, 20, 20, -20],
     ticksDistanceX => 4, ticksDistanceY => 4,
     minorTicksX => 3, minorTicksY => 3,
     ariaDescription => 'Graph a parabola that represents an odd function.',
     cmpOptions => { list_checker => sub { return 0; } }
);

my $cmp = $gt->cmp->withPreFilter('erase')->withPostFilter(sub {
     my $ans = shift;
     $ans->{score} = 1 if $ans->{student_value} eq '';
     return $ans;
});

######################################################################
BEGIN_PGML
If possible, draw parabolas (using a solid line) which satisfy each of the following conditions individually. If it is impossible to satisfy a condition, just leave the graph empty.

a. A parabola which is an even function
[_]{$graph0}

a. A parabola which is an odd function
[@ $gt->ans_rule @]*

a. A parabola which is neither even nor odd
[_]{$graph2}
END_PGML

LABELED_ANS($gt->ANS_NAME, $cmp);
######################################################################

ENDDOCUMENT();
In reply to Nathan Warkentin

Re: Empty answer for GraphTool objects

by Glenn Rice -

The issue is with the labeled answers and order or something or other.  I am not entirely certain what causes the issue I admit.  However, if you insert all of the answers in the same way, then it works.  I have attached a version that does this.

In reply to Glenn Rice

Re: Empty answer for GraphTool objects

by Nathan Warkentin -

Thank you again, Glen! I started implementing WeBWorK just a couple years ago and have always used the PGML answer checker style, so I am deeply unfamiliar and uncomfortable with the old style. I've been forced to use them for complicated checkers regarding series convergence, but it was all kludgey and I didn't really bother trying to gather takeaways about their ins-and-outs.

Anyway, thanks again!

In reply to Nathan Warkentin

Re: Empty answer for GraphTool objects

by Glenn Rice -
I also use PGML. PGML does not have different answer checker's though, so I am not entirely certain what you mean.