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
6e702c31
Commit
6e702c31
authored
Jun 09, 2014
by
Julia Hansbrough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix conditional module rendering
parent
749cb4ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletions
+46
-1
common/lib/xmodule/xmodule/conditional_module.py
+4
-1
common/lib/xmodule/xmodule/tests/test_conditional.py
+42
-0
No files found.
common/lib/xmodule/xmodule/conditional_module.py
View file @
6e702c31
...
...
@@ -197,7 +197,10 @@ class ConditionalDescriptor(ConditionalFields, SequenceDescriptor):
# substitution can be done.
if
not
self
.
sources_list
:
if
'sources'
in
self
.
xml_attributes
and
isinstance
(
self
.
xml_attributes
[
'sources'
],
basestring
):
self
.
sources_list
=
ConditionalDescriptor
.
parse_sources
(
self
.
xml_attributes
)
self
.
sources_list
=
[
self
.
location
.
course_key
.
make_usage_key_from_deprecated_string
(
item
)
for
item
in
ConditionalDescriptor
.
parse_sources
(
self
.
xml_attributes
)
]
@staticmethod
def
parse_sources
(
xml_element
):
...
...
common/lib/xmodule/xmodule/tests/test_conditional.py
View file @
6e702c31
...
...
@@ -253,3 +253,45 @@ class ConditionalModuleXmlTest(unittest.TestCase):
print
"post-attempt ajax: "
,
ajax
html
=
ajax
[
'html'
]
self
.
assertTrue
(
any
([
'This is a secret'
in
item
for
item
in
html
]))
def
test_conditional_module_with_empty_sources_list
(
self
):
"""
If a ConditionalDescriptor is initialized with an empty sources_list, we assert that the sources_list is set
via generating UsageKeys from the values in xml_attributes['sources']
"""
dummy_system
=
Mock
()
dummy_location
=
Location
(
"edX"
,
"conditional_test"
,
"test_run"
,
"conditional"
,
"SampleConditional"
,
None
)
dummy_scope_ids
=
ScopeIds
(
None
,
None
,
dummy_location
,
dummy_location
)
dummy_field_data
=
DictFieldData
({
'data'
:
'<conditional/>'
,
'xml_attributes'
:
{
'sources'
:
'i4x://HarvardX/ER22x/poll_question/T15_poll'
},
'children'
:
None
,
})
conditional
=
ConditionalDescriptor
(
dummy_system
,
dummy_field_data
,
dummy_scope_ids
,
)
self
.
assertEqual
(
conditional
.
sources_list
[
0
],
conditional
.
location
.
course_key
.
make_usage_key_from_deprecated_string
(
conditional
.
xml_attributes
[
'sources'
])
)
def
test_conditional_module_parse_sources
(
self
):
dummy_system
=
Mock
()
dummy_location
=
Location
(
"edX"
,
"conditional_test"
,
"test_run"
,
"conditional"
,
"SampleConditional"
,
None
)
dummy_scope_ids
=
ScopeIds
(
None
,
None
,
dummy_location
,
dummy_location
)
dummy_field_data
=
DictFieldData
({
'data'
:
'<conditional/>'
,
'xml_attributes'
:
{
'sources'
:
'i4x://HarvardX/ER22x/poll_question/T15_poll;i4x://HarvardX/ER22x/poll_question/T16_poll'
},
'children'
:
None
,
})
conditional
=
ConditionalDescriptor
(
dummy_system
,
dummy_field_data
,
dummy_scope_ids
,
)
self
.
assertEqual
(
conditional
.
parse_sources
(
conditional
.
xml_attributes
),
[
'i4x://HarvardX/ER22x/poll_question/T15_poll'
,
'i4x://HarvardX/ER22x/poll_question/T16_poll'
]
)
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