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
e83fb3f8
Commit
e83fb3f8
authored
Sep 20, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new API to xmodule(descriptor). get_children_locations and has_dynamic_children.
parent
70818f8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
common/lib/xmodule/xmodule/abtest_module.py
+7
-5
common/lib/xmodule/xmodule/x_module.py
+28
-1
No files found.
common/lib/xmodule/xmodule/abtest_module.py
View file @
e83fb3f8
...
...
@@ -47,11 +47,9 @@ class ABTestModule(XModule):
def
get_shared_state
(
self
):
return
json
.
dumps
({
'group'
:
self
.
group
})
def
displayable_items
(
self
):
child_locations
=
self
.
definition
[
'data'
][
'group_content'
][
self
.
group
]
children
=
[
self
.
system
.
get_module
(
loc
)
for
loc
in
child_locations
]
return
[
c
for
c
in
children
if
c
is
not
None
]
def
get_children_locations
(
self
):
return
self
.
definition
[
'data'
][
'group_content'
][
self
.
group
]
# TODO (cpennington): Use Groups should be a first class object, rather than being
...
...
@@ -158,3 +156,7 @@ class ABTestDescriptor(RawDescriptor, XmlDescriptor):
group_elem
.
append
(
etree
.
fromstring
(
child
.
export_to_xml
(
resource_fs
)))
return
xml_object
def
has_dynamic_children
(
self
):
return
True
common/lib/xmodule/xmodule/x_module.py
View file @
e83fb3f8
...
...
@@ -219,13 +219,28 @@ class XModule(HTMLSnippet):
Return module instances for all the children of this module.
'''
if
self
.
_loaded_children
is
None
:
child_locations
=
self
.
definition
.
get
(
'children'
,
[]
)
child_locations
=
self
.
get_children_locations
(
)
children
=
[
self
.
system
.
get_module
(
loc
)
for
loc
in
child_locations
]
# get_module returns None if the current user doesn't have access
# to the location.
self
.
_loaded_children
=
[
c
for
c
in
children
if
c
is
not
None
]
return
self
.
_loaded_children
def
get_children_locations
(
self
):
'''
Returns the locations of each of child modules.
Overriding this changes the behavior of get_children and
anything that uses get_children, such as get_display_items.
This method will not instantiate the modules of the children
unless absolutely necessary, so it is cheaper to call than get_children
These children will be the same children returned by the
descriptor unless descriptor.has_dynamic_children() is true.
'''
return
self
.
definition
.
get
(
'children'
,
[])
def
get_display_items
(
self
):
'''
...
...
@@ -489,6 +504,18 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
self
,
metadata
=
self
.
metadata
)
def
has_dynamic_children
(
self
):
"""
Returns True if this descriptor has dynamic children for a given
student when the module is created.
Returns False if the children of this descriptor are the same
children that the module will return for any student.
"""
return
False
# ================================= JSON PARSING ===========================
@staticmethod
...
...
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