-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Tagging] Don't put tags in OLX when duplicating/copy-pasting #203
Comments
@yusuf-musleh CC @bradenmacdonald This part is giving me trouble:
The StagedContent OLX doesn't store usage keys for the child blocks, and I can't always compute them from the E.g. suppose I copy a Unit to the clipboard that contains a bunch of blocks of various types: Source UsageKey:
I can work out the source child usage keys for the blocks that have a Alternatively, I could accumulate the tags for each block into a list that matches the block creation order, and just pop them off as new blocks are created.. but that doesn't seem very reliable. How should I approach this? |
@pomegranited One approach I can think of was building on top of your suggestion
It would be to create a hash for each block and store that in a dictionary (rather than a list), mapping the hash -> tags that block holds. So then when it's time to paste, and you're extracting the serialized tags from the staged content blocks, you can recompute the hash and get the tags you should apply to it from the dict, that way its more reliable. I was looking through the codebase, there are a few examples of hashing content. For example (though for a different purpose), here we hash the content of the static assets we are copying. What do you think of this approach? edit: I realized I'm making the assumption that each block would have something different/unique about it, is that the case? From the example above, if we look at |
@pomegranited It's too bad the url_name is inconsistent. One option would be to modify
I think an approach along those lines would be fine. But I wouldn't rely on the creation order or the order they're re-created. I agree it's not very reliable. But what should be reliable is the order of the children relative to the root block. So you can store the tags like: tags = {
"0": {root block tags},
"0.0": {tags for the first child of the root block},
"0.1": {tags for the second child of the root block},
"0.1.0": {tags for the first child of the second child of the root block},
} etc. When you get the BLOCK_COPIED signal, you can recurse the children, capture the tags, and create this structure. And when you get the BLOCK_PASTED, you wait until the whole tree of blocks is pasted, then apply the tags by walking the tree structure. You can store this tag data in |
Thank you for your suggestions @yusuf-musleh and @bradenmacdonald !
This one seems the simplest, so I'll try that first.
We don't currently have |
Oh, it doesn't have to be a signal/event. You can just call the function directly. My bad. |
@bradenmacdonald @pomegranited Wouldn't we hit the same issue we faced before when we wanted to add tags to the OLX, i.e. where we'd need to make changes in other special block repos (like ora2) to introduce changes to the data being serialized? |
@yusuf-musleh XBlockSerializer is different -- before, we were relying on properties and methods in the XBLOCK_MIXIN classes, which could be overridden by custom XBlocks like ora2. But XBlockSerializer is just a tool used to serialize any XBlock, so I can modify it to inject a |
@pomegranited Maybe I'm missing something, but XBlockSerializer uses the |
Here's what I ended up doing: openedx/edx-platform@7702971
Yes, there's a lot of similarities to this approach. The main difference is that instead of storing the serialized tags in the OLX (using TaggedBlockMixin), I'm storing them in a new XBlockSerializer.tags property. These serialized tags are then saved to the new
I ended up modifying
Yes -- we could have added tags to the OLX using this approach, and avoided TaggedBlockMixin and the issues with the non-XML block types. But Axim didn't want us putting tags in the OLX, even temporarily, for a bunch of reasons. |
@yusuf-musleh What you're missing is that And yeah, as @pomegranited has pointed out, we've decided not to include tags into OLX at any point due to concerns about forwards/backwards compatibility with the way that Learning Core will be using OLX for all XBlock storage in the future. |
@pomegranited @bradenmacdonald I see, makes sense, thanks for the clarification! |
"As platform developers, we don't want to change the OLX format for Redwood in a way that will be difficult to maintain when Learning Core is used more in the future".
Context: see this discussion.
Acceptance criteria:
ObjectTag
entries and make them point to theStagedContent
instances, or add a newtags
field to theStagedContent
model. Note it should be able to handle units and sections that are copied, with children that have tags.TaggedBlockMixin
from the platform and remove the related functionality from ORA2.The text was updated successfully, but these errors were encountered: