-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Add mode and is_active to CourseEnrollment, shift enrollment logic to model #651
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from django.test import TestCase | ||
|
||
from django_comment_common.models import Role | ||
from student.models import CourseEnrollment, User | ||
|
||
class RoleAssignmentTest(TestCase): | ||
""" | ||
Basic checks to make sure our Roles get assigned and unassigned as students | ||
are enrolled and unenrolled from a course. | ||
""" | ||
|
||
def setUp(self): | ||
self.staff_user = User.objects.create_user( | ||
"patty", | ||
"patty@fake.edx.org", | ||
) | ||
self.staff_user.is_staff = True | ||
|
||
self.student_user = User.objects.create_user( | ||
"hacky", | ||
"hacky@fake.edx.org" | ||
) | ||
self.course_id = "edX/Fake101/2012" | ||
CourseEnrollment.enroll(self.staff_user, self.course_id) | ||
CourseEnrollment.enroll(self.student_user, self.course_id) | ||
|
||
def test_enrollment_auto_role_creation(self): | ||
moderator_role = Role.objects.get( | ||
course_id=self.course_id, | ||
name="Moderator" | ||
) | ||
student_role = Role.objects.get( | ||
course_id=self.course_id, | ||
name="Student" | ||
) | ||
self.assertIn(moderator_role, self.staff_user.roles.all()) | ||
|
||
self.assertIn(student_role, self.student_user.roles.all()) | ||
self.assertNotIn(moderator_role, self.student_user.roles.all()) | ||
|
||
# The following was written on the assumption that unenrolling from a course | ||
# should remove all forum Roles for that student for that course. This is | ||
# not necessarily the case -- please see comments at the top of | ||
# django_comment_client.models.assign_default_role(). Leaving it for the | ||
# forums team to sort out. | ||
# | ||
# def test_unenrollment_auto_role_removal(self): | ||
# another_student = User.objects.create_user("sol", "sol@fake.edx.org") | ||
# CourseEnrollment.enroll(another_student, self.course_id) | ||
# | ||
# CourseEnrollment.unenroll(self.student_user, self.course_id) | ||
# # Make sure we didn't delete the actual Role | ||
# student_role = Role.objects.get( | ||
# course_id=self.course_id, | ||
# name="Student" | ||
# ) | ||
# self.assertNotIn(student_role, self.student_user.roles.all()) | ||
# self.assertIn(student_role, another_student.roles.all()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want two consecutive ifs rather than nested ones? It will likely never matter, but semantically, do you want to make one branch if you're a staff and another if you're a student. The edge case is a staff who unregisters for a course but should still have staff access. I guess the question is do you only want to check the active flag for non-staff, more as a policy question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why a staff member should continue to have Moderator privileges for a course that they are no longer enrolled in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was more concerned about the corollary where this essentially requires all moderators to be enrolled. Does every PM and every TA have to be enrolled explicitly to have rights in the forums? How about the instructor? I don't know the answer to that but if the answer is no, then we'll inadvertently remove all course roles for staff by virtue of their not being enrolled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I had forgotten just how divorced forum user privileges are from everything else in our system. @jimabramson: What's the desired behavior here? Remove student roles only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is important for researchers studying course histories to know what roles a student had in the forum, during the course, eg community TA or other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, how about this? I'll comment this check out, I'll comment out the tests that depend on it, and the forum team can implement whatever the right thing is at a later date. This will make the situation no worse than before the merge (since it didn't take any action back then on unenrollment either).