Difference between revisions of "FormattingCorrectAnswers: Equations"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 39: Line 39:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context(".....");
 
Define context and variables for the questions
 
   
$expr = Formula("....");
+
$dfx = 3;
  +
$yintercept = 4;
  +
Context("ImplicitPlane");
  +
Context()->variables->remove("z");
  +
$h = ImplicitPlane("y = $dfx x + $yintercept");
  +
 
</pre>
 
</pre>
 
</td>
 
</td>

Revision as of 12:07, 17 June 2008

Your title here: PG Code Snippet


This code snippet shows the essential PG code to check student answers that are equations. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.

Problem Techniques Index

PG problem file Explanation
  loadMacros("parserImplicitPlane.pl");

We don't have to change the tagging and documentation section of the problem file. In the initialization section, we need to include the macros file parserImplicitPlane.pl.


  $dfx = 3;
  $yintercept = 4;
  Context("ImplicitPlane");
  Context()->variables->remove("z");
  $h = ImplicitPlane("y = $dfx x + $yintercept");

In the problem set-up section of the file, we specify that the Context should be ......, and define the answer to be a formula.

Notes: on using this and related Contexts.

  BEGIN_TEXT
  ...... question text ......
  END_TEXT

The problem text section of the file is as we'd expect.

  ANS( $expr->cmp() );

As is the answer.

Problem Techniques Index