Team Allocation: Add tutors by searching students#1912
Conversation
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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. ChangesTutor import flows
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
clients/team_allocation_component/src/team_allocation/network/queries/searchStudents.tsclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsxclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsxclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsx
mathildeshagl
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
clients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportDialog.tsxclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorImportFromCourse.tsxclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSearchStudents.tsxclients/team_allocation_component/src/team_allocation/pages/TeamAllocation/components/TutorSelection.tsxservers/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
✨ 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:
This lets a lecturer add tutors who are not part of any other PROMPT course, directly from the student directory.
Implementation notes:
TutorImportDialog) plus two focused tab components (TutorImportFromCourse,TutorSearchStudents). Both tabs reuse the existingTutorSelectionlist and share onegetAllTeamsquery, theimportTutorsmutation, and error/loading state.GET /api/students/search/:searchStringvia the sharedaxiosInstancefrom@tumaet/prompt-shared-state(new querysearchStudents.ts).POST .../team/tutorshandler upserts into thetutortable with no participant/foreign-key requirement oncourse_participation_id, and tutor team-scoping resolves byuniversity_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
🖼️ Screenshots (if UI changes are included)
✅ PR Checklist
Summary by CodeRabbit