## WeBWorK Problems

### Including PGcourse.pl in all problems

by Louis Zulli -
Number of replies: 11

Is there any downside to including this macro in every problem?

If no, would someone with access to the OPL write a script that adds this macro call to all problems in the collection that don't already contain it?

Thanks.

### Re: Including PGcourse.pl in all problems

by John Jones -
Hi,

I don't have much of an opinion on whether PGcourse should be loaded every time a problem is translated.  It seems like a reasonable idea.

But, if there is a decision to load certain macros every time, I don't think it is a good idea to do it via a script which modifies OPL problems.  Changing webwork itself is a change in 1 place (maybe one could change loadMacros to always include PGcourse in the list).  If this turns out to be a mistake, it only needs to be reverted in one place.

Changing the OPL problems means changing it in over 20,000 places and no good paths for going back. Since some files already have it, you can't just delete it from every file, and you can't rely on git since there may have been many other OPL changes between the time this change is made and the time of the reversion.

John

### Re: Including PGcourse.pl in all problems

by Davide Cervone -
The problem with having it done in loadMacros() is that this may not be called only once. For example, some macro files load other macro files, so loadMacros() call can even be nested. PGcourse.pl is supposed to be the last macro file loaded, so that it can make changes to configuration for anything else that has been loaded, so getting that to work properly by modifying loadMacros() could be a bit complicated.

I think Louis is right, the place it really belongs is in the problem files.

On the other hand, there are some other ways to get something like PGcourses.pl without having it in every file. For example, the file parserCustomization.pl is loaded whenever MathObjects.pl is loaded, so you can use that for customization in any MathObject-basd problem.

### Re: Including PGcourse.pl in all problems

by John Jones -
I see, that does make it more troublesome.

On the other hand, there are fewer files in pg calling loadMacros than there are in the OPL.  loadMacros is just a wrapper to another function, so that may open the door.  I haven't thought this through, but it seems that the internal calls could be changed to a different wrapper function (for the sake of argument internalLoadMacros) which tells the loadMacro object that it is not the top level call.  Then of course, the loadMacro object appends PGcourse.pl to the end of the list only when it is the top-level call.

### Re: Including PGcourse.pl in all problems

by Louis Zulli -

Hi Davide,

Resurrecting an old thread. Do all problems in the OPL now properly load PGcourse.pl? That is, were all existing  OPL problems edited at some point to load this macro?

Best,

Louis

### Re: Including PGcourse.pl in all problems

by Glenn Rice -

I don't know if this was ever done.

I know that there are files in the library that do not load PGcourse.pl.  However, it seems that the only problems that don't do so are in the OpenProblemLibrary/UBC/MECH and OpenProblemLibrary/UBC/STAT directories.

There are also quite a few problems in the Contrib and Pending directories that don't load the macro.

### Re: Including PGcourse.pl in all problems

by Danny Glin -

I believe at some point John Jones added PGcourse.pl to all files in the OPL.  Likely the UBC directories you reference were contributions that happened after this was done.

The Contrib directory is not held to the same standard as the OPL, so I could see there being a lot of files there that are missing this.

Would it make sense (and be possible) to have PG automatically load PGcourse.pl even if it isn't explicitly loaded by the problem?  I don't immediately see a downside to this, as anyone using PGcourse.pl would be aware of it being loaded, and I would assume that they would want it loaded for all problems in their course.

### Re: Including PGcourse.pl in all problems

by Louis Zulli -

Thanks for the replies. As I've reviewed some of our local problem sets, I've noted a smattering of problems that failed to load PGcourse.pl.

### Re: Including PGcourse.pl in all problems

by Dick Lane -
My PGcourse.pl does several things:
a)  show a GetNewVersion button to a student after the student has earned full marks for the problem or after the assignment's dueDate
b)  show a GetNewVersion button to a TA or Professor at any time
c)  show a ShowProblemSource button to a TA or Professor at any time

There are several problems I use regularly despite their having no randomization:
Utah/Trigonometry/set11_Analytic_Trigonometry/p10.pg
Since there can be no new version of these problems, I would comment-out a loading of PGcourse.pl if it were in the source file.

Note: the snippet posted at
http://webwork.maa.org/wiki/Customize_Course
omits my initial lines

##  Note: 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.
sub _PGcourse_init {};          ####    Don't reload this file.

so Davide's comment about the possibility of loadMacros being used several times becomes more significant since my version would be loaded only on the first use of loadMacros (rather than being last on the last use of loadMacros).

The line
loadMacros( 'source.pl' ) if $observe ; was commented out when we used this PGcourse.pl for PREP-2011 but I use it because its display of a problem's coding is much easier to read than that in an editor (and this viewing is "safe" because no accidental change can be made). Since a student should never see the ShowProblemSource button and since an instructor might want it available for each problem, I suggest this be something settable in course.conf or localOverrides.conf provided the "if$observe" condition can be effective in that context.  (Qualification: privileged shell access is probably needed to put show_source.cgi into the course's html directory with execute permission.)

### Re: Including PGcourse.pl in all problems

by Dick Lane -
I've described my technical reasons for loading my PGcourse.pl in all problems I write.  My pedagogical goal for enabling controlled use of problemRandomize is to provide an opportunity for each student to reflect on their work for a particular task (usually involving more than a single step) and to self-identify where s/he might benefit from further practice with feedback.

WHAT are the main reasons other WeBWorK instructors/authors have for loading a PGcourse.pl file?

background:

There were some vague comments about "Show Me Another" after this summer's code-camp at Vancouver.  It was unclear whether they were knowledgeable or ignorant of what was already available [and the possibility of serving different pedagogical goals].  In any event, some of my colleagues have commented about wanting the ability to reveal an answer/solution after a few failed attempts --- Paul Pearson's PeriodicRerandomization.pl provides one way to deal with that (at the price of having relevant code in each problem's code).

In the short term, I am an enthusiastic advocate for managed use of problemRandomize in PGcourse.pl.  On the other hand, I suggest one of the upcoming "code-camps" focus on ideas about providing pedagogical options on a broader scale.  (Part of AnnArbor-2013 involved long-range design of data structure.  AIM-2007 produced some visionary ideas that are not yet implemented.)

FWiW:  the few non-randomized problems which I have used several times are on the "revise, randomize, write a solution" part of my ToDo list.

### Re: Including PGcourse.pl in all problems

by Alex Jordan -
We currently use PGcourse.pl for a similar reason that you do. We are also working on a module that is discussed here,which would eliminate the need to use PGcourse.pl this way.

John's concern about adding PGcourse.pl to the OPL problems is reversibility. How about a script that found each instance of "loadMacros(", found the next ");", and then after that, inserted a second loadMacros call:
"loadMacros("PGcourse.pl"); # inserted to all OPL problems 10/24/13"

A special string like that, with the comment to identify it, would make it easy for a mass text editor to remove such strings later.