diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py
index bc650c426f..ee327dde52 100644
--- a/common/lib/capa/capa/capa_problem.py
+++ b/common/lib/capa/capa/capa_problem.py
@@ -485,7 +485,7 @@ class LoncapaProblem(object):
# include solutions from ... stanzas
for entry in self.tree.xpath("//" + "|//".join(solution_tags)):
- answer = etree.tostring(entry)
+ answer = etree.tostring(entry).decode('utf-8')
if answer:
answer_map[entry.get('id')] = contextualize_text(answer, self.context)
diff --git a/common/lib/capa/capa/tests/test_capa_problem.py b/common/lib/capa/capa/tests/test_capa_problem.py
index b5d6e0a107..547f2c7570 100644
--- a/common/lib/capa/capa/tests/test_capa_problem.py
+++ b/common/lib/capa/capa/tests/test_capa_problem.py
@@ -719,3 +719,24 @@ class CAPAProblemReportHelpersTest(unittest.TestCase):
"""
)
self.assertEquals(problem.find_answer_text('1_2_1', 'hide'), 'hide')
+
+ def test_get_question_answer(self):
+ problem = new_loncapa_problem(
+ """
+
+
+
+
+
+
+
Explanation
+
Blue is the answer.
+
+
+
+ """
+ )
+
+ # Ensure that the answer is a string so that the dict returned from this
+ # function can eventualy be serialized to json without issues.
+ self.assertIsInstance(problem.get_question_answers()['1_solution_1'], six.text_type)