ReferencefeedbackDefinition

<feedbackDefinition>

A reusable feedback definition referenced by other components

<feedbackDefinition> defines a reusable feedback string keyed by a code. Authors place one or more <feedbackDefinition> elements in a <setup> block, then reference them by code from <award> elements (via the feedbackCodes attribute). When that award is achieved, the matching feedback text becomes available on the answer’s feedbacks property (and on the award’s own feedback).

The author must then render the feedback in the desired location by referencing one of those properties — <answer> is an inline component and DoenetML cannot infer where to place the block-level feedback on its own. Typical pattern: put $ans.feedbacks in a paragraph or block right after the <answer>. Without that reference, the feedbackCodes match has no visible effect.

This separates what feedback is shown from what triggers it. The same code can be reused across many problems, and per-section overrides are respected: a <feedbackDefinition> inside a nested <setup> shadows one defined further up the tree. Code matching is case-insensitive.

Attributes and Properties

Attributes for <feedbackDefinition>

Other (2)

text. Identifier used to reference this feedback definition.

text. Default feedback text for this code.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <feedbackDefinition name="f">

Other (4)
$f.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$f.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$f.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$f.hidden

boolean. Whether this component is hidden from the rendered output.

Common to all components (4)
$f.doenetML

text. The DoenetML source code that produced this component.

$f.hide

boolean. Whether to hide this component from the rendered output.

$f.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$f.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Built-in feedback codes

Four feedback codes are pre-defined and available without any <feedbackDefinition>. Reference them from <award feedbackCodes="…"> (or <choice feedbackCodes="…">) exactly like author-defined codes; the lookup is case-insensitive, so goodJob, GOODJOB, and goodjob all match the same entry.

CodeDefault text
goodJobGood job!
numericalErrorCredit reduced because numbers in your answer weren’t quite right. Did you round too much?
oneSignErrorCredit reduced because it appears that you made a sign error.
twoSignErrorsCredit reduced because it appears that you made two sign errors.

A document- or section-scoped <feedbackDefinition> may shadow any of these by reusing the same code — see “Override feedback per section” below. Scoping is by ancestor: a shadow inside one section affects only that section’s descendants, so sibling sections still see the built-in defaults.

Examples

Example: Define and use feedback by code

Each <award> names a feedback code via feedbackCodes. When that award is matched, the text from the matching <feedbackDefinition> becomes available on $ans.feedbacks; rendering that reference (here in a paragraph below the answer) is what actually shows the feedback to the learner. (The code goodJob is one of the four built-in codes listed above, so it does not need its own <feedbackDefinition>.)


Example: Override feedback per section

The second problem’s local <feedbackDefinition> overrides the document-level one, so the same rounded code produces different feedback text in each problem. Each <problem> renders its own answer’s feedbacks reference so the correct text appears in context.

Attribute Examples

Attribute Example: code, text

code is the case-insensitive lookup key referenced from <award feedbackCodes="...">; text is the feedback string the referenced answer’s feedbacks property delivers (here rendered just below the answer).