Difference between revisions of "PGLabs"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 23: Line 23:
 
TEXT($fp->cmp->evaluate("2x-3")->pretty_print ); -- or this complicated command can be replaced by the command below
 
TEXT($fp->cmp->evaluate("2x-3")->pretty_print ); -- or this complicated command can be replaced by the command below
   
=== Experimental PGML markup lab ===
+
=== PGML markup lab ===
 
* Experiment with the new PG markup language syntax (PGML)] which simplifies the graphical layout
 
* Experiment with the new PG markup language syntax (PGML)] which simplifies the graphical layout
 
of the mathematics question. This is still under development and can't yet be used in standard
 
of the mathematics question. This is still under development and can't yet be used in standard
Line 29: Line 29:
   
 
http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML?login_practice_user=true
 
http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML?login_practice_user=true
 
   
 
Homework sets using PGML
 
Homework sets using PGML
   
 
http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML-examples/?login_practice_user=true
 
http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML-examples/?login_practice_user=true
  +
  +
To use these commands in your own courses you will need a recent version of PG. (You can update by changing
  +
to the /opt/pg directory and typing
  +
cvs update -A
  +
which will get you the latest version of all of the PG code
  +
You can move back to the more stable code base by typing
  +
cvs update -r rel-2-4-patches
  +
  +
Include PGML.pm in your loadMacros() segment.
  +
Start the display of your problem text with BEGIN_PGML and end with END_PGML instead of using the BEGIN_TEXT/END_TEXT construct
   
 
[[Category:Authors]]
 
[[Category:Authors]]

Revision as of 12:57, 5 November 2009

PG Labs

On-line labs for rendering of PG code. These two labs allow you to experiment with PG syntax.

Test your PG code fragments

Click on this link to go to PG calculator:

http://hosted2.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/2/?login_practice_user=true

For example you could enter the code fragment below into the calculator:

Context("Numeric");
$f = Compute("x^2-3x+5");
$fp = $f->D; # calculate the derivative
 checkAnswer($fp, "2x-3");      # the first argument is a MathObject, the second the student's answer string
  
  • On the last line TEXT prints the results of (reading from left to right)
    • Constructing the AnswerEvaluator for the contents of the Formula $fp
    • Evaluating the string "2x-3" using this AnswerEvaluator to produce an AnswerHash
    • Recursively representing the contents of the AnswerHash in a nice table
  checkAnswer() inserts its arguments into a more complicated command.  e.g. last line above becomes:
  TEXT($fp->cmp->evaluate("2x-3")->pretty_print );  -- or this complicated command can be replaced by the command below

PGML markup lab

  • Experiment with the new PG markup language syntax (PGML)] which simplifies the graphical layout

of the mathematics question. This is still under development and can't yet be used in standard PG problems.

http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML?login_practice_user=true

Homework sets using PGML

http://hosted2.webwork.rochester.edu/webwork2/cervone_course/PGML-examples/?login_practice_user=true

 To use these commands in your own courses you will need a recent version of PG.  (You can update by changing 
 to the /opt/pg directory and typing
 cvs update -A   
 which will get you the latest version of all of the PG code
 You can move back to the more stable code base by typing
 cvs update -r rel-2-4-patches
Include  PGML.pm in your loadMacros() segment.
Start the display of your problem text with BEGIN_PGML and end with END_PGML  instead of using the BEGIN_TEXT/END_TEXT construct