## WeBWorK Main Forum

### Where is the PGcourse.pl file?

by Murphy Waggoner -
Number of replies: 8
I want to make changes to the PGcourse.pl file so that there is a 'generate new version' button for problems, but I've never worked witht he PGcourse.pl file.

Is there one PGcourse.pl file per course or one for all courses?

I have looked in my files for my class and can't find a file named PGcourse.pl in templates or templates/macros.  Is there one there by default or do I just create it.

OR

Is there one for all courses?  If so, where do I find it.

Thanks,
Murphy

### Re: Where is the PGcourse.pl file?

by Arnold Pizer -
Hi Murphy,

You will find an essentially empty PGcousre.pl file in /opt/webwork/pg/macros/PGcourse.pl

If you want the same thing to happen for all courses, just edit that file and leave it there.  If you want different actions for different courses, copy that file to  /opt/webwork/courses/course_name/templates/macros/ and modify it to do what you want. E.g. see    http://webwork.maa.org/wiki/Customize_Course.

Note that when in a pg problem you load PGcourse.pl, it will first look for /opt/webwork/courses/course_name/templates/macros/PGcourse.pl and use that file if it finds it. If not, it will use the file /opt/webwork/pg/macros/PGcourse.pl

Hope this helps.

Arnie

### Re: Where is the PGcourse.pl file?

by Murphy Waggoner -
Thanks.  I wasn't finding any files in templates/macros at all and couldn't find a PCcourse.pl file in any other folders of my class.  Thanks for the information about both the scoping and customization webpage.

In fact, I do want to add code to let students regenerate the problem.  I had been doing this problem by problem for the ones I had written because I wasn't sure where the PGcourse.pl file went.

Now that I have the 'regenerate problem' code in the PGcourse.pl file, I am finding that very few of the problems in my Calc III course have PGcourse.pl loaded.  Since I link to those problems from the OPL, does this mean I have to save each of them to my own server and edit them?  This doesn't save me any work.

Suggestions?

### Re: Where is the PGcourse.pl file?

by Alex Jordan -
Hi Murphy,

Just in case you are interested, there is a newer alternative way to give students re-randomized problems. It doesn't have quite the same functionality as problemRandomize.pl. In some ways it offers less, and in some ways more. But it doesn't involve PGcourse.pl; it just involves Course Configuration. You have to have WeBWorK 2.10 or newer, so maybe it's out of reach for you for now.

Some of the details here are outdated already, but the overall gist is still good:
http://cmhugheswebwork.blogspot.com/2014/05/show-me-another-feature-for-webwork.html

And a video:

Alex

### Re: Where is the PGcourse.pl file?

by Alex Jordan -
I'm afraid that if an OPL problem doesn't load PGcourse.pl, then you are pretty much correct.

I've brought up a few times recently the possibility to run a script to see that every OPL problem loads PGcourse.pl. It would only be a problem if some people somewhere put nontrivial stuff in their PGcourse.pl, and for some problems in the OPL they have been assuming that PGcourse.pl is absent from the problem. But my own opinion is that to know that each and every OPL problem uses PGcourse.pl would be worth that risk. If there are instances of that issue, then the onus would be on those people to make a local copy that *removes* PGcourse.pl, or perhaps to write their PGcourse.pl in such a way that it can selectively not apply to some problems.

### Re: Where is the PGcourse.pl file?

by Davide Cervone -
I agree, I think adding PGcourse.pl to all problems would be a good thing. Perhaps I'll write the script to do it. (In fact, I have such a script, but it does a lot of other things, so I will need to remove that.)

### Re: Where is the PGcourse.pl file?

by Davide Cervone -
There actually is a terrible hack that you could do to get something that should work for all problems.

The idea is to tie into some other file that is called by all problems. PGbasicmacros.pl is one such file. The way to do it would be to make a copy of PGbasicmacros.pl and put it in your course templates/macros folder, and then rename it as PGbasicmcros-orig.pl. Then make a new file called PGbasicmacros.pl and put the line

    loadMacros("PGbasicmacros-orig.pl");

at the top pf the file. Then add whatever you would normally have put into PGcourse.pl to this new file.

As I said, it is a terrible hack, but can be useful in a pinch.

There are some files that are preloaded by WeBWorK (PG.pl is one), and so those can't be used in this way, but I'm pretty sure PGbasicmacros.pl isn't one of them.

### Re: Where is the PGcourse.pl file?

by Murphy Waggoner -
Thanks, Davide, Alex, Arnold and Dick,

We are on 2.9 but I've asked for a version update for over the holiday break.  That will allow others in the department, who aren't as coding-friendly to use the generate new version option.  Actually I have appreciated the course configuration options in general and this is a good addition.

Until then, I have taken advantage of Davide's hack option for my one course.  I hope I remember to unhack it later.