## WeBWorK Main Forum

### Regenerate a Problem After Submission

by Patrick Spencer -
Number of replies: 6
Is there a way to set WW up so students can regenerate a problem after it's been submitted (for extra practice)? Some people have requested this at our school. We use the PeriodicRandomization.pl script.

Thank you!
Patrick Spencer

### Re: Regenerate a Problem After Submission

by Alex Jordan -
Currently this is done with problemRandomize.pl, and it can do exactly what you want. Personally, I think that there is a down side to this in that you have to either:
• write problemRandomize.pl into the .pg file, and then you are making a choice for future instructor users of that problem who don't know how to edit problems.
• use PGcourse.pl as Davide suggests here. This is pretty cool but it does rely on PGcourse.pl being written into the .pg file, which it should be, but is often missing.

There will also be the Show Me Another feature in a future release. Based on this post and another related recent post, I eventually plan to enhance Show Me Another so that it can be configured to work in the way you have asked about.

### Re: Regenerate a Problem After Submission

by Patrick Spencer -
I should clarify a little bit. I meant to say I would like students to be able to regenerate the problem after the due date has passed or after the maximum number of submissions have been reached.

It's ok with me if we have to include problemRandomize.pl of PGCourse.pl in the problem file.

Which release is the show me another feature in?

### Re: Regenerate a Problem After Submission

by Alex Jordan -
problemRandomize.pl offers the option to allow this after the due date and/or after the student has full credit.

If you can get access to the variable that counts how many attempts have been used, you could wrap a loadMacros("problemRandomize.pl") inside a conditional that uses this. I'm not sure how you access that variable though.

### Re: Regenerate a Problem After Submission

by Patrick Spencer -
What do you mean "wrap a loadMacros("problemRandomize.pl") inside a conditional"? I thought load macros were called at the beginning of the problem files.

I'm still a little confused about how to go about implementing this feature. Would I have to edit problemRerandomize.pl?

### Re: Regenerate a Problem After Submission

by Alex Jordan -
loadMacros is a subroutine that loads the macro files that you tell it to. It should be used at the beginning of the pg file right after the DOCUMENT command, but you can use it more than once.

So I was referring to adding a line like:
if ($attemptsUsed > 2) {loadMacros("problemRandomize.pl");} But I do not know how to access a variable like$attemptsUsed or something like that. (And now that I write it down, I think the conditional should be wrapped around the ProblemRandomize() command:
if (\$attemptsUsed > 2) {ProblemRandomize();}
).

The problemRandomize.pl documentation is linked above. In there, it shows you how to apply its options. One of them is:

ProblemRandomize( onlyAfterDue=> 0 );

(For some reason the post is inserting an 'X' character that I cannot make go away. That 'X' should not be there) which would only grant access to the randomization button once the student has the problem correct, regardless of when the due date is. There are more options explained in the linked documentation.