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 ...@@ -540,22 +540,6 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
""" """
return [self.display_name] 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 @staticmethod
def workbench_scenarios(): def workbench_scenarios():
""" """
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
<tip values="bugs">Nah, there aren't any!</tip> <tip values="bugs">Nah, there aren't any!</tip>
</mrq> </mrq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
<tip values="bugs">Nah, there aren't any!</tip> <tip values="bugs">Nah, there aren't any!</tip>
</mrq> </mrq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
<tip values="notwant">Your loss!</tip> <tip values="notwant">Your loss!</tip>
</rating> </rating>
<message type="completed"> <mentoring-message type="completed">
All is good now... All is good now...
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
<!--<message type="on-submit">This is deliberately commented out to test parsing of XML comments</message> --> <!--<message type="on-submit">This is deliberately commented out to test parsing of XML comments</message> -->
</mrq> </mrq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
<tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip> <tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip>
</mcq> </mcq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
<tip values="bugs" width = "100" height = "200">Nah, there aren\'t any!</tip> <tip values="bugs" width = "100" height = "200">Nah, there aren\'t any!</tip>
</mrq> </mrq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring display_submit="false" enforce_dependency="false"> <mentoring display_submit="false" enforce_dependency="false">
<mentoring-table> <mentoring-table>
<column header="Header Test 1"> <mentoring-column header="Header Test 1">
<answer-recap name="table_1_answer_1"/> <answer-recap name="table_1_answer_1"/>
</column> </mentoring-column>
<column header="Header Test 2"> <mentoring-column header="Header Test 2">
<answer-recap name="table_1_answer_2"/> <answer-recap name="table_1_answer_2"/>
</column> </mentoring-column>
</mentoring-table> </mentoring-table>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip>
<tip values="bugs">Nah, there isn't any!</tip> <tip values="bugs">Nah, there isn't any!</tip>
</mrq> </mrq>
<message type="completed"> <mentoring-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</message> </mentoring-message>
<message type="incomplete"> <mentoring-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</message> </mentoring-message>
</mentoring> </mentoring>
...@@ -30,7 +30,7 @@ ...@@ -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="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> <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> </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. 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>
<mentoring display_submit="false" enforce_dependency="false"> <mentoring display_submit="false" enforce_dependency="false">
<mentoring-table type="table_test" url_name="table_2"> <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" /> <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" /> <answer-recap name="table_1_answer_2" />
<html><p>Inline HTML</p></html> <html><p>Inline HTML</p></html>
<answer-recap name="table_1_answer_2" /> <answer-recap name="table_1_answer_2" />
</column> </mentoring-column>
</mentoring-table> </mentoring-table>
</mentoring> </mentoring>
...@@ -69,9 +69,9 @@ class TableColumnHeader(Change): ...@@ -69,9 +69,9 @@ class TableColumnHeader(Change):
</mentoring-table> </mentoring-table>
with with
<mentoring-table> <mentoring-table>
<column header="Answer 1"> <mentoring-column header="Answer 1">
<answer-recap name="answer_1" /> <answer-recap name="answer_1" />
</column> </mentoring-column>
</mentoring-table> </mentoring-table>
""" """
@staticmethod @staticmethod
...@@ -79,6 +79,7 @@ class TableColumnHeader(Change): ...@@ -79,6 +79,7 @@ class TableColumnHeader(Change):
return node.tag == "column" and node.getparent().tag == "mentoring-table" return node.tag == "column" and node.getparent().tag == "mentoring-table"
def apply(self): def apply(self):
self.node.tag = "mentoring-column"
header_html = u"" header_html = u""
to_remove = [] to_remove = []
for child in list(self.node): for child in list(self.node):
...@@ -102,6 +103,19 @@ class TableColumnHeader(Change): ...@@ -102,6 +103,19 @@ class TableColumnHeader(Change):
self.node.attrib["header"] = header_html 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): class QuizzToMCQ(Change):
""" <quizz> element was an alias for <mcq>. In v2 we only have <mcq> """ """ <quizz> element was an alias for <mcq>. In v2 we only have <mcq> """
@staticmethod @staticmethod
...@@ -241,6 +255,7 @@ xml_changes = ( ...@@ -241,6 +255,7 @@ xml_changes = (
RemoveTitle, RemoveTitle,
UnwrapHTML, UnwrapHTML,
TableColumnHeader, TableColumnHeader,
PrefixMessageElements,
QuizzToMCQ, QuizzToMCQ,
MCQToRating, MCQToRating,
ReadOnlyAnswerToRecap, ReadOnlyAnswerToRecap,
......
...@@ -47,12 +47,20 @@ BLOCKS = [ ...@@ -47,12 +47,20 @@ BLOCKS = [
'mentoring-table = mentoring:MentoringTableBlock', 'mentoring-table = mentoring:MentoringTableBlock',
'mentoring-column = mentoring:MentoringTableColumn', '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 = mentoring:AnswerBlock',
'mentoring-answer-recap = mentoring:AnswerRecapBlock', 'mentoring-answer-recap = mentoring:AnswerRecapBlock',
'mentoring-mcq = mentoring:MCQBlock', 'mentoring-mcq = mentoring:MCQBlock',
'mentoring-rating = mentoring:RatingBlock', 'mentoring-rating = mentoring:RatingBlock',
'mentoring-mrq = mentoring:MRQBlock', 'mentoring-mrq = mentoring:MRQBlock',
'mentoring-message = mentoring:MentoringMessageBlock',
'mentoring-tip = mentoring:TipBlock', 'mentoring-tip = mentoring:TipBlock',
'mentoring-choice = mentoring:ChoiceBlock', '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