School name autocomplete for student and educator signup#1721
Open
mwvolo wants to merge 10 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces the existing school-name inputs in Newflow student signup and educator profile completion with a shared, accessible autocomplete backed by a new unauthenticated /i/schools?q= endpoint, aiming to reduce free-text variance and improve data cleanliness by linking to canonical School records when selected.
Changes:
- Added
School.searchfor substring + trigram-tolerant autocomplete queries (ranked, capped) and a newNewflow::SchoolsController#indexJSON endpoint. - Updated student and educator signup/profile flows to accept
school_idand persist both the canonicalSchoollink (when valid) and the canonical name intoself_reported_school. - Introduced a shared ARIA combobox UI component (
OxSchoolAutocomplete) with associated styling, and added model/controller/handler/feature specs.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/models/school_spec.rb | Adds specs covering .search matching, ranking, typo tolerance, and caps. |
| spec/handlers/newflow/student_signup/signup_form_spec.rb | Adds handler specs for valid/blank/invalid school_id behavior. |
| spec/handlers/newflow/educator_signup/complete_profile_spec.rb | Adds handler specs for school_id linking and fuzzy-match skip. |
| spec/features/newflow/school_autocomplete_spec.rb | Adds JS feature specs for selecting, use-as-entered, and edit-clears-link. |
| spec/controllers/newflow/schools_controller_spec.rb | Adds controller specs for JSON shape, short/missing queries, and logged-out access. |
| config/routes.rb | Adds route for GET /i/schools to the newflow schools controller. |
| config/locales/en.yml | Adds i18n string for the “Use {school}” footer row label. |
| app/views/newflow/student_signup/student_signup_form.html.erb | Replaces <datalist> usage with the new autocomplete container + hidden school_id. |
| app/views/newflow/educator_signup/educator_profile_form.html.erb | Wraps school field in autocomplete container and adds hidden school_id. |
| app/models/school.rb | Implements MAX_SEARCH_DISTANCE and .search scope-like class method. |
| app/handlers/newflow/student_signup/signup_form.rb | Adds school_id param handling and canonical-name persistence. |
| app/handlers/newflow/educator_signup/complete_profile.rb | Adds school_id param handling and canonical-name persistence. |
| app/controllers/newflow/schools_controller.rb | Implements the /i/schools JSON endpoint. |
| app/assets/stylesheets/newflow.scss | Adds styles for the autocomplete dropdown and active/utility rows. |
| app/assets/javascripts/newflow/school_autocomplete.js | Adds the shared ARIA combobox/autocomplete implementation. |
| app/assets/javascripts/newflow/newflow_ui.js.coffee | Removes the old CMS-backed <datalist> fetching implementation. |
| app/assets/javascripts/newflow/index.js | Requires the new autocomplete asset. |
| app/assets/javascripts/newflow/educator_complete_dynamic.js.coffee | Tightens selector to the visible text input in the school-name block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For: https://openstax.atlassian.net/browse/DATA-300
Summary
Replaces the two school-name fields in signup with one shared, accessible autocomplete that produces clean data:
<datalist>populated from the openstax.org CMS endpoint — browser-styled dark dropdown, names only, and whatever text was in the box saved as free text (school_idnever set).What changed
School.searchscope on the local Salesforce-syncedschoolstable: case-insensitive substring match + trigram typo tolerance (uses the existinggist_trgm_opsindex), prefix matches ranked first, max 10 results.GET /i/schools?q=endpoint (Newflow::SchoolsController) returning{id, name, city, state}. The cross-origin CMS dependency is removed entirely.newflow/school_autocomplete.js, no new dependencies): debounced fetch with abort, keyboard navigation, suggestions show name + city, state to disambiguate same-named schools, and an always-presentUse "<typed text>"footer row so schools not in our list can still be entered.signup[school_id]; both handlers link the realSchoolrecord and store its canonical name inself_reported_school. Editing after picking clears the link. Free text behaves exactly as before. The educator CS-form fuzzy match is skipped when a real pick was made; SheerID flows are untouched.Tests
School.search(ranking, typo tolerance, min length, cap)school_idon both flows, including fuzzy-match skipjs: true) feature specs driving the real dropdown: pick from list, use-as-entered, edit-clears-link🤖 Generated with Claude Code