Skip to content

Use Translator versions of problem graders instead of PGanswermacros.pl versions. - #1548

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:use-translator-graders
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:use-translator-graders

Conversation

@drgrice1

Copy link
Copy Markdown
Member

Instead of the ENDDOCUMENT method setting the PROBLEM_GRADER_TO_USE flag to the avg_problem_grader or std_problem_grader methods from the PGanswermacros.pl file (in the case that macro is loaded, or generally if those methods are defined), the PROBLEM_GRADER_TO_USE environment variable value is simply transferred to the corresponding flag at that time. Then the code in WeBWorK::PG that already exists for this takes care of choosing the WeBWorK::PG::Translator versions of those methods instead. If the install_problem_grader method is used to set the problem grader to code, that is still used as before.

The std_problem_grader code is cleaned up and synchronized in both the WeBWorK::PG::Translator package and in the PGTanswermacros.pl file, although the code in the latter will no longer be used.

The POD for both the std_problem_grader and avg_problem_grader methods is also copied into the WeBWorK::PG::Translator package.

This is the last thing that is needed to make everything in the PGanswermacros.pl either deprecated or unneeded.

This should work with all existing problems since the methods in the PGanswermacros.pl file and the methods in the WeBWorK::PG::Translator package are functionally the same. Note that those problems that load the PGanswermacros.pl macro (typically via loading PGstandard.pl) and then set the grader via install_problem_grader(~~&std_problem_grader) or install_problem_grader(~~&avg_problem_grader) will still be using the methods from the PGanswermacros.pl file.

If instead that macro is NOT loaded, and the grader is set with install_problem_grader('std_problem_grader') or
install_problem_grader('avg_problem_grader'), then the WeBWorK::PG::Translator versions will be used. That should be considered the modern way of doing this. Of course setting the avg_problem_grader is pointless since that is the default. The sample problems that mention using the std_problem_grader have been updated to use this approach. You should note that this approach of using the string instead of the method has actually always worked, and is how this should have been done along. It is much nicer than using the ~~& construct.

Comment thread lib/WeBWorK/PG/Translator.pm Outdated
@drgrice1
drgrice1 force-pushed the use-translator-graders branch 5 times, most recently from 15b16d1 to ad756a6 Compare September 27, 2026 15:53
…os.pl` versions.

Instead of the `ENDDOCUMENT` method setting the `PROBLEM_GRADER_TO_USE`
flag to the `avg_problem_grader` or `std_problem_grader` methods from
the `PGanswermacros.pl` file (in the case that macro is loaded, or
generally if those methods are defined), the `PROBLEM_GRADER_TO_USE`
environment variable value is simply transferred to the corresponding
flag at that time.  Then the code in `WeBWorK::PG` that already exists
for this takes care of choosing the `WeBWorK::PG::Translator` versions
of those methods instead.  If the `install_problem_grader` method is
used to set the problem grader to code, that is still used as before.

The `std_problem_grader` code is cleaned up and synchronized in both the
`WeBWorK::PG::Translator` package and in the `PGTanswermacros.pl` file,
although the code in the latter will no longer be used.

The POD for both the `std_problem_grader` and `avg_problem_grader`
methods is also copied into the `WeBWorK::PG::Translator` package.

This is the last thing that is needed to make everything in the
`PGanswermacros.pl` either deprecated or unneeded.

This should work with all existing problems since the methods in the
`PGanswermacros.pl` file and the methods in the `WeBWorK::PG::Translator`
package are functionally the same.  Note that those problems that load
the `PGanswermacros.pl` macro (typically via loading `PGstandard.pl`)
and then set the grader via `install_problem_grader(~~&std_problem_grader)`
or `install_problem_grader(~~&avg_problem_grader)` will still be using
the methods from the `PGanswermacros.pl` file.

If instead that macro is NOT loaded, and the grader is set with
`install_problem_grader('std_problem_grader')` or
`install_problem_grader('avg_problem_grader')`, then the
`WeBWorK::PG::Translator` versions will be used. That should be
considered the modern way of doing this. Of course setting the
`avg_problem_grader` is pointless since that is the default. The sample
problems that mention using the `std_problem_grader` have been updated
to use this approach.  You should note that this approach of using the
string instead of the method has actually always worked, and is how this
should have been done along.  It is much nicer than using the `~~&`
construct.
@drgrice1
drgrice1 force-pushed the use-translator-graders branch from ea68712 to 8b045b8 Compare October 6, 2026 13:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants