<answer>
The following examples illustrate use of the <answer> tag attributes (Part 1).
Attributes
Attributes for <answer>
Highlighted (2)
boolean. Default value: false. Whether to render the answer's input inline rather than as a block.
boolean. Default value: false. Whether comparison uses symbolic equality (rather than numeric evaluation).
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Answer grading (11)
boolean. Default value: true. Whether to color-code the response based on its correctness.
boolean. Default value: false. Whether to disable the answer after a fully correct response has been submitted.
integer. Default value: 3. Number of significant digits to display for the credit achieved value.
integer. Default value: 10. Number of significant digits to display when rendering numeric responses.
boolean. Default value: false. Whether this answer is graded by hand rather than automatically.
boolean. Default value: false. Whether to award partial credit when the response is partially correct.
integer. Default value: Infinity. Maximum number of times the response can be submitted.
boolean. Default value: true. Whether to display whether the submitted response is correct.
text. Default value: Check Work. Label for the submit button when correctness is shown.
text. Default value: Submit Response. Label for the submit button when correctness is not shown.
number. Default value: 1. Relative weight of this answer when aggregating credit across multiple answers.
Other (26)
number. Default value: 0. Maximum allowed numeric error when comparing numbers (relative or absolute).
boolean. Default value: false. Whether allowedErrorInNumbers is interpreted as an absolute (rather than relative) tolerance.
boolean. Default value: false. Whether text comparisons ignore letter case.
creditByAttemptnumberList. Per-attempt credit multipliers (e.g. "1 0.7 0.5" for full/70%/50% on attempts 1/2/3+).
disableWrongChoicesboolean. Default value: false. Whether incorrect choices are disabled after being submitted.
boolean. Default value: false. Whether the answer's submitted-response panel is expanded by default.
boolean. Default value: false. Whether to expand math expressions before comparing them.
boolean. Default value: false. Whether to always render a full-size check-work button.
boolean. Default value: false. Whether to always render a small check-work button.
boolean. Default value: false. Whether the allowed numeric error also applies to numbers in exponents.
boolean. Default value: false. Whether unfilled blanks in a math expression count as a match.
boolean. Default value: false. Whether to match list responses by exact position rather than by content.
integer. Default value: 1. Maximum number of matching awards whose credits are summed.
numPeriodicSetMatchesRequiredinteger. Default value: 3. Number of consecutive elements of a periodic set required to count as a match.
numSignErrorsMatchednumber. Default value: 0. Maximum number of sign errors that still count as a match.
parseScientificNotationboolean. Default value: false. Whether to parse expressions like 1e3 as scientific notation.
preserveLastChoiceboolean. Default value: false. For choice answers: whether the last-rendered choice keeps its position when shuffling.
boolean. Default value: false. For choice answers: whether multiple choices may be selected.
showPreviewboolean. Default value: false. Whether to display a preview of the response as the student types.
boolean. Default value: false. For choice answers: whether to display choices in randomized order.
keyword. Level of simplification applied to math expressions before comparing them.
| Value | Description |
|---|---|
none (default) | No simplification is applied before comparing. |
full | Fully simplify both expressions before comparing. |
numbers | Simplify numeric subexpressions only, leaving symbolic structure intact. |
numbersPreserveOrder | Like numbers, but does not reorder commutative operands. |
normalizeOrder | Reorder commutative operands into a canonical form without simplifying values. |
boolean. Default value: true. Whether multi-character symbols should be split into a product of single-character variables when parsing.
typekeyword. Type of input the answer expects.
| Value | Description |
|---|---|
math | Expect a math expression answer. |
text | Expect a text answer. |
boolean | Expect a boolean answer. |
videoWatched | Mark correct when the associated video has been watched. |
boolean. Default value: false. Whether order is ignored when comparing list-like responses.
videoreference. Reference to a video; when watched, this answer's videoWatched type marks credit.
videoCreditLabeltext. Label shown next to the credit indicator for a video-watched answer.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
boolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Attribute Examples
Example: disabled
The condition within the disabled attribute is true until the
user achieves credit for the first <answer>.
The symbolicEquality attribute was added to prevent mathematical operations
in the answer validation, so that, for example, 2-1 is not a correct
answer to the first question.
Example: weight
This example illustrates the use the weight attribute
within an <answer>. Use weight to reduce or enhance the
proportion of total credit on the page obtained for a correct response to a
single <answer>. By default, each <answer> has an equal weight of .
Example: inline
For a multiple choice question, the inline attribute causes the choices to displayed using an inline format.
Example: handGraded
The handGraded attribute is applied when auto-grading is not possible or
preferred. The student’s responses are stored for future grading.
Example: matchPartial
When the matchPartial attribute is applied, an automated partial
credit evaluation will be attempted, potentially giving credit between 0 and 1. Without the matchPartial attribute, the response
must be completely correct before it receives credit.
The automated partial credit algorithm will attempt to break up logical conditions into pieces, look separately at components of vectors, and award partially matched choices.
More fine grained control can be obtained by adding multiple <award> children to an <answer> and giving
each <award> a different credit attribute.
For comparison of vectors, the attributes matchByExactPositions and unorderedCompare influence the partial credit algorithm.
Example: symbolicEquality
Note that you cannot repeat the original expression in the first question, and you cannot commute the terms in the second question.
For answer validation that is more liberal (but still stricter than the default numerical checker),
combine symbolicEquality with the simplifyOnCompare and expandOnCompare attributes.
Example: forceFullCheckWorkButton
When an <answer> has an input field inside it, it will, by default use a small check work button to the right of the
input field. To override this default and use the large button, add the forceFullCheckWorkButton attribute.
An answer without an input field uses the large button, by default. (See forceSmallCheckWorkButton, below).
With the large button, it is also possible to customize the message on the button using the submitLabel attribute.
Example: forceSmallCheckWorkButton
When an <answer> does not have an input field inside it, it will, by default use a full check work button.
To override this default and use the small button, add the forceSmallCheckWorkButton attribute.
An answer with an input field always uses the small button, by default. (See forceFullCheckWorkButton, above.)
If both forceFullCheckWorkButton and forceSmallCheckWorkButton are supplied, forceFullCheckWorkButton takes precedence.
Example: simplifyOnCompare
Specifying the symbolicEquality attribute switches to a symbolic answer-checker that demands exact syntatical equality. The symbolic equality can be relaxed with the simplifyOnCompare attribute.
The simplifyOnCompare attribute has five options:
simplifyOnCompare="none": the default value of demanding exact equality.simplifyOnCompare="full"(or simplysimplifyOnCompareby itself): apply currently available simplification routines before checking. Does not include expanding factored expressions.simplifyOnCompare="numbers": simplify numerical expressions like1+2but not algebraic expressions. Permute terms and factors into a canonical order before checking equality.simplifyOnCompare="numbersPreserveOrder": simplify numbers but without permuting terms or factors.simplifyOnCompare="normalizeOrder": permute terms and factors to a standard order but perform no other simplifications.
To include expansion of factored expressions, you can add the expandOnCompare attribute.
Note: if symbolicEquality is not specified, simplifyOnCompare has no effect.
Example: expandOnCompare
The default comparison is a numerical answer-checker with a liberal definition of equality.
Specifying the symbolicEquality attribute switches to a symbolic answer-checker
that demands exact syntactical equality. The symbolic equality can be relaxed with
the simplifyOnCompare attribute. To expand factor expressions prior to comparison, you should also include the expandOnCompare attribute.
Note: if symbolicEquality is not specified, expandOnCompare has no effect.
Example: unorderedCompare
When multiple values are compared within a single <answer> tag, the
default behavior is to match the order of the sequenced values. If order is
irrelevant, use the unorderedCompare attribute.
unorderedCompare can be used with list components (e.g., <mathList>, <numberList>,
and <textList>) as well as the <math> component containing a list (e.g, ), tuple
(e.g., ) or array (e.g., ).
Alternatively, and for more control over what is ordered, one can add the unordered attribute
directly to a list component or a <math>, which will cause an unordered comparison
to be used when comparing it to anything else.
Example: matchByExactPositions
The attribute matchByExactPositions influences how the matchPartial calculates partial
credit involving vectors, lists, and related quantities. Without matchByExactPositions,
the vectors and would be deemed by matchPartial to have a 67% match, as
both contain the sequence , even though no components match. With matchByExactPositions,
they would have a 0% match, as none of the first, second or third coordinates match.
In general, for a comparison of vectors, one would want to include matchByExactPositions along
with matchPartial to give partial credit only for matches in a coordinate. For comparing
ordered lists, matchByExactPositions may not be desired.
matchByExactPositions implies an ordered comparison, so attributes like unorderedCompare and unordered are ignored.
Example: numAwardsCredited
By default, if an <answer> has multiple <award> children, only a single
award will be credited. If multiple awards match, then the award with the largest credit
will be chosen (with order in the document breaking ties).
The behavior can be changed by setting the numAwardsCredited attribute to an
integer larger than the default of 1. If numAwardsCredited="2", then up to two <award>s can
be matched, and the credit achieved will the sum of their corresponding credits (up to a maximum of 1).
Combining multiple <award>s with numAwardsCredited can be an approach for
assigning partial credit based on different required aspects of the answer.