fix: do not remove comments from XML during course import#28557
fix: do not remove comments from XML during course import#28557nedbat merged 1 commit intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @Agrendalath! I've created OSPR-5996 to keep track of it in JIRA. As a core committer in this repo, you can merge this once the pull request is approved per the core committer reviewer requirements and according to the agreement with your edX Champion. |
xitij2000
left a comment
There was a problem hiding this comment.
👍
- I tested this: I tried exporting and importing a course without this PR and the XML comments were lost in the process. I tried again with this PR checked out and the comments are retained now.
- I read through the code
- [na] I checked for accessibility issues
- [na] Includes documentation
- [na] I made sure any change in configuration variables is reflected in the corresponding client's
configuration-securerepository.
|
@Agrendalath I think I would treat as probably a technical enhancement. Since this is capa-related, the owning team is @edx/teaching-and-learning Would someone on T&L ack this change, as per https://openedx.atlassian.net/wiki/spaces/COMM/pages/1529675973/Open+edX+Core+Committers#Reviews-and-Ownership which says that ack from owning team is sufficient for a PR with CC review. I tagged you because this changes the xml parser behavior. |
|
or possibly @nedbat who reviewed the original revert PR? |
|
@sarina, won't we need another CC to review this change, as @xitij2000 is not the CC of |
|
Ah, great point. Yeah it's be good if Ned or someone from T&L could review in that case. |
|
The code I mentioned in my comment on the old PR is still in the repo ( It is true that if you try to parse |
|
Thank you for your guidance here, @nedbat. I've scheduled some time for the next week to verify this case and add a test for it. |
|
@nedbat, you were right - when a comment was manually added to the LibraryContentBlock directly in the XML export, then this block was being ignored on import. I've changed this behavior (to ignoring XML comments) and added a test case for this. I've also tried manually adding comments to verticals in the XML export and there were some exceptions raised by modulestore/xml.py, but they are already handled in seq_module and vertical_block. I see that this code from the TranslateCustomTagBlock might not handle this, but when I'm trying to add a Traceback (most recent call last):
File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/preview.py", line 327, in get_preview_fragment
fragment = module.render(preview_view, context)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 198, in render
return self.runtime.render(self, view, context)
File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1969, in render
return self.__getattr__('render')(block, view_name, context)
File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1418, in render
return super().render(block, view_name, context=context)
File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 823, in render
raise NoSuchViewError(block, view_name)
xblock.exceptions.NoSuchViewError |
There was a problem hiding this comment.
This isn't an error, it would be better to do what XBlock does: explicitly check for a comment node and skip it. But this will rarely happen, so let's move ahead.
There was a problem hiding this comment.
You don't need to define setUp if it only calls super().setUp(). The parent's setUp will be inherited.
There was a problem hiding this comment.
@nedbat, it looks a bit confusing in the diff, but both super().setUp() and self.lc_block.refresh_children() have the same indentation level.
|
Sorry for the delay. This is good to merge. |
nedbat
left a comment
There was a problem hiding this comment.
Let me know if you want me to merge, or if you want to make any more adjustments.
a5d1fa2 to
b162521
Compare
Agrendalath
left a comment
There was a problem hiding this comment.
@nedbat, I've squashed the commits. Please merge this when the CI passes. Thank you!
There was a problem hiding this comment.
@nedbat, it looks a bit confusing in the diff, but both super().setUp() and self.lc_block.refresh_children() have the same indentation level.
|
jenkins run all |
b162521 to
4d2c2eb
Compare
|
@nedbat, just a friendly reminder about this PR. |
This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users.
4d2c2eb to
bda2228
Compare
|
@nedbat, checking again, as it would be great to include this in Maple. |
|
@jmbowman: thought you might like to know that Agrendalath merged this pull request. |
|
@Agrendalath 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
|
I've cherry-picked this onto Maple. |
|
Thank you, @nedbat! |
|
Your PR has finished running tests. There were no failures. |
|
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. |
This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users.
) This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
) This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
) This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
) This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
) This is a follow-up to edx#1087, which reverted this change. According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks. This also handles (ignores) the comments that could be added directly to the LibraryContentBlock in the XML export by users. (cherry picked from commit 4bf829d)
This is a follow-up to edx#1087, which reverted this change.
According to the PR comments, parsing strings with XML comments inside them was causing errors. This does not seem to be the case anymore - these strings are just hidden when the block is rendered, but they are not breaking XBlocks.
Jira
OSPR-5996
BB-3827
Sandbox
https://pr28557.sandbox.opencraft.hosting/ (provisioning)
Testing instructions
Create a new course with the following
Blank Advanced Problem:Export the course.
Import the exported course.
Check that the comments were retained in the XBlock.
Deadline
None.
Reviewers
Settings