Difference between revisions of "FormulaDomain1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Add link to PGML version in OPL)
(Remove answerHints)
Line 46: Line 46:
 
"MathObjects.pl",
 
"MathObjects.pl",
 
"AnswerFormatHelp.pl",
 
"AnswerFormatHelp.pl",
"answerHints.pl",
 
 
);
 
);
   
Line 55: Line 54:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
We load <code>AnswerFormatHelp.pl</code> to provide help links to students. We load <code>answerHints.pl</code> to provide customized answer hints in the answer evaluation section.
+
We load <code>AnswerFormatHelp.pl</code> to provide help links to students.
 
</p>
 
</p>
 
</td>
 
</td>
Line 129: Line 128:
   
 
ANS( $answer1->cmp() );
 
ANS( $answer1->cmp() );
 
  +
ANS( $answer2->cmp() );
ANS( $answer2->cmp()
 
->withPostFilter(AnswerHints(
 
[Compute("ln(x/(x-$a))"),Compute("ln(x)-ln(x-$a)")] =>
 
"Don't forget to use absolute value",
 
))
 
);
 
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">
Line 141: Line 134:
 
<b>Answer Evaluation:</b>
 
<b>Answer Evaluation:</b>
 
It is possible to get diagnostic information about the answer checker using <code>cmp(diagnostics=>1)</code>. When diagnostics are turned on and a student answer is submitted, you will get a graph of the correct answer and the student answer on the same graph, as well as a table that specifies which test points were used by the answer checker, and how much of a difference there was between the student answer and the correct answer at these checkpoints. To test the reliability of your answer checker, it is good to click the reload button on your browser several times after a student answer has been submitted, since reloading changes the test points used.
 
It is possible to get diagnostic information about the answer checker using <code>cmp(diagnostics=>1)</code>. When diagnostics are turned on and a student answer is submitted, you will get a graph of the correct answer and the student answer on the same graph, as well as a table that specifies which test points were used by the answer checker, and how much of a difference there was between the student answer and the correct answer at these checkpoints. To test the reliability of your answer checker, it is good to click the reload button on your browser several times after a student answer has been submitted, since reloading changes the test points used.
</p>
 
<p>
 
For the second answer, we have used <code>AnswerHints</code> to give students who enter particular answers customized feedback messages. For more details, please see [http://webwork.maa.org/wiki/AnswerHints answer hints] in the index of problem techniques.
 
 
</p>
 
</p>
 
</td>
 
</td>

Revision as of 12:10, 31 July 2015

Answer is a Function with Domain Issues

Click to enlarge

This PG code shows how to set the domain and test points for a formula.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
);

TEXT(beginproblem());

Initialization: We load AnswerFormatHelp.pl to provide help links to students.

Context("Numeric");

$a = random(2,5,1);

$answer1 = Compute("sqrt(x-$a)");
$answer1->{limits} = [$a+1,$a+4];

$answer2 = Compute("ln(abs( x / (x-$a) ))");
$answer2->{test_points} = [[-5],[-4],[1],[$a-1],[7],[8]];

Setup: We restrict the domain of function evaluation using $answer1->{limits} = [$a+1,$a+4];, which will choose test points at random in the interval [$a+1,$a+4]

The domain for $answer2 is all real numbers except for 0 and $a, and we would like to stay away from these vertical asymptotes because answer evaluators don't work well when the function values are very large or very small. Thus, we explicitly list those test points in the domain that will be used when the function is evaluated.

It is possible to set the domain once for all of the functions within a particular context. For more details, please see formula test points in the index of problem techniques.

Context()->texStrings;
BEGIN_TEXT
(a) Suppose the first answer is 
\( \displaystyle $answer1 \).
$BR
\{ ans_rule(20) \}
\{ AnswerFormatHelp("formulas") \}
$BR
$BR
(b) Suppose the second answer is 
\( \displaystyle $answer2 \)
$BR
\{ ans_rule(20) \}
\{ AnswerFormatHelp("formulas") \}
END_TEXT
Context()->normalStrings;

Main Text: Notice that in this multipart question we have grouped the text for each part together in a block, put each answer blank on a new line immediately below each block of text, and added extra space between each part. This should make the question easy to read both in HTML and PDF format.

$showPartialCorrectAnswers = 1;

ANS( $answer1->cmp() );
ANS( $answer2->cmp() );

Answer Evaluation: It is possible to get diagnostic information about the answer checker using cmp(diagnostics=>1). When diagnostics are turned on and a student answer is submitted, you will get a graph of the correct answer and the student answer on the same graph, as well as a table that specifies which test points were used by the answer checker, and how much of a difference there was between the student answer and the correct answer at these checkpoints. To test the reliability of your answer checker, it is good to click the reload button on your browser several times after a student answer has been submitted, since reloading changes the test points used.

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area