Add recommended project-group generation with diversity and faultline preview#307
Conversation
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
mgmodell
left a comment
There was a problem hiding this comment.
We should also have a Cucumber test of 'reject' - verify that no groups are created.
If groups already exist and the user asks for suggestions and accepts those suggestions, the user should be warned that the existing groups will be removed and replaced. Then, if the user still accepts, we should verify that the old groups were removed and the new groups created as suggested.
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Addressed in fe4e5e6. Added Cucumber coverage for rejecting recommended groups without creating any groups, added a warning in the Groups tab before accepting a recommendation that would replace existing groups, and added acceptance coverage verifying the original group is removed and the remembered suggested groups are created as previewed. |
mgmodell
left a comment
There was a problem hiding this comment.
Add ruby doc (rdoc) docs for the new methods in projects_controller.rb and group.rb. How do they fit in?
|
@copilot Add ruby doc (rdoc) docs for the new methods in |
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Addressed in 9078cd4. Added RDoc comments in |
mgmodell
left a comment
There was a problem hiding this comment.
@copilot , I'm seeing the following error on features/admin_project.feature:329:350:368 at features/step_definitions/admin_project_steps.rb:260:
2026-09-05 00:00:00 +0000 Rack app ("POST /api-backend/projects/suggest_groups/1.json" - (10.89.0.17)): #<ActiveSupport::DelegationError: gender_code delegated to gender, but gender is nil>
Then the user requests recommended groups with target count 3 # features/step_definitions/admin_project_steps.rb:260
gender_code delegated to gender, but gender is nil (ActiveSupport::DelegationError)
./app/models/user.rb:34:in 'User#gender_code'
./app/models/group.rb:274:in 'Group.suggestion_sort_key_for'
./app/models/group.rb:256:in 'block in Group.suggestion_candidate_orders_for'
./app/models/group.rb:255:in 'Array#each'
./app/models/group.rb:255:in 'Enumerable#sort_by'
./app/models/group.rb:255:in 'Group.suggestion_candidate_orders_for'
./app/models/group.rb:173:in 'Group.suggest_optimal_groups'
./app/controllers/projects_controller.rb:193:in 'ProjectsController#suggest_groups'
./app/controllers/application_controller.rb:49:in 'ApplicationController#switch_locale'
features/admin_project.feature:339:in `the user requests recommended groups with target count 3'
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Addressed in 2ab1285. The recommendation sorter was calling delegated demographic helpers on users with missing demographics, which could raise during |
mgmodell
left a comment
There was a problem hiding this comment.
@copilot, now features/admin_project.feature:329:350:368 are giving me:
Then the user switches to the "Groups" tab # features/step_definitions/admin_project_steps.rb:1022026-09-05 00:00:00 +0000 Rack app ("POST /api-backend/projects/suggest_groups/1.json" - (10.89.0.17)): #<NoMethodError: undefined method '<' for an instance of Array>
Then the user requests recommended groups with target count 3 # features/step_definitions/admin_project_steps.rb:260
undefined method '<' for an instance of Array (NoMethodError)
./app/models/group.rb:369:in 'block (5 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:364:in 'Array#each_index'
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Addressed in 815f240. I found another nil-association path in recommendation scoring: diversity calculation could still dereference |
mgmodell
left a comment
There was a problem hiding this comment.
@copilot step names must be unique to avoid:
Then the user switches to the "Groups" tab # features/step_definitions/admin_project_steps.rb:1022026-09-05 00:00:00 +0000 Rack app ("POST /api-backend/projects/suggest_groups/1.json" - (10.89.0.17)): #<NoMethodError: undefined method '<' for an instance of Array>
Then the user requests recommended groups with target count 3 # features/step_definitions/admin_project_steps.rb:260
undefined method '<' for an instance of Array (NoMethodError)
./app/models/group.rb:372:in 'block (5 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:367:in 'Array#each_index'
./app/models/group.rb:367:in 'block (4 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:364:in 'Array#each_index'
./app/models/group.rb:364:in 'block (3 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:361:in 'Range#each'
./app/models/group.rb:361:in 'block (2 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:358:in 'Array#each'
./app/models/group.rb:358:in 'Enumerable#each_with_index'
./app/models/group.rb:358:in 'block in Group.suggestion_locally_improve'
./app/models/group.rb:355:in 'Integer#times'
./app/models/group.rb:355:in 'Group.suggestion_locally_improve'
./app/models/group.rb:185:in 'block in Group.suggest_optimal_groups'
./app/models/group.rb:184:in 'Array#map'
./app/models/group.rb:184:in 'Group.suggest_optimal_groups'
./app/controllers/projects_controller.rb:199:in 'ProjectsController#suggest_groups'
./app/controllers/application_controller.rb:49:in 'ApplicationController#switch_locale'
features/admin_project.feature:379:in `the user requests recommended groups with target count 3'
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Addressed in 293957e. I removed the duplicate |
| right_group.each_index do | right_member_index | | ||
| candidate_groups = current_groups.map( &:dup ) | ||
| candidate_groups[left_index][left_member_index] = right_group[right_member_index] | ||
| candidate_groups[right_index][right_member_index] = left_group[left_member_index] | ||
| candidate_score = suggestion_score_for candidate_groups | ||
| next unless candidate_score < current_score | ||
|
|
There was a problem hiding this comment.
@copilot , this is yielding the following error during Cucumber test runs (features/admin_project.feature:329:350:368):
Then the user switches to the "Groups" tab # features/step_definitions/admin_project_steps.rb:1022026-09-05 00:00:00 +0000 Rack app ("POST /api-backend/projects/suggest_groups/1.json" - (10.89.0.17)): #<NoMethodError: undefined method '<' for an instance of Array>
Then the user requests recommended groups with target count 3 # features/step_definitions/admin_project_steps.rb:260
undefined method '<' for an instance of Array (NoMethodError)
./app/models/group.rb:369:in 'block (5 levels) in Group.suggestion_locally_improve'
./app/models/group.rb:364:in 'Array#each_index'
There was a problem hiding this comment.
Addressed in 8f741a1. The failure was coming from comparing two score arrays with < inside the recommendation-improvement loop; Ruby arrays don’t implement <, so that could raise during suggest_groups. I changed it to a lexicographic <=> comparison.
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
mgmodell
left a comment
There was a problem hiding this comment.
@copilot features/admin_project.feature:272 gives me an error reported on ProjectGroups.tsx:259:
error TypeError: Converting circular structure to JSON
--> starting at object with constructor 'HTMLButtonElement'
| property '__reactFiber$kgqjjrkdina' -> object with constructor 'FiberNode'
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
This adds a recommendation flow for project groups from a course roster. Instructors can generate balanced suggested groups for a target group count, inspect per-group diversity and faultline metrics, then accept or reject the proposal before applying it.
Backend recommendation flow
>= 2Project groups API
suggest_groupsJSON endpoint for project-group recommendationsGroups tab UI
ProjectGroups.tsxwith a recommendation workflow:Coverage