Commit a7e0c3f4 by Amir Qayyum Khan

Fixed issue with non-Latin characters in loncapa/python problems

parent 8a5782eb
......@@ -18,6 +18,7 @@ try:
except ImportError:
dog_stats_api = None
from pytz import utc
from django.utils.encoding import smart_text
from capa.capa_problem import LoncapaProblem, LoncapaSystem
from capa.inputtypes import Status
......@@ -700,7 +701,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
content = {
'name': self.display_name_with_default,
'html': html,
'html': smart_text(html),
'weight': self.weight,
}
......
......@@ -14,6 +14,7 @@ import textwrap
import unittest
import ddt
from django.utils.encoding import smart_text
from lxml import etree
from mock import Mock, patch, DEFAULT
import webob
......@@ -2530,6 +2531,27 @@ 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 "
self.assertEquals(
descriptor.index_dictionary(), {
'content_type': CapaDescriptor.INDEX_CONTENT_TYPE,
'problem_types': [],
'content': {
'display_name': name,
'capa_content': smart_text(capa_content)
}
}
)
def test_indexing_checkboxes_with_hints_and_feedback(self):
name = "Checkboxes with Hints and Feedback"
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