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
63f81d8a
Commit
63f81d8a
authored
Sep 30, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! course_api updates from DRF upgrade.
parent
678da3d2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
10 deletions
+14
-10
lms/djangoapps/course_api/blocks/serializers.py
+2
-2
lms/djangoapps/course_api/blocks/transformers/navigation.py
+1
-1
lms/djangoapps/course_api/blocks/transformers/tests/test_navigation.py
+3
-3
lms/djangoapps/course_api/blocks/views.py
+8
-4
No files found.
lms/djangoapps/course_api/blocks/serializers.py
View file @
63f81d8a
...
...
@@ -21,7 +21,7 @@ class BlockSerializer(serializers.Serializer):
# for example, if student_view_multi_device is false, just don't specify it?
return
value
if
(
value
is
not
None
)
else
default
def
to_
native
(
self
,
block_key
):
def
to_
representation
(
self
,
block_key
):
# create response data dict for basic fields
data
=
{
'id'
:
unicode
(
block_key
),
...
...
@@ -62,7 +62,7 @@ class BlockDictSerializer(serializers.Serializer):
Serializer that formats to a dictionary, rather than a list, of blocks
"""
root
=
serializers
.
CharField
(
source
=
'root_block_key'
)
blocks
=
serializers
.
SerializerMethodField
(
'get_blocks'
)
blocks
=
serializers
.
SerializerMethodField
()
def
get_blocks
(
self
,
structure
):
"""
...
...
lms/djangoapps/course_api/blocks/transformers/navigation.py
View file @
63f81d8a
...
...
@@ -56,7 +56,7 @@ class BlockNavigationTransformer(BlockStructureTransformer):
# add self to parent's descendants
for
parent_desc_list
in
parents_descendants_list
:
if
parent_desc_list
is
not
None
:
parent_desc_list
.
items
.
append
(
block_key
)
parent_desc_list
.
items
.
append
(
unicode
(
block_key
)
)
if
BlockDepthTransformer
.
get_block_depth
(
block_structure
,
block_key
)
>
self
.
nav_depth
:
children_descendants_list
=
parents_descendants_list
...
...
lms/djangoapps/course_api/blocks/transformers/tests/test_navigation.py
View file @
63f81d8a
...
...
@@ -49,7 +49,7 @@ class BlockNavigationTransformerTestCase(TestCase, ChildrenMapTestMixin):
for
block_key
,
expected_nav
in
enumerate
(
expected_nav_map
):
self
.
assertSetEqual
(
set
(
expected_nav
),
set
(
unicode
(
block
)
for
block
in
expected_nav
),
set
(
block_structure
.
get_transformer_block_data
(
block_key
,
...
...
@@ -104,7 +104,7 @@ class BlockNavigationTransformerCourseTestCase(ModuleStoreTestCase):
course_key
.
make_usage_key
(
'vertical'
,
'vertical_y1a'
),
course_key
.
make_usage_key
(
'problem'
,
'problem_y1a_1'
),
]:
self
.
assertIn
(
block_key
,
course_descendants
)
self
.
assertIn
(
unicode
(
block_key
)
,
course_descendants
)
# chapter_x and its descendants should not be included
for
block_key
in
[
...
...
@@ -113,4 +113,4 @@ class BlockNavigationTransformerCourseTestCase(ModuleStoreTestCase):
course_key
.
make_usage_key
(
'vertical'
,
'vertical_x1a'
),
course_key
.
make_usage_key
(
'problem'
,
'problem_x1a_1'
),
]:
self
.
assertNotIn
(
block_key
,
course_descendants
)
self
.
assertNotIn
(
unicode
(
block_key
)
,
course_descendants
)
lms/djangoapps/course_api/blocks/views.py
View file @
63f81d8a
...
...
@@ -24,10 +24,10 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
GET /api/courses/v1/blocks/<root_block_usage_id>/?depth=all
GET /api/courses/v1/blocks/<usage_id>/?
user=anjali,
&fields=graded,format,multi_device,
&depth=all,
&requested_fields=graded,format,student_view_multi_device,
&block_counts=video,
&student_view_data=video,
&student_view_data.video=mobile_low
**Parameters**:
...
...
@@ -42,7 +42,7 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
* requested_fields: (list) Indicates which additional fields to return for each block.
The following fields are always returned: type, display_name
Example: requested_fields=graded,format,student_view_multi_device
,children
Example: requested_fields=graded,format,student_view_multi_device
* depth (integer or all) Indicates how deep to traverse into the blocks hierarchy.
A value of all means the entire hierarchy.
...
...
@@ -50,7 +50,11 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
Example: depth=all
NOTE: This parameter is currently not honored or supported. For now, it only implements depth=all.
* nav_depth (integer) Indicates how far deep to traverse into the course hierarchy before bundling
all the descendants.
Default is 3 since typical navigational views of the course show a maximum of chapter->sequential->vertical.
Example: nav_depth=3
* return_type (string) Indicates in what data type to return the blocks.
Default is dict. Supported values are: dict, list
...
...
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