Difference between revisions of "AnyAnswerMarkedCorrect"
(Created page with '<h2>Any Answer Marked Correct</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>…') |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/AnyAnswerMarkedCorrect.html a newer version of this problem]</p> |
||
<h2>Any Answer Marked Correct</h2> |
<h2>Any Answer Marked Correct</h2> |
||
Line 4: | Line 7: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This PG code shows how to mark any answer a student submits as correct. |
+ | <em>This PG code shows how to mark any answer a student submits as correct. |
+ | There are, as usual, many ways to do this; we show two here, one using a |
||
+ | [[CustomAnswerCheckers|custom answer checker]], and one using a special |
||
+ | answer checker that marks any answer correct.</em> |
||
</p> |
</p> |
||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
− | [[ |
+ | [[Problem_Techniques|Problem Techniques Index]] |
</p> |
</p> |
||
+ | |||
+ | <strong>With the Special Answer Checker</strong> |
||
<table cellspacing="0" cellpadding="2" border="0"> |
<table cellspacing="0" cellpadding="2" border="0"> |
||
Line 47: | Line 52: | ||
<pre> |
<pre> |
||
Context("Numeric"); |
Context("Numeric"); |
||
− | Context()->variables->are(x=>"Real",y=>"Real",u=>"Real"); |
||
$a = random(2,9,1); |
$a = random(2,9,1); |
||
Line 68: | Line 72: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | Enter anything, e.g. \($a\) and |
+ | Enter anything, e.g. \($a\) and |
+ | it will be marked correct: |
||
\{ans_rule(10) \}. |
\{ans_rule(10) \}. |
||
Line 98: | Line 102: | ||
<p> |
<p> |
||
<b>Answer Evaluation:</b> |
<b>Answer Evaluation:</b> |
||
− | We use the <code>ANS(auto_right("All answers are marked correct"));</code> routine to evaluate the answer. The phrase in quotes (which can be empty) is displayed when "Show correct answers" is checked. See [http://webwork.maa.org/pod/ |
+ | We use the <code>ANS(auto_right("All answers are marked correct"));</code> routine to evaluate the answer. The phrase in quotes (which can be empty) is displayed when "Show correct answers" is checked. See [http://webwork.maa.org/pod/pg/macros/PGasu.html PGasu.pl] for more options and details. |
</p> |
</p> |
||
</td> |
</td> |
||
Line 104: | Line 108: | ||
</table> |
</table> |
||
− | <p style="text-align:center;"> |
||
+ | <strong>With a Custom Checker</strong> |
||
− | [[IndexOfProblemTechniques|Problem Techniques Index]] |
||
+ | |||
+ | <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> |
||
+ | DOCUMENT(); |
||
+ | loadMacros( |
||
+ | "PGstandard.pl", |
||
+ | "MathObjects.pl", |
||
+ | ); |
||
+ | TEXT(beginproblem()); |
||
+ | </pre> |
||
+ | </td> |
||
+ | <td style="background-color:#ccffcc;padding:7px;"> |
||
+ | <p> |
||
+ | <b>Initialization:</b> |
||
+ | No additions are needed to the initialization section of the file. |
||
</p> |
</p> |
||
+ | </td> |
||
+ | </tr> |
||
− | [[Category:Problem Techniques]] |
||
+ | <!-- Setup section --> |
||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | Context("Numeric"); |
||
+ | $a = Compute(random(2,9,1)); |
||
+ | |||
+ | </pre> |
||
+ | </td> |
||
+ | <td style="background-color:#ffffcc;padding:7px;"> |
||
+ | <p> |
||
+ | <b>Setup:</b> |
||
+ | Everything is as usual. In this case we are going to need a MathObject to do the answer checking, so create one here. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | |||
+ | <!-- Question text section --> |
||
+ | |||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | Context()->texStrings; |
||
+ | BEGIN_TEXT |
||
+ | Enter any number, e.g. \($a\) and it |
||
+ | will be marked correct: |
||
+ | \{ans_rule(10) \}. |
||
+ | |||
+ | |||
+ | END_TEXT |
||
+ | Context()->normalStrings; |
||
+ | |||
+ | </pre> |
||
+ | <td style="background-color:#ffcccc;padding:7px;"> |
||
+ | <p> |
||
+ | <b>Main Text:</b> |
||
+ | The text section is as we'd expect. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | |||
+ | <!-- Answer section --> |
||
+ | |||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#eeddff;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | $showPartialCorrectAnswers = 1; |
||
+ | |||
+ | ANS( $a->cmp( checker=>sub { |
||
+ | my ( $cor, $stu, $ans ) = @_; |
||
+ | return 1; } ) ); |
||
+ | |||
+ | ENDDOCUMENT(); |
||
+ | </pre> |
||
+ | <td style="background-color:#eeccff;padding:7px;"> |
||
+ | <p> |
||
+ | <b>Answer Evaluation:</b> |
||
+ | We use our MathObject to check the answer, but specify a [[CustomAnswerCheckers|custom answer checker]] to do the actual checking. Here we return 1 for any answer, so anything will be marked correct. One note about this method: because our MathObject is a real number, it will require that the student's answer be a real number to be marked correct. We could accept any formula or number by specifying <code>$a = Formula(random(2,9,1))</code> above. |
||
+ | </p> |
||
+ | <p> |
||
+ | <i>It should also be possible to turn off type checking---we need to document this.</i> |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | </table> |
||
+ | <p style="text-align:center;"> |
||
+ | [[Problem_Techniques|Problem Techniques Index]] |
||
+ | </p> |
||
+ | |||
+ | [[Category:Problem Techniques]] |
||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/pod/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/PGasu.html PGasu.pl]</li> |
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/PGasu.pl?view=log PGasu.pl]</li> |
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/PGasu.pl?view=log PGasu.pl]</li> |
||
</ul> |
</ul> |
Latest revision as of 15:54, 20 June 2023
This problem has been replaced with a newer version of this problem
Any Answer Marked Correct
This PG code shows how to mark any answer a student submits as correct. There are, as usual, many ways to do this; we show two here, one using a custom answer checker, and one using a special answer checker that marks any answer correct.
With the Special Answer Checker
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGasu.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric"); $a = random(2,9,1); |
Setup: Everything is as usual. |
Context()->texStrings; BEGIN_TEXT Enter anything, e.g. \($a\) and it will be marked correct: \{ans_rule(10) \}. END_TEXT Context()->normalStrings; |
Main Text: The text section is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS(auto_right("All answers are marked correct")); ENDDOCUMENT(); |
Answer Evaluation:
We use the |
With a Custom Checker
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", ); TEXT(beginproblem()); |
Initialization: No additions are needed to the initialization section of the file. |
Context("Numeric"); $a = Compute(random(2,9,1)); |
Setup: Everything is as usual. In this case we are going to need a MathObject to do the answer checking, so create one here. |
Context()->texStrings; BEGIN_TEXT Enter any number, e.g. \($a\) and it will be marked correct: \{ans_rule(10) \}. END_TEXT Context()->normalStrings; |
Main Text: The text section is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $a->cmp( checker=>sub { my ( $cor, $stu, $ans ) = @_; return 1; } ) ); ENDDOCUMENT(); |
Answer Evaluation:
We use our MathObject to check the answer, but specify a custom answer checker to do the actual checking. Here we return 1 for any answer, so anything will be marked correct. One note about this method: because our MathObject is a real number, it will require that the student's answer be a real number to be marked correct. We could accept any formula or number by specifying It should also be possible to turn off type checking---we need to document this. |