Skip to content

Commit

Permalink
Merge pull request #296 from mitocw/sherali/ede-1347/fix-course-impor…
Browse files Browse the repository at this point in the history
…t-pre-tag-issue

fixes pre tag problem import issue
  • Loading branch information
sheralim012 authored Feb 11, 2021
2 parents f4f81bc + 3e6de26 commit cbb213d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions cms/djangoapps/contentstore/views/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,19 +1084,17 @@ def assert_problem_definition(self, course_location, expected_problem_content):

@ddt.data(
[
'<problem><pre><code>x=10 print("hello \n")</code></pre>'
'<pre><div><pre><code>x=10 print("hello \n")</code></pre></div></pre>'
'<problem><pre><code>x=10 print("hello")[]</code></pre>'
'<pre><div><pre><code>x=10 print("hello")</code></pre></div></pre>'
'<multiplechoiceresponse></multiplechoiceresponse></problem>',
'<problem>\n <pre>\n <code>x=10 print("hello \n")</code>\n </pre>\n <pre>\n <div>\n <pre>\n '
' <code>x=10 print("hello \n")</code>\n </pre>\n </div>\n </pre>\n '
'<multiplechoiceresponse/>\n</problem>\n'
'<problem>\n <pre><code>x=10 print("hello")[]</code></pre>\n '
'<pre>\n <div>\n <pre><code>x=10 print("hello")</code></pre>\n </div>\n '
'</pre>\n <multiplechoiceresponse/>\n</problem>\n'
],
[
'<problem><pre><code>x=10 print("hello \n")</code></pre>'
'<multiplechoiceresponse></multiplechoiceresponse></problem>',
'<problem>\n <pre>\n <code>x=10 print("hello \n")</code>\n </pre>\n '
'<problem>\n <pre><code>x=10 print("hello \n")</code></pre>\n '
'<multiplechoiceresponse/>\n</problem>\n'
]
)
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/raw_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def definition_from_xml(cls, xml_object, system):
if pre_tag_data:
matches = re.finditer(PRE_TAG_REGEX, data)
for match_num, match in enumerate(matches):
data = re.sub(match.group(), pre_tag_data[match_num].decode(), data)
data = re.sub(re.escape(match.group()), pre_tag_data[match_num].decode(), data)
etree.XML(data) # it just checks if generated string is valid xml
return {'data': data}, []
except etree.XMLSyntaxError:
Expand Down

0 comments on commit cbb213d

Please sign in to comment.