WeBWorK Problems

Code for perl functions

Code for perl functions

by Mike O'Sullivan -
Number of replies: 1
We have been writing problems for discrete mathematics and have created some functions in perl: e.g.
1) a factorization function
2) a function to get the exponents appearing in a factorization
3) the number of divisors function
4 set operation functions.
It is our understanding that these type of functions are not in the WebWork macros typically loaded at the beginning
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl"

We use the functions in several different problems, and don't want to have to include the code in all of them.

For our own purposes we can put the functions in a local directory and load them. But, if we create a library for others to use they may encounter difficulties setting up their own local directory for the perl code.

Any suggestions?

Mike O'Sullivan, Tom Schmidt


In reply to Mike O'Sullivan

Re: Code for perl functions

by Arnold Pizer -
Hi Mike and Tom,

If you look at 
/opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary/macros
you will see the directories
CollegeOfIdaho/
Dartmouth/
FortLewis/
Michigan/
NAU/
TCNJ/
Union/
WHFreeman/

These contain macro files used in problems contributed by the named institutions.  Of course a problem using the macros has to load the necessary files(s).  In order for WeBWorK to find the files, in defaults.config you will see the code:
   $pg{directories}{macros},
   "$courseDirs{templates}/Library/macros/Union",
   "$courseDirs{templates}/Library/macros/Michigan",
   "$courseDirs{templates}/Library/macros/CollegeOfIdaho",
   "$courseDirs{templates}/Library/macros/FortLewis",
   "$courseDirs{templates}/Library/macros/TCNJ",
   "$courseDirs{templates}/Library/macros/NAU",
   "$courseDirs{templates}/Library/macros/Dartmouth",
   "$courseDirs{templates}/Library/macros/WHFreeman",

If you contribute your problems to the OPL, we could add your macros to the above.  If you want to set up you own server in a similar manner, I would suggest editing localOverrides.conf adding the above code from defaults.config plus whatever you call your new macros directory.

Arnie