fix: make the studio user_id the actual anonymous_user_id - #30248
Conversation
|
@pomegranited Can you think of any negative effects of this change? |
|
@schenedx These are the effects I can think of.. But note that I don't think they're a reason not to continue with this change, they may just require some communication. In Studio:
Are any of these concerns a worry for you @pdpinch ? For context, see the Slack discussion. |
| "settings": SettingsService(), | ||
| "user": DjangoXBlockUserService( | ||
| request.user, | ||
| anonymous_user_id='student', |
There was a problem hiding this comment.
@schenedx This is not enough to fix the issue.. you'll need to actually compute the anonymous_user_id for the current user, and pass it into the UserService as is done by the LMS ModuleSystem.
Alternatively, you can move the logic for computing this value into a new function on the UserService (it will need access to the module descriptor and the course_id) to avoid duplicating code.
There was a problem hiding this comment.
Nudge @schenedx :) Do you have an estimate for when you'll be able to address my comments?
Just planning my week, and want to make sure I allow time for a 2nd review. Thanks!
There was a problem hiding this comment.
@pomegranited This fell off my radar last week. I apologize. I thought the DjangoXBlockUserService instance already have the get_anynomous_user_id that returns the calculated value, no? Also, this is on CMS. The LMS side has the correct value returned.
There was a problem hiding this comment.
No worries @schenedx :)
Also, this is on CMS. The LMS side has the correct value returned.
Yes. What I'm saying above is the CMS needs to return the same value as the LMS, and this requires some code changes.
I thought the DjangoXBlockUserService instance already have the get_anynomous_user_id that returns the calculated value, no? ([sic: corrected source link])
Yes it does have that method, but there's some issues with using it directly:
- performance: that method hits the database to get the User object for the given username, so we'd likely want to cache it
- There's some subtleties of the LMS code -- some blocks expect a per-student anonymous ID, while some expect a per-course anonymous ID. The
DjangoXBlockUserServicecurrently has no knowledge ofcourse_id, or of the block'srequires_per_student_anonymous_idflag.
All of these issues can be solved, but they require code changes to implement them.
I have no developer experience in this area, so this is difficult for me to setup.
Ah ok.. I misunderstood. Do you have time and interest in making this change? If not, then we should find someone who does. OpenCraft could do it (for a fee), if there's no one in the community who wants to do it?
How do we test the anynomous_user_id with randomized content? Do I just need to set it up on my local environment?
Yep, if you want to implement this change, you'll need a devstack. You can test it manually, but we'd also want some automated tests to protect the change, and ensure that future code changes don't break it.
Also, I think all the side effect of this change @pomegranited have listed is worth a heads up for 2U internal.
Yep, that's worth doing, and can be done as part of the OSPR too. It's always easier to see the effects of a change when the code is in place so it can be tested.
|
@pomegranited I am grateful for your feedback. How do we test the anynomous_user_id with randomized content? Do I just need to set it up on my local environment? I have no developer experience in this area, so this is difficult for me to setup. |
|
Also, I think all the side effect of this change @pomegranited have listed is worth a heads up for 2U internal. The true question is, should we manage the communication of these side effects? Or the current behavior/no fix, would be the better behavior going forward. I'll need sometime to have this conversation with 2U stakeholders. |
bfeed04 to
4e9a35e
Compare
|
@pomegranited OK, with your explanation and a bit of my devstack testing, I now understand you better. |
13d73e1 to
79b3b02
Compare
26e69f0 to
6ede845
Compare
|
|
||
| preview_anonymous_user_id = 'student' | ||
| if individualize_anonymous_user_id(course_id): | ||
| preview_anonymous_user_id = anonymous_id_for_user(request.user, course_id) |
There was a problem hiding this comment.
@schenedx In order to ensure the same anonymous ID is used in Studio as in the LMS, you need to check the block descriptor to find out whether the anonymous user ID should be course-specific or not.
| preview_anonymous_user_id = anonymous_id_for_user(request.user, course_id) | |
| if getattr(descriptor, 'requires_per_student_anonymous_id', False): | |
| preview_anonymous_user_id = anonymous_id_for_user(request.user, None) | |
| else: | |
| preview_anonymous_user_id = anonymous_id_for_user(request.user, course_id) |
There was a problem hiding this comment.
I see. Thank you for pointing this out! This just points out my lack of knowledge in this area.
Made the change and please review again @pomegranited
There was a problem hiding this comment.
Thanks @schenedx -- I can review the code, but need a functional LTI provider in order to test it. And since Open edX no longer supports this with the new Learner MFE, I need your help with this step.
Can you provide a secret:key and URL that I can use to test this from my devstack?
There was a problem hiding this comment.
@pomegranited You can use https://saltire.lti.app/tool (check this URL for config parameters, but the values below should work).
- Launch URL: https://saltire.lti.app/tool
- ID:
test - LTI passport:
test:jisc.ac.uk:secret
Great idea! Could you flesh out your PR description to provide full Testing Instructions for how to verify this change? It'll be useful for anyone looking to figure out the history of this request. |
pomegranited
left a comment
There was a problem hiding this comment.
Provisional 👍 : Works perfectly! Just needs tests added, see schen/MST-1455...open-craft:jill/schen/MST-1455
- I tested this on my devstack using the LTI Test tool described here.
- I read through the code
-
I checked for accessibility issuesN/A - Includes documentation for the new course waffle flag added.
@schenedx FYI, I don't have merge rights on edx-platform, so you'll still need a core committer or someone at 2U/edX to approve this.
| preview_anonymous_user_id = anonymous_id_for_user(request.user, None) | ||
| else: | ||
| preview_anonymous_user_id = anonymous_id_for_user(request.user, course_id) | ||
|
|
There was a problem hiding this comment.
This is working great @schenedx , exactly as expected.
But to make sure your change doesn't get broken somewhere down the line, we need to update the unit tests to test these different cases. Here's what I'd recommend: schen/MST-1455...open-craft:jill/schen/MST-1455
There was a problem hiding this comment.
Great. I made a PR on the unit tests you wrote above and merged it. Once this PR is going green, I plan to merge as well.
and the INDIVIDUALIZE_ANONYMOUS_USER_ID flag. Co-authored-by: Jillian Vogel <jill@opencraft.com>
|
Merged! Once it deploys to prod. I'll start adding in CourseWaffleFlags and see what happens |
|
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. |
1 similar comment
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
Creating A Revert PR as this has potentially caused an outage in the content store. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
* feat: test out individualized anonymouse_user_id for studio preview on xblocks * test: adds tests for the PreviewModuleSystem anonymous_user_id (#30400) and the INDIVIDUALIZE_ANONYMOUS_USER_ID flag. Co-authored-by: Jillian Vogel <jill@opencraft.com> Co-authored-by: Simon Chen <schen@edX-C02FW0GUML85.local> Co-authored-by: Jillian Vogel <jill@opencraft.com>
Description
MST-1455
Currently, during studio preview of the xblock, we would render the xblock using the anonymous_user_id with value
student. Why not just render the xblock using the actual anonymous_user_id?One uncertainty is that the anonymous_user_id for non edX staff user would be
none. That might be a problem?Testing instructions
contentstore.individualize_anonymous_user_idstudentvalue.