Numeric Answers - PGML

From WeBWorK
(Difference between revisions)
Jump to: navigation, search
m (Add PGML Sytnax category)
m (Add link to MathObject Answers)
 
Line 4: Line 4:
  
 
   BEGIN_PGML
 
   BEGIN_PGML
   The value of [: 3 + 5:] is [______]{8}
+
   The value of [: 3 + 5 :] is [______]{8}
 
   END_PGML
 
   END_PGML
  
Line 13: Line 13:
 
    
 
    
 
   BEGIN_PGML
 
   BEGIN_PGML
   The value of [: [$a] + [$b]:] is [______]{$answer}
+
   The value of [: [$a] + [$b] :] is [______]{$answer}
 
   END_PGML
 
   END_PGML
  
Line 21: Line 21:
 
    
 
    
 
   BEGIN_PGML
 
   BEGIN_PGML
   The value of [: [$a] + [$b]:] is [______]{$a+$b}
+
   The value of [: [$a] + [$b] :] is [______]{$a+$b}
 
   END_PGML
 
   END_PGML
  
Line 30: Line 30:
 
    
 
    
 
   BEGIN_PGML
 
   BEGIN_PGML
   The value of [: [$a] + [$b]:] is [______]{$answer}
+
   The value of [: [$a] + [$b] :] is [______]{$answer}
 
   END_PGML
 
   END_PGML
  
Line 38: Line 38:
  
 
   BEGIN_PGML
 
   BEGIN_PGML
   The value of [: [$a] + [$b]:] is [______]{"$a + $b"}
+
   The value of [: [$a] + [$b] :] is [______]{"$a + $b"}
 
   END_PGML
 
   END_PGML
  
 
will show "3 + 5" as the correct answer, not 8.  ('''Note:''' this requires a recent version of PGML.pl)
 
will show "3 + 5" as the correct answer, not 8.  ('''Note:''' this requires a recent version of PGML.pl)
 +
 +
See the section on [[MathObject Answers - PGML|MathObject Answers]] for details on how to provide additional control over the MathObject answer checkers.
  
  

Latest revision as of 10:50, 12 May 2015

Numeric Answer Checkers

To use a number as an answer, just put the number in braces after the answer blank:

 BEGIN_PGML
 The value of [: 3 + 5 :] is [______]{8}
 END_PGML

The value can be stored in a variable:

 $a = 3; $b = 5;
 $answer = $a + $b;
 
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [______]{$answer}
 END_PGML

or it can be an expression producing the value:

 $a = 3; $b = 5;
 
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [______]{$a+$b}
 END_PGML

The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well

 $a = 3; $b = 5;
 $answer = Compute("$a + $b");
 
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [______]{$answer}
 END_PGML

It is also possible to put the number (or formula leading to the number) in quotation marks, though this isn't necessary. If you do, however, the correct answer will be shown as the formula you used rather than the numeric value itself.

 $a = 3; $b = 5;
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [______]{"$a + $b"}
 END_PGML

will show "3 + 5" as the correct answer, not 8. (Note: this requires a recent version of PGML.pl)

See the section on MathObject Answers for details on how to provide additional control over the MathObject answer checkers.

follow us