From f0a28af460cba4da1f325fe2ce978c33785bb38e Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Thu, 19 Jun 2025 08:55:22 -0700 Subject: [PATCH 1/4] Deprecate some more macros and set a warning if using. Include the rest of the Union macros in the deprecate and move the PGnumericevaluators out of deprecate because every problem loads it. In addition show a warning to instructors if a problem is using a deprecated macro. --- lib/PGloadfiles.pm | 8 +++++++- macros/{deprecated => answers}/PGnumericevaluators.pl | 0 macros/{misc => deprecated}/PGunion.pl | 0 macros/{misc => deprecated}/unionMacros.pl | 0 macros/{misc => deprecated}/unionMessages.pl | 0 macros/{misc => deprecated}/unionProblem.pl | 0 macros/{misc => deprecated}/unionUtils.pl | 0 7 files changed, 7 insertions(+), 1 deletion(-) rename macros/{deprecated => answers}/PGnumericevaluators.pl (100%) rename macros/{misc => deprecated}/PGunion.pl (100%) rename macros/{misc => deprecated}/unionMacros.pl (100%) rename macros/{misc => deprecated}/unionMessages.pl (100%) rename macros/{misc => deprecated}/unionProblem.pl (100%) rename macros/{misc => deprecated}/unionUtils.pl (100%) diff --git a/lib/PGloadfiles.pm b/lib/PGloadfiles.pm index af1c455512..083f45e928 100644 --- a/lib/PGloadfiles.pm +++ b/lib/PGloadfiles.pm @@ -53,6 +53,7 @@ package PGloadfiles; use strict; #use Encode(qw(encode decode)); use Exporter; + use PGcore; use WeBWorK::PG::Translator; use WeBWorK::PG::IO; @@ -117,7 +118,6 @@ sub loadMacros { # At this point the directories have been defined from %envir and we can define # the directories for this file ############################################################################### - while (@files) { $fileName = shift @files; @@ -145,6 +145,12 @@ sub loadMacros { unless ($macro_file_loaded) { warn "loadMacros: loading macro file $fileName" if $debugON; my $filePath = $self->findMacroFile($fileName); + my @dirs = split(/\//, $filePath); + warn "This problem uses the deprecated macro $filePath. It will continue to work but this macro " + . 'will be removed in a future version. This problem should be updated to remove this macro ' + . 'to work.' + if $dirs[ $#dirs - 1 ] eq 'deprecated' && $self->{envir}{isInstructor}; + #### (check for renamed files here?) #### warn "loadMacros: look for $fileName at |$filePath|" if $debugON; if ($filePath) { diff --git a/macros/deprecated/PGnumericevaluators.pl b/macros/answers/PGnumericevaluators.pl similarity index 100% rename from macros/deprecated/PGnumericevaluators.pl rename to macros/answers/PGnumericevaluators.pl diff --git a/macros/misc/PGunion.pl b/macros/deprecated/PGunion.pl similarity index 100% rename from macros/misc/PGunion.pl rename to macros/deprecated/PGunion.pl diff --git a/macros/misc/unionMacros.pl b/macros/deprecated/unionMacros.pl similarity index 100% rename from macros/misc/unionMacros.pl rename to macros/deprecated/unionMacros.pl diff --git a/macros/misc/unionMessages.pl b/macros/deprecated/unionMessages.pl similarity index 100% rename from macros/misc/unionMessages.pl rename to macros/deprecated/unionMessages.pl diff --git a/macros/misc/unionProblem.pl b/macros/deprecated/unionProblem.pl similarity index 100% rename from macros/misc/unionProblem.pl rename to macros/deprecated/unionProblem.pl diff --git a/macros/misc/unionUtils.pl b/macros/deprecated/unionUtils.pl similarity index 100% rename from macros/misc/unionUtils.pl rename to macros/deprecated/unionUtils.pl From 71cbbb83aa785ad4dcdc0492610102b497cb74ae Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Fri, 20 Jun 2025 20:11:44 -0700 Subject: [PATCH 2/4] Restore these macro. --- macros/{deprecated => answers}/weightedGrader.pl | 0 macros/{deprecated => parsers}/parserQuotedString.pl | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename macros/{deprecated => answers}/weightedGrader.pl (100%) rename macros/{deprecated => parsers}/parserQuotedString.pl (100%) diff --git a/macros/deprecated/weightedGrader.pl b/macros/answers/weightedGrader.pl similarity index 100% rename from macros/deprecated/weightedGrader.pl rename to macros/answers/weightedGrader.pl diff --git a/macros/deprecated/parserQuotedString.pl b/macros/parsers/parserQuotedString.pl similarity index 100% rename from macros/deprecated/parserQuotedString.pl rename to macros/parsers/parserQuotedString.pl From bc250eda710fbb73292545a4cab69825cca6cb69 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Fri, 20 Jun 2025 21:46:24 -0600 Subject: [PATCH 3/4] Save the list of deprecated macros in the PGloadfiles object. --- lib/PGloadfiles.pm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/PGloadfiles.pm b/lib/PGloadfiles.pm index 083f45e928..0985104cac 100644 --- a/lib/PGloadfiles.pm +++ b/lib/PGloadfiles.pm @@ -69,10 +69,11 @@ sub new { my $envir = shift; #pointer to environment hash warn "PGloadmacros must be called with an environment" unless ref($envir) eq 'HASH'; my $self = { - envir => $envir, - macroFileList => {}, # records macros used in compilation - macrosPath => '', - pwd => '', # current directory -- defined in initialize + envir => $envir, + macroFileList => {}, # records macros used in compilation + macrosPath => '', + pwd => '', # current directory -- defined in initialize + deprecated_macros => [], }; bless $self, $class; $self->initialize; @@ -145,11 +146,8 @@ sub loadMacros { unless ($macro_file_loaded) { warn "loadMacros: loading macro file $fileName" if $debugON; my $filePath = $self->findMacroFile($fileName); - my @dirs = split(/\//, $filePath); - warn "This problem uses the deprecated macro $filePath. It will continue to work but this macro " - . 'will be removed in a future version. This problem should be updated to remove this macro ' - . 'to work.' - if $dirs[ $#dirs - 1 ] eq 'deprecated' && $self->{envir}{isInstructor}; + my @dirs = split('/', $filePath); + push(@{ $self->{deprecated_macros} }, $dirs[$#dirs]) if $dirs[ $#dirs - 1 ] eq 'deprecated'; #### (check for renamed files here?) #### warn "loadMacros: look for $fileName at |$filePath|" if $debugON; From 4b796125e5c1922f66b68d5c0bdba7fa5f827df4 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Tue, 24 Jun 2025 15:47:10 -0400 Subject: [PATCH 4/4] revert to previous version of PGloadfiles --- lib/PGloadfiles.pm | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/PGloadfiles.pm b/lib/PGloadfiles.pm index 0985104cac..af1c455512 100644 --- a/lib/PGloadfiles.pm +++ b/lib/PGloadfiles.pm @@ -53,7 +53,6 @@ package PGloadfiles; use strict; #use Encode(qw(encode decode)); use Exporter; - use PGcore; use WeBWorK::PG::Translator; use WeBWorK::PG::IO; @@ -69,11 +68,10 @@ sub new { my $envir = shift; #pointer to environment hash warn "PGloadmacros must be called with an environment" unless ref($envir) eq 'HASH'; my $self = { - envir => $envir, - macroFileList => {}, # records macros used in compilation - macrosPath => '', - pwd => '', # current directory -- defined in initialize - deprecated_macros => [], + envir => $envir, + macroFileList => {}, # records macros used in compilation + macrosPath => '', + pwd => '', # current directory -- defined in initialize }; bless $self, $class; $self->initialize; @@ -119,6 +117,7 @@ sub loadMacros { # At this point the directories have been defined from %envir and we can define # the directories for this file ############################################################################### + while (@files) { $fileName = shift @files; @@ -146,9 +145,6 @@ sub loadMacros { unless ($macro_file_loaded) { warn "loadMacros: loading macro file $fileName" if $debugON; my $filePath = $self->findMacroFile($fileName); - my @dirs = split('/', $filePath); - push(@{ $self->{deprecated_macros} }, $dirs[$#dirs]) if $dirs[ $#dirs - 1 ] eq 'deprecated'; - #### (check for renamed files here?) #### warn "loadMacros: look for $fileName at |$filePath|" if $debugON; if ($filePath) {