📜 ⬆️ ⬇️

PG as Perl evolution for mathematicians at WeBWorK

Disclaimer : The information presented may be useful to teachers, course authors. Most of the information is a free translation from the English-language Wiki WeBWorK .

To start: What is WeBWorK?

WeBWorK is a free system written in Perl for providing individual homework through the network. The system allows teachers to create courses from a set of homework that can be subsequently solved by students.
')
A student can access homework from any computer. The system involves entering formulas in any identical form, which removes unnecessary worries from the student. Due to the fact that the information on the correctness of the decision comes immediately, the student has the opportunity to decide the task.

The teacher is also not limited to the access point. For the preparation of the course can be used as new tasks, and thousands of ready-made tasks of several universities. To prevent cheating, it is possible to set the individual characteristics of the task for each student. All information about students, courses and problem solving statistics is available to the teacher, which allows a better assessment of student performance, both general and individual.
All tasks (problems) in WeBWorK are read from text files that are written in a language called PG (for Problem Generation).

The PG language is a collection of macros (subroutines) written in Perl that simplifies the writing of math problems. Its development began in 1995 and the language is still under development.

Currently PG has three dialects:

  1. Original PG;
  2. MathObjects;
  3. PGML.

I wrote a little information about WeBWorK and PG, let's try to parse the PG language itself.

The standard WeBWorK PG file has five sections:

  1. The section notes and descriptions, which describes the task for future users and authors;
  2. Initialization section that loads the required macros for the task;
  3. Section in which variables are set, necessary in this task;
  4. The section of the text in which the text of the task is recorded, shown to the student;
  5. Section of the answer.

Let us analyze a simple task written in PG.

Section notes and descriptions
Part code
# DESCRIPTION
# A simple sample problem that asks students to
# differentiate a trigonometric function.
# WeBWorK problem written by Gavin LaRose,
# <glarose (at) umich (dot) edu>
# ENDDESCRIPTION

## DBsubject ('WeBWorK')
## DBchapter ('Demos')
## DBsection ('Problem')
## KEYWORDS ('')
## TitleText1 ('')
## EditionText1 ('')
## AuthorText1 ('')
## Section1 ('')
## Problem1 ('')
## Author ('Gavin LaRose')
## Institution ('UMich')

Any line starting with the "#" character is a comment for teachers and other authors of the problems. The description is necessary so that another task author or teacher can learn the essence of the problem without delving into the code itself.

All information about the task is filled in the notes. Marks begin with the characters "##". This is necessary so that the task can be easily indexed.

There are online lists of the current names of chapters and sections , and a similar list of keywords .

Keywords should be separated by commas and quoted (for example, KEYWORDS ('calculus', 'derivatives') ).

Initialization section
Part code
DOCUMENT ();
loadMacros (
"PGstandard.pl",
"MathObjects.pl",
);

The first command in the task must be the DOCUMENT () command ;
Note that each command must end with a semicolon.
With the loadMacros command we load the necessary macros.

Variable Section
Part code
# make sure we're in the context we want
Context ("Numeric");

$ a = random (2,9,1);
$ trigFunc = Formula ("sin ($ ax)");
$ trigDeriv = $ trigFunc-> D ();

Team Context ("Numeric"); sets a "Context" setting how variables are interpreted.
All contexts and contextual explanations are given on this help page .
The main part of the section defines the variables that we use in the rest of the task.

All scalar variables are marked with a "$": so $ a is a variable that has a value.
We also define $ trigFunc and $ trigDeriv using the commands from MathObject .

Text section
Part code
TEXT (beginproblem ());
Context () -> texStrings;
BEGIN_TEXT
Find the derivative of the function \ (f (x) = $ trigFunc \).
$ PAR
\ (\ frac {df} {dx} = \) \ {ans_rule (35) \}
END_TEXT
Context () -> normalStrings;

Team TEXT (beginproblem ()); displays the title of the task.

Team Context () -> texStrings; Sets how formulas will be displayed in the task text.

Everything between BEGIN_TEXT and END_TEXT will be shown to the student.

Mathematical equations are divided into \ (\) (for embedded equations) or \ [\] (for displayed equations). There are a number of variables that set the formatting. This page contains a list of these variables.

But \ {\} highlights the part of the code that will be executed in the text of the task. Here ans_rule (35) is a function that inserts a 35-character-wide response field.

Answer section
Part code
ANS ($ trigDeriv-> cmp ());

Context () -> texStrings;
SOLUTION (EV3 (<< 'END_SOLUTION'));
$ PAR SOLUTION $ PAR
We find the derivative
chain rule. The inside function is \ ($ ax \),
so that its is is ($ a \), and the
outside function is \ (\ sin (x) \), which has
derivative \ (\ cos (x) \). Thus the solution is
\ [\ frac {d} {dx} $ trigFunc = $ trigDeriv. \]
END_SOLUTION
Context () -> normalStrings;

ENDDOCUMENT ();

The answer is checked by the ANS team ($ trigDeriv-> cmp ()); . This command verifies the correct answer and the answer entered by the student. Then we explain the solution to the student. This solution will be displayed when the student presses the “SOLUTION” button. ENDDOCUMENT () command ; is the last command in the file.

The only problem with this system is that it is not localized for Russia and the CIS countries, and therefore very few people know about it and use this system for teaching and testing students' knowledge.

Source: https://habr.com/ru/post/269981/


All Articles