DigitsTolType: Difference between revisions
No edit summary |
(first draft of page.) |
||
Line 34: | Line 34: | ||
</pre> | </pre> | ||
</td> | </td> | ||
<td style="background-color:#ccffcc;padding:7px;"> | <td style="background-color:#ccffcc;padding:7px;"> | ||
<p> | <p> | ||
<b>Initialization:</b> | <b>Initialization:</b> | ||
The <tt>tolType</tt> of type </tt>digits</tt> is built-in to MathObjects. | |||
</p> | </p> | ||
</td> | </td> | ||
Line 47: | Line 48: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | <td style="background-color:#ffffdd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
Context("Numeric")->flags->set(tolType=>'digits', | Context("Numeric") | ||
Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>1); | |||
$answer = Real("pi"); | |||
</pre> | </pre> | ||
</td> | </td> | ||
<td style="background-color:#ffffcc;padding:7px;"> | <td style="background-color:#ffffcc;padding:7px;"> | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
<ul> | <ul> | ||
<li>The < | <li>Ensure that the <code>Numeric</code> context is set. This only pertains to numbers. </li> | ||
<li> The < | <li>The <code>tolType=>'digits'</code> switch to the digits tolerance. </li> | ||
<li> The < | <li> The <code>tolerance=>3</code> sets the number of digits to 3 (the default). </li> | ||
<li> | <li> The <code>tolTruncation</code> parameter is either 1 (true) or 0 (false). Details are explained below.</li> | ||
<li> The <code>tolExtraDigits</code> parameter sets the number of extra digits for checking answers. This is explained below. </li> | |||
</ul> | </ul> | ||
</p> | |||
<p> | |||
In short, this will set the answer checked to see if the student answer matches the correct answer to <code>tolerance</code> digits. For the example of pi, this will be 3.14. If there are extra digits, there are a few other parameters to check: | |||
<ul><li> If <code>tolTruncation</code> is true (the default), the correct answer and student answer are both truncated to the number of digits + the extra digits (parameter <code>tolExtraDigits</code>). The result is that both 3.141 and 3.142 are accepted. | |||
</li> | |||
<li>If <code>tolTruncation</code> is false, then only the answer that matches the number of digits + extra digits is valid. In this example, only 3.141 will be accepted. </li> | |||
</ul> | |||
<p> | |||
The default value of <code>tolTruncation</code> is true. | |||
</p> | |||
</td> | |||
</tr> | |||
<!-- First Block text section --> | |||
<tr valign="top"> | |||
<td style="background-color:#ffdddd;border:black 1px dashed;"> | |||
<pre> | |||
BEGIN_PGML | |||
This section is with [|tolTruncation|] set to true (1). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. | |||
[`\pi=`][_]{$answer} | |||
END_PGML</pre> | |||
</td> | |||
<td style="background-color:#ffcccc;padding:7px;"> | |||
<p> | |||
<b>First Section:</b> This tests the default characteristic of this answer checker. It should accept 3.14, 3.141 and 3.142 as correct, but not 3.15. | |||
</p> | </p> | ||
</td> | </td> | ||
</tr> | </tr> | ||
<!-- | <!-- Setup 2nd block --> | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | |||
<pre> | |||
Context("Numeric"); | |||
Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0); | |||
$answer2 = Real("pi"); | |||
</pre> | |||
</td> | |||
<td style="background-color:#ffffcc;padding:7px;"> | |||
<p> | |||
<b>Second block explanation: </b> First, reset the context with <code>Context("Numeric")</code> and then the set flags are set except for <code>tolTruncation=>0</code>. | |||
</td> | |||
<!-- Second Block text section --> | |||
<tr valign="top"> | <tr valign="top"> | ||
Line 69: | Line 119: | ||
<pre> | <pre> | ||
BEGIN_PGML | BEGIN_PGML | ||
This section is with [|tolTruncation|] set to false (0). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. | |||
[`\pi=`][_]{$answer2} | |||
END_PGML | END_PGML | ||
</pre> | </pre> | ||
</td> | |||
<td style="background-color:#ffcccc;padding:7px;"> | <td style="background-color:#ffcccc;padding:7px;"> | ||
<p> | <p> | ||
<b> | <b>Second Section:</b> This tests the default characteristic of this answer checker. It should accept 3.14, 3.142 as correct, but not 3.141 or 3.15. | ||
This | </p> | ||
</td> | |||
</tr> | |||
<!-- Setup 3rd block --> | |||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | |||
<pre> | <pre> | ||
Context("Numeric"); | |||
Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0,tolExtraDigits=>2); | |||
$answer3 = Real("3.14"); | |||
</pre> | </pre> | ||
</td> | </td> | ||
</ | <td style="background-color:#ffffcc;padding:7px;"> | ||
<p> | |||
<b>Second block explanation: </b> First, reset the context with <code>Context("Numeric")</code> and then the set flags are set except | |||
for <code>tolTruncation=>0</code> as well as the <code>tolExtraDigits=>2</code>. | |||
</td> | |||
<!-- | <!-- Third Block text section --> | ||
<tr valign="top"> | <tr valign="top"> | ||
<td style="background-color:# | <td style="background-color:#ffdddd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
BEGIN_PGML | |||
If we want to consider only answers to some number to digits. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. | |||
Enter [`\pi`] to the first 2 decimal places after the decimal point [_]{$answer3} | |||
END_PGML | |||
</pre> | </pre> | ||
<td style="background-color:# | </td> | ||
<td style="background-color:#ffcccc;padding:7px;"> | |||
<p> | <p> | ||
This | <b>Third Section:</b> This allows only to the given number of digits (3). It should accept only 3.14 as correct. | ||
</p> | </p> | ||
</td> | </td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Line 116: | Line 178: | ||
[[Category:Problem Techniques]] | [[Category:Problem Techniques]] | ||
Revision as of 13:34, 30 April 2021
Digits TolType
This describes an alternative way for determining the tolerance type based on the number of digits.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl" ); TEXT(beginproblem()); |
Initialization: The tolType of type digits is built-in to MathObjects. |
Context("Numeric") Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>1); $answer = Real("pi"); |
Setup:
In short, this will set the answer checked to see if the student answer matches the correct answer to
The default value of |
BEGIN_PGML This section is with [|tolTruncation|] set to true (1). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer} END_PGML |
First Section: This tests the default characteristic of this answer checker. It should accept 3.14, 3.141 and 3.142 as correct, but not 3.15. |
Context("Numeric"); Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0); $answer2 = Real("pi"); |
Second block explanation: First, reset the context with |
BEGIN_PGML This section is with [|tolTruncation|] set to false (0). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer2} END_PGML |
Second Section: This tests the default characteristic of this answer checker. It should accept 3.14, 3.142 as correct, but not 3.141 or 3.15. |
Context("Numeric"); Context()->flags->set(tolType=>'digits', tolerance=>3, tolTruncation=>0,tolExtraDigits=>2); $answer3 = Real("3.14"); |
Second block explanation: First, reset the context with |
BEGIN_PGML If we want to consider only answers to some number to digits. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. Enter [`\pi`] to the first 2 decimal places after the decimal point [_]{$answer3} END_PGML |
Third Section: This allows only to the given number of digits (3). It should accept only 3.14 as correct. |