Difference between revisions of "FractionAnswer1"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
<h2>Answer is a Fraction</h2>
 
<h2>Answer is a Fraction</h2>
   
  +
[[File:FractionAnswer1.png|300px|thumb|right|Click to enlarge]]
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
This PG code shows how to write a question in which the answer must be a fraction (rational number).
 
This PG code shows how to write a question in which the answer must be a fraction (rational number).
<ul>
 
<li>Download file: [[File:FractionAnswer1.txt]] (change the file extension from txt to pg when you save it)</li>
 
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Algebra/FractionAnswer1.pg</code></li>
 
</ul>
 
 
</p>
 
</p>
  +
* Download file: [[File:FractionAnswer1.txt]] (change the file extension from txt to pg when you save it)
  +
* File location in NPL: <code>FortLewis/Authoring/Templates/Algebra/FractionAnswer1.pg</code>
   
  +
<br clear="all" />
 
<p style="text-align:center;">
 
<p style="text-align:center;">
 
[[SubjectAreaTemplates|Templates by Subject Area]]
 
[[SubjectAreaTemplates|Templates by Subject Area]]

Revision as of 14:50, 2 December 2010

Answer is a Fraction

Click to enlarge

This PG code shows how to write a question in which the answer must be a fraction (rational number).

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


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.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,
  allowMixedNumbers=>0, 
  ) 
);

Answer Evaluation: There are many context flags that control how fraction answers are checked. See the POD documentation contextFraction.pl.html


Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Factor and cancel to obtain 
\( \displaystyle $answer \)
END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();

Solution:

Templates by Subject Area