From 2f3536fe5dfc3e6756cd49fc5c2515662839b9cd Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Mon, 17 Aug 2026 11:13:02 -0600 Subject: [PATCH] Fix bug in problemRandomize hardcopy. When generating hardcopy with a problem using problemRandomize, `$input_ref` doesn't contain the `user` or `effectiveUser` keys, which causes an error when trying to compare them. Only compare if `user` and `efficitveUser` are equal in the case `effectiveUser` is a defined key in `$input_ref`. Fixes #1515. --- macros/deprecated/problemRandomize.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macros/deprecated/problemRandomize.pl b/macros/deprecated/problemRandomize.pl index a71eab249..7ea9474b9 100644 --- a/macros/deprecated/problemRandomize.pl +++ b/macros/deprecated/problemRandomize.pl @@ -166,8 +166,10 @@ sub new { when => "correct", onlyAfterDue => 1, style => "Button", - styleName => - ($main::inputs_ref->{effectiveUser} ne $main::inputs_ref->{user} ? "checkAnswers" : "submitAnswers"), + styleName => ( + !$main::inputs_ref->{effectiveUser} + || ($main::inputs_ref->{effectiveUser} ne $main::inputs_ref->{user}) ? "checkAnswers" : "submitAnswers" + ), label => undef, buttonLabel => $main::PG->maketext("Get a new version of this problem"), checkboxLabel => $main::PG->maketext("Get a new version of this problem"),