ExercisesHooks
Overview
Hooks for building custom exercise types
The exercise components are built on hooks from @bside-tech/tbx-ui/hooks. Use these when building custom exercise types or composing exercises outside the built-in components.
All exercise hooks integrate with useExerciseGroup when present: they call group.register() and group.setResult() so results roll up to the parent ExerciseGroup. They also support checkOn: "auto" to validate when answers change.
Available hooks
| Hook | Use case | Key return values |
|---|---|---|
| useExerciseGroup | Access grouped scoring when inside ExerciseGroup | correct, total, group |
| useMatchPairsExercise | Match pairs between two sets (e.g. words to definitions) | connections, setConnection, removeConnection, isCorrect, check, reset |
| useFillBlanksExercise | Fill-in-the-blank exercises with multiple valid answers per blank | answers, setAnswer, isCorrect, check, reset |
| usePickMultiExercise | Single or multiple selections per slot. Used by PickOne, PickMulti, YesNo | answers, setAnswer, isCorrect, check, reset |
| usePickOneExercise | Single-choice, one slot only | answer, setAnswer, isCorrect, check |
| useSortListExercise | Sort a list into correct order | order, reorder, setOrder, isCorrect, check, reset |
| useCompareGrid | Compare user-filled grid against solution (Crosswords) | grid, setCell, wordResults, isCorrect, check, reset, getLegendId |
| useFindWordsExercise | Word search: find hidden words by selecting cells | displayGrid, wordResults, selectedCells, setSelection, commitSelection, reset |
| useGroupItemsExercise | Sort items from a common pool into labeled groups | itemsByGroup, moveItem, setItemsByGroup, solution, isCorrect, check, reset |