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
b6e6eb6e
Commit
b6e6eb6e
authored
Jun 19, 2014
by
Zia Fazal
Committed by
Xavier Antoviaque
Sep 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get projects by course
parent
6c1f5d8a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
lms/djangoapps/api_manager/courses/tests.py
+19
-0
lms/djangoapps/api_manager/courses/urls.py
+1
-0
lms/djangoapps/api_manager/courses/views.py
+23
-0
No files found.
lms/djangoapps/api_manager/courses/tests.py
View file @
b6e6eb6e
...
@@ -1338,3 +1338,22 @@ class CoursesApiTests(TestCase):
...
@@ -1338,3 +1338,22 @@ class CoursesApiTests(TestCase):
test_uri
=
'{}/{}/grades'
.
format
(
self
.
base_courses_uri
,
self
.
test_bogus_course_id
)
test_uri
=
'{}/{}/grades'
.
format
(
self
.
base_courses_uri
,
self
.
test_bogus_course_id
)
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_course_project_list
(
self
):
projects_uri
=
'/api/projects/'
for
i
in
xrange
(
0
,
25
):
data
=
{
'course_id'
:
self
.
test_course_id
,
'content_id'
:
'{}_{}'
.
format
(
self
.
test_course_content_id
,
i
)
}
response
=
self
.
do_post
(
projects_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
response
=
self
.
do_get
(
'{}/{}/projects/?page_size=10'
.
format
(
self
.
base_courses_uri
,
self
.
test_course_id
))
self
.
assertEqual
(
response
.
data
[
'count'
],
25
)
self
.
assertEqual
(
len
(
response
.
data
[
'results'
]),
10
)
self
.
assertEqual
(
response
.
data
[
'num_pages'
],
3
)
response
=
self
.
do_get
(
'{}/{}/projects/'
.
format
(
self
.
base_courses_uri
,
self
.
test_bogus_course_id
))
self
.
assertEqual
(
response
.
status_code
,
404
)
lms/djangoapps/api_manager/courses/urls.py
View file @
b6e6eb6e
...
@@ -28,6 +28,7 @@ urlpatterns = patterns(
...
@@ -28,6 +28,7 @@ urlpatterns = patterns(
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/users/(?P<user_id>[0-9]+)$'
,
courses_views
.
CoursesUsersDetail
.
as_view
()),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/users/(?P<user_id>[0-9]+)$'
,
courses_views
.
CoursesUsersDetail
.
as_view
()),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/users/*$'
,
courses_views
.
CoursesUsersList
.
as_view
()),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/users/*$'
,
courses_views
.
CoursesUsersList
.
as_view
()),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/completions/*$'
,
courses_views
.
CourseModuleCompletionList
.
as_view
(),
name
=
'completion-list'
),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/completions/*$'
,
courses_views
.
CourseModuleCompletionList
.
as_view
(),
name
=
'completion-list'
),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/projects/*$'
,
courses_views
.
CoursesProjectList
.
as_view
(),
name
=
'courseproject-list'
),
)
)
urlpatterns
=
format_suffix_patterns
(
urlpatterns
)
urlpatterns
=
format_suffix_patterns
(
urlpatterns
)
lms/djangoapps/api_manager/courses/views.py
View file @
b6e6eb6e
...
@@ -30,6 +30,8 @@ from xmodule.modulestore.django import modulestore
...
@@ -30,6 +30,8 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore
import
Location
,
InvalidLocationError
from
xmodule.modulestore
import
Location
,
InvalidLocationError
from
api_manager.permissions
import
SecureAPIView
,
SecureListAPIView
from
api_manager.permissions
import
SecureAPIView
,
SecureListAPIView
from
api_manager.utils
import
generate_base_uri
from
api_manager.utils
import
generate_base_uri
from
projects.models
import
Project
from
projects.serializers
import
ProjectSerializer
from
.serializers
import
CourseModuleCompletionSerializer
from
.serializers
import
CourseModuleCompletionSerializer
from
.serializers
import
GradeSerializer
from
.serializers
import
GradeSerializer
...
@@ -1375,3 +1377,24 @@ class CoursesGradesList(SecureListAPIView):
...
@@ -1375,3 +1377,24 @@ class CoursesGradesList(SecureListAPIView):
serializer
=
GradeSerializer
(
row
)
serializer
=
GradeSerializer
(
row
)
response_data
[
'grades'
]
.
append
(
serializer
.
data
)
response_data
[
'grades'
]
.
append
(
serializer
.
data
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
class
CoursesProjectList
(
SecureListAPIView
):
"""
### The CoursesProjectList view allows clients to retrieve paginated list of projects by course
- URI: ```/api/courses/{course_id}/projects/```
- GET: Provides paginated list of projects for a course
"""
serializer_class
=
ProjectSerializer
def
get_queryset
(
self
):
course_id
=
self
.
kwargs
[
'course_id'
]
try
:
existing_course
=
get_course
(
course_id
)
except
ValueError
:
existing_course
=
None
if
not
existing_course
:
raise
Http404
return
Project
.
objects
.
filter
(
course_id
=
course_id
)
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