Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a5f3d8a9
Commit
a5f3d8a9
authored
Jul 04, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix handling of tail in inputtypes.math (needed saxutils.escape)
parent
edeb81ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
common/lib/capa/inputtypes.py
+16
-2
No files found.
common/lib/capa/inputtypes.py
View file @
a5f3d8a9
...
@@ -22,10 +22,14 @@ Each input type takes the xml tree as 'element', the previous answer as 'value',
...
@@ -22,10 +22,14 @@ Each input type takes the xml tree as 'element', the previous answer as 'value',
# status is currently the answer for the problem ID for the input element,
# status is currently the answer for the problem ID for the input element,
# but it will turn into a dict containing both the answer and any associated message for the problem ID for the input element.
# but it will turn into a dict containing both the answer and any associated message for the problem ID for the input element.
import
logging
import
re
import
re
import
shlex
# for splitting quoted strings
import
shlex
# for splitting quoted strings
from
lxml
import
etree
from
lxml
import
etree
import
xml.sax.saxutils
as
saxutils
log
=
logging
.
getLogger
(
'mitx.'
+
__name__
)
def
get_input_xml_tags
():
def
get_input_xml_tags
():
''' Eventually, this will be for all registered input types '''
''' Eventually, this will be for all registered input types '''
...
@@ -299,8 +303,18 @@ def math(element, value, status, render_template, msg=''):
...
@@ -299,8 +303,18 @@ def math(element, value, status, render_template, msg=''):
# isinline = True
# isinline = True
# html = render_template("mathstring.html",{'mathstr':mathstr,'isinline':isinline,'tail':element.tail})
# html = render_template("mathstring.html",{'mathstr':mathstr,'isinline':isinline,'tail':element.tail})
html
=
'<html><html>
%
s</html><html>
%
s</html></html>'
%
(
mathstr
,
element
.
tail
)
html
=
'<html><html>
%
s</html><html>
%
s</html></html>'
%
(
mathstr
,
saxutils
.
escape
(
element
.
tail
))
xhtml
=
etree
.
XML
(
html
)
try
:
xhtml
=
etree
.
XML
(
html
)
except
Exception
as
err
:
if
False
:
# TODO needs to be self.system.DEBUG - but can't access system
msg
=
"<html><font color='red'><p>Error
%
s</p>"
%
str
(
err
)
.
replace
(
'<'
,
'<'
)
msg
+=
'<p>Failed to construct math expression from <pre>
%
s</pre></p>'
%
html
.
replace
(
'<'
,
'<'
)
msg
+=
"</font></html>"
log
.
error
(
msg
)
return
etree
.
XML
(
msg
)
else
:
raise
# xhtml.tail = element.tail # don't forget to include the tail!
# xhtml.tail = element.tail # don't forget to include the tail!
return
xhtml
return
xhtml
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment