This repository was archived by the owner on Jun 1, 2024. It is now read-only.

Description
It should not be possible (as is currently the case in prod 😅) for a teacher to assign the same activity to the same student for the same piece.
Proposed resolution:
- Update the assignment model to have this constraint (unique across 3
assignment
fields: activity
, enrollment
, piece
)
- makemigrations
- update the autogenerated migration to have a cleanup process that runs first (before the operation that adds the unique constraint) which will:
- for each enrollment
- for each piece
- for each activity
- determine if there are "duplicate" assignments (aggregate a "dupe_set")
- if there are, try to see whether more than 1 has a submission:
- if there is exactly 1 assignment in the "dupe_set" with submissions, delete all other assignments in the "dupe_set"
- elif there are 0 with submissions, delete all but the most recent assignments in the "dupe_set"
- elif there are > 1 with submissions, find the one with the most recent submission or submissionattachment and keep this and delete the others.
see the de-dupe-assns branch