diff --git a/lib/WeBWorK/PG.pm b/lib/WeBWorK/PG.pm index d3e5dc654c..a89fb374c3 100644 --- a/lib/WeBWorK/PG.pm +++ b/lib/WeBWorK/PG.pm @@ -173,9 +173,9 @@ sub new_helper ($invocant, %options) { ); } - # HTML_dpng uses an ImageGenerator. We have to render the queued equations. - # This must be done before the post processing, since the image tags output by the image generator initially - # include markers which are invalid html. Mojo::DOM will change these markers into attributes and this will fail. + # HTML_dpng uses an ImageGenerator. We have to render the queued equations. This must be done before the post + # processing, since the image tags output by the image generator initially include markers which are invalid html. + # Mojo::DOM will change these markers into attributes with values and this will fail. if ($image_generator) { my $sourceFile = "$options{templateDirectory}$options{sourceFilePath}"; $image_generator->render( @@ -185,6 +185,7 @@ sub new_helper ($invocant, %options) { } $translator->post_process_content if ref($translator->{rh_pgcore}) eq 'PGcore'; + $translator->stringify_answers; return bless { translator => $translator, diff --git a/lib/WeBWorK/PG/Translator.pm b/lib/WeBWorK/PG/Translator.pm index 21c8249811..931c99e59b 100644 --- a/lib/WeBWorK/PG/Translator.pm +++ b/lib/WeBWorK/PG/Translator.pm @@ -49,6 +49,7 @@ WeBWorK::PG::Translator - Evaluate PG code and evaluate answers safely my $rh_problem_result = $pt->grade_problem(%options); # grades the problem. $pt->post_process_content; # Execute macro or problem hooks that further modify the problem content. + $pt->stringify_answers; # Convert objects to strings in the answer hash =head1 DESCRIPTION @@ -1036,7 +1037,6 @@ sub grade_problem { use strict; die $@ if $@; - $self->stringify_answers; return ($self->{rh_problem_result}, $self->{rh_problem_state}); }