## Forum archive 2000-2006

### Michael Gage - PG language

by Arnold Pizer -
Number of replies: 0
 PG language topic started 4/25/2000; 11:06:45 PMlast post 8/15/2000; 8:03:05 PM
Michael Gage - PG language
4/25/2000; 11:06:45 PM (reads: 15907, responses: 2)

### Intro to the PG language

Tutorial
Step-by-step introduction to the process of writing a problem and the basic types of problems. This covers all the essential PG macros. Shows how to use each of the various list objects useful for creating matching questions, true/false questions, and multiple choice questions that are intuitive to the students. Even covers the less tested idea of using Java or Javascript in your problems.

WeBWorK Newbie Guide
A Dartmouth College website, maintained and created by Prof. Tom Shemanske, covers many of the basics needed to understand and use the WeBWork system. It also contains several references on LaTeX that range from covering the essentials to being extremely comprehensive.

PG language basics
Basic PG language reference material. Covers some perl syntax necessary for understanding how to better manipulate data in problem. Also contains list of macros and basic references on managing answers and using answer evaluators.

PG reference documents
Primary reference documents. These are the comments taken directly from comments in the source code of all of the major macro files and PG packages. These comments tend to be somewhat technical and often terse but are usually the most up to date because they come directly from source itself.

manpages Detailed descriptions of individual macros. (under construction)

### PG overview

PG language stands for Problem Generating language. It is implemented as a suite of Perl macros. The underlying constructions are for the most part identical with those in Perl with the exception of the use of the backslash which is replaced by ~~ (see Perl basics below).

The parts of the problem description which require calculations are written in Perl. To avoid damage to the computer system, only a portion of the Perl language is available. Commands which write to disk and system commands are disabled.

Mathematical formulas are written using the syntax of LaTeX. Most commands in LaTeX start with a backslash and because of this, the backslash is reserved for LaTeX math formulas.

<| Post or View Comments |>

Michael Gage - PG language basics
8/15/2000; 7:57:01 PM (reads: 10560, responses: 0)

### PG basics

Basic Perl Syntax
Fortunately you only need a little knowledge of Perl in order modify or write problems for WeBWorK. If you know more, you can write very powerful macros. It's possible to outgrow many problem generating languages as you become more ambitious about the kind of math problems you'd like to present. This is unlikely to happen with PG because it is based on Perl, and allows you nearly full access to the constructs of that very powerful language.
The problem text
Details how The problem text is evaluated and printed when placed within the BEGIN_TEXT .... END_TEXT construction.

### Arithmetic functions in PG

Accepted math functions

( this doesn't yet have all of the latest macros -- check PGanswermacros.pl for more)
Describes some of the subroutines which can be used for checking the answers.

### Numerical methods

<| Post or View Comments |>

Michael Gage - PG advanced reference
8/15/2000; 8:03:05 PM (reads: 9960, responses: 0)

### PG language Reference

#### Specifications of data types

Each answer evaluator should accept a single input from the student and return an answer hash satisfying these specifications.
PG environment variables
A list of all of the variables that are predefined for a WeBWorK PG problem.
How to define additional environment variables in webworkCourse.ph using %PG_environment

#### Detailed descriptions of macros

These descriptions are intermixed with the code itself. They are likely to be somewhat technical and terse, but, since they are close to the actual code, they are also likely to be the most up-to-date and complete descriptions available.

Note: If your are accessing this page from webwork.math.rochester.edu, these descriptions may not be viewable. If not, connect to our dynamic site webhost.math.rochester.edu/webworkdocs to view the descriptions.

PGtranslator.pm
The main code for rendering PG problems is found here. There is an example showing the PGtranslator methods used in rendering a problem.
Macros in the file PG.pl
This macro file contains the macros which define the basic aspects of the Program Generating language. DOCUMENT(); TEXT(); HEADER_TEXT(); ANS(); ENDDOCUMENT;
Macros in the file dangerousMacros.pl
This implements macros that require access to disk files: alias, loadMacros,insertGraph,tth
As the name implies, this contains additional answer evaluators contributed by John Jones at Arizona State University.
Macros in the file PGasu.pl
Additional macros contributed by John Jones at Arizona State University.
This contains some details on how to use the basic answer evaluator factories -- num_cmp, str_cmp and function_cmp. This documentation, and the implementation of answer macros is due for redesign and streamlining this summer.
Macros in the file PGbasicmacros.pl
The majority of the commonly used macros are in this file, including ans_rule
Macros in the file PG_CAPAmacros.pl
Contains the runtime macros used to render files translated from the CAPA language. (Currently these are mostly physics problems.)
Macros in the file PGchoicemacros.pl
Describes the basic macros for implimenting matching lists and true false questions. For examples see the Matching list example and the True false example above. For more details look at the Match and Select packages described below. Some older macros which were used in the past to implement matching lists are also available, for backward compatibility.
Macros in the file PGcomplexmacros.pl
This describes some of the macros for printing and manipulating complex numbers. See also Complex.pm
Macros in the file PGdiffeqmacros.pl
Describes the macros for use with differential equations. While these macros have been used in courses at the University of Rochester, these macros have not yet been completely tested and polished. Regard them as a Beta release and use at your own risk.
A collection of alternative graders -- different methods of scoring the problems.
Macros in the file PGgraphmacros.pl
Describes the macros for simple uses of the graph objects.
Macros in the file PGmatrixmacros.pl
This describes some of the macros which manipulate and display matrices. See also Matrix.pm.
Macros in the file PGnumericalmacros.pl
This describes some of the numerical routines, including Newton's method, and integration routines, which can be used in defining PG problems.
Macros in the file PGpolynomialmacros.pl
Describes the macros for manipulating polynomials as objects.
Macros in the file PGstatisticsmacros.pl
Describes a few macros for statistics, in particular there are formulas for calculating the area under the normal distribution between two points (as well as the inverse of this function). See also Distributions.pm and Regression.pm
Macros in the file StdConst.pg and StdUnits.pg
These files contain runtime constants used by files translated from the CAPA language.

#### Detailed descriptions of packages augmenting the PG language:

These descriptions are intermixed with the code itself. They are likely to be somewhat technical and terse, but, since they are close to the actual code, they are also likely to be the most up-to-date and complete descriptions available.
Describes the structure of the AnswerHash object used by all answer evaluators. Also contains a description of the AnswerEvaluator object which can be used to build answer evaluators.
The Circle.pm interface
Describes the circle graph object.
The Complex.pm interface
Describes complex number objects.
The Distributions.pm interface
Objects for statistics problems
The Fun.pm interface
Describes the commands recognized by the function objects (which live in the graph object). This is useful for creating more complicated graphics examples than those described in PGgraphmacros.pl for constructing PG macros such as those in PGgraphmacros.pl. T hey can also be used directly to create things such as parametric functions, or functions with complicated definitions or other special functions that are not easily handled by the macro plot_functions in PGgraphmacros.pl.
The Hermite.pm interface
Describes the commands for defining a Hermite polynomial (for use in drawing graphs).
The Label.pm interface
Describes the label graph object.

The List.pm interface
The list object is a powerful replacement for both the Match.pm and Select.pm modules. It also has additional capabilities.
The Match.pm interface
Describes the commands for writing questions involving matching.
The Matrix.pm interface
Describes matrix objects and operations
The Multiple.pm interface
Describes the commands for writing multiple choice objects.
The PGrandom.pm interface
Low level pseudo-random generator object. Used mostly in other macro files.
The Regression.pm interface
Objects for use in statistics problems.
The Select.pm interface
Describes the commands for writing true-false questions or lists of short answer questions.
The Units.pm interface
Describes the basic command for using units in answers. There is also a complete List of Units one can use. See also macros in the file PGanswermacros.pl
The VectorField.pm interface
Describes the commands for drawing graphs of vector fields.
The WWPlot.pm interface
Describes the commands recognized by the graph objects. Useful for constructing PG macros such as the ones in PGgraphmacros.pl
The GD.pm interface
Each WWPlot object contains a GD object in which to draw. The GD.pm module is maintained on CPAN. You can reach the GD object within WWplot like so: $gd_object =$wwplot_object->im\$.

<| Post or View Comments |>