Difference between revisions of "SnippetTemplate"

From WeBWorK_wiki
Jump to navigation Jump to search
m
m
Line 23: Line 23:
 
<td style="background-color:#ddffdd;border:black 1px dashed;">
 
<td style="background-color:#ddffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
loadMacros("any macros files that are needed");
+
loadMacros("any macros files that are needed");
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 41: Line 41:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context(".....");
+
Context(".....");
Define context and variables for the questions
+
Define context and variables for the questions
   
$expr = Formula("....");
+
$expr = Formula("....");
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 64: Line 64:
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<pre>
 
<pre>
BEGIN_TEXT
+
BEGIN_TEXT
...... question text ......
+
...... question text ......
END_TEXT
+
END_TEXT
 
</pre>
 
</pre>
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
Line 81: Line 81:
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<pre>
 
<pre>
ANS( $expr->cmp() );
+
ANS( $expr->cmp() );
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">

Revision as of 15:07, 22 January 2010

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("any macros files that are needed");

Initialization: To do ..(what you are doing)........., 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 -------.pl.

Context(".....");
Define context and  variables for the questions

$expr = Formula("....");

Setup: 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

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

ANS( $expr->cmp() );

Answer Evaluation: As is the answer.

Problem Techniques Index