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
a6130507
Commit
a6130507
authored
Jan 28, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mobile Video Summary API: add filter for get_children
parent
4b9434a3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
39 deletions
+52
-39
common/lib/xmodule/xmodule/x_module.py
+4
-1
lms/djangoapps/mobile_api/video_outlines/serializers.py
+15
-5
lms/djangoapps/mobile_api/video_outlines/tests.py
+33
-33
No files found.
common/lib/xmodule/xmodule/x_module.py
View file @
a6130507
...
...
@@ -402,7 +402,7 @@ class XModuleMixin(XBlockMixin):
else
:
return
[
self
.
display_name_with_default
]
def
get_children
(
self
):
def
get_children
(
self
,
usage_key_filter
=
lambda
location
:
True
):
"""Returns a list of XBlock instances for the children of
this module"""
...
...
@@ -412,6 +412,9 @@ class XModuleMixin(XBlockMixin):
if
getattr
(
self
,
'_child_instances'
,
None
)
is
None
:
self
.
_child_instances
=
[]
# pylint: disable=attribute-defined-outside-init
for
child_loc
in
self
.
children
:
# Skip if it doesn't satisfy the filter function
if
not
usage_key_filter
(
child_loc
):
continue
try
:
child
=
self
.
runtime
.
get_block
(
child_loc
)
if
child
is
None
:
...
...
lms/djangoapps/mobile_api/video_outlines/serializers.py
View file @
a6130507
...
...
@@ -3,6 +3,7 @@ Serializer for video outline
"""
from
rest_framework.reverse
import
reverse
from
xmodule.modulestore.mongo.base
import
BLOCK_TYPES_WITH_CHILDREN
from
courseware.access
import
has_access
from
edxval.api
import
(
...
...
@@ -14,10 +15,10 @@ class BlockOutline(object):
"""
Serializes course videos, pulling data from VAL and the video modules.
"""
def
__init__
(
self
,
course_id
,
start_block
,
categories_to_outliner
,
request
):
def
__init__
(
self
,
course_id
,
start_block
,
block_types
,
request
):
"""Create a BlockOutline using `start_block` as a starting point."""
self
.
start_block
=
start_block
self
.
categories_to_outliner
=
categories_to_outliner
self
.
block_types
=
block_types
self
.
course_id
=
course_id
self
.
request
=
request
# needed for making full URLS
self
.
local_cache
=
{}
...
...
@@ -143,11 +144,11 @@ class BlockOutline(object):
# from the table-of-contents.
continue
if
curr_block
.
category
in
self
.
categories_to_outliner
:
if
curr_block
.
location
.
block_type
in
self
.
block_types
:
if
not
has_access
(
user
,
'load'
,
curr_block
,
course_key
=
self
.
course_id
):
continue
summary_fn
=
self
.
categories_to_outliner
[
curr_block
.
category
]
summary_fn
=
self
.
block_types
[
curr_block
.
category
]
block_path
=
list
(
path
(
curr_block
))
unit_url
,
section_url
=
find_urls
(
curr_block
)
...
...
@@ -159,8 +160,17 @@ class BlockOutline(object):
"summary"
:
summary_fn
(
self
.
course_id
,
curr_block
,
self
.
request
,
self
.
local_cache
)
}
def
parent_or_requested_block_type
(
usage_key
):
"""
Returns whether the usage_key's block_type is one of self.block_types or a parent type.
"""
return
(
usage_key
.
block_type
in
self
.
block_types
or
usage_key
.
block_type
in
BLOCK_TYPES_WITH_CHILDREN
)
if
curr_block
.
has_children
:
for
block
in
reversed
(
curr_block
.
get_children
()):
for
block
in
reversed
(
curr_block
.
get_children
(
usage_key_filter
=
parent_or_requested_block_type
)):
stack
.
append
(
block
)
child_to_parent
[
block
]
=
curr_block
...
...
lms/djangoapps/mobile_api/video_outlines/tests.py
View file @
a6130507
This diff is collapsed.
Click to expand it.
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