-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix: the get_completion JS handler should not ignore FBE blocks #27422
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
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.
The surrounding little refactor was all to just expose _get_usage_key_for_course and _get_descriptor_by_usage_key so that we could call them outside the context of get_module_by_usage_id.
63f4495 to
f8c2a5b
Compare
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 know we use the will_recheck_access argument in other places, so this is fine, though otherwise I wonder if you could have an argument that more clearly communicates the purpose like strip_inacessible_blocks_from_tree or something
- were you able to test that the bug was fixed locally for a FBE example?
- do you think it would be worthwhile to add a test with some FBE problems that confirms the completion is calculated correctly?
Dillon-Dumesnil
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.
From what I could understand, yeah, makes sense. Thanks for the PR comment
| this.num_contents = this.contents.length; | ||
| this.id = this.el.data('id'); | ||
| this.ajaxUrl = this.el.data('ajax-url'); | ||
| this.getCompletionUrl = runtime.handlerUrl(element, 'get_completion'); |
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 think this is a part I don't have a great understanding of. The runtime already has a method defined to handle this? I don't see any other changes related.
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 don't fully understand this concept of a runtime either. It's a versioned JS specific runtime that only seems to have this method?
But it's how the rest of the modern xblock JS code gets handler URLs.
Well that's how I'm using it, but some future handler might actually want to check access itself. I wanted to keep as close to the existing usage of the phrase as possible (show up in searches for that flag, etc).
Yeah it seems to work. You know I ain't touching xblock code without testing it. :P
Yeah I hadn't gotten to the test part of this PR, honestly. Either fixing or adding. Probably makes sense to add some sort of test somewhere for this new flag / handler behavior. |
f8c2a5b to
f89e988
Compare
Because xblock handlers normally get a block tree that already has inaccessible blocks stripped, they don't see FBE gated blocks at all. So the get_completion handler would return True for FBE units incorrectly. Leading to a visual bug as an audit user went through their units in the courseware. In order to let the handler know about the full tree, I've added a new attribute you can set on your xblock handlers: my_handler.will_recheck_access = True This will tell the top-level handler code get the full tree for you. As part of this, I've also changed the sequence xblock handler's into proper xblock handlers (not old-style xmodule handlers). This changes their URLs slightly. I've kept the old URLs for now as well, but they'll be removed after Maple. AA-409
f89e988 to
b90039b
Compare
|
Your PR has finished running tests. There were no failures. |
|
Heads up that I fixed tests and added some new ones. No actual "real code" changes so a re-review is not necessary, but if you're bored you can look over the tests. |
|
@mikix: Thanks for pinging @kdmccormick and myself on this. I'm good with the architectural issues. In the longer term, I definitely have concerns about the level at which FBE is implemented, and the mixing of concerns that is happening by introducing markup HTML at the access permissions layer. But as we discussed earlier, I agree that implicitly passing it along as a parameter of the handler via the Some other high level questions/observations:
|
I'm not sure I understand the question. Xblock handlers do some default event tracking? (I didn't notice it, but I believe it) And the worry would be that we have some number crunching somewhere that would be interrupted by this handler URL change? |
Some of the events are explicitly emitted, others are derived from server tracking logs. But I think we're safe here because the ones around sequence navigation look like they're explicitly emitted at the JS layer to the tracking endpoint: https://edx.readthedocs.io/projects/devdata/en/stable/internal_data_formats/tracking_logs.html#seq-goto-seq-next-and-seq-prev @doctoryes: Does that sound right to you? |
|
@ormsbee Correct - the sequence events are emitted explicitly. For example, and then transformed into That flow isn't being changed in this PR. And these events can be seen in Snowflake using queries like this one: You could use Snowflake queries post-deploy to ensure that the proper events are still being emitted. |
|
Thank you for looking, Julia! OK, I'll merge this in 30min or so if no one has any objections |
|
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. |
|
|
||
| try { | ||
| module = new window[moduleType](element); | ||
| module = new window[moduleType](element, runtime); |
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.
@mikix @MatthewPiatetsky This seems to have caused a regression for the Conditional Block. After cherry-picking it, the conditional_get handler is not being called causing the ConditionalBlock to display empty. This is because calledElId here gets set to runtime and then the render() on line 17 is not called.
See https://openedx.atlassian.net/browse/TNL-8318 for details.
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 geeze sorry - let me work on a fix.
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.
PR for fix: https://github.com/edx/edx-platform/pull/27625 (needs some more local testing, but I think that's the idea)
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! 🙂
Commit message:
Because xblock handlers normally get a block tree that already has inaccessible blocks stripped, they don't see FBE gated blocks at all. So the get_completion handler would return True for FBE units incorrectly. Leading to a visual bug as an audit user went through their units in the courseware.
In order to let the handler know about the full tree, I've added a new attribute you can set on your xblock handlers:
my_handler.will_recheck_access = TrueThis will tell the top-level handler code to get the full tree for you.
As part of this, I've also changed the sequence xblock handlers into proper xblock handlers (not old-style xmodule handlers). This changes their URLs slightly. I've kept the old URLs for now as well, but they can be removed after Maple.
https://openedx.atlassian.net/browse/AA-409
Full set of changes with explanations:
will_recheck_access. The toplevel handler code in module_render.py will now peek at the xblock to see if it should strip inaccessible blocks or not.metadatahandler altogether. This was added for the learning MFE's benefit, but then never properly used because that team later added a new API request that then internally called the handler. I think they needed different module lookup flags, much like I did (they seem to both disable debug info and also set will_recheck_access). The handler is not actually called externally from the learning MFE.XBlockToXModuleShiminxmodule.js). This lets old JS easily get the proper handler URL the same way that modern JS does.get_completion.will_recheck_access = True.This will also need changes to the learning MFE to call the new locations of these handers.