Forum archive 2000-2006

Michael Gage - PG environment variables

Michael Gage - PG environment variables

by Arnold Pizer -
Number of replies: 0
inactiveTopicPG environment variables topic started 5/11/2000; 6:08:29 PM
last post 2/8/2001; 8:37:24 PM
userMichael Gage - PG environment variables  blueArrow
5/11/2000; 6:08:29 PM (reads: 3843, responses: 2)

PG environment variables

Vital state information

psvn (Problem set version number) is a number which identifies an individual problem set. This is the primary key in the record table defining the problem set.
A synonym for $psvn
Problem number. This number identifies the order in which this problem appears in the problem set.
Synonym for $probNum
The path to the template for this problem (relative to the template directory.)
A synonym for $fileName
The number used to initialize the random number generator. A problem seed is stored for each problem in each individualized problem set record. The template ($fileName) and seed ($problemSeed) completely determine the individual problem seen by the student. Changing the seed changes the coefficients in the problem. Using the same seed for all students gives them identical problems.
One of HTML (text mode), HTML_tth (formatted text mode) or Latex2HTML (typeset mode)
Obsolete synonym for $displayMode
Obsolete synonym for $displayMode

Problem Information

This information can be read, but altering it affects nothing outside the problem. The dates are guaranteed to be in ascending order.
Text string containing the date after which students will be able to view the problems.
Number representing the date in the unix system. This is useful for comparing dates.
Text string containing the due date of the problem set. After this date, answers are not recorded.
Number representing the date in the unix system. This is useful for comparing dates.
Text string containing the date the answers will be viewable by students .
Number representing the date in the unix system. This is useful for comparing dates.
The number of previous times this problem has been attempted. You can use this to trigger hints or other information.
A number (default is 1) representing the problem value within the set. Hard problems can be assigned a greater weight from the professor page.
A string which is used as the time limited "password" for this session. (A session lasts from the login until the student logs out, or the session logs out because of inactivity for more than a specified period of time (usually set to about 20 minutes). After a timeout, the student resumes by entering their password again, and a new session key is issued. One possible use of the session key is to generate the problem seed so that the student sees a new problem set with every session. This might be useful for using WeBWorK to administer gateway exams.

Student Information

A text string -- usually containing the name of the professor administering the lecture session.
A synonym for $sectionName
A text string -- usually containing the name of the TA administering the recitation session or the time and place of the recitation.
A synonym for $recitationName
A string identifying the set.
The student's login name. At the U of R this is usually the same as their user name for the campus e-mail system.
Text string containing the student's full name.
Text string containing the student's identification number.

Answer Information

A reference to a hash containing all of the inputs from the HTML form. This can be used to access the students answers. ($inputs_ref->{Answer1} will obtain the students answer to the answer rule labeled "Answer1".) This data is certainly tainted and should be used with great care.
Obsolete -- list of answers labeled with the default answer label (= AnSwEr ???). Use inputs_ref instead.

Default values for evaluating answers


Directories and URL's


<| Post or View Comments |>

userZbigniew Fiedorowicz - Re: PG environment variables  blueArrow
2/6/2001; 8:18:26 PM (reads: 2820, responses: 0)
Mike, Arnie,

You should document the fact that you can define your own environment variables in

See my post in the discussion list.


<| Post or View Comments |>

userMichael Gage - Creating your own PG environment variables  blueArrow
2/8/2001; 8:37:24 PM (reads: 3042, responses: 0)

Creating your own PG environment variables

Any element of the hash %Global::PG_environment will also be inserted as an environmental variable. These elements are most often defined in (Every variable in is implicitly in the package Global::, hence in that file you don't need to include the prefix., a statement such as

$PG_environment{NEW_ENVIRONMENT_VARIABLE} = 5000;

will be enough. )

This defines an environment variable $NEW_ENVIRONMENT_VARIABLE which can be used in any problem and which has the value of 5000.

You should use this feature cautiously. Because these PG_environment environment variables are the last ones defined, they can overwrite previously defined environment variables, and this might cause unexpected problems if it is done accidently.

Here are several environment variables commonly defined in

$PG_environment{'PRINT_FILE_NAMES_FOR'} = ['gage','apizer'];

is used by the macro beginproblem() defined in If the current users name is in this array reference, then beginproblem() prints out the name of the file containing the problem template, in addition to printing the number of points the problem is worth, and other information. This is very helpful for making corrections to the problem template.

$PG_environment{PROBLEM_GRADER_TO_USE} = 'std_problem_grader';

Defines the 'std_problem_grader' as the one to use in grading a problem, unless the problem explicitly asks that another problem be used.

This variable is used in the ENDDOCUMENT() mac