Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e34b0520
Unverified
Commit
e34b0520
authored
4 years ago
by
Awais Qureshi
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #23939 from eduNEXT/lmz/fixing_cgi_escape_warning
Fixing cgi.escape DeprecationWarning
parents
083f1bb8
943bd6f1
Branches
Branches containing commit
Tags
release-2020-06-23-10.53
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/poll_module.py
+14
-9
14 additions, 9 deletions
common/lib/xmodule/xmodule/poll_module.py
with
14 additions
and
9 deletions
common/lib/xmodule/xmodule/poll_module.py
+
14
−
9
View file @
e34b0520
...
...
@@ -7,7 +7,7 @@ If student have answered - Question with statistics for each answers.
"""
import
cgi
import
html
import
json
import
logging
from
collections
import
OrderedDict
...
...
@@ -17,7 +17,7 @@ from pkg_resources import resource_string
import
six
from
lxml
import
etree
from
openedx.core.djangolib.markup
import
Text
from
openedx.core.djangolib.markup
import
Text
,
HTML
from
xblock.fields
import
Boolean
,
Dict
,
List
,
Scope
,
String
from
xmodule.mako_module
import
MakoModuleDescriptor
from
xmodule.stringify
import
stringify_children
...
...
@@ -152,12 +152,12 @@ class PollModule(PollFields, XModule):
# Set default count for answer = 0.
if
answer
[
'
id
'
]
not
in
temp_poll_answers
:
temp_poll_answers
[
answer
[
'
id
'
]]
=
0
answers_to_json
[
answer
[
'
id
'
]]
=
cgi
.
escape
(
answer
[
'
text
'
])
answers_to_json
[
answer
[
'
id
'
]]
=
html
.
escape
(
answer
[
'
text
'
]
,
quote
=
False
)
self
.
poll_answers
=
temp_poll_answers
return
json
.
dumps
({
'
answers
'
:
answers_to_json
,
'
question
'
:
cgi
.
escape
(
self
.
question
),
'
question
'
:
html
.
escape
(
self
.
question
,
quote
=
False
),
# to show answered poll after reload:
'
poll_answer
'
:
self
.
poll_answer
,
'
poll_answers
'
:
self
.
poll_answers
if
self
.
voted
else
{},
...
...
@@ -215,17 +215,22 @@ class PollDescriptor(PollFields, MakoModuleDescriptor, XmlDescriptor):
def
definition_to_xml
(
self
,
resource_fs
):
"""
Return an xml element representing to this definition.
"""
poll_str
=
u
'
<{tag_name}>{text}</{tag_name}>
'
.
format
(
poll_str
=
HTML
(
'
<{tag_name}>{text}</{tag_name}>
'
)
.
format
(
tag_name
=
self
.
_tag_name
,
text
=
self
.
question
)
xml_object
=
etree
.
fromstring
(
poll_str
)
xml_object
.
set
(
'
display_name
'
,
self
.
display_name
)
def
add_child
(
xml_obj
,
answer
):
# Escape answer text before adding to xml tree.
answer_text
=
six
.
text_type
(
Text
(
answer
[
'
text
'
]))
child_str
=
u
'
<{tag_name} id=
"
{id}
"
>{text}</{tag_name}>
'
.
format
(
tag_name
=
self
.
_child_tag_name
,
id
=
answer
[
'
id
'
],
text
=
answer_text
)
answer_text
=
str
(
answer
[
'
text
'
])
child_str
=
Text
(
'
{tag_begin}{text}{tag_end}
'
).
format
(
tag_begin
=
HTML
(
'
<{tag_name} id=
"
{id}
"
>
'
).
format
(
tag_name
=
self
.
_child_tag_name
,
id
=
answer
[
'
id
'
]
),
text
=
answer_text
,
tag_end
=
HTML
(
'
</{tag_name}>
'
).
format
(
tag_name
=
self
.
_child_tag_name
)
)
child_node
=
etree
.
fromstring
(
child_str
)
xml_object
.
append
(
child_node
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment