TBX Docs
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

HookUse caseKey return values
useExerciseGroupAccess grouped scoring when inside ExerciseGroupcorrect, total, group
useMatchPairsExerciseMatch pairs between two sets (e.g. words to definitions)connections, setConnection, removeConnection, isCorrect, check, reset
useFillBlanksExerciseFill-in-the-blank exercises with multiple valid answers per blankanswers, setAnswer, isCorrect, check, reset
usePickMultiExerciseSingle or multiple selections per slot. Used by PickOne, PickMulti, YesNoanswers, setAnswer, isCorrect, check, reset
usePickOneExerciseSingle-choice, one slot onlyanswer, setAnswer, isCorrect, check
useSortListExerciseSort a list into correct orderorder, reorder, setOrder, isCorrect, check, reset
useCompareGridCompare user-filled grid against solution (Crosswords)grid, setCell, wordResults, isCorrect, check, reset, getLegendId
useFindWordsExerciseWord search: find hidden words by selecting cellsdisplayGrid, wordResults, selectedCells, setSelection, commitSelection, reset
useGroupItemsExerciseSort items from a common pool into labeled groupsitemsByGroup, moveItem, setItemsByGroup, solution, isCorrect, check, reset

On this page