From bcb2038843f5e30c6a8f3c63f4a241e7477814f5 Mon Sep 17 00:00:00 2001 From: Awais Jibran Date: Mon, 3 Feb 2020 14:55:03 +0500 Subject: [PATCH] Fix CAPA Problems --- common/lib/capa/capa/capa_problem.py | 1 + common/lib/capa/capa/tests/test_capa_problem.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 5f44750ccb..6d9f2fd2cf 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -64,6 +64,7 @@ html_transforms = { # These should be removed from HTML output, including all subelements html_problem_semantics = [ + "additional_answer", "codeparam", "responseparam", "answer", diff --git a/common/lib/capa/capa/tests/test_capa_problem.py b/common/lib/capa/capa/tests/test_capa_problem.py index 6c59985d32..5331096c6d 100644 --- a/common/lib/capa/capa/tests/test_capa_problem.py +++ b/common/lib/capa/capa/tests/test_capa_problem.py @@ -189,6 +189,23 @@ class CAPAProblemTest(unittest.TestCase): } ) + def test_additional_answer_is_skipped_from_resulting_html(self): + """Tests that additional_answer element is not present in transformed HTML""" + xml = """ + +

Be sure to check your spelling.

+ + + Anyone who looks the world as if it was a game of chess deserves to lose. + + + +
+ """ + problem = new_loncapa_problem(xml) + self.assertEqual(len(problem.extracted_tree.xpath('//additional_answer')), 0) + self.assertNotIn('additional_answer', problem.get_html()) + def test_non_accessible_inputtype(self): """ Verify that tag with question text is not removed when inputtype is not fully accessible.