diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index cca195baac..df09cff2f6 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -457,8 +457,9 @@ class TextLine(InputTypeBase): """ A text line input. Can do math preview if "math"="1" is specified. - If "trailing_text" is set to a value, then the textline will be shown with the value after the text input. - This is useful if you would like to specify a specific type of units for the text input. + 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. diff --git a/common/lib/capa/capa/templates/textline.html b/common/lib/capa/capa/templates/textline.html index 01cf4dc535..ffc23cc90b 100644 --- a/common/lib/capa/capa/templates/textline.html +++ b/common/lib/capa/capa/templates/textline.html @@ -31,7 +31,7 @@ style="display:none;" % endif /> - ${trailing_text} + ${trailing_text | h}
% if status == 'unsubmitted':
diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py
index 818240c188..6c820503b1 100644
--- a/common/lib/capa/capa/tests/test_inputtypes.py
+++ b/common/lib/capa/capa/tests/test_inputtypes.py
@@ -1,5 +1,6 @@
+# coding='utf-8'
"""
-Tests of input types.
+feature Tests of input types.
TODO:
- refactor: so much repetive code (have factory methods that build xml elements directly, etc)
@@ -20,6 +21,7 @@ import json
from lxml import etree
import unittest
import xml.sax.saxutils as saxutils
+import unicodedata as ud
from . import test_system
from capa import inputtypes
@@ -219,7 +221,10 @@ class TextLineTest(unittest.TestCase):
def test_trailing_text_rendering(self):
size = "42"
trailing_text = 'm/s'
- xml_str = """