WeBWorK Main Forum

Allowing students to "reseed" problems

Allowing students to "reseed" problems

by Louis Zulli -
Number of replies: 4
A colleague is interested in allowing his students to solve multiple versions of problems, for extra practice with certain sorts of standard manipulations.

I've discovered the problemRandomize.pl macro, which seems to provide precisely the functionality my colleague wants. However, it seems he would need to edit the pg source file for each problem he wishes to use, to ensure that the macro is loaded and to call ProblemRandomize(). Or he could include the appropriate lines in his local PGcourse.pl, and hope that this macro is loaded in the problems he wants to use. Two questions:

1) Other than by including multiple copies of a problem in a problem set, is there a way for my colleague to achieve his goal without using the problemRandomize.pl macro?

2) Should loading of PGcourse.pl be considered a "best practice" that should be followed by all would-be problem authors?

In reply to Louis Zulli

Re: Allowing students to "reseed" problems

by Davide Cervone -
For (1), I don't know of any that don't involve writing code that would be effectively equivalent to that.

For (2), yes, I consider including "PGcourse.pl" as a best practice (it should be the LAST file loaded, though not all problems do that).

If the problems the colleague is interested in don't include PGcourse.pl, there are some other ways to handle it. For example, you could make a copy of PGstandard.pl in the course's templates/macros file, and add PGcourse.pl to the list of files it loads.

Of course, not all problems use PGstandard.pl, either. In that case, you could make a copy of something like PG.pl in the templates/macro file and add loadMacros("PGcourse.pl") to that, but you are not getting pretty hackish.

Note that all problems that use MathObjects should include MathObjects.pl, and that causes the parserCustomization.pl file to be loaded. The default parserCustomization.pl file is empty, so an alternative would be to make a parserCustomization.pl in templates/macros and do the randomization code there rathe than PGcourse.pl.

In reply to Louis Zulli

Re: Allowing students to "reseed" problems

by Dick Lane -
Source for problemRandomize.pl is in webwork/pg/macros; online documentation is at
This very useful macro was written by Davide Cervone.

Paul Pearson wrote PeriodicRerandomization.pl which he described in
with full source (including internal documentation) at

For my classes, problemRandomize is invoked via my PGcourse.pl (attached, with renewed thanks to Davide for his help improving it) which offers a "Get new version" button to a student either (a) after complete success before due-date or (b) after due-date [and never changes scoring for a student's performance which is always based on their original version].

I agree with Davide about "best practice" (since I'm in Montana, I get to say LAST and BEST ;-).  The usual path for loading macro files includes an identically-named file which does nothing; problem files which explicitly load PGcourse.pl will be usable by any course, independent of the course having its own version.
In reply to Dick Lane

Re: Allowing students to "reseed" problems

by Louis Zulli -

I looked at the "best practices" document at


but found no mention of PGcourse.pl. (I did note that the document is now quite old.)