Commit ff999d76 by Ehtesham

test fixes

parent 62059b58
...@@ -862,17 +862,10 @@ class LoncapaProblem(object): ...@@ -862,17 +862,10 @@ class LoncapaProblem(object):
entry.attrib['id'] = "%s_%i_%i" % (self.problem_id, response_id, answer_id) entry.attrib['id'] = "%s_%i_%i" % (self.problem_id, response_id, answer_id)
answer_id = answer_id + 1 answer_id = answer_id + 1
p_ids = []
for p_index, p_element in enumerate(response.findall('.//p')):
p_tag_id = '{}_q{}_desc{}'.format(self.problem_id, response_id, p_index)
p_element.attrib['id'] = p_tag_id
p_ids.append(p_tag_id)
# Find the label and save it for html transformation step # Find the label and save it for html transformation step
responsetype_label = response.find('label') responsetype_label = response.find('label')
problem_data[self.problem_id + '_' + str(response_id)] = { problem_data[self.problem_id + '_' + str(response_id)] = {
'label': responsetype_label.text if responsetype_label is not None else '', 'label': responsetype_label.text if responsetype_label is not None else ''
'p_ids': p_ids
} }
# instantiate capa Response # instantiate capa Response
......
...@@ -320,7 +320,7 @@ class InputTypeBase(object): ...@@ -320,7 +320,7 @@ class InputTypeBase(object):
'STATIC_URL': self.capa_system.STATIC_URL 'STATIC_URL': self.capa_system.STATIC_URL
} }
if self.response_data is not None: if self.response_data and self.response_data['label'] != '':
context['response_data'] = self.response_data context['response_data'] = self.response_data
context.update( context.update(
......
...@@ -128,7 +128,9 @@ class ChoiceGroupTemplateTest(TemplateTestCase): ...@@ -128,7 +128,9 @@ class ChoiceGroupTemplateTest(TemplateTestCase):
'label': 'test', 'label': 'test',
'input_type': 'checkbox', 'input_type': 'checkbox',
'name_array_suffix': '1', 'name_array_suffix': '1',
'value': '3'} 'value': '3',
'response_data': {'label': 'test'}
}
super(ChoiceGroupTemplateTest, self).setUp() super(ChoiceGroupTemplateTest, self).setUp()
def test_problem_marked_correct(self): def test_problem_marked_correct(self):
...@@ -340,8 +342,8 @@ class ChoiceGroupTemplateTest(TemplateTestCase): ...@@ -340,8 +342,8 @@ class ChoiceGroupTemplateTest(TemplateTestCase):
def test_label(self): def test_label(self):
xml = self.render_to_xml(self.context) xml = self.render_to_xml(self.context)
xpath = "//fieldset[@aria-label='%s']" % self.context['label'] xpath = "//legend"
self.assert_has_xpath(xml, xpath, self.context) self.assert_has_text(xml, xpath, self.context['label'])
class TextlineTemplateTest(TemplateTestCase): class TextlineTemplateTest(TemplateTestCase):
......
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