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
c1846134
Commit
c1846134
authored
Mar 07, 2013
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1624 from MITx/diana/fix-problem-javascript
Fix issue where javascript was disappearing from problem html
parents
b02ff247
2c6ee50a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
common/lib/capa/capa/capa_problem.py
+2
-2
common/lib/capa/capa/tests/test_html_render.py
+22
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
c1846134
...
...
@@ -29,6 +29,7 @@ import sys
from
lxml
import
etree
from
xml.sax.saxutils
import
unescape
from
copy
import
deepcopy
import
chem
import
chem.chemcalc
...
...
@@ -497,11 +498,10 @@ class LoncapaProblem(object):
Used by get_html.
'''
if
(
problemtree
.
tag
==
'script'
and
problemtree
.
get
(
'type'
)
and
'javascript'
in
problemtree
.
get
(
'type'
)):
# leave javascript intact.
return
problemtree
return
deepcopy
(
problemtree
)
if
problemtree
.
tag
in
html_problem_semantics
:
return
...
...
common/lib/capa/capa/tests/test_html_render.py
View file @
c1846134
...
...
@@ -3,6 +3,7 @@ from lxml import etree
import
os
import
textwrap
import
json
import
mock
from
capa.capa_problem
import
LoncapaProblem
...
...
@@ -49,6 +50,8 @@ class CapaHtmlRenderTest(unittest.TestCase):
self
.
assertEqual
(
test_element
.
text
,
"Test include"
)
def
test_process_outtext
(
self
):
# Generate some XML with <startouttext /> and <endouttext />
xml_str
=
textwrap
.
dedent
(
"""
...
...
@@ -86,6 +89,25 @@ class CapaHtmlRenderTest(unittest.TestCase):
script_element
=
rendered_html
.
find
(
'script'
)
self
.
assertEqual
(
None
,
script_element
)
def
test_render_javascript
(
self
):
# Generate some XML with a <script> tag
xml_str
=
textwrap
.
dedent
(
"""
<problem>
<script type="text/javascript">function(){}</script>
</problem>
"""
)
# Create the problem
problem
=
LoncapaProblem
(
xml_str
,
'1'
,
system
=
test_system
)
# Render the HTML
rendered_html
=
etree
.
XML
(
problem
.
get_html
())
# expect the javascript is still present in the rendered html
self
.
assertTrue
(
"<script type=
\"
text/javascript
\"
>function(){}</script>"
in
etree
.
tostring
(
rendered_html
))
def
test_render_response_xml
(
self
):
# Generate some XML for a string response
kwargs
=
{
'question_text'
:
"Test question"
,
...
...
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