/home/jaubrey/webwork//pg_TRUNK/lib/PGloadfiles.pm

From WeBWorK

Jump to: navigation


loadMacros

        loadMacros(@macroFiles)

loadMacros takes a list of file names and evaluates the contents of each file. This is used to load macros which define and augment the PG language. The macro files are searched for in the directories specified by the array referenced by $macrosPath, which by default is the current course's macros directory followed by WeBWorK's pg/macros directory. The latter is where the default behaviour of the PG language is defined. The default path is set in the global.conf file.

Macro files named PG.pl or IO.pl will be loaded with no opcode restrictions, hence any code in those files will be able to execute privileged operations. This is true no matter which macro directory the file is in. For example, if $macrosPath contains the path to a problem library macros directory which contains a PG.pl file, this file will be loaded and allowed to engage in privileged behavior.

Overloading macro files

An individual course can modify the PG language, for that course only, by duplicating one of the macro files in the system-wide macros directory and placing this file in the macros directory for the course. The new file in the course's macros directory will now be used instead of the file in the system-wide macros directory.

The new file in the course macros directory can by modified by adding macros or modifying existing macros.

Modifying existing macros

Modifying macros is for users with some experience.

Modifying existing macros might break other standard macros or problems which depend on the unmodified behavior of these macors so do this with great caution. In addition problems which use new macros defined in these files or which depend on the modified behavior of existing macros will not work in other courses unless the macros are also transferred to the new course. It helps to document the problems by indicating any special macros which the problems require.

There is no facility for modifying or overloading a single macro. The entire file containing the macro must be overloaded.

Modifications to files in the course macros directory affect only that course, they will not interfere with the normal behavior of WeBWorK in other courses.

sourceAlias

        sourceAlias($path_to_PG_file);

Returns a relative URL to the source.pl script, which may be installed in a course's html directory to allow formatted viewing of the problem source.