Skip to content
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

feat: add content tag serialization/deserialization [FC-0049] #385

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drag_and_drop_v2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Drag and Drop v2 XBlock """
from .drag_and_drop_v2 import DragAndDropBlock

__version__ = "3.4.0"
__version__ = "3.5.0"
30 changes: 30 additions & 0 deletions drag_and_drop_v2/drag_and_drop_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ class DragAndDropBlock(

block_settings_key = 'drag-and-drop-v2'

xml_attributes = Dict(help="Map of unhandled xml attributes, used only for storage between import and export",
default={}, scope=Scope.settings)

@property
def score(self):
"""
Expand Down Expand Up @@ -1387,3 +1390,30 @@ def index_dictionary(self):
xblock_body["content_type"] = "Drag and Drop"

return xblock_body

def add_xml_to_node(self, node):
"""
Serialize the XBlock to XML for exporting.
"""
super().add_xml_to_node(node)

# Serialize and add tag data if any
if hasattr(self, 'add_tags_to_node') and callable(self.add_tags_to_node): # pylint: disable=no-member
# This comes from TaggedBlockMixin
self.add_tags_to_node(node) # pylint: disable=no-member

@classmethod
def parse_xml(cls, node, runtime, keys, id_generator):
"""Instantiate XBlock object from runtime XML definition.

Inherited by XBlock core.
"""
breakpoint()
block = super().parse_xml(node, runtime, keys, id_generator)

# Deserialize and add tag data info to block if any
if hasattr(block, 'read_tags_from_node') and callable(block.read_tags_from_node): # pylint: disable=no-member
# This comes from TaggedBlockMixin
block.read_tags_from_node(node) # pylint: disable=no-member

return block
Loading