Difference between revisions of "PanicButton"

From WeBWorK_wiki
Jump to navigation Jump to search
(New page: <h2>Panic Button for Answer Hints with a Penalty</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3p...)
 
Line 128: Line 128:
   
 
<ul>
 
<ul>
<li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/ nameOfMacro.pl.html]</li>
+
<li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/problemPanic.pl.html problemPanic.pl.html]</li>
<li>PG macro: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/#dirlist nameOfMacro.pl]</li>
+
<li>PG macro: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/problemPanic.pl problemPanic.pl]</li>
 
</ul>
 
</ul>

Revision as of 23:44, 26 April 2010

Panic Button for Answer Hints with a Penalty


This PG code shows how to implement a panic button for answer hints with a penalty.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

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

TEXT(beginproblem());

Initialization: We need to include the macros file problemPanic.pl.

Context("Numeric");

$answer = Real("sin(pi/3)");

Setup: Everything is standard

BEGIN_TEXT
\( \sin(\pi/3) \) = \{ ans_rule(10) \}
$PAR
\{ Panic::Button(label => "Request a Hint (25% Penalty)", penalty => .25) \}
END_TEXT

if ($panicked) {
BEGIN_TEXT
$PAR
${BBOLD}Hint:${EBOLD} The answer is greater than \( 1/2 \).
$PAR
\{Panic::Button(label => "Another Hint (25% Penalty)", penalty => .25)\}
END_TEXT

# if you want a secondary hint
if ($panicked > 1) {
BEGIN_TEXT
${BBOLD}Hint:${EBOLD} The answer is greater than \( \sqrt{2}/2 \).
END_TEXT
}

}

Main Text: We can construct a hint button that has a penalty associated with it.

$showPartialCorrectAnswers = 1;

# install_problem_grader(~~&avg_problem_grader);

Panic::GradeWithPenalty();

ANS( $answer->cmp() );

ENDDOCUMENT();

Answer Evaluation: We must issue the command Panic::GradeWithPenalty(); after installing a problem grader. The avg_problem_grader is the default, which is why we commented out its installation. If we were to use a different problem grader, we would need to uncomment it.

Problem Techniques Index