We use WeBWorK to generate randomized paper quizzes in some of our classes. This problem renders just fine on the web, but throws an error when we go to generate hardcopy. The error message is:

Odd number of elements in anonymous hash at line 75 of (eval 4063).

Problem source follows. You can see where I tried to fiddle with the variables hash on line 75 and where I tried using different Context or no Context. These did not help. Thanks in advance for any assistance.

##DESCRIPTION

## Absolute Value Equalites and Inequalities

##

##ENDDESCRIPTION

## DBsubject(Algebra)

## DBchapter(Absolute value expressions and functions)

## DBsection(Solving equations with absolute values)

## Institution(The College of Idaho)

## Author(RA Cruz)

## MLT(AbsVal3)

## MLTleader(1)

## Level(2)

## MO(1)

## TitleText1('Essentials of Intermediate Algebra')

## AuthorText1('Blitzer')

## EditionText1('1')

## Section1('.')

## Problem1('')

## KEYWORDS('inequalities','absolute value')

## Date: 2007/10

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"contextInequalitiesAllowStrings.pl",

#"contextInequalities.pl", # this didn't work any better

# can't leave out the context

"PGchoicemacros.pl"

);

TEXT(beginproblem());

######################################

# Setup

@letters = ("a", "b","g","p","q","t","w","x","y","z");

@pick = NchooseK(10,4);

$v0 = $letters[$pick[0]];

$v1 = $letters[$pick[1]];

$v2 = $letters[$pick[2]];

#$v3 = $letters[$pick[3]]; # trying to fix a bug dwr 2023-10-11

$a = list_random(-10,-9,-8,-7,-6,-5,-4,4,5,6,7,8,9,10);

$b = $a>0 ? random(-12,-2,1) : random(2,12,1);

$RequiredFormat = "Enter your answer in the form: ".

"${BITALIC}x=m.$EITALIC $BR For more than one answer: ".

"${BITALIC}x=m$EITALIC or ${BITALIC}x=n$EITALIC ".

"(include the word ${BBOLD}or$EBOLD between the solutions), ".

"or enter your answer as a set ${BITALIC}{m, n}${EITALIC}. $BR".

"For no solution, type ${BBOLD}No solution${EBOLD} and ".

"if all real numbers are solutions, ".

"type ${BBOLD}All real numbers${EBOLD}.";

######################################

# Main text

BEGIN_TEXT

Solve:

$PAR

(a) \( |$v0| = $a \)

$BR

Answer: \{ ans_rule(30) \}

$PAR

(b) \( |$v1| = $b \)

$BR

Answer: \{ ans_rule(30) \}

$BR

END_TEXT

######################################

# Answer

Context("Inequalities-AllowStrings");

Context()->variables->are($v0=>'Real',$v1=>'Real',$v2=>'Real');

#Context()->variables->are($v0=>'Real',$v1=>'Real',$v2=>'Real',$v3=>'Real');

Context()->strings->add(None=>{},"No solution"=>{None});

sub errMsg {

my $ans = shift;

$ans->{ans_message} = $RequiredFormat

if $ans->{ans_message} =~ /it looks like/;

return $ans;

}

$ans_a = ($a<0) ? Compute("No solution") : Compute("$v0=-$a or $v0=$a")->reduce;

ANS($ans_a->cmp->withPostFilter(~~&errMsg));

$ans_b = ($b<0) ? Compute("No solution") : Compute("$v1=-$b or $v1=$b")->reduce;

ANS($ans_b->cmp->withPostFilter(~~&errMsg));

$showPartialCorrectAnswers = 1;

###################################

# Solution

$display_a = ($a<0) ? "No solution" : "\($v0=-$a\) or \($v0=$a\)";

$display_b = ($b<0) ? "No solution" : "\($v1=-$b\) or \($v1=$b\)";

#Context()->texStrings;

BEGIN_SOLUTION

$PAR Solution: $BR $BR

(a) $display_a

$BR

(b) $display_b

END_SOLUTION

Context()->normalStrings;

ENDDOCUMENT();