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
cd0df9e5
Commit
cd0df9e5
authored
Jul 25, 2016
by
wajeeha-khalid
Committed by
GitHub
Jul 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13012 from edx/jia/MA-2076
MA-2076: add due date to course block API
parents
733abe37
98ba4b77
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
5 deletions
+15
-5
lms/djangoapps/course_api/blocks/tests/test_views.py
+10
-3
lms/djangoapps/course_api/blocks/transformers/__init__.py
+1
-0
lms/djangoapps/course_api/blocks/transformers/blocks_api.py
+1
-1
lms/djangoapps/course_api/blocks/views.py
+3
-1
No files found.
lms/djangoapps/course_api/blocks/tests/test_views.py
View file @
cd0df9e5
"""
"""
Tests for Blocks Views
Tests for Blocks Views
"""
"""
from
datetime
import
datetime
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
string
import
join
from
string
import
join
...
@@ -20,7 +21,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
...
@@ -20,7 +21,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
"""
"""
Test class for BlocksView
Test class for BlocksView
"""
"""
requested_fields
=
[
'graded'
,
'format'
,
'student_view_multi_device'
,
'children'
,
'not_a_field'
]
requested_fields
=
[
'graded'
,
'format'
,
'student_view_multi_device'
,
'children'
,
'not_a_field'
,
'due'
]
BLOCK_TYPES_WITH_STUDENT_VIEW_DATA
=
[
'video'
,
'discussion'
]
BLOCK_TYPES_WITH_STUDENT_VIEW_DATA
=
[
'video'
,
'discussion'
]
@classmethod
@classmethod
...
@@ -28,8 +29,13 @@ class TestBlocksView(SharedModuleStoreTestCase):
...
@@ -28,8 +29,13 @@ class TestBlocksView(SharedModuleStoreTestCase):
super
(
TestBlocksView
,
cls
)
.
setUpClass
()
super
(
TestBlocksView
,
cls
)
.
setUpClass
()
# create a toy course
# create a toy course
cls
.
course_key
=
ToyCourseFactory
.
create
()
.
id
cls
.
course
=
ToyCourseFactory
.
create
(
modulestore
=
cls
.
store
,
due
=
datetime
(
3013
,
9
,
18
,
11
,
30
,
00
),
)
cls
.
course_key
=
cls
.
course
.
id
cls
.
course_usage_key
=
cls
.
store
.
make_course_usage_key
(
cls
.
course_key
)
cls
.
course_usage_key
=
cls
.
store
.
make_course_usage_key
(
cls
.
course_key
)
cls
.
non_orphaned_block_usage_keys
=
set
(
cls
.
non_orphaned_block_usage_keys
=
set
(
unicode
(
item
.
location
)
unicode
(
item
.
location
)
for
item
in
cls
.
store
.
get_items
(
cls
.
course_key
)
for
item
in
cls
.
store
.
get_items
(
cls
.
course_key
)
...
@@ -40,7 +46,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
...
@@ -40,7 +46,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestBlocksView
,
self
)
.
setUp
()
super
(
TestBlocksView
,
self
)
.
setUp
()
# create a
user, enrolled
in the toy course
# create a
nd enroll user
in the toy course
self
.
user
=
UserFactory
.
create
()
self
.
user
=
UserFactory
.
create
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'test'
)
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'test'
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course_key
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course_key
)
...
@@ -103,6 +109,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
...
@@ -103,6 +109,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
self
.
assert_in_iff
(
'children'
,
block_data
,
xblock
.
has_children
)
self
.
assert_in_iff
(
'children'
,
block_data
,
xblock
.
has_children
)
self
.
assert_in_iff
(
'graded'
,
block_data
,
xblock
.
graded
is
not
None
)
self
.
assert_in_iff
(
'graded'
,
block_data
,
xblock
.
graded
is
not
None
)
self
.
assert_in_iff
(
'format'
,
block_data
,
xblock
.
format
is
not
None
)
self
.
assert_in_iff
(
'format'
,
block_data
,
xblock
.
format
is
not
None
)
self
.
assert_in_iff
(
'due'
,
block_data
,
xblock
.
due
is
not
None
)
self
.
assert_true_iff
(
block_data
[
'student_view_multi_device'
],
block_data
[
'type'
]
==
'html'
)
self
.
assert_true_iff
(
block_data
[
'student_view_multi_device'
],
block_data
[
'type'
]
==
'html'
)
self
.
assertNotIn
(
'not_a_field'
,
block_data
)
self
.
assertNotIn
(
'not_a_field'
,
block_data
)
...
...
lms/djangoapps/course_api/blocks/transformers/__init__.py
View file @
cd0df9e5
...
@@ -38,6 +38,7 @@ SUPPORTED_FIELDS = [
...
@@ -38,6 +38,7 @@ SUPPORTED_FIELDS = [
SupportedFieldType
(
'display_name'
,
default_value
=
''
),
SupportedFieldType
(
'display_name'
,
default_value
=
''
),
SupportedFieldType
(
'graded'
),
SupportedFieldType
(
'graded'
),
SupportedFieldType
(
'format'
),
SupportedFieldType
(
'format'
),
SupportedFieldType
(
'due'
),
# 'student_view_data'
# 'student_view_data'
SupportedFieldType
(
StudentViewTransformer
.
STUDENT_VIEW_DATA
,
StudentViewTransformer
),
SupportedFieldType
(
StudentViewTransformer
.
STUDENT_VIEW_DATA
,
StudentViewTransformer
),
# 'student_view_multi_device'
# 'student_view_multi_device'
...
...
lms/djangoapps/course_api/blocks/transformers/blocks_api.py
View file @
cd0df9e5
...
@@ -43,7 +43,7 @@ class BlocksAPITransformer(BlockStructureTransformer):
...
@@ -43,7 +43,7 @@ class BlocksAPITransformer(BlockStructureTransformer):
transform method.
transform method.
"""
"""
# collect basic xblock fields
# collect basic xblock fields
block_structure
.
request_xblock_fields
(
'graded'
,
'format'
,
'display_name'
,
'category'
)
block_structure
.
request_xblock_fields
(
'graded'
,
'format'
,
'display_name'
,
'category'
,
'due'
)
# collect data from containing transformers
# collect data from containing transformers
StudentViewTransformer
.
collect
(
block_structure
)
StudentViewTransformer
.
collect
(
block_structure
)
...
...
lms/djangoapps/course_api/blocks/views.py
View file @
cd0df9e5
...
@@ -30,7 +30,7 @@ class BlocksView(DeveloperErrorViewMixin, ListAPIView):
...
@@ -30,7 +30,7 @@ class BlocksView(DeveloperErrorViewMixin, ListAPIView):
GET /api/courses/v1/blocks/<usage_id>/?
GET /api/courses/v1/blocks/<usage_id>/?
username=anjali
username=anjali
&depth=all
&depth=all
&requested_fields=graded,format,student_view_multi_device,lti_url
&requested_fields=graded,format,student_view_multi_device,lti_url
,due
&block_counts=video
&block_counts=video
&student_view_data=video
&student_view_data=video
&block_types_filter=problem,html
&block_types_filter=problem,html
...
@@ -170,6 +170,8 @@ class BlocksView(DeveloperErrorViewMixin, ListAPIView):
...
@@ -170,6 +170,8 @@ class BlocksView(DeveloperErrorViewMixin, ListAPIView):
* lti_url: The block URL for an LTI consumer. Returned only if the
* lti_url: The block URL for an LTI consumer. Returned only if the
"ENABLE_LTI_PROVIDER" Django settign is set to "True".
"ENABLE_LTI_PROVIDER" Django settign is set to "True".
* due: The due date of the block. Returned only if "due" is included
in the "requested_fields" parameter.
"""
"""
def
list
(
self
,
request
,
usage_key_string
):
# pylint: disable=arguments-differ
def
list
(
self
,
request
,
usage_key_string
):
# pylint: disable=arguments-differ
...
...
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