MathObject Answers - PGML
Contents
Answers from MathObejcts
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to Compute()
). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,
Context("Interval"); BEGIN_PGML The interval from 0 to 1 excluding 0 but including 1 is written: [___________]{"(0,1]"} END_PGML
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.
Instead of using quotation marks, you can use a MathObject creator function, like Real()
or Matrix()
if you prefer.
Context("Complex"); BEGIN_PGML As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)} END_PGML
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.
Context("Vector"); $p = Point(0,2), $q = Point(1,-1); $v = Vector($q-$p); BEGIN_PGML A vector from [`[$p]`] to [`[$q]`] is [______________]{$v} END_PGML