Skip to content
Merged
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: 0 additions & 2 deletions common/lib/xmodule/xmodule/annotatable_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)

Expand All @@ -35,7 +34,6 @@ class AnnotatableBlock(
RawMixin,
XmlMixin,
EditingMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
7 changes: 0 additions & 7 deletions common/lib/xmodule/xmodule/capa_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from xmodule.x_module import (
HTMLSnippet,
ResourceTemplates,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
shim_xmodule_js
Expand Down Expand Up @@ -131,7 +130,6 @@ class ProblemBlock(
RawMixin,
XmlMixin,
EditingMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down Expand Up @@ -163,11 +161,6 @@ class ProblemBlock(
mako_template = "widgets/problem-edit.html"
has_author_view = True

# The capa format specifies that what we call max_attempts in the code
# is the attribute `attempts`. This will do that conversion
metadata_translations = dict(XmlMixin.metadata_translations)
metadata_translations['attempts'] = 'max_attempts'

icon_class = 'problem'

uses_xmodule_styles_setup = True
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/conditional_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ResourceTemplates,
shim_xmodule_js,
STUDENT_VIEW,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand All @@ -44,7 +43,6 @@ class ConditionalBlock(
SequenceMixin,
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
31 changes: 29 additions & 2 deletions common/lib/xmodule/xmodule/error_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
HTMLSnippet,
ResourceTemplates,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)

Expand All @@ -47,7 +46,6 @@ class ErrorFields:
@XBlock.needs('mako')
class ErrorBlock(
ErrorFields,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down Expand Up @@ -181,6 +179,16 @@ def from_xml(cls, xml_data, system, id_generator, # pylint: disable=arguments-d

return cls._construct(system, xml_data, error_msg, location=id_generator.create_definition('error'))

@classmethod
def parse_xml(cls, node, runtime, keys, id_generator): # lint-amnesty, pylint: disable=unused-argument
"""
Interpret the parsed XML in `node`, creating an XModuleDescriptor.
"""
# It'd be great to not reserialize and deserialize the xml
xml = etree.tostring(node).decode('utf-8')
block = cls.from_xml(xml, runtime, id_generator)
return block

def export_to_xml(self, resource_fs):
'''
If the definition data is invalid xml, export it wrapped in an "error"
Expand All @@ -201,6 +209,25 @@ def export_to_xml(self, resource_fs):
err_node.text = self.error_msg
return etree.tostring(root, encoding='unicode')

def add_xml_to_node(self, node):
"""
Export this :class:`XModuleDescriptor` as XML, by setting attributes on the provided
`node`.
"""
xml_string = self.export_to_xml(self.runtime.export_fs)
exported_node = etree.fromstring(xml_string)
node.tag = exported_node.tag
node.text = exported_node.text
node.tail = exported_node.tail

for key, value in exported_node.items():
if key == 'url_name' and value == 'course' and key in node.attrib:
# if url_name is set in ExportManager then do not override it here.
continue
node.set(key, value)

node.extend(list(exported_node))


class NonStaffErrorBlock(ErrorBlock): # pylint: disable=abstract-method
"""
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/hidden_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from xmodule.raw_module import RawMixin
from xmodule.xml_module import XmlMixin
from xmodule.x_module import (
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand All @@ -17,7 +16,6 @@
class HiddenDescriptor(
RawMixin,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
XModuleMixin,
):
Expand Down
3 changes: 1 addition & 2 deletions common/lib/xmodule/xmodule/html_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)
from xmodule.xml_module import XmlMixin, name_to_pathname
Expand All @@ -47,7 +46,7 @@
@XBlock.needs("user")
class HtmlBlockMixin( # lint-amnesty, pylint: disable=abstract-method
XmlMixin, EditingMixin,
XModuleDescriptorToXBlockMixin, XModuleToXBlockMixin, HTMLSnippet, ResourceTemplates, XModuleMixin,
XModuleToXBlockMixin, HTMLSnippet, ResourceTemplates, XModuleMixin,
):
"""
The HTML XBlock mixin.
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/library_content_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
shim_xmodule_js,
STUDENT_VIEW,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)

Expand Down Expand Up @@ -73,7 +72,6 @@ def _get_capa_types():
class LibraryContentBlock(
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/lti_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
HTMLSnippet,
ResourceTemplates,
shim_xmodule_js,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand Down Expand Up @@ -282,7 +281,6 @@ class LTIBlock(
XmlMixin,
EditingMixin,
MakoTemplateBlockBase,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
4 changes: 0 additions & 4 deletions common/lib/xmodule/xmodule/modulestore/mongo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ def load_item(self, location, for_parent=None): # lint-amnesty, pylint: disable

definition = json_data.get('definition', {})
metadata = json_data.get('metadata', {})
for old_name, new_name in getattr(class_, 'metadata_translations', {}).items():
if old_name in metadata:
metadata[new_name] = metadata[old_name]
del metadata[old_name]

children = [
self._convert_reference_to_key(childloc)
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/poll_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)
from xmodule.xml_module import XmlMixin
Expand All @@ -41,7 +40,6 @@
class PollBlock(
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/randomize_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
HTMLSnippet,
ResourceTemplates,
STUDENT_VIEW,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand All @@ -26,7 +25,6 @@ class RandomizeBlock(
SequenceMixin,
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/seq_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
ResourceTemplates,
shim_xmodule_js,
STUDENT_VIEW,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand Down Expand Up @@ -261,7 +260,6 @@ class SequenceBlock(
ProctoringFields,
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/split_test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
ResourceTemplates,
shim_xmodule_js,
STUDENT_VIEW,
XModuleDescriptorToXBlockMixin,
XModuleMixin,
XModuleToXBlockMixin,
)
Expand Down Expand Up @@ -132,7 +131,6 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
ProctoringFields,
MakoTemplateBlockBase,
XmlMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
3 changes: 0 additions & 3 deletions common/lib/xmodule/xmodule/template_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)
from xmodule.xml_module import XmlMixin
Expand All @@ -28,7 +27,6 @@ class CustomTagTemplateBlock( # pylint: disable=abstract-method
RawMixin,
XmlMixin,
EditingMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down Expand Up @@ -139,7 +137,6 @@ def export_to_file(self):


class TranslateCustomTagBlock( # pylint: disable=abstract-method
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
XModuleMixin,
):
Expand Down
4 changes: 2 additions & 2 deletions common/lib/xmodule/xmodule/video_module/video_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from xmodule.x_module import (
PUBLIC_VIEW, STUDENT_VIEW,
HTMLSnippet, ResourceTemplates, shim_xmodule_js,
XModuleMixin, XModuleToXBlockMixin, XModuleDescriptorToXBlockMixin,
XModuleMixin, XModuleToXBlockMixin,
)
from xmodule.xml_module import XmlMixin, deserialize_field, is_pointer_tag, name_to_pathname

Expand Down Expand Up @@ -113,7 +113,7 @@
class VideoBlock(
VideoFields, VideoTranscriptsMixin, VideoStudioViewHandlers, VideoStudentViewHandlers,
TabsEditingMixin, EmptyDataRawMixin, XmlMixin, EditingMixin,
XModuleDescriptorToXBlockMixin, XModuleToXBlockMixin, HTMLSnippet, ResourceTemplates, XModuleMixin,
XModuleToXBlockMixin, HTMLSnippet, ResourceTemplates, XModuleMixin,
LicenseMixin):
"""
XML source example:
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/word_cloud_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
)
log = logging.getLogger(__name__)
Expand All @@ -49,7 +48,6 @@ class WordCloudBlock( # pylint: disable=abstract-method
EmptyDataRawMixin,
XmlMixin,
EditingMixin,
XModuleDescriptorToXBlockMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
Expand Down
Loading