Commit 2605bf99 by George Song Committed by GitHub

Merge pull request #15700 from mitodl/aq_unicode_issue_capa

Fixed problem with non-Latin characters in loncapa/python problems
parents 457b9a11 6d4b9cb5
...@@ -18,6 +18,7 @@ try: ...@@ -18,6 +18,7 @@ try:
except ImportError: except ImportError:
dog_stats_api = None dog_stats_api = None
from pytz import utc from pytz import utc
from django.utils.encoding import smart_text
from capa.capa_problem import LoncapaProblem, LoncapaSystem from capa.capa_problem import LoncapaProblem, LoncapaSystem
from capa.inputtypes import Status from capa.inputtypes import Status
...@@ -700,7 +701,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields): ...@@ -700,7 +701,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
content = { content = {
'name': self.display_name_with_default, 'name': self.display_name_with_default,
'html': html, 'html': smart_text(html),
'weight': self.weight, 'weight': self.weight,
} }
......
...@@ -14,6 +14,7 @@ import textwrap ...@@ -14,6 +14,7 @@ import textwrap
import unittest import unittest
import ddt import ddt
from django.utils.encoding import smart_text
from lxml import etree from lxml import etree
from mock import Mock, patch, DEFAULT from mock import Mock, patch, DEFAULT
import webob import webob
...@@ -2567,6 +2568,22 @@ class CapaDescriptorTest(unittest.TestCase): ...@@ -2567,6 +2568,22 @@ class CapaDescriptorTest(unittest.TestCase):
} }
) )
def test_indexing_non_latin_problem(self):
sample_text_input_problem_xml = textwrap.dedent("""
<problem>
<script type="text/python">FX1_VAL='Καλημέρα'</script>
<p>Δοκιμή με μεταβλητές με Ελληνικούς χαρακτήρες μέσα σε python: $FX1_VAL</p>
</problem>
""")
name = "Non latin Input"
descriptor = self._create_descriptor(sample_text_input_problem_xml, name=name)
capa_content = " FX1_VAL='Καλημέρα' Δοκιμή με μεταβλητές με Ελληνικούς χαρακτήρες μέσα σε python: $FX1_VAL "
descriptor_dict = descriptor.index_dictionary()
self.assertEquals(
descriptor_dict['content']['capa_content'], smart_text(capa_content)
)
def test_indexing_checkboxes_with_hints_and_feedback(self): def test_indexing_checkboxes_with_hints_and_feedback(self):
name = "Checkboxes with Hints and Feedback" name = "Checkboxes with Hints and Feedback"
descriptor = self._create_descriptor(self.sample_checkboxes_with_hints_and_feedback_problem_xml, name=name) descriptor = self._create_descriptor(self.sample_checkboxes_with_hints_and_feedback_problem_xml, name=name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment