AnswerHints: Difference between revisions
(Update links to http://webwork.maa.org/pod/pg_TRUNK/macros/answerHints.pl.html, etc) |
m (Formatting changes) |
||
Line 3: | Line 3: | ||
<!-- Header for these sections -- no modification needed --> | <!-- Header for these sections -- no modification needed --> | ||
< | <div style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> | ||
This PG code shows how to include two different kinds of answer hints: | This PG code shows how to include two different kinds of answer hints: | ||
<ul type="square"> | <ul type="square"> | ||
Line 11: | Line 11: | ||
<br /> | <br /> | ||
You may also be interested in [http://webwork.maa.org/wiki/ErrorMessageCustomization ErrorMessageCustomization] | You may also be interested in [http://webwork.maa.org/wiki/ErrorMessageCustomization ErrorMessageCustomization] | ||
</ | </div> | ||
<p style="text-align:center;"> | <p style="text-align:center;"> | ||
Line 31: | Line 31: | ||
DOCUMENT(); | DOCUMENT(); | ||
loadMacros( | loadMacros( | ||
"PGstandard.pl", | "PGstandard.pl", | ||
"MathObjects.pl", | "MathObjects.pl", | ||
"answerHints.pl", | "answerHints.pl", | ||
); | ); | ||
Line 104: | Line 104: | ||
$showPartialCorrectAnswers = 1; | $showPartialCorrectAnswers = 1; | ||
ANS($answer->cmp() | ANS($answer->cmp()->withPostFilter(AnswerHints( | ||
->withPostFilter(AnswerHints( | |||
Formula("6 t") => "Are you using the correct variable?", | Formula("6 t") => "Are you using the correct variable?", | ||
Formula("6 u") => "Good work!", | Formula("6 u") => "Good work!", | ||
)) | ))); | ||
); | |||
</pre> | </pre> | ||
<td style="background-color:#eeccff;padding:7px;"> | <td style="background-color:#eeccff;padding:7px;"> | ||
Line 119: | Line 117: | ||
If the same error message should be given for several different answers, you should make a square bracketed list of those answers. For example, if the variables x, t, and u were all in the context, we could use | If the same error message should be given for several different answers, you should make a square bracketed list of those answers. For example, if the variables x, t, and u were all in the context, we could use | ||
<pre> | <pre> | ||
ANS($answer->cmp() | ANS($answer->cmp()->withPostFilter(AnswerHints( | ||
->withPostFilter(AnswerHints( | |||
[Compute("6 t"),Compute("6 x")] => | [Compute("6 t"),Compute("6 x")] => | ||
"Are you using the correct variable?", | "Are you using the correct variable?", | ||
)) | ))); | ||
); | |||
</pre> | </pre> | ||
</p> | </p> | ||
Line 130: | Line 126: | ||
If the MathObjects answer evaluator normally generates a message, the default is not to change a message that is already in place. To override a message generated by a MathObjects answer evaluator, you should set <code>replaceMessage=>1</code> as below. | If the MathObjects answer evaluator normally generates a message, the default is not to change a message that is already in place. To override a message generated by a MathObjects answer evaluator, you should set <code>replaceMessage=>1</code> as below. | ||
<pre> | <pre> | ||
ANS($answer->cmp() | ANS($answer->cmp()->withPostFilter(AnswerHints( | ||
->withPostFilter(AnswerHints( | |||
Compute("6 u") => ["Good work!",replaceMessage=>1], | Compute("6 u") => ["Good work!",replaceMessage=>1], | ||
)) | ))); | ||
); | |||
</pre> | </pre> | ||
</p> | </p> |
Revision as of 19:26, 20 July 2012
Answer Hints
This PG code shows how to include two different kinds of answer hints:
- General answer hints that help students get started on a problem and are made available after a student has submitted an answer at least once (a "Show hints" checkbox appears near the "Submit Answers" button).
- Specific, customized answer hints that appear in the answer feedback messages box after a student submits a particular answer that activates a pre-programmed hint.
You may also be interested in ErrorMessageCustomization
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "answerHints.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric"); Context()->variables->are(t=>"Real",u=>"Real"); $f = Formula("2 t"); $answer = Formula("6 u"); |
Setup:
We restrict the variables to |
Context()->texStrings; BEGIN_TEXT If \( f(t) = $f \), then \( f(3u) \) = \{ ans_rule(10) \} END_TEXT $showHint = 5; BEGIN_TEXT $PAR If you don't get this in $showHint tries, you can get a hint. END_TEXT BEGIN_HINT Substitute \( 3u \) wherever you see \( t \) in the formula for \( f(t) = $f \). END_HINT Context()->normalStrings; |
Main Text:
We set |
$showPartialCorrectAnswers = 1; ANS($answer->cmp()->withPostFilter(AnswerHints( Formula("6 t") => "Are you using the correct variable?", Formula("6 u") => "Good work!", ))); |
Answer Evaluation:
To generate specific, customized answer hints for particular answers, we use the If the same error message should be given for several different answers, you should make a square bracketed list of those answers. For example, if the variables x, t, and u were all in the context, we could use ANS($answer->cmp()->withPostFilter(AnswerHints( [Compute("6 t"),Compute("6 x")] => "Are you using the correct variable?", )));
If the MathObjects answer evaluator normally generates a message, the default is not to change a message that is already in place. To override a message generated by a MathObjects answer evaluator, you should set ANS($answer->cmp()->withPostFilter(AnswerHints( Compute("6 u") => ["Good work!",replaceMessage=>1], ))); |
- POD documentation: answerHints.pl.html
- PG macro code: answerHints.pl
- POD documentation: problemPanic.pl.html
- PG macro code: problemPanic.pl