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
c7c8a4e5
Commit
c7c8a4e5
authored
Sep 13, 2016
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't delete question p-tag if children.
TNL-5510
parent
939a3d20
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
common/lib/capa/capa/capa_problem.py
+6
-0
common/lib/capa/capa/tests/test_capa_problem.py
+33
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
c7c8a4e5
...
@@ -951,8 +951,14 @@ class LoncapaProblem(object):
...
@@ -951,8 +951,14 @@ class LoncapaProblem(object):
if
p_tag
and
p_tag
[
0
]
.
text
==
inputfields
[
0
]
.
attrib
[
'label'
]:
if
p_tag
and
p_tag
[
0
]
.
text
==
inputfields
[
0
]
.
attrib
[
'label'
]:
label
=
p_tag
[
0
]
.
text
label
=
p_tag
[
0
]
.
text
p_tag_children
=
list
(
p_tag
[
0
])
if
len
(
p_tag_children
)
==
0
:
element_to_be_deleted
=
p_tag
[
0
]
element_to_be_deleted
=
p_tag
[
0
]
else
:
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
# 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.
# so we will get the first preceding label tag w.r.t to this responsetype.
# This will take care of those multi-question problems that are not using --- in their markdown.
# This will take care of those multi-question problems that are not using --- in their markdown.
...
...
common/lib/capa/capa/tests/test_capa_problem.py
View file @
c7c8a4e5
...
@@ -424,6 +424,39 @@ class CAPAProblemTest(unittest.TestCase):
...
@@ -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
=
'label'
,
label_attr
=
False
)
self
.
assert_question_tag
(
question1
,
question2
,
tag
=
'p'
,
label_attr
=
True
)
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
@ddt.ddt
class
CAPAMultiInputProblemTest
(
unittest
.
TestCase
):
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