From a8478b2e5b2ba8d045e2d214a38d6a13b262d67d Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 15 Sep 2023 19:31:06 -0500 Subject: [PATCH] Move answer stringification after content post processing. This is so that the content post processor methods have access to the full answer objects. This gives this approach a whole lot more power than the (soon to be eliminated) results table has. --- lib/WeBWorK/PG.pm | 1 + lib/WeBWorK/PG/Translator.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/WeBWorK/PG.pm b/lib/WeBWorK/PG.pm index 87880142f..e535e9bcf 100644 --- a/lib/WeBWorK/PG.pm +++ b/lib/WeBWorK/PG.pm @@ -173,6 +173,7 @@ sub new_helper ($invocant, %options) { } $translator->post_process_content; + $translator->stringify_answers; # HTML_dpng uses an ImageGenerator. We have to render the queued equations. if ($image_generator) { diff --git a/lib/WeBWorK/PG/Translator.pm b/lib/WeBWorK/PG/Translator.pm index e8440e88c..bf1ba8fa1 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 @@ -1059,7 +1060,6 @@ sub grade_problem { use strict; die $@ if $@; - $self->stringify_answers; return ($self->{rh_problem_result}, $self->{rh_problem_state}); }