<answer>
The following examples illustrate use of the <answer> tag attributes (Part 2).
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: maxNumAttempts
The maxNumAttempts attribute may be used to limit the number of attempts
on a question-by-question basis.
Example: allowedErrorInNumbers
The allowedErrorInNumbers attribute may be used to specify a tolerance on numerical values that are considered to be correct.
If the answer includes variables as well as numbers, using the symbolicEquality attribute will typically give more precise behavior.
By default, the error tolerance is specified as a fraction of the absolute value of the correct response.
The allowedErrorIsAbsolute attribute will change the tolerance to be specified as an absolute number.
Example: allowedErrorIsAbsolute
To specify an allowed error with a specific numerical value (rather than as a fraction of the correct response),
use the allowedErrorIsAbsolute attribute in combination with the allowedErrorInNumbers attribute.
Example: includeErrorInNumberExponents
By default, allowedErrorInNumbers does not apply to exponents
so that is not considered within 1% of . To allow error in such
exponents, add the includeErrorInNumberExponents attribute, preferably with the symbolicEquality attribute.
Example: caseInsensitiveMatch
Use the caseInsensitiveMatch attribute if capitalization is not relevant for validation.
Example: showCorrectness
The showCorrectness attribute may be used to hide the validation of individual questions for assessments.
The default behavior is to show correctness unless either the handGraded attribute was
specified or we are in assignment where the Show Correctness setting has been set to false.
The showCorrectness attribute on <answer> will override these settings to either
always show or never show correctness.
Example: colorCorrectness
The colorCorrectness attribute defaults to true, which means answer boxes by default have a colored border (and corresponding aria-label)
to indicate the correctness of the response.
If an input (e.g., <mathInput>) is linked to an answer with the forAnswer attribute,
then that input’s box coloring will be determined by the answer’s colorCorrectness attribute.
Example: type=“text”
The type attribute of <answer> is needed in a few cases to switch the answer to text mode
when it cannot be inferred. In text mode, the response must match
exactly with only whitespace difference at the beginning or end. See caseInsensitiveMatch for one
way to relax this requirement.
Example: disableAfterCorrect
The disableAfterCorrect attribute can be used to render <answer> components disabled after credit is achieved.
Example: submitLabel
The submitLabel attribute can be used to create a custom label for the “Check Work” button.
Example: submitLabelNoCorrectness
The submitLabelNoCorrectness attribute modifies the standard
“Submit Response” button label for answers where it is not desired to show correctness.
Example: selectMultiple
The selectMultiple attribute allows multiple <choice> components to be selected for response.
Example: shuffleOrder
The shuffleOrder will create different variants of the document with the choices rendered in different orders.
Due to the algorithm used to generate these variants, the displayed variant may display the choices in the original order if there are fewer than 5 choices.
Example: splitSymbols
By default, an <answer> will split multiple characters entered into the
product of single character variables (unless the combination contains a non-leading number).
Setting splitSymbols to false will turn off this splitting so that variables in a
product must be separated by a space or a multiplication symbol.
Example: expanded
The expanded attribute renders an expanded text box for answers with type="text".
Example: displayDigitsForResponses
The displayDigitsForResponses determines how many digits are displayed when
referencing the users responses of the answer.
The default value is 10 digits.
Example: displayDigitsForCreditAchieved
The displayDigitsForCreditAchieved determines how many digits are displayed when referencing
the creditAchieved property of the answer.
The default value is 3 digits.
Example: matchBlanks
If a mathematical expression is incomplete, such as <math>3+()</math>, it may contain blanks that
are rendered by an underscore or a gray square. Since such blanks typically indicate an error in a
mathematical expression, any expression with a blank will, by default, never match a correct answer.
To valid as correct a response that includes a blank, add the matchBlanks attribute to the <answer>.