Difference between revisions of "Writing Your Own Homework Problems Using PGML"

From WeBWorK_wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 4 users not shown)
Line 8: Line 8:
 
* If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.
 
* If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.
   
  +
== [http://webwork.maa.org/wiki/Problem_Authoring_Videos MAA PREP 2015 Problem Authoring Course Videos] ==
   
 
== Typical PGML Problem Example ==
 
== Typical PGML Problem Example ==
Line 26: Line 27:
 
TEXT(beginproblem());
 
TEXT(beginproblem());
 
$showPartialCorrectAnswers = 1;
 
$showPartialCorrectAnswers = 1;
######################################################################
 
   
 
The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features
 
The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features
Line 37: Line 37:
 
You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less.
 
You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less.
   
  +
######################################################################
 
BEGIN_PGML
 
BEGIN_PGML
 
Simplify [`2 + 4 \cdot 5`].
 
Simplify [`2 + 4 \cdot 5`].
[____________]{Compute("22")}
+
[____________]{"22"}
 
Now simplify [`2x + 4x + 5x`].
 
Now simplify [`2x + 4x + 5x`].
[____________]{Compute("11*x")}
+
[____________]{"11x"}
 
END_PGML
 
END_PGML
  +
######################################################################
   
The is the central part of a PGML homework problem and what you will be working on the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enlose it inside [` and `]. Your answer field is represented by the [____________]. After the answer field you specify the correct answer in braces. In this case the correct answer is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. This example include two questions. Your problems can have only 1 question or even more than 2 if you wish.
+
The is what you will be changing the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enclose it inside [` and `]. Your answer field is represented by [____________]. After the answer field, you specify the correct answer you desire in braces. In this example, the correct answer for the first question is a number and for the second it is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. Your problems can have only 1 question or even more than 2 if you wish. By the way, the hash marks which being and end this section are optional. I include them so I can easily see this part of any PGML problem quickly and easily.
   
 
######################################################################
 
 
ENDDOCUMENT();
 
ENDDOCUMENT();
   
 
This last part is more boilerplate that should not change much if at all.
 
This last part is more boilerplate that should not change much if at all.
  +
  +
== For Further Study ==
  +
  +
* '''[[Introduction to PGML]]''' -- a more complete introduction to PGML
  +
* '''[[:Category:PGML|PGML Reference materia|]]''' -- full reference material on PGML
  +
  +
For further exploration of PGML, see the many [https://courses1.webwork.maa.org/webwork2/cervone_course/PGML-examples/?login_practice_user=true|live PGML examples]
  +
  +
[[Category:Instructors]]
  +
[[Category:Authors]]

Latest revision as of 20:04, 19 July 2020

Intro To Writing Your Own Homework Problems Using PGML

Introduction

  • PGML makes writing your own homework problems so much nicer than what came before. Many chores which previously were difficult are now easier, if not automated away. The best part is that there is little to learn to get started. PGML is so elegant and intuitive that you can often get started by simply viewing and tweaking existing PGML based problem files.


So Why Isn't PGML Used Everywhere If It Is So Great?

  • If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.

MAA PREP 2015 Problem Authoring Course Videos

Typical PGML Problem Example

  DOCUMENT();
  loadMacros(
    "PGstandard.pl",
    "PGML.pl",
    "MathObjects.pl",
    "PGcourse.pl",
    "parserNumberWithUnits.pl",
    "contextArbitraryString.pl",
    "parserMultiAnswer.pl",
    "parserPopUp.pl",
    "contextInequalities.pl",
    "PGgraphmacros.pl",
  );
  TEXT(beginproblem());
  $showPartialCorrectAnswers = 1;

The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features you use in your problems, you may or may not need all the macros I have loaded above. On the other hand, one strategy is to always include any and every macro you have ever used in the past, or will use in the future, so as to not have to bother thinking about this initial boilerplate.

  Context("Numeric") ; 
  Context()->flags->set(tolerance => 0.01);

You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less.

  ######################################################################
  BEGIN_PGML
  Simplify [`2 + 4 \cdot 5`].
  [____________]{"22"}
  Now simplify [`2x + 4x + 5x`].
  [____________]{"11x"}
  END_PGML
  ######################################################################

The is what you will be changing the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enclose it inside [` and `]. Your answer field is represented by [____________]. After the answer field, you specify the correct answer you desire in braces. In this example, the correct answer for the first question is a number and for the second it is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. Your problems can have only 1 question or even more than 2 if you wish. By the way, the hash marks which being and end this section are optional. I include them so I can easily see this part of any PGML problem quickly and easily.

  ENDDOCUMENT();

This last part is more boilerplate that should not change much if at all.

For Further Study

For further exploration of PGML, see the many PGML examples