Learning Events
Learning Events from Web Components
Algebrakit's web components emit events to notify your system of key moments in the student learning process. These events cover:
- Lifecycle events (e.g. component creation and activation)
- Student actions (e.g. submitting an answer, requesting a hint)
You can listen to these events using the addExerciseListener() method.
addExerciseListener()
Listen for learning events globally or for a specific session.
AlgebraKIT.addExerciseListener((eventData) => {
// handle event
});
// listen to events related to a session
AlgebraKIT.addExerciseListener("my-session-id", (eventData) => {
// handle session-specific event
});
Event Reference
exercise-created
Triggered when an <akit-exercise> component is initialized and all interactions are loaded.
Payload:
{
event: 'exercise-created',
sessionId: string,
data: {
element: Element,
interactions: InteractionDescription[]
}
}
InteractionDescription = {
refId: string,
scorable: boolean,
type: string
}
| Property | Description |
|---|---|
element |
DOM element of the exercise component. |
interactions |
List of interactions in the exercise. |
refId |
Unique ID of the interaction. |
scorable |
Indicates whether the interaction is scored or display-only. |
type |
Type of interaction (multistep, geometry, fill-in-the-blanks, etc.). |
interaction-created
Triggered when an <akit-interaction> component is initialized and ready.
Payload:
{
event: 'interaction-created',
sessionId: string,
refId: string,
data: {
element: Element,
interaction: string
}
}
| Property | Description |
|---|---|
element |
DOM element of the interaction component. |
refId |
ID of the interaction within the exercise. |
interaction |
Type of interaction (e.g. multistep, geometry). |
interaction-activated
Triggered the first time a student activates an interaction (e.g. by clicking on it).
No payload.
interaction-hint
Triggered when the student requests a hint.
No payload.
interaction-evaluate
Triggered when a student submits an answer for evaluation.
Payload:
| Property | Type | Description |
|---|---|---|
exerciseFinished |
boolean | Whether the full exercise is now finished. |
interactionType |
string | Type of the interaction (e.g. choice, multistep). |
progress |
number | Progress in the range [0, 1] for multi-part questions. |
replay |
boolean | true if this is part of a replay (e.g. in review mode). |
scoring |
object | Scoring info (if a model was configured). See Scoring. |
interaction-input-state-changed
Triggered when the student input of an interaction changes from empty to non-empty. Currently only supported in Multistep interactions
Payload:
| Property | Type | Description |
|---|---|---|
inputIsEmpty |
boolean | true if the input line(s) of the interaction is empty |
interaction-virgin-state-changed
Triggered when the virgin state of the interaction changes. An interaction is considered virgin when a student has not worked on it yet i.e. the student has not entered any input, has not submitted anything and not asked any hints. This learning event is currently only supported for Multistep and Arithmetic Notebook interactions
Payload:
| Property | Type | Description |
|---|---|---|
virgin |
boolean | true if the interaction is in the virgin state |
isAnswerEmpty |
boolean | Arithmetic Notebook only. true if the answer field is empty |
isDerivationEmpty |
boolean | Arithmetic Notebook only. true if the student has not provided any intermediate steps |
interaction-finished
Triggered when a student completes an interaction.
Payload:
Same as interaction-evaluate.
question-finished
Triggered when all interactions in a specific question are complete.
Payload:
| Property | Type | Description |
|---|---|---|
scoring |
object | Aggregated score for all interactions in the question. |
replay |
boolean | true if submitted during replay or review mode. |
exercise-finished
Triggered when all interactions in the entire exercise are finished.
Payload:
| Property | Type | Description |
|---|---|---|
scoring |
object | Final scoring for the entire exercise. |
replay |
boolean | true if submitted during replay or review mode. |
Exposed API
After loading the script, the following functions become available:
| Function | Description |
|---|---|
addExerciseListener |
Register to listen to learning events. |
getWidgets |
Returns metadata for all rendered widgets. |
render |
Renders inline LaTeX and MathML in the DOM. |
waitUntilReady |
Await full widget initialization. |