Difference between revisions of "AnswerHints"

From WeBWorK_wiki
Jump to navigation Jump to search
(New page: <h2>Answer Hints</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This PG code shows how ...)
 
Line 40: Line 40:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
We need to include the macros file <code>MathObjects.pl</code> and <code>answerHints.pl</code>.
+
We need to include the macros file <code>MathObjects.pl</code> and <code>answerHints.pl</code>, which only works with MathObjects answer checkers (not old answer checkers).
 
</p>
 
</p>
 
</td>
 
</td>
Line 112: Line 112:
   
 
[[Category:Problem Techniques]]
 
[[Category:Problem Techniques]]
  +
  +
  +
  +
<ul>
  +
<li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/answerHints.pl answerHints.pl]</li>
  +
<li>PG macro code: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/answerHints.pl answerHints.pl]</li>
  +
</ul>

Revision as of 22:19, 8 February 2010

Answer Hints


This PG code shows how to include customized answer hints in the messages box after a student submits a particular answer.

See also ErrorMessageCustomization and TextHints

Problem Techniques Index

PG problem file Explanation
DOCUMENT(); 
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"answerHints.pl",
);

TEXT(beginproblem());

Initialization: We need to include the macros file MathObjects.pl and answerHints.pl, which only works with MathObjects answer checkers (not old answer checkers).

Context("Numeric");
Context()->variables->are(t=>"Real",u=>"Real");

$f = Formula("2 t");
$answer = Formula("6 u");

Setup: We restrict the variables to only t and u

Context()->texStrings;
BEGIN_TEXT
If \( f(t) = $f \), then \( f(3u) \) = \{ ans_rule(10) \} 
END_TEXT
Context()->normalStrings;

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

$showPartialCorrectAnswers = 1;

ANS($answer->cmp()
->withPostFilter(AnswerHints( 
  Formula("6 t") => "Are you using the correct variable?",
  Formula("6 u") => "Good work!", 
))
);

Answer Evaluation: We use the AnswerHints postfilter provided by answerHints.pl. The answer hints should be provided by a particular answer, followed by a hash table association =>, followed by a string that will show up in the messages portion of the answer preview and feedback box when students submit their answers.

Problem Techniques Index