Difference between revisions of "AnswerHints"
Paultpearson (talk | contribs) (Add one more sentence.) |
|||
(3 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/AnswerHints.html a newer version of this problem]</p> |
||
<h2>Answer Hints</h2> |
<h2>Answer Hints</h2> |
||
Line 98: | Line 101: | ||
<p> |
<p> |
||
<b>Main Text:</b> |
<b>Main Text:</b> |
||
− | Knowls (little bits of knowledge) provide an always present link to a hint that, when clicked on, expands to reveal the hint or, when clicked on again, retracts to hide the hint. The <code>value</code> of a knowl should be plain text |
+ | Knowls (little bits of knowledge) provide an always present link to a hint that, when clicked on, expands to reveal the hint or, when clicked on again, retracts to hide the hint. The <code>value</code> of a knowl should be plain text (math mode may cause problems, as it did for me using ww 2.9). It is possible to get math to display, but it requires using a few escape tricks: <code>value=>escapeSolutionHTML(EV3P('Substitute \\(3u\\) ...')), base64=>1)</code>. In particular, note the use of <code>escapeSolutionHTML(EV3P())</code> to do extra interpretation of the string formatting and also note the use of double backslashes <code>\\( \\)</code> for the math mode delimiters. No special macros are needed for Knowls. |
</p> |
</p> |
||
<p> |
<p> |
||
Line 122: | Line 125: | ||
<p> |
<p> |
||
<b>Answer Evaluation:</b> |
<b>Answer Evaluation:</b> |
||
− | To generate specific, customized answer hints for particular answers, we use the <code>AnswerHints</code> postfilter provided by <code>answerHints.pl</code>. The answer hints should be provided by a particular answer, followed by the hash table association operator <code>=></code>, followed by a string that will show up in the messages portion of the answer preview and feedback box when students submit their answers. You may include as many answer and hint pairs as you like, and even use subroutines in them (see [http://webwork.maa.org/pod/ |
+ | To generate specific, customized answer hints for particular answers, we use the <code>AnswerHints</code> postfilter provided by <code>answerHints.pl</code>. The answer hints should be provided by a particular answer, followed by the hash table association operator <code>=></code>, followed by a string that will show up in the messages portion of the answer preview and feedback box when students submit their answers. You may include as many answer and hint pairs as you like, and even use subroutines in them (see [http://webwork.maa.org/pod/pg/macros/answerHints.html answerHints.pl] for more on this). |
</p> |
</p> |
||
<p> |
<p> |
||
Line 154: | Line 157: | ||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/pod/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/answerHints.html answerHints.pl]</li> |
<li>PG macro code: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/answerHints.pl?view=log answerHints.pl]</li> |
<li>PG macro code: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/answerHints.pl?view=log answerHints.pl]</li> |
||
</ul> |
</ul> |
||
Line 160: | Line 163: | ||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/pod/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/problemPanic.html problemPanic.pl]</li> |
<li>PG macro code: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/problemPanic.pl?view=log problemPanic.pl]</li> |
<li>PG macro code: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/problemPanic.pl?view=log problemPanic.pl]</li> |
||
</ul> |
</ul> |
Latest revision as of 15:52, 20 June 2023
This problem has been replaced with a newer version of this problem
Answer Hints
This PG code shows how to include three different kinds of answer hints:
- General answer hints that help students get started on a problem and are always available via "Knowls".
- 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) via a
BEGIN_HINT / END_HINT
block of text. - 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 via the
answerHints.pl
macro and a post-filter with answer hints for the answer checker.
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) \} $BR $BR \{ knowlLink("Click for a hint", value=>'Substitute 3u wherever you see t in the formula for f.') \} 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:
Knowls (little bits of knowledge) provide an always present link to a hint that, when clicked on, expands to reveal the hint or, when clicked on again, retracts to hide the hint. The
For hints that are revealed to students only after a certain number of submissions, 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
- PG macro code: answerHints.pl
- POD documentation: problemPanic.pl
- PG macro code: problemPanic.pl