Difference between revisions of "Common MathObject Properties"
(Created table of values) |
(Add Reference Tables category) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
$mo->{property} = $x; |
$mo->{property} = $x; |
||
− | The common properties include: |
||
+ | In addition to the properties listed below, you can also set any of the Context flags listed in the [[Context flags]] documentation page as properties of a MathObject. In this case, the value will override that stored in the Context, but for that MathObject only. For example, you could set the <code>tolerance</code> on a Real, or the <code>limits</code> for a Formula in that way. |
||
+ | |||
+ | === Properties Common to All Classes === |
||
{| class="wikitable" |
{| class="wikitable" |
||
Line 68: | Line 70: | ||
| style="padding: 5px" | This is a reference to a hash that specifies options for the answer array layout, including the characters to use for the left and right delimiters and the separator in answer arrays. It provides values for <code>open</code>, <code>close</code>, and <code>sep</code>; the defaults are dependent on the class, and correspond to the open and close delimiters for the object, and either comma or blank as the separator, depending on the class. |
| style="padding: 5px" | This is a reference to a hash that specifies options for the answer array layout, including the characters to use for the left and right delimiters and the separator in answer arrays. It provides values for <code>open</code>, <code>close</code>, and <code>sep</code>; the defaults are dependent on the class, and correspond to the open and close delimiters for the object, and either comma or blank as the separator, depending on the class. |
||
| style="text-align: center" | object specific |
| style="text-align: center" | object specific |
||
+ | |||
+ | |} |
||
+ | |||
+ | === Variables and Constants === |
||
+ | |||
+ | {| class="wikitable" |
||
+ | ! Variable !! Description !! style="padding:5px" | Default |
||
+ | |||
+ | |- style="vertical-align: top" |
||
+ | | style="padding: 5px; white-space: nowrap" | <code>%Value::Type</code> |
||
+ | | style="padding: 5px" | A hash containing type definitions needed for the values of <code>Parser::Item</code> objects. Use |
||
+ | |||
+ | : <code>TEXT(join(',',lex_sort(keys(%Value::Type))));</code> |
||
+ | |||
+ | in the [http://hosted2.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/2/?login_practice_user=true PG labs] to get a list of the available types. |
||
+ | | style="text-align: center" | |
||
+ | |||
+ | |- style="vertical-align: top" |
||
+ | | style="padding: 5px; white-space: nowrap" | <code>$Value::answerPrefix</code> |
||
+ | | style="padding: 5px" | The answer name prefix to use for answer arrays created by the <code>ans_array()</code> method. |
||
+ | | style="text-align: center" | <code>"MaTrIx"</code> |
||
+ | |||
+ | |- style="vertical-align: top" |
||
+ | | style="padding: 5px; white-space: nowrap" | <code>$Value::CMP_ERROR</code><br><code>$Value::CMP_WARNING</code><br><code>$Value::CMP_MESSAGE</code> |
||
+ | | style="padding: 5px" | Error values used with <code>$context->setError()</code> to indicate the severity of the error in answer checkers. |
||
+ | | style="text-align: center" | <code>2</code><br><code>3</code><br><code>4</code> |
||
|} |
|} |
||
Line 74: | Line 102: | ||
[[Category:MathObjects]] |
[[Category:MathObjects]] |
||
+ | [[Category:Reference Tables]] |
Latest revision as of 06:51, 13 August 2012
There are a number of properties that are common to all MathObejcts, as described below. Note that these properties apply to all MathObjects, but not every MathObject will have all of them defined. Some classes have additional properties, and many of these are listed in the documentation for the individual MathObject Classes. You set or get the value of a property of a MathObject as you would a property for any Perl object, using the ->
operator with the MathObject on the left and the propery name in braces on the right. E.g.,
$x = $mo->{property}; $mo->{property} = $x;
In addition to the properties listed below, you can also set any of the Context flags listed in the Context flags documentation page as properties of a MathObject. In this case, the value will override that stored in the Context, but for that MathObject only. For example, you could set the tolerance
on a Real, or the limits
for a Formula in that way.
Properties Common to All Classes
Option | Description | Default |
---|---|---|
$mo->{context}
|
A reference to the Context object under which the MathObject was created. Even if the Context is changed, the MathObject will continue to operate within its original Context. | Context()
|
$mo->{equation}
|
A reference to the Formula object from which a MathObject was created (if it was the result of evaluating a Formula). | parent Formula |
$mo->{correct_ans}
|
The string to use for the correct answer when students request answers (after the due date). This is set automatically by | undef
|
$mo->{data}
|
A reference to an array containing the information defining the MathObject (e.g., the coordinates of a Point, the elements of a List, the intervals in a Union, or the real and imaginary parts of a Complex number. | object data |
$mo->{format}
|
A printf -style string indicating how real numbers should be formatted for display. If the format ends in # , then trailing zeros are removed after the number is formatted. Example: "%.4f" would format numbers using 4-place decimals.
|
"%g"
|
$mo->{open}
|
For list-type objects (e.g., Points, Vectors, Matrices, Sets), the symbol to use at the left of the object when it is displayed. | See specific class page |
$mo->{close}
|
For list-type objects (e.g., Points, Vectors, Matrices, Sets), the symbol to use at the right of the object when it is displayed. | See specific class page |
$mo->{noinherit}
|
A reference to an array of property names that will not be included when a copy of a MathObject is made. This includes things like text_values and f for Formulas, and other values that are maintained automatically by the object.
|
object specific |
$mo->{isValue}
|
When creating subclasses of MathObject classes, you may need to set this value so that the MathObject library will recognize your object class as belonging to the Value package. | undef
|
$mo->{isClass} E.g., $mo->{isVector}
|
When creating a subclass of a MathObject class, you may need to set this so that the MathObjects library will properly recognize your object as being of the given type when it does type-matching for things like comparisons with student answers, and so on. The Class can be any of the MathObject class names, e.g, $mo->{isReal} .
|
undef
|
$mo->{ans_name} $mo->{ans_rows} $mo->{ans_cols}
|
These are used by the $mo->ans_array method to store information about the name used for the answer array, and its size.
|
undef
|
$mo->{format_options}
|
This is a reference to a hash that specifies options for the answer array layout, including the characters to use for the left and right delimiters and the separator in answer arrays. It provides values for open , close , and sep ; the defaults are dependent on the class, and correspond to the open and close delimiters for the object, and either comma or blank as the separator, depending on the class.
|
object specific |
Variables and Constants
Variable | Description | Default |
---|---|---|
%Value::Type
|
A hash containing type definitions needed for the values of Parser::Item objects. Use
in the PG labs to get a list of the available types. |
|
$Value::answerPrefix
|
The answer name prefix to use for answer arrays created by the ans_array() method.
|
"MaTrIx"
|
$Value::CMP_ERROR $Value::CMP_WARNING $Value::CMP_MESSAGE
|
Error values used with $context->setError() to indicate the severity of the error in answer checkers.
|
2 3 4
|