Commit 335ee78e by Xavier Antoviaque

Also rewrite jump_to_id URLs in quizz tips & messages

parent ae01d124
...@@ -166,6 +166,17 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock): ...@@ -166,6 +166,17 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
""" """
Current HTML view of the XBlock, for refresh by client Current HTML view of the XBlock, for refresh by client
""" """
frag = self.student_view({})
frag = self.fragment_text_rewriting(frag)
return {
'html': frag.content,
}
def fragment_text_rewriting(self, fragment):
"""
Do replacements like `/jump_to_id` URL rewriting in the provided text
"""
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`? # TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
try: try:
course_id = self.xmodule_runtime.course_id course_id = self.xmodule_runtime.course_id
...@@ -179,13 +190,8 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock): ...@@ -179,13 +190,8 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench # TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
jump_to_url = '/jump_to_id' jump_to_url = '/jump_to_id'
frag = self.student_view({}) fragment = replace_jump_to_id_urls(course_id, jump_to_url, self, 'student_view', fragment, {})
frag = replace_jump_to_id_urls(course_id, jump_to_url, self, 'student_view', frag, {}) return fragment
return {
'html': frag.content,
}
class LightChild(Plugin, LightChildrenMixin): class LightChild(Plugin, LightChildrenMixin):
""" """
......
...@@ -146,7 +146,8 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -146,7 +146,8 @@ class MentoringBlock(XBlockWithLightChildren):
def get_message_fragment(self, message_type): def get_message_fragment(self, message_type):
for child in self.get_children_objects(): for child in self.get_children_objects():
if isinstance(child, MentoringMessageBlock) and child.type == message_type: if isinstance(child, MentoringMessageBlock) and child.type == message_type:
return self.render_child(child, 'mentoring_view', {}) frag = self.render_child(child, 'mentoring_view', {})
return self.fragment_text_rewriting(frag)
def get_message_html(self, message_type): def get_message_html(self, message_type):
fragment = self.get_message_fragment(message_type) fragment = self.get_message_fragment(message_type)
......
...@@ -167,7 +167,7 @@ class QuizzTipBlock(LightChild): ...@@ -167,7 +167,7 @@ class QuizzTipBlock(LightChild):
'self': self, 'self': self,
'named_children': named_children, 'named_children': named_children,
})) }))
return fragment return self.xblock_container.fragment_text_rewriting(fragment)
def is_completed(self, submission): def is_completed(self, submission):
return submission and submission not in self.reject_with_defaults return submission and submission not in self.reject_with_defaults
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment