WeBWorK Problems

Can't call method "strings" on an undefined value

Can't call method "strings" on an undefined value

by Bruce Yoshiwara -
Number of replies: 1

I have four popups with identical entries for choices. When the string “0, 2” or “2, 3” is selected in any of the popups, the “Can't call method "strings" on an undefined value”. So why do these pairs (that do not start with a negative) cause difficulties, and why don't “-1, 2” or “-2, 2” (or “negative, positive”) cause problems?

$popup1 = PopUp(["?", "-1, 2", "0, 2", "2, 3", "-2, 2"], "0, 2");

$popup2 = PopUp(["?", "-1, 2", "0, 2", "2, 3", "-2, 2"], "-1, 2");

$popup3 = PopUp(["?", "-1, 2", "0, 2", "2, 3", "-2, 2"], "-2, 2");

$popup4 = PopUp(["?", "-1, 2", "0, 2", "2, 3", "-2, 2"], "2, 3");

ANS( $popup1->cmp() );

ANS( $popup2->cmp() );

ANS( $popup3->cmp() );

ANS( $popup4->cmp() );

These are just unordered pairs of numbers, and I'm avoiding set notation.

In reply to Bruce Yoshiwara

Re: Can't call method "strings" on an undefined value

by Davide Cervone -
I have modified the contextString.pl file (which is used by the parserPopUp.pl macros) to correct the issue. The problem was that the parser was looking for numbers before strings, and that matched "0, 2" and "2, 3" but not "-1, 2" or "-2, 2" because negation is an operator and not part of the number itself. (That is so that 5-2 is subtraction and not 5*(-2).)

You can get the updated contextString.pl from the CVS repoistory.

Davide