Difference between revisions of "FractionAnswer1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Answer is a Fraction</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to ... <ul> <li>Download file: [[File:FractionAnswe…')
 
Line 62: Line 62:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context("LimitedProperFraction");
+
Context("Fraction-NoDecimals");
   
 
$answer = Compute("3/2");
 
$answer = Compute("3/2");
Line 112: Line 112:
 
$showPartialCorrectAnswers = 1;
 
$showPartialCorrectAnswers = 1;
   
ANS( $answer->cmp() );
+
ANS( $answer->cmp(
  +
studentsMustReduceFractions=>1,
  +
reduceFractions=>1
  +
)
  +
);
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">

Revision as of 18:50, 30 November 2010

Answer is a Fraction

This PG code shows how to ...

  • Download file: File:FractionAnswer1.txt (change the file extension from txt to pg)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/Algebra/FractionAnswer1.pg

Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();
loadMacros(
"PGstandard.pl",
"contextFraction.pl",
"AnswerFormatHelp.pl",
);
TEXT(beginproblem());

Initialization:

Context("Fraction-NoDecimals");

$answer = Compute("3/2");

Setup: The macro contextFraction.pl provides four contexts:

Context("Fraction");
Context("Fraction-NoDecimals");
Context("LimitedFraction");
Context("LimitedProperFraction");

For the differences among these, see the POD documentation contextFraction.pl.html

Context()->texStrings;
BEGIN_TEXT
Simplify \( \displaystyle \frac{6}{4} \).
$BR
$BR
Answer =
\{ ans_rule(20) \}
\{ AnswerFormatHelp("fractions") \}
END_TEXT
Context()->normalStrings;

Main Text:

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp(
  studentsMustReduceFractions=>1,
  reduceFractions=>1 
  ) 
);

Answer Evaluation:


Context()->texStrings;
BEGIN_SOLUTION
Factor and cancel to obtain 
\( \displaystyle $answer \)
END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();

Solution:

Templates by Subject Area