Skip to content

Team Allocation: Add tutors by searching students#1912

Merged
rappm merged 6 commits into
mainfrom
feat/726-tutor-search-import
Jul 19, 2026
Merged

Team Allocation: Add tutors by searching students#1912
rappm merged 6 commits into
mainfrom
feat/726-tutor-search-import

Conversation

@rappm

@rappm rappm commented Jul 12, 2026

Copy link
Copy Markdown
Member

✨ What is the change?

Extends the Import Tutors dialog in Team Allocation with a second way to add tutors. The dialog now has two tabs:

  • From Course — the existing flow: pick a source course/phase and import its students as tutors.
  • Search Students — a new flow: search the global student pool (debounced, by name, email, matriculation number, or university login), select one or more people, assign each a team, and add them as tutors.

This lets a lecturer add tutors who are not part of any other PROMPT course, directly from the student directory.

Implementation notes:

  • The old single-file dialog was split into a small shell (TutorImportDialog) plus two focused tab components (TutorImportFromCourse, TutorSearchStudents). Both tabs reuse the existing TutorSelection list and share one getAllTeams query, the importTutors mutation, and error/loading state.
  • Student search calls the existing core endpoint GET /api/students/search/:searchString via the shared axiosInstance from @tumaet/prompt-shared-state (new query searchStudents.ts).
  • No backend change was needed. The existing POST .../team/tutors handler upserts into the tutor table with no participant/foreign-key requirement on course_participation_id, and tutor team-scoping resolves by university_login (not participation ID), so a searched non-participant added with their login is scoped correctly on login.

📌 Reason for the change / Link to issue

Lecturers previously could only import tutors from another PROMPT course/phase, so anyone not already in a PROMPT course could not be made a tutor. This adds the search-and-add UI for that case.

Closes #726
Closes #1538

🧪 How to Test

  1. Open a Team Allocation phase as a lecturer and click Import Tutors.
  2. From Course tab: confirm the existing import-from-course flow still works (select course, phase, students, assign teams, import).
  3. Search Students tab: type at least 2 characters; matching students load. Select one or more, assign each a team, and click Add Selected Tutors.
  4. Confirm the added people appear as tutors and that a person with an existing tutor login triggers the duplicate-login error rather than a silent overwrite.

🖼️ Screenshots (if UI changes are included)

Before After
Import Tutors dialog: course flow only Import Tutors dialog: From Course + Search Students tabs

✅ PR Checklist

  • Tested locally or on the dev environment
  • Code is clean, readable, and documented
  • Tests added or updated (if needed)
  • Screenshots attached for UI changes (if any)
  • Documentation updated (if relevant)

Summary by CodeRabbit

  • New Features
    • Added debounced student search during tutor imports, with loading, error, and no-results states.
    • Introduced a tabbed import flow to import tutors from a course phase or by searching students.
    • Added student selection, select-all, and per-student team assignment before importing.
    • Import now shows progress feedback and stays unavailable until required selections are complete.
  • Bug Fixes
    • Improved handling of duplicate tutor logins during import with more specific error details.

@rappm
rappm requested a review from a team July 12, 2026 14:10
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@rappm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 03fa7df2-e2ac-43e7-b37e-a7349004257a

📥 Commits

Reviewing files that changed from the base of the PR and between a339b1f and 1d3a44a.

📒 Files selected for processing (1)
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSelection.tsx
📝 Walkthrough

Walkthrough

The tutor import dialog now provides separate course-based and student-search-based import tabs. New components handle selection and team assignment, while the dialog validates submitted tutors and invokes the existing import mutation. Duplicate-login errors now include the conflicting login.

Changes

Tutor import flows

Layer / File(s) Summary
Student search import flow
clients/team_allocation_component/src/team_allocation/network/queries/searchStudents.ts, clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx
Adds debounced student lookup, login-aware selection, team assignment, and conversion of selected students into Tutor objects.
Course-based tutor selection
clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsx, clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSelection.tsx
Adds course and phase selection, conditional student loading, login-gated selection, team assignment, and tutor import handling.
Tabbed dialog orchestration and import errors
clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsx, servers/team_allocation/team/service.go
Replaces the former inline selection flow with tabs, shared team validation, delegated import handling, and duplicate-login error context.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TutorImportDialog
  participant TutorSearchStudents
  participant searchStudents
  participant axiosInstance
  participant ImportTutors
  User->>TutorImportDialog: open Search Students tab
  TutorImportDialog->>TutorSearchStudents: provide phaseId and teamOptions
  User->>TutorSearchStudents: enter search text and select students
  TutorSearchStudents->>searchStudents: request debounced query
  searchStudents->>axiosInstance: GET student search endpoint
  axiosInstance-->>searchStudents: return Student[]
  searchStudents-->>TutorSearchStudents: display results
  TutorSearchStudents->>TutorImportDialog: onImport(Tutor[])
  TutorImportDialog->>TutorImportDialog: validate team assignments
  TutorImportDialog->>ImportTutors: submit tutors
  ImportTutors-->>TutorImportDialog: return duplicate-login error context
Loading

Possibly related PRs

Suggested reviewers: mathildeshagl

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding tutor import via student search in Team Allocation.
Description check ✅ Passed The PR description includes the required change, reason, testing steps, screenshots, and checklist sections.
Linked Issues check ✅ Passed The changes satisfy #726 and #1538 by adding a student-search import flow and the tabbed Import Tutors UI.
Out of Scope Changes check ✅ Passed The server-side duplicate-login error wrapping supports the new import flow and remains related to the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/726-tutor-search-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx`:
- Around line 32-80: Reset selectedStudents and teamAssignments whenever the
debounced search query changes, so selections from prior result sets cannot
remain active or affect the import count. Add the reset alongside the
trimmedQuery/search state flow, using an effect keyed to the query value;
preserve the existing selection and import behavior within the current search
results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f92b553f-c370-4b4d-9c3e-3af789c732da

📥 Commits

Reviewing files that changed from the base of the PR and between 7a25923 and 0da8829.

📒 Files selected for processing (4)
  • clients/team_allocation_component/src/team_allocation/network/queries/searchStudents.ts
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx

@rappm rappm added the schau mi o Translation: Ready to review label Jul 15, 2026

@mathildeshagl mathildeshagl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, clean refactor — splitting the dialog into a shell + two focused tabs reads well, and the backend claims mostly check out (login-based scoping + the idx_tutor_phase_login unique index + 23505 → 409 mapping). A few things I'd like addressed before merge, mainly around the search flow.

- Hide the Search Students tab for roles without prompt-wide access, since
  /students/search is gated to PromptAdmin/PromptLecturer
- Disable selection of students without a university login; they can never be
  team-scoped via GetTutorTeamByUniversityLogin
- Surface the backend error (including the colliding login) on import failure
  instead of the generic Axios message
- Document that search maps the student's own ID into course_participation_id

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSelection.tsx`:
- Around line 37-39: Update the button label condition in TutorSelection so it
displays “Select All” whenever selectableCount is 0, while preserving “Deselect
All” only when all available tutors are selected. Keep the existing disabled
behavior and onSelectAll handler unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9435278a-1a90-4113-a18e-f6cb95f45cf4

📥 Commits

Reviewing files that changed from the base of the PR and between 0da8829 and a339b1f.

📒 Files selected for processing (5)
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSelection.tsx
  • servers/team_allocation/team/service.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx
  • clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsx

@rappm
rappm deployed to prompt-dev-vm July 17, 2026 22:36 — with GitHub Actions Active
@rappm
rappm merged commit 194cbe5 into main Jul 19, 2026
78 checks passed
@rappm
rappm deleted the feat/726-tutor-search-import branch July 19, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

schau mi o Translation: Ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import Tutors User Interface Team Allocation: Import Tutors that are not part of another PROMPT course

2 participants