Appearance
Lifecycle
The Mathew activity solver runs functions called lifecycle hooks every time something happens in it (e.g. when an activity has started, when the student answered an exercise, etc.).
You can use these hooks to run your own code at these times.
Registering lifecycle hooks
Lifecycle hooks are registered in the startActivitySolver function.
javascript
import { startActivitySolver } from '@adaptical/mathew-activity-solver'
const activitySolverRoot = document.querySelector('#app')
const activitySolverOptions = {}
const lifecycleHooks = {
onGoToNextExercise: (oldExercise, newExercise) => console.log('Next exercise'),
onStartActivity: (exercises) => console.log('Activity started'),
onFinishActivity: (exercises) => console.log('Activity finished'),
onSeeRelatedContent: (content) => openBookSection(content.book.isbn, content.bookSection.identifier),
}
startActivitySolver(activitySolverRoot, activitySolverOptions, lifecycleHooks)