Commit 179a4af5 by Arthur Barrett

fixed failing annotationinput test and refactored response factory

parent 3f407816
......@@ -676,26 +676,23 @@ class AnnotationResponseXMLFactory(ResponseXMLFactory):
def create_input_element(self, **kwargs):
""" Create a <annotationinput> element."""
title = kwargs.get('title', 'super cool annotation')
text = kwargs.get('text', 'texty text')
comment = kwargs.get('comment', 'blah blah erudite comment blah blah')
comment_prompt = kwargs.get('comment_prompt', 'type a commentary below')
tag_prompt = kwargs.get('tag_prompt', 'select one tag')
options = kwargs.get('options', [
('green', 'correct'),
('eggs', 'incorrect'),
('ham', 'partially-correct')
])
# Create the <annotationinput> element
input_element = etree.Element("annotationinput")
etree.SubElement(input_element, 'title')
etree.SubElement(input_element, 'text')
etree.SubElement(input_element, 'comment')
etree.SubElement(input_element, 'comment_prompt')
etree.SubElement(input_element, 'tag_prompt')
text_children = [
{'tag': 'title', 'text': kwargs.get('title', 'super cool annotation') },
{'tag': 'text', 'text': kwargs.get('text', 'texty text') },
{'tag': 'comment', 'text':kwargs.get('comment', 'blah blah erudite comment blah blah') },
{'tag': 'comment_prompt', 'text': kwargs.get('comment_prompt', 'type a commentary below') },
{'tag': 'tag_prompt', 'text': kwargs.get('tag_prompt', 'select one tag') }
]
for child in text_children:
etree.SubElement(input_element, child['tag']).text = child['text']
default_options = [('green', 'correct'),('eggs', 'incorrect'),('ham', 'partially-correct')]
options = kwargs.get('options', default_options)
options_element = etree.SubElement(input_element, 'options')
for (description, correctness) in options:
option_element = etree.SubElement(options_element, 'option', {'choice': correctness})
option_element.text = description
......
......@@ -624,6 +624,7 @@ class AnnotationInputTest(unittest.TestCase):
],
'value': json_value,
'options_value': value['options'],
'has_options_value': len(value['options']) > 0,
'comment_value': value['comment'],
'debug': False,
'return_to_annotation': True
......
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