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

fix: students levels are not shared with anybody when the student is … #2376

Conversation

sebp999
Copy link
Contributor

@sebp999 sebp999 commented Oct 31, 2024

…dismissed

Description

Fixes #2315
When a student is released by a teacher, the students levels are no longer shared.

How Has This Been Tested?

Modified unit test test_views.TestTeacherViews.test_release_verified_student and verified manually

Checklist:

  • [ x ] My change requires a change to the documentation.
  • [ x ] I have updated the documentation accordingly.
  • [ / ] I have linked this PR to a ZenHub Issue.

This change is Reviewable

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @sebp999)


portal/views/teacher/teach.py line 623 at r1 (raw file):

        students_levels = Level.objects.filter(owner=student.new_user.userprofile).all()
        for level in students_levels.all():

I feel like you might not need all() here since you're already using all() when creating students_levels above


portal/views/teacher/teach.py line 625 at r1 (raw file):

        for level in students_levels.all():
            for other in level.shared_with.all():
                level.shared_with.remove(other)

Let's simply set level.shared_with to an empty queryset if possible, since technically an newly independent student can't shared levels with anyone anyway - so no need to iterate through the queryset itself.

Code quote:

            for other in level.shared_with.all():
                level.shared_with.remove(other)

portal/views/teacher/teach.py line 627 at r1 (raw file):

                level.shared_with.remove(other)

        student.class_field = None

Let's execute level.save() before this line to ensure the new value of the shared_with field is properly saved

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sebp999)

@faucomte97 faucomte97 merged commit b5773f6 into ocadotechnology:master Nov 2, 2024
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Releasing a student doesn't unshare custom levels
2 participants