Header Files More Information

From WeBWorK_wiki
Jump to navigation Jump to search

There are two PG header files, the set header and the hardcopy header which give information about each individual assignment. The set header is displayed on the homework set screen to the right of the problem list. The hardcopy header is included in hardcopy output at the start of the problem set.

See Site Info, Login Info, Course Info for information on the somewhat related customizable files which are used to display information for the whole WeBWorK site, on a course login page and on a course front page.


In current versions of WeBWorK the default is to use the same file for both headers, webwork2/conf/snippets/setHeader.pg. This file is designed so that is renders in both HTML-based display modes (when used onscreen) and TeX mode (when used in hardcopy). However, some people prefer to use separate files since the information given, while often similar, is usually different (e.g. you probably want to list the Student Name on the hardcopy output, but not onscreen) and the output formats are different. Also while some people are happy using the default headers that come with the WeBWorK system, most will want to write either a default header to use with all their assignments or to write different headers for each assignment. We explain these options below.

Simple Sample Header Files

In the templates directory of each course the are three sample header files, ASimpleCombinedHeaderFile.pg, ASimpleHardCopyHeaderFile.pg and ASimpleScreenHeaderFile.pg. The default file webwork2/conf/snippets/setHeader.pg is similar to, but not identical, to ASimpleCombinedHeaderFile.pg. These are usable as is and hopefully it is clear from their names what they are used for. In addition there are header files for the Orientation set and other sets. All these files can be used as samples when creating your own. To see and edit them, go to the Hmwk Set Editor and click the number of problems to the right of the homework set name (or alternately, click the pencil and then click the set name under Edit All Set Data). The first item in the listing of possible header files is Use Default Header File. This is the header file which will be used if no other header file is selected

Default Header File

The Default Header Files are defined in the global.conf file. Usually global.conf is found in the /opt/webwork/webwork2/conf directory. This file is only editable by a WeBWorK administrator. The relevant pieces of code in global.conf are:

# The setHeader preceeds each set in hardcopy output. It is a PG file.
# This is the default file which is used if a specific files is not selected
$webworkFiles{hardcopySnippets}{setHeader}      = "$webworkDirs{conf}/snippets/setHeader.pg";  # hardcopySetHeader.pg",
#$webworkFiles{hardcopySnippets}{setHeader}     = "$courseDirs{templates}/ASimpleHardCopyHeaderFile.pg"; # An alternate default header file

and

# The set header is displayed on the problem set page. It is a PG file.
# This is the default file which is used if a specific files is not selected
$webworkFiles{screenSnippets}{setHeader}        = "$webworkDirs{conf}/snippets/setHeader.pg"; # screenSetHeader.pg"
#$webworkFiles{screenSnippets}{setHeader}       = "$courseDirs{templates}/ASimpleScreenHeaderFile.pg"; # An alternate default header file

If your WeBWorK administrator wants to make it relatively easy for all instructors to create their own default header files, all he or she has to do is to comment out the third lines above and uncomment the forth lines. If they prefer to do this, but make ASimpleCombinedHeaderFile.pg the default, they should comment out the third lines above and then add the lines

$webworkFiles{hardcopySnippets}{setHeader}     = "$courseDirs{templates}/ASimpleCombinedHeaderFile.pg";
$webworkFiles{screenSnippets}{setHeader}       = "$courseDirs{templates}/ASimpleCombinedHeaderFile.pg";

in the appropriate locations. If your WeBWorK administrator does not want to make this change, instructors can do the equivalent thing for their own course by editing the course.conf file.

Editing the course.conf File

To edit the course.conf file, go to the File Manager, click the "^" at the top to move up one level in the directory structure from the templates directory to your course directory, then select course.conf and click Edit. At the bottom of the file add the two lines

$webworkFiles{hardcopySnippets}{setHeader}     = "$courseDirs{templates}/ASimpleHardCopyHeaderFile.pg"; 
$webworkFiles{screenSnippets}{setHeader}       = "$courseDirs{templates}/ASimpleScreenHeaderFile.pg"; 

or, if you want to use the same file for both headers,

$webworkFiles{hardcopySnippets}{setHeader}     = "$courseDirs{templates}/ASimpleCombinedHeaderFile.pg";
$webworkFiles{screenSnippets}{setHeader}       = "$courseDirs{templates}/ASimpleCombinedHeaderFile.pg";

Then click 'Save'. Now the default header files for your course will be set to the above.

Editing the sample default header files

There are several ways to edit the default header files. To edit ASimpleHardCopyHeaderFile.pg, you can use the File Manager as above, or go to the Hmwk Set Editor and click the number of problems to the right of the homework set name (or alternately, click the pencil and then click the set name under Edit All Set Data). Then under Headers, click Edit it. To edit ASimpleScreenHeaderFile.pg or ASimpleCombinedHeaderFile.pg, you can do the above, or on the page where it is displayed, click Edit.

You own default header file(s)

Of course, if you prefer not to edit one of the sample files but to create and name your own, e.g. myScreenHeaderFile.pg, myHardcopyHeaderFile.pg, you can name them want you want and then in course.conf define

$webworkFiles{hardcopySnippets}{setHeader}     = "$courseDirs{templates}/myScreenHeaderFile.pg";
$webworkFiles{screenSnippets}{setHeader}       = "$courseDirs{templates}/myHardcopyHeaderFile.pg";

Note that the file should end with the .pg extension and "Header" should be part of the name if you want it to be listed by the Hmwk Set Editor in the dropdown list of all available header files.

Individual header files for each assignment

If you want individual header files for each assignment, create the file(s), e.g. set3ScreenHeader.pg in the templates directory (making sure Header is part of the name and the file ends in .pg), and then use the the Hmwk Set Editor to select the appropriate header file for each set. Your files will be listed in the drop down list of all available header files.

PG_environment Variables

Some people like to use PG_environment Variables in their header files. For information on this see e.g. TextbookSpecificMessages.