From 313eb689f07eb2228207982e9103c8b84ca86aba Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sat, 25 Jan 2025 16:48:11 -0600 Subject: [PATCH] Fix a debugging messages in the `formatRenderedProblem` method. The `formatRenderedProblem` method of the `FormatRenderedProblem` module ensures that the `debug_messages` key of the rendered problem result is an array reference, but checks the wrong thing. It checks if the result itself is an array reference instead of the `debug_messages` hash key of the result. Since the result is always a hash reference and never an array reference, this means that the debugging messages from PG are always wiped out and replaced with a reference to an empty array. This was discovered when investigating https://github.com/openwebwork/webwork2/issues/2661. If we want to switch the PG problem editor to using the `debug` output format of the `formatRenderedProblem` method we could, but in order to get the benefit of that change we need this. --- lib/FormatRenderedProblem.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 4ac56a80d6..dfaa1f977e 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -187,8 +187,8 @@ sub formatRenderedProblem { if $ws->c->current_route eq 'render_rpc' && ($ws->c->param('displayMode') // '') eq 'PTX'; } - # Make sure this is defined and is an array reference as saveGradeToLTI might add to it. - $rh_result->{debug_messages} = [] unless defined $rh_result && ref $rh_result eq 'ARRAY'; + # Make sure $rh_result->{debug_messages} an array reference as saveGradeToLTI might add to it. + $rh_result->{debug_messages} = [] unless ref $rh_result->{debug_messages} eq 'ARRAY'; $forbidGradePassback = 1 if !$forbidGradePassback && !$submitMode;