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
2afc9866
Commit
2afc9866
authored
Sep 14, 2016
by
Christina Roberts
Committed by
GitHub
Sep 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13469 from edx/release
Merge release back into master
parents
8887869a
f13f05b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletions
+40
-1
common/lib/capa/capa/capa_problem.py
+7
-1
common/lib/capa/capa/tests/test_capa_problem.py
+33
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
2afc9866
...
...
@@ -951,7 +951,13 @@ class LoncapaProblem(object):
if
p_tag
and
p_tag
[
0
]
.
text
==
inputfields
[
0
]
.
attrib
[
'label'
]:
label
=
p_tag
[
0
]
.
text
element_to_be_deleted
=
p_tag
[
0
]
p_tag_children
=
list
(
p_tag
[
0
])
if
len
(
p_tag_children
)
==
0
:
element_to_be_deleted
=
p_tag
[
0
]
else
:
# Delete the text from the p-tag, but leave the children.
p_tag
[
0
]
.
text
=
''
else
:
# In this case the problems don't have tag or label attribute inside the responsetype
# so we will get the first preceding label tag w.r.t to this responsetype.
...
...
common/lib/capa/capa/tests/test_capa_problem.py
View file @
2afc9866
...
...
@@ -424,6 +424,39 @@ class CAPAProblemTest(unittest.TestCase):
self
.
assert_question_tag
(
question1
,
question2
,
tag
=
'label'
,
label_attr
=
False
)
self
.
assert_question_tag
(
question1
,
question2
,
tag
=
'p'
,
label_attr
=
True
)
def
test_question_tag_child_left
(
self
):
"""
If the "old" question tag has children, don't delete the children when
transforming to the new label tag.
"""
xml
=
"""
<problem>
<p>Question<img src='img/src'/></p>
<choiceresponse>
<checkboxgroup label="Question">
<choice correct="true">choice1</choice>
<choice correct="false">choice2</choice>
</checkboxgroup>
</choiceresponse>
</problem>
"""
problem
=
new_loncapa_problem
(
xml
)
self
.
assertEqual
(
problem
.
problem_data
,
{
'1_2_1'
:
{
'label'
:
"Question"
,
'descriptions'
:
{}
}
}
)
# img tag is still present within the paragraph, but p text has been deleted
self
.
assertEqual
(
len
(
problem
.
tree
.
xpath
(
'//p'
)),
1
)
self
.
assertEqual
(
problem
.
tree
.
xpath
(
'//p'
)[
0
]
.
text
,
''
)
self
.
assertEqual
(
len
(
problem
.
tree
.
xpath
(
'//p/img'
)),
1
)
@ddt.ddt
class
CAPAMultiInputProblemTest
(
unittest
.
TestCase
):
...
...
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