-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,11 @@ | ||
| """ | ||
| Constants used by DjangoXBlockUserService | ||
| """ | ||
|
|
||
| # Optional attributes stored on the XBlockUser | ||
| ATTR_KEY_ANONYMOUS_USER_ID = 'edx-platform.anonymous_user_id' | ||
| ATTR_KEY_IS_AUTHENTICATED = 'edx-platform.is_authenticated' | ||
| ATTR_KEY_USER_ID = 'edx-platform.user_id' | ||
| ATTR_KEY_USERNAME = 'edx-platform.username' | ||
| ATTR_KEY_USER_IS_STAFF = 'edx-platform.user_is_staff' | ||
| ATTR_KEY_USER_PREFERENCES = 'edx-platform.user_preferences' |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
@symbolist @ormsbee I was able to reproduce the issue with the flip-flopping
anonymous_student_idvalues and this branch, but only on the legacy courseware view.Problem blocks have
requires_per_student_anonymous_id = Trueset on their descriptors, and so should be using the per-useranonymous_user_idvalue.However, with this branch:
anonymous_user_idin its user service, instead of the per-useranonymous_user_id.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 theProblemBlock.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_userobject gets passed through when creating the ProblemBlock's user service, and its parent Vertical and Sequence blocks. I unwisely stored theanonymous_user_idattribute on that shareddjango_userobject (mimicking theuser_is_staffattribute storage in the line above), and since theanonymous_user_idvalue is different for Problem/HTML blocks vs Vertical/Sequence blocks (cfrequires_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.