LimitsOfIntegration

From WeBWorK_wiki
Revision as of 01:05, 27 April 2010 by Pearson (talk | contribs) (New page: <h2>Your title here: PG Code Snippet</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>Thi...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Your title here: PG Code Snippet


This PG code shows how to put answer blanks into the limits of an integral.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"unionTables.pl",
);
TEXT(beginproblem());

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

#
# display the integral nicely
#
if ($displayMode eq 'TeX') {
  $integral =
    '\[\int_{'.ans_rule(4).'}^{'.ans_rule(4).'}'.
         ans_rule(35).'\,dx\]';
} else {
  $integral =
   $PAR.
   $BCENTER.
   BeginTable().
     Row(['\(\displaystyle \int\)',
       ans_rule(4).$BR.$BR.ans_rule(4),
       ans_rule(35),
       '\(dx\).'],separation=>2).
   EndTable().
   $ECENTER;
}

Setup: We define a mode dependent integral with three answer blanks.

Context()->texStrings;
BEGIN_TEXT
\( \displaystyle \int_1^3 x^2 \, dx = \)
$integral
END_TEXT
Context()->normalStrings;

Main Text: The problem text section of the file is as we'd expect. We insert the integral with answer blanks using $integral.

$showPartialCorrectAnswers = 1;

ANS( Real(3)->cmp() );
ANS( Real(1)->cmp() );
ANS( Formula("x^2")->cmp() );

ENDDOCUMENT();

Answer Evaluation: As is the answer.

Problem Techniques Index