Commit 378386f7 by Braden MacDonald

Remove mentoring- prefixes from most of the blocks

parent f84a59c2
......@@ -540,22 +540,6 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
"""
return [self.display_name]
@classmethod
def parse_xml(cls, node, runtime, keys, id_generator):
"""
To avoid collisions with e.g. the existing <html> XBlock in edx-platform,
we prefix all of the mentoring block tags with "mentoring-". However,
using that prefix in the XML is optional. This method adds that prefix
in when parsing XML in a mentoring context.
"""
PREFIX_TAGS = ("answer", "answer-recap", "quizz", "mcq", "mrq", "rating", "message", "tip", "choice", "column")
for element in node.iter():
# We have prefixed all our XBlock entry points with "mentoring-". But using the "mentoring-"
# prefix in the XML is optional:
if element.tag in PREFIX_TAGS:
element.tag = "mentoring-{}".format(element.tag)
return super(MentoringBlock, cls).parse_xml(node, runtime, keys, id_generator)
@staticmethod
def workbench_scenarios():
"""
......
......@@ -34,10 +34,10 @@
<tip values="bugs">Nah, there aren't any!</tip>
</mrq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
......@@ -14,10 +14,10 @@
<tip values="bugs">Nah, there aren't any!</tip>
</mrq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
......@@ -18,9 +18,9 @@
<tip values="notwant">Your loss!</tip>
</rating>
<message type="completed">
<mentoring-message type="completed">
All is good now...
<p>Congratulations!</p>
</message>
</mentoring-message>
</mentoring>
</vertical_demo>
......@@ -14,11 +14,11 @@
<!--<message type="on-submit">This is deliberately commented out to test parsing of XML comments</message> -->
</mrq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
</vertical_demo>
......@@ -12,11 +12,11 @@
<tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip>
</mcq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
</vertical_demo>
......@@ -12,11 +12,11 @@
<tip values="bugs" width = "100" height = "200">Nah, there aren\'t any!</tip>
</mrq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
</vertical_demo>
<vertical_demo>
<mentoring display_submit="false" enforce_dependency="false">
<mentoring-table>
<column header="Header Test 1">
<mentoring-column header="Header Test 1">
<answer-recap name="table_1_answer_1"/>
</column>
<column header="Header Test 2">
</mentoring-column>
<mentoring-column header="Header Test 2">
<answer-recap name="table_1_answer_2"/>
</column>
</mentoring-column>
</mentoring-table>
</mentoring>
</vertical_demo>
......@@ -31,10 +31,10 @@
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip>
<tip values="bugs">Nah, there isn't any!</tip>
</mrq>
<message type="completed">
<mentoring-message type="completed">
<p>Congratulations!</p>
</message>
<message type="incomplete">
</mentoring-message>
<mentoring-message type="incomplete">
<p>Still some work to do...</p>
</message>
</mentoring-message>
</mentoring>
......@@ -30,7 +30,7 @@
<tip values="1,2,3">The Trial of Uruk-Shan helps you uncover some of the core beliefs and assumptions you have held that are preventing you from making change.</tip>
<tip values="understand">A frog is important if it is one that could make a big difference in helping you reach your frogs in your work life or your personal life (or both).</tip>
</rating>
<message type="completed">
<mentoring-message type="completed">
Great! You have indicated that you have chosen a frog that is happy for you, implicates you, has room for improvement, and is important to you. You are now ready to move onto the next step.
</message>
</mentoring-message>
</mentoring>
<mentoring display_submit="false" enforce_dependency="false">
<mentoring-table type="table_test" url_name="table_2">
<column header="Header Test 1">
<mentoring-column header="Header Test 1">
<answer-recap name="table_1_answer_1" />
</column>
</mentoring-column>
<column header="Header &lt;strong&gt;Test 2&lt;/strong&gt;">
<mentoring-column header="Header &lt;strong&gt;Test 2&lt;/strong&gt;">
<answer-recap name="table_1_answer_2" />
<html><p>Inline HTML</p></html>
<answer-recap name="table_1_answer_2" />
</column>
</mentoring-column>
</mentoring-table>
</mentoring>
......@@ -69,9 +69,9 @@ class TableColumnHeader(Change):
</mentoring-table>
with
<mentoring-table>
<column header="Answer 1">
<mentoring-column header="Answer 1">
<answer-recap name="answer_1" />
</column>
</mentoring-column>
</mentoring-table>
"""
@staticmethod
......@@ -79,6 +79,7 @@ class TableColumnHeader(Change):
return node.tag == "column" and node.getparent().tag == "mentoring-table"
def apply(self):
self.node.tag = "mentoring-column"
header_html = u""
to_remove = []
for child in list(self.node):
......@@ -102,6 +103,19 @@ class TableColumnHeader(Change):
self.node.attrib["header"] = header_html
class PrefixMessageElements(Change):
"""
<message> is renamed to <mentoring-message> since it only works as a direct child of
<mentoring> and <message> could collide with other future XBlocks.
"""
@staticmethod
def applies_to(node):
return node.tag == "message" and node.getparent().tag == "mentoring"
def apply(self):
self.node.tag = "mentoring-message"
class QuizzToMCQ(Change):
""" <quizz> element was an alias for <mcq>. In v2 we only have <mcq> """
@staticmethod
......@@ -241,6 +255,7 @@ xml_changes = (
RemoveTitle,
UnwrapHTML,
TableColumnHeader,
PrefixMessageElements,
QuizzToMCQ,
MCQToRating,
ReadOnlyAnswerToRecap,
......
......@@ -47,12 +47,20 @@ BLOCKS = [
'mentoring-table = mentoring:MentoringTableBlock',
'mentoring-column = mentoring:MentoringTableColumn',
'answer = mentoring:AnswerBlock',
'answer-recap = mentoring:AnswerRecapBlock',
'mcq = mentoring:MCQBlock',
'rating = mentoring:RatingBlock',
'mrq = mentoring:MRQBlock',
'mentoring-message = mentoring:MentoringMessageBlock',
'tip = mentoring:TipBlock',
'choice = mentoring:ChoiceBlock',
# Deprecated:
'mentoring-answer = mentoring:AnswerBlock',
'mentoring-answer-recap = mentoring:AnswerRecapBlock',
'mentoring-mcq = mentoring:MCQBlock',
'mentoring-rating = mentoring:RatingBlock',
'mentoring-mrq = mentoring:MRQBlock',
'mentoring-message = mentoring:MentoringMessageBlock',
'mentoring-tip = mentoring:TipBlock',
'mentoring-choice = mentoring:ChoiceBlock',
]
......
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