## WeBWorK Problems

### Problems with NAU Graph exercises

by Douglas Brown -
Number of replies: 6
I have been using some Graph Theory problems from NAU, however after upgrading to 2.11 many have stopped working. They are all exercises which require entering a string to represent a circuit. The common error message is:

### Warning messages

• HASH(0x872f97cc) is not an answerHash in queue evaluator
• HASH(0x872f97cc) is not an answerHash in queue post_filter

### Error messages

Can't call method "error_flag" on unblessed reference at /opt/webwork/pg/lib/WeBWorK/PG/Translator.pm line 1230

### Call stack

The information below can help locate the source of the problem.

• in WeBWorK::PG::Local::new called at line 50 of /opt/webwork/webwork2/lib/WeBWorK/PG.pm
• in WeBWorK::PG::new called at line 910 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
• in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 184 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
• in WeBWorK::ContentGenerator::go called at line 382 of /opt/webwork/webwork2/lib/WeBWorK.pm
The problem code follows:

DOCUMENT();

"PGnauGraphtheory.pl"
);

COMMENT('Plots the graph in the answer.');

TEXT(&beginproblem);
$showPartialCorrectAnswers = 1;$size = random(4,6,1); # number of vertices
$letters = join '', 'A'..'Z';$offset = random(0,25 - $size, 1);$labels = substr $letters,$offset, $size ;$vertices = GRvertices_labels_size($labels,$size);
$graph = GRgraph_size_random($size,0.43);
$edges = GRedgesstr_graph_labels($graph,$labels);$edgestex = GRtex_braces($edges); @degrees = GRdegrees_graph($graph);
$degreesstr = join ', ' , @degrees; ##############################$evalfunc = sub {
my $orig_in = shift; my ($in, $pic,$view, $intex,$score, $graphin, @degreesin,$degreesinstr);
if ($orig_in eq ''){$score = 0;
$view = '';$message = '';
} else {
$graphin = GRgraph_size_labels_edgesstr($size,$labels,$orig_in);
$pic = GRpic_graph_labels($graphin, $labels);$in = GRedgesstr_graph_labels($graphin,$labels);
$pic->gifName($pic->gifName()."-$in");$view = Plot($pic);$intex = GRtex_braces($in); @degreesin = &GRdegrees_graph($graphin);
$degreesinstr = join ', ' , @degreesin;$score = ($degreesinstr eq$degreesstr);
}

my$ans_hash = { score =>$score,
correct_ans => $edges, student_ans =>$view,
preview_latex_string => $intex, # original_student_ans =>$orig_in,
ans_message => ($score) ? '' :$message
};
};

BEGIN_TEXT
$PAR Construct a simple graph with vertices $$vertices$$ whose degrees are$degreesstr

$PAR What is the edge set? \{ ans_rule(70) \} END_TEXT ANS($evalfunc);

ENDDOCUMENT();

Any help will be greatly appreciated. Thanks,
Doug

### Re: Problems with NAU Graph exercises

by Tim Alderson -
Same issue here...Did you find any solution?

### Re: Problems with NAU Graph exercises

by Douglas Brown -
Not yet - at this point in the semester, this will be on the summer to-do list if I haven't heard from anyone. If I get a solution, I'll let you know.

### Re: Problems with NAU Graph exercises

by Davide Cervone -
Note that the warning messages are indicating that something isn't an AnswerHash, so that is the first thing to look into. The problem is that the custom answer checker that you are using isn't returning an AnswerHash, but instead is returning a plain hash that has some of the keys of an AnswerHash.

Instead, you should create a new AnswerHash object and sets its keys and values and return that. Something like

my $ans_hash = new AnswerHash;$ans_hash->setKeys(
score => $score, correct_ans =>$edges,
student_ans => $view, preview_latex_string =>$intex,
# original_student_ans => $orig_in, ans_message => ($score) ? '' : $message ); return$ans_hash;

should do the trick.

### Re: Problems with NAU Graph exercises

by Tim Alderson -
That did it for me...Thanks so much Davide!

Tim.

### Re: Problems with NAU Graph exercises

by Nandor Sieben -
Could you send me the fixed pg files so that I can update the OPL.

### Re: Problems with NAU Graph exercises

by Katie Johnson -
This fix worked well for me until this semester. Now, it's throwing the following error:

## WeBWorK error

An error occured while processing your request. For help, please send mail to this site's webmaster (root@localhost), including all of the following information as well as what what you were doing when the error occured.

Wed Jan 16 15:55:11 2019

### Warning messages

• HASH(0x5642ce8be888) is not an answerHash in queue evaluator
• HASH(0x5642ce8be888) is not an answerHash in queue post_filter

### Error messages

Can't call method "error_flag" on unblessed reference at /opt/fgcuww/pg/lib/WeBWorK/PG/Translator.pm line 1230

### Call stack

The information below can help locate the source of the problem.

• in WeBWorK::PG::Local::new called at line 50 of /opt/fgcuww/webwork2/lib/WeBWorK/PG.pm
• in WeBWorK::PG::new called at line 923 of /opt/fgcuww/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
• in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 184 of /opt/fgcuww/webwork2/lib/WeBWorK/ContentGenerator.pm
• in WeBWorK::ContentGenerator::go called at line 382 of /opt/fgcuww/webwork2/lib/WeBWorK.pm

### Request information

Method POST
URI /webwork2/12413012019/IV-Graph_Theory_HW_1/6/