Skip to content

School name autocomplete for student and educator signup#1721

Open
mwvolo wants to merge 10 commits into
mainfrom
school-autocomplete
Open

School name autocomplete for student and educator signup#1721
mwvolo wants to merge 10 commits into
mainfrom
school-autocomplete

Conversation

@mwvolo

@mwvolo mwvolo commented Jun 12, 2026

Copy link
Copy Markdown
Member

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:

  • Student signup previously used a native HTML5 <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_id never set).
  • Educator profile (step 4) was a plain free-text field (shown when SheerID fails/is unavailable or on the CS form).

What changed

  • New School.search scope on the local Salesforce-synced schools table: case-insensitive substring match + trigram typo tolerance (uses the existing gist_trgm_ops index), prefix matches ranked first, max 10 results.
  • New unauthenticated GET /i/schools?q= endpoint (Newflow::SchoolsController) returning {id, name, city, state}. The cross-origin CMS dependency is removed entirely.
  • Shared ARIA combobox component (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-present Use "<typed text>" footer row so schools not in our list can still be entered.
  • Clean data path: picking a suggestion sets a hidden signup[school_id]; both handlers link the real School record and store its canonical name in self_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.
  • Graceful degradation: if the endpoint is down, the field just acts as free text — signup is never blocked.

Tests

  • Model specs for School.search (ranking, typo tolerance, min length, cap)
  • Controller specs for the endpoint (JSON shape, blank/short queries, logged-out access)
  • Handler specs for valid / blank / nonexistent school_id on both flows, including fuzzy-match skip
  • 3 selenium (js: true) feature specs driving the real dropdown: pick from list, use-as-entered, edit-clears-link

🤖 Generated with Claude Code

mwvolo and others added 9 commits June 11, 2026 20:35
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>
Copilot AI review requested due to automatic review settings June 12, 2026 02:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.search for substring + trigram-tolerant autocomplete queries (ranked, capped) and a new Newflow::SchoolsController#index JSON endpoint.
  • Updated student and educator signup/profile flows to accept school_id and persist both the canonical School link (when valid) and the canonical name into self_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.

Comment thread app/handlers/newflow/educator_signup/complete_profile.rb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants