Difference between revisions of "FormattingCorrectAnswers: Equations"

From WeBWorK_wiki
Jump to navigation Jump to search
(New page: There are a number of ways to effect the way the correct answer is displayed to the student. The interaction between eval() , substitute() , reduceConstants , reduceConstantFunctions ....)
 
m (1 revision: import all default namespace pages from old wiki)
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
There are a number of ways to effect the way the correct answer is displayed to the student. The interaction between eval() , substitute() , reduceConstants , reduceConstantFunctions .
 
  +
<h2>Formatting Correct Answers: Equations: PG Code Snippet</h2>
Note:[[PGLabs]] is an efficient way to check code.
 
  +
  +
<!-- Header for these sections -- no modification needed -->
  +
  +
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
  +
<em>This code snippet shows the essential PG code to check student answers that are equations. Note that these are <b>insertions</b>, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.</em>
  +
</p>
  +
  +
<p style="text-align:center;">
  +
[[IndexOfProblemTechniques|Problem Techniques Index]]
  +
</p>
  +
  +
<table cellspacing="0" cellpadding="2" border="0">
  +
  +
<tr valign="top">
  +
<th> PG problem file </th>
  +
<th> Explanation </th>
  +
</tr>
  +
  +
<!-- Load specialized macro files section -->
  +
  +
<tr valign="top">
  +
<td style="background-color:#ddffdd;border:black 1px dashed;">
  +
<pre>
  +
loadMacros("parserImplicitPlane.pl");
  +
</pre>
  +
</td>
  +
<td style="background-color:#ccffcc;padding:7px;">
  +
<p>
  +
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 <code>parserImplicitPlane.pl</code>.
  +
</p>
  +
</td>
  +
</tr>
  +
  +
<!-- Setup section -->
  +
  +
<tr valign="top">
  +
<td style="background-color:#ffffdd;border:black 1px dashed;">
  +
<pre>
  +
  +
$dfx = 3;
  +
$yintercept = 4;
  +
Context("ImplicitPlane");
  +
Context()->variables->remove("z");
  +
$h = ImplicitPlane("y = $dfx x + $yintercept");
  +
  +
</pre>
  +
</td>
  +
<td style="background-color:#ffffcc;padding:7px;">
  +
<p>
  +
In the problem set-up section of the file, we specify that the Context should be <code>......</code>, and define the answer to be a formula.
  +
</p>
  +
<p>
  +
Notes: on using this and related Contexts.
  +
</p>
  +
  +
</td>
  +
</tr>
  +
  +
<!-- Question text section -->
  +
  +
<tr valign="top">
  +
<td style="background-color:#ffdddd;border:black 1px dashed;">
  +
<pre>
  +
BEGIN_TEXT
  +
...... question text ......
  +
END_TEXT
  +
</pre>
  +
<td style="background-color:#ffcccc;padding:7px;">
  +
<p>
  +
The problem text section of the file is as we'd expect.
  +
</p>
  +
</td>
  +
</tr>
  +
  +
<!-- Answer section -->
  +
  +
<tr valign="top">
  +
<td style="background-color:#eeddff;border:black 1px dashed;">
  +
<pre>
  +
ANS( $expr->cmp() );
  +
</pre>
  +
<td style="background-color:#eeccff;padding:7px;">
  +
<p>
  +
As is the answer.
  +
</p>
  +
</td>
  +
</tr>
  +
</table>
  +
  +
<p style="text-align:center;">
  +
[[IndexOfProblemTechniques|Problem Techniques Index]]
  +
</p>
  +
  +
[[Category:Problem Techniques]]

Revision as of 16:19, 14 May 2010

Formatting Correct Answers: Equations: 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