WeBWorK Problems

how to make custom list_checker?

how to make custom list_checker?

by Joseph Pedersen -
Number of replies: 1

I made a problem for which I would like either List(0,1,5,INF) or List(0,1,5,5,INF) to be acceptable solutions.  I tried to write my own custom list checker based on what I read here:

https://webwork.maa.org/wiki/Custom_Answer_Checkers_for_Lists

However, when my code wasn't working, I tried to start with the simplest possible version - a custom list_checker that marks every answer correct, and even that is not working, so apparently I am misunderstanding something fundamental, and I cannot figure out what.

Here's my code:

DOCUMENT();

loadMacros(

    "PGstandard.pl",    # Standard macros for PG language

    "PGML.pl",          # PGML markup and Math Objects

    "PGcourse.pl",      # Customization file for the course

);

$ans1 = List(0, 1, 5, INF);

$ans2 = List(0, 1, 5, 5, INF);

sub mycheck1 {

  my ($correct,$student,$ansHash,$value) = @_;

  $result = ($ans1 == $correct || $ans2 == $correct);

  return ($result, ());

}

BEGIN_PGML

I want either (0, 1, 5, INF) or (0, 1, 5, 5, INF) to be accepted as correct, but first I'm trying to make ANY ANSWER correct.

[_]{$ans1->cmp( list_checker=> sub{return (1, ());} );}

END_PGML

ENDDOCUMENT();

In reply to Joseph Pedersen

Re: how to make custom list_checker?

by Joseph Pedersen -

Oh, I see now... the score returned by the custom checker for Lists is divided by the length of the List it was applied to.

I must have skimmed over "The list_checker should return an array consisting of the number of student entries that are correct" too quickly.  I just assumed the return value was the score, like in other custom checkers I have written.