Commit e25c36ac by Xavier Antoviaque

Merge pull request #74 from open-craft/master

Fixed exception when parsing XML with comments.
parents 1a29c212 1a6e2092
......@@ -40,6 +40,7 @@ from xblock.plugin import Plugin
from .models import LightChild as LightChildModel
try:
from xmodule_modifiers import replace_jump_to_id_urls
except:
......@@ -126,7 +127,8 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
if not hasattr(self, 'xml_content') or not self.xml_content:
return
node = etree.parse(StringIO(self.xml_content)).getroot()
parser = etree.XMLParser(remove_comments=True)
node = etree.parse(StringIO(self.xml_content), parser=parser).getroot()
LightChildrenMixin.init_block_from_node(self, node, node.items())
def get_children_objects(self):
......
......@@ -141,3 +141,34 @@ class MCQBlockTest(MentoringBaseTest):
self.assertEqual(progress.text, '')
self.assertTrue(progress.find_elements_by_css_selector('img'))
def test_mcq_with_comments(self):
mentoring = self.go_to_page('MCQ With Comments 1')
mcq = mentoring.find_element_by_css_selector('fieldset.choices')
messages = mentoring.find_element_by_css_selector('.messages')
progress = mentoring.find_element_by_css_selector('.progress > .indicator')
self.assertEqual(messages.text, '')
self.assertFalse(messages.find_elements_by_xpath('./*'))
self.assertEqual(progress.text, '')
self.assertFalse(progress.find_elements_by_xpath('./*'))
mcq_legend = mcq.find_element_by_css_selector('legend')
self.assertEqual(mcq_legend.text, 'Do you like this MCQ?')
mcq_choices = mcq.find_elements_by_css_selector('.choices .choice label')
self.assertEqual(len(mcq_choices), 3)
self.assertEqual(mcq_choices[0].text, 'Its elegance')
self.assertEqual(mcq_choices[1].text, 'Its beauty')
self.assertEqual(mcq_choices[2].text, "Its gracefulness")
self.assertEqual(mcq_choices[3].text, "Its bugs")
mcq_choices_input = [
mcq_choices[0].find_element_by_css_selector('input'),
mcq_choices[1].find_element_by_css_selector('input'),
mcq_choices[2].find_element_by_css_selector('input'),
]
self.assertEqual(mcq_choices_input[0].get_attribute('value'), 'elegance')
self.assertEqual(mcq_choices_input[1].get_attribute('value'), 'beauty')
self.assertEqual(mcq_choices_input[2].get_attribute('value'), 'gracefulness')
self.assertEqual(mcq_choices_input[3].get_attribute('value'), 'bugs')
<vertical>
<mentoring url_name="mentoring-87043a1f-f14a-4813-b89f-3e051939a7ee" display_name="MRQ Exercise 7" weight="1">
<title>MRQ With Resizable popups</title>
<mrq name="mrq_1_1_7" type="choices">
<question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice>
<choice value="beauty">Its beauty</choice>
<choice value="gracefulness">Its gracefulness</choice>
<choice value="bugs">Its bugs</choice>
<tip require="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</tip>
<tip require="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</tip>
<tip require="beauty" width ="400" height = "600">This is something everyone has to like about beauty</tip>
<tip reject="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip>
<!--<message type="on-submit">Thank you for answering!</message> -->
</mrq>
<message type="completed">
<html><p>Congratulations!</p></html>
</message>
<message type="incomplete">
<html><p>Still some work to do...</p></html>
</message>
</mentoring>
</vertical>
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