Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

De-dupe assignments #48

Open
hcientist opened this issue Mar 17, 2024 · 0 comments
Open

De-dupe assignments #48

hcientist opened this issue Mar 17, 2024 · 0 comments
Assignees

Comments

@hcientist
Copy link
Contributor

hcientist commented Mar 17, 2024

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:

  1. Update the assignment model to have this constraint (unique across 3 assignment fields: activity, enrollment, piece)
  2. makemigrations
    1. update the autogenerated migration to have a cleanup process that runs first (before the operation that adds the unique constraint) which will:
      1. for each enrollment
        1. for each piece
          1. for each activity
            1. determine if there are "duplicate" assignments (aggregate a "dupe_set")
              1. if there are, try to see whether more than 1 has a submission:
                1. if there is exactly 1 assignment in the "dupe_set" with submissions, delete all other assignments in the "dupe_set"
                2. elif there are 0 with submissions, delete all but the most recent assignments in the "dupe_set"
                3. 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

@hcientist hcientist changed the title write a migration that adds a unique constraint across 3 assignment fields: activity, enrollment, piece De-dupe assignments Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants