-
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
Conversation
created = models.DateTimeField(auto_now_add=True, null=True, db_index=True) | ||
|
||
# If is_active is False, then the student is not enrolled, and | ||
# `is_enrolled()` will return False. This lets us track a record of courses | ||
# that the user |
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.
This comment trails off and seems a little confusing. I think it makes sense to say something like "then the student is not considered to be enrolled in the course"
Also, the last sentence trails off.
I think this looks good otherwise. We should also make sure Stanford is up to date on these changes. |
Squashed and rebased. |
Btw, this has a conflict and can't be merged right now (probably in the CHANGELOG file) |
instance.user.roles.remove(*course_roles) | ||
return | ||
|
||
# We've enrolled the student, so make sure they have a default role | ||
if instance.user.is_staff: |
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).
…and mode. Features coming down the pipe will want to be able to: * Refer to enrollments before they are actually activated (approval step). * See what courses a user used to be enrolled in for when they re-enroll in the same course, or a different run of that course. * Have different "modes" of enrolling in a course, representing things like honor certificate enrollment, auditing (no certs), etc. This change adds an is_active flag and mode (with default being "honor"). The commit is only as large as it is because many parts of the codebase were manipulating enrollments by adding and removing CourseEnrollment objects directly. It was necessary to create classmethods on CourseEnrollment to encapsulate this functionality and then port everything over to using them. The migration to add columns has been tested on a prod replica, and seems to be fine for running on a live system with single digit millions of rows of enrollments.
Add mode and is_active to CourseEnrollment, shift enrollment logic to model
@ormsbee @dianakhuang
correct? |
oh, and no data migration is necessary because is_active defaults to true and mode defaults to "honor", correct? |
@jbau In regards to item 3, we'll be adding different types shortly, in the next week or so. |
And yes, no data migration necessary because of the defaults. The migration is fast enough to run on our live prod instance without trouble. |
Re: .is_enrolled() We sometimes run SQL scripts to determine # enrolled. Some PMs also have What is the best thing to do going forward to determine #Enrolled from the On Thu, Aug 15, 2013 at 10:15 AM, David Ormsbee notifications@github.comwrote:
|
@stroilova: I'd like edx-platform code to use the CourseEnrollment model, but you folks should still use SQL in the aggregate queries. I updated the relevant SQL query on the linked page. Thank you. |
Just saw that, thank you! On Thu, Aug 15, 2013 at 12:59 PM, David Ormsbee notifications@github.comwrote:
|
@stroilova we should discourage PMs from running that kind of query on the database since the enrollment number is accessible from the analytics tab on the instructor panel. However, if you still need the SQL query, it something like this:
|
@ormsbee Yes, I'm planning on using the methods. Was just asking about the representation to make sure I understood it. On Aug 15, 2013, at 7:14 AM, David Ormsbee notifications@github.com wrote:
|
Feature/victor/proper 404s
Update static tabs APIs to cache tab contents
Confirmation email sub
Add a mode field to allow us to support different kinds of enrollments (all current enrollments are honor code enrollments). Also add an is_active flag. This will let us do things like have an approval step before a CourseEnrollment is activated, as well as track what courses a person used to be signed up for, in case that information is necessary to determine their eligibility for other courses.
There's actually a lot more that I'd eventually like to move into CourseEnrollment (knowledge of courses, permissions, CourseEnrollmentAllowed, etc.) But shifting enroll/unenroll/is_enrolled was good enough for what I needed in the short term goal of supporting is_active as the toggle.
@dianakhuang: I still need to add some docs for this and test the migration on fake prod before I can merge this, but the code should be reviewable at this point.
@gwprice, @kevinchugh: Please review the forums code?
@sefk, @jbau: Just wanted to give you a heads up on this one.