Difference between revisions of "SnippetTemplate"
Jump to navigation
Jump to search
(New page: <h2>Your title here: PG Code Snippet</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>Thi...) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code |
+ | <em>This PG code shows how to check student answers that are equations. Note that this is an <b>insertion</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> |
||
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"); |
||
+ | DOCUMENT(); |
||
+ | loadMacros( |
||
+ | "PGstandard.pl", |
||
+ | "MathObjects.pl", |
||
+ | ); |
||
+ | TEXT(beginproblem()); |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
<td style="background-color:#ccffcc;padding:7px;"> |
<td style="background-color:#ccffcc;padding:7px;"> |
||
<p> |
<p> |
||
+ | <b>Initialization:</b> |
||
To do ..(what you are doing)........., we don't have to change the |
To do ..(what you are doing)........., we don't have to change the |
||
tagging and documentation section of the problem file. |
tagging and documentation section of the problem file. |
||
Line 40: | Line 46: | ||
<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("...."); |
|
</pre> |
</pre> |
||
</td> |
</td> |
||
<td style="background-color:#ffffcc;padding:7px;"> |
<td style="background-color:#ffffcc;padding:7px;"> |
||
<p> |
<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. |
||
+ | <b>Setup:</b> |
||
+ | We specify that the Context should be <code>......</code>, and define the answer to be a formula. |
||
</p> |
</p> |
||
<p> |
<p> |
||
Line 62: | Line 69: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | + | BEGIN_TEXT |
|
− | + | ...... question text ...... |
|
− | + | END_TEXT |
|
</pre> |
</pre> |
||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
+ | <b>Main Text:</b> |
||
The problem text section of the file is as we'd expect. |
The problem text section of the file is as we'd expect. |
||
</p> |
</p> |
||
Line 78: | Line 86: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> |
<td style="background-color:#eeddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | ANS( $expr->cmp() ); |
||
+ | $showPartialCorrectAnswers = 1; |
||
+ | |||
+ | ANS( $expr->cmp() ); |
||
+ | |||
+ | ENDDOCUMENT(); |
||
</pre> |
</pre> |
||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
+ | <b>Answer Evaluation:</b> |
||
As is the answer. |
As is the answer. |
||
</p> |
</p> |
||
Line 93: | Line 106: | ||
[[Category:Problem Techniques]] |
[[Category:Problem Techniques]] |
||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [https://webwork.maa.org/pod/pg/current/nameOfMacro.html nameOfMacro.pl]</li> |
||
+ | <li>PG macro: [https://github.com/openwebwork/pg/blob/master/macros/nameOfMacro.pl nameOfMacro.pl]</li> |
||
+ | </ul> |
Latest revision as of 22:41, 14 April 2021
Your title here: PG Code Snippet
This PG code shows how to check student answers that are equations. Note that this is an insertion, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", ); TEXT(beginproblem()); |
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 |
Context("....."); Define context and variables for the questions $expr = Formula("...."); |
Setup:
We specify that the Context should be 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. |
$showPartialCorrectAnswers = 1; ANS( $expr->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: nameOfMacro.pl
- PG macro: nameOfMacro.pl