diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py
index 18bc92f0a3..aa507a5281 100644
--- a/common/lib/capa/capa/inputtypes.py
+++ b/common/lib/capa/capa/inputtypes.py
@@ -457,8 +457,21 @@ class TextLine(InputTypeBase):
"""
A text line input. Can do math preview if "math"="1" is specified.
- If the hidden attribute is specified, the textline is hidden and the input id is stored in a div with name equal
- to the value of the hidden attribute. This is used e.g. for embedding simulations turned into questions.
+ If "trailing_text" is set to a value, then the textline will be shown with
+ the value after the text input, and before the checkmark or any input-specific
+ feedback. HTML will not work, but properly escaped HTML characters will. This
+ feature is useful if you would like to specify a specific type of units for the
+ text input.
+
+ If the hidden attribute is specified, the textline is hidden and the input id
+ is stored in a div with name equal to the value of the hidden attribute. This
+ is used e.g. for embedding simulations turned into questions.
+
+ Example:
+
% if status == 'unsubmitted':
diff --git a/common/lib/capa/capa/tests/test_html_render.py b/common/lib/capa/capa/tests/test_html_render.py
index e99308587e..492fcb2743 100644
--- a/common/lib/capa/capa/tests/test_html_render.py
+++ b/common/lib/capa/capa/tests/test_html_render.py
@@ -156,6 +156,7 @@ class CapaHtmlRenderTest(unittest.TestCase):
'hidden': False,
'do_math': False,
'id': '1_2_1',
+ 'trailing_text': '',
'size': None}
expected_solution_context = {'id': '1_solution_1'}
diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py
index e7f0b784bc..7e2f956f56 100644
--- a/common/lib/capa/capa/tests/test_inputtypes.py
+++ b/common/lib/capa/capa/tests/test_inputtypes.py
@@ -182,6 +182,7 @@ class TextLineTest(unittest.TestCase):
'hidden': False,
'inline': False,
'do_math': False,
+ 'trailing_text': '',
'preprocessor': None}
self.assertEqual(context, expected)
@@ -209,11 +210,49 @@ class TextLineTest(unittest.TestCase):
'msg': '',
'hidden': False,
'inline': False,
+ 'trailing_text': '',
'do_math': True,
'preprocessor': {'class_name': preprocessorClass,
'script_src': script}}
self.assertEqual(context, expected)
+ def test_trailing_text_rendering(self):
+ size = "42"
+ # store (xml_text, expected)
+ trailing_text = []
+ # standard trailing text
+ trailing_text.append(('m/s', 'm/s'))
+ # unicode trailing text
+ trailing_text.append((u'\xc3', u'\xc3'))
+ # html escaped trailing text
+ # this is the only one we expect to change
+ trailing_text.append(('a < b','a < b'))
+
+ for xml_text, expected_text in trailing_text:
+ xml_str = u"""