Allow non-leaf nodes as correct answers - #16
Conversation
- Schema: add `allow_non_leaf_answers` (treeConfigs) and `selected_link` (treeTaskResults) columns; migration 0007_happy_cammi.sql - Types: add allowNonLeafAnswers to StudyFormData.tasks and TreeTestConfig - Actions: thread allowNonLeafAnswers through saveStudyData / loadStudyData / loadTestConfig; persist selectedLink in storeTreeTaskResult; prefer stored selectedLink over the resolver heuristic in recalculateStudyResults and the answer-changed branch of saveStudyData (legacy NULL rows still use the resolver) - Setup tasks tab: add allowNonLeafAnswers Switch; fix getAllPaths to use sanitizeTreeTestLink (resolves consistency bug) and emit non-leaf paths when the setting is on; drive checkPathInTree off availablePaths so picker and validator always agree; make leaf-only hint text conditional - Participant tree (tree-test.tsx): when allowNonLeafAnswers is on, parent rows gain a sibling "Select" button revealed on hover/focus (desktop) and when expanded (touch) with gradient text-fade; default click still toggles; selectedLink is now persisted on every submission (leaf and non-leaf) - results-actions: add comment clarifying expectedParentPaths derivation for non-leaf correct answers
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds optional support for non-leaf (parent category) nodes as correct answers in tree tests, gated by a new per-study
Confidence Score: 4/5Safe to merge for new studies; existing live studies that retroactively adopt non-leaf answers and trigger a stats recalculation on legacy results may see incorrect success flags for those old rows. The feature is well-scoped and the happy path (new participants on new studies with the toggle enabled) is correctly implemented end-to-end. The one concern is
Important Files Changed
Reviews (3): Last reviewed commit: "style: fix oxfmt formatting failures in ..." | Re-trigger Greptile |
- Restore ownership checks in loadStudyData and recalculateStudyResults that were accidentally committed from local uncommitted edits (P0) - Set Navigation's internal selectedLink in handleSelectNonLeaf so the selected styling (green border/button, persistent fade) activates for non-leaf selections (P2)
|
@greptileai review |
…s toggles Validation badges previously persisted after flipping the toggle, showing green for non-leaf paths that were no longer selectable by participants.
- Move the "Select" button before the expand/collapse chevron so the chevron stays flush right like every other row - Mirror the non-leaf select behavior in the tree tab's Interactive Tree Preview, with an "Allow non-leaf nodes as answers" checkbox (two-way bound to the study setting) next to "What participants will see" - Clear stale validation results via effect so toggling the setting from either tab resets validation badges
Focus-based reveal was unreliable on touch devices. Below the sm breakpoint the button (and label fade) is now always visible; sm+ keeps the hover/focus reveal.
The accordion auto-collapse shifts layout under the finger on tap, and mobile browsers re-evaluate sticky :hover at the old touch point — a child row (or its Select button) under that point lit up as if focused. Gating hover styles behind @media(hover:hover) removes the artifact; desktop behavior is unchanged.
|
@greptileai review |
Problem / Intent
Tree tests currently only allow leaf (final-destination) nodes as correct answers. This prevents study owners from setting a parent category as the intended destination — a valid scenario when the goal is to reach a section rather than a specific page.
Approach
The feature is gated by a per-study
allowNonLeafAnswerstoggle (mirroringrandomizeTasks) so existing studies are entirely unaffected when off.On the participant side, parent rows gain a "Select" button that reveals on hover/focus (desktop) or when the node is expanded (touch), with a gradient text-fade so long labels never collide with the button. The default click on a parent still toggles expand/collapse.
A
selected_linkcolumn is added totree_task_resultsand written at submission time (for both leaf and non-leaf answers). Scoring and Recalculate Stats now compare against this stored value directly, eliminating the resolver heuristic for any new result. Legacy rows (NULL) continue using the existing resolver unchanged.A secondary fix lands in passing: the setup answer picker was computing non-leaf paths with a different sanitizer than the one
tree-tab.tsxuses for leaf links (sanitizeTreeTestLink). This would have caused byte mismatches between owner-saved answers and participant selections — now both sides use the same function.