-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[BD-13] Let ModuleSystem use UserService #28440
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
Conversation
|
Thanks for the pull request, @pomegranited! I've created BLENDED-937 to keep track of it in Jira. More details are on the BD-13 project page. When this pull request is ready, tag your edX technical lead. |
640078b to
e029feb
Compare
symbolist
left a comment
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.
Thanks, I have done a pass.
f99e457 to
e24a8f7
Compare
1523b7b to
7c24e84
Compare
|
Hi @ormsbee ! This PR is ready for your eyes. There's a question in the Author Notes that could use your feedback too, when you get a chance. CC @symbolist |
7c24e84 to
4f95b3b
Compare
|
@pomegranited I missed this earlier:
It looks like it only needs the Django User object? Or does it need the |
|
@symbolist I've addressed your last comment, so this should be ready for your final review. CC @ormsbee |
symbolist
left a comment
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 tested this by checking changes to HTML and Problem XBlocks, due dates, timed exams.
- I read through the code
- I checked for accessibility issues
- Includes documentation
|
@pomegranited Have a couple of questions and then this just needs a rebase! |
25dce1d to
7cb20bf
Compare
…vice The following ModuleSystem attributes are deprecated by this change, and should be pulled directly from the user service instead: * anonymous_student_id * seed * user_id * user_is_staff Related changes: * Removes the `user` and `anonymous_student_id` parameters from the ModuleService constructor. * Stores anonymous_user_id in XBlockDjangoUserService's opt_attr * Pulls out constants used by DjangoXBlockUserService opt_attr so they can be used in the platform code. * LmsModuleSystem uses the user service created in wrapper function for runtime.publish to avoid requiring the user service to be "needed" by all XBlocks. * LmsModuleSystem no longer checks for instances of XModuleDescriptor when deciding what kind of anonymous_user_id to provide: all XModules are XBlocks, so this check is unnecessary. * XBlockRuntime returns a user service when requested * Adds tests for deprecated ModuleSystem attributes and changes to XBlockDjangoUserService.
Removes references to these deprecated attributes from the platform code: * runtime.anonymous_student_id * runtime.seed * runtime.user_id * runtime.user_is_staff Related changes: * Ensure that all platform XBlocks which use these attributes "need" the user service. * ProblemBlock: Removes check for existence of runtime.seed attribute in preparation for removal of this attribute from ModuleSystem. * edxnotes: Catches NoSuchServiceError just in case some XBlocks using notes don't have the user service. * UserTagsService refactor: pass user and course_id on creation
* UserStubService now takes user, user_is_staff, and anonymous_user_id * get_test_system() creates a UserStubService with an anonymous_user_id of 'student' * Removes references to deprecated ModuleSystem attributes from test code * Fixes and simplifies the ConditionalBlock tests, using get_module provided by TestModuleSystem instead of trying to mock out all the pieces.
b20c99f to
927016a
Compare
|
Your PR has finished running tests. There were no failures. |
symbolist
left a comment
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.
@ormsbee This is ready for merge at a convenient time (preferably early in the day). 🙂
|
Talked to @symbolist about this and I'll merge tomorrow morning, around 9 AM EDT. |
|
Yay!! Thank you @ormsbee and @symbolist ! |
|
@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
| text = self.data | ||
|
|
||
| user_service = self.runtime.service(self, 'user') | ||
| anonymous_student_id = user_service.get_current_user().opt_attrs.get(ATTR_KEY_ANONYMOUS_USER_ID) |
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.
@symbolist @ormsbee I was able to reproduce the issue with the flip-flopping anonymous_student_id values and this branch, but only on the legacy courseware view.
Problem blocks have requires_per_student_anonymous_id = True set on their descriptors, and so should be using the per-user anonymous_user_id value.
However, with this branch:
- When the problem block is first viewed in the legacy courseware view, it incorrectly has the per-course
anonymous_user_idin its user service, instead of the per-useranonymous_user_id. - When the problem block is viewed in the new learning MFE, or when the problem block is scored via AJAX, it correctly uses the per-user
anonymous_user_id.
I hacked a few things and it seems like the runtime (and user service) used to initialize the ProblemBlock in the legacy courseware view isn't actually the problem block's runtime, it's the parent unit's runtime + user service. Does that sound possible? And do you have any idea how/where that's being passed 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.
Hmm, the child of a block is loaded via https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/module_render.py#L501. Checking what happens inside it with a debugger may provide some insights. You may also want to particularly check what happens when bind_for_student() gets called in these different scenarios on the ProblemBlock.
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.
@symbolist CC @ormsbee Here's the line that caused the issue, in DjangoXBlockUserService.init
That same django_user object gets passed through when creating the ProblemBlock's user service, and its parent Vertical and Sequence blocks. I unwisely stored the anonymous_user_id attribute on that shared django_user object (mimicking the user_is_staff attribute storage in the line above), and since the anonymous_user_id value is different for Problem/HTML blocks vs Vertical/Sequence blocks (cf requires_per_student_anonymous_id), it was being altered during rendering.
https://github.com/edx/edx-platform/pull/29190 will address this issue and add a test to verify the fix.
Description
Initial step towards combining the ModuleSystem and DescriptorSystem classes.
Adds a shim which deprecates these ModuleSystem attributes, pulling them from the
userservice instead of requiring them in the constructor.anonymous_student_idseeduser_iduser_is_staffThis change is only a refactoring, and should not affect Learners, Course Authors, or anyone else using edx-platform.
Supporting information
Dependent on:
Testing instructions
LMS: https://pr28440.sandbox.opencraft.hosting/
honor@example.com/edx)Studio: https://studio.pr28440.sandbox.opencraft.hosting/
staff@example.com/edx)Deadline
None