Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle mismatching datasets for exams and lessons to prevent syncing issues #8513

Merged

Conversation

bjester
Copy link
Member

@bjester bjester commented Oct 21, 2021

Background

Lesson and exam models have foreign references to the user model, and if those models are created by a user who was in a different facility (like a superuser), then the models would fail to deserialize when synced

Summary

References

Resolves: #7453
Builds off: #7887
Ref: #7859

Reviewer guidance


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@bjester bjester changed the title Handle mismatching datasets for exams and lessons to avoid syncing issues Handle mismatching datasets for exams and lessons to prevent syncing issues Oct 21, 2021
@bjester bjester added this to the 0.15.0 milestone Oct 21, 2021
@bjester bjester added DEV: backend Python, databases, networking, filesystem... python TODO: needs review Waiting for review labels Oct 21, 2021
@bjester bjester marked this pull request as ready for review October 21, 2021 20:06
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I had to read a bit harder to parse what was happening in the upgrade steps - but nothing blocking. Code makes sense and tests cover it!

],
output_field=UUIDField(),
)
Exam.objects.exclude(collection__dataset_id=F("dataset_id")).update(
Copy link
Member

Choose a reason for hiding this comment

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

This took me a couple of reads to get my head around. I think I understand what is going on though.

The dataset_id of the Exam has previously been set from the creator, and so if there is a mismatch between the dataset_id of the Exam and the dataset_id of the collection it belongs to, then we have discovered our problem exams.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the dataset inference was changed in #7887 so this migrates that change, like you said where the collection dataset doesn't match the exam's. This wasn't as simple as I wanted, and as simple as the query could have been, but Django constrained me a little bit.

)

# un-set assigned_by for all exam assignments assigned by a user in a different dataset
assignment_sub_query = Subquery(
Copy link
Member

Choose a reason for hiding this comment

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

Presumably this is now relying on the migration above having happened?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's a good note, it does depend on that to achieve the end result we want

@rtibbles rtibbles merged commit 6eb003e into learningequality:release-v0.15.x Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't set user as created_by for lesson when superadmin from Facility B creates a lesson in Facility A
2 participants