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
1133ffa4
Commit
1133ffa4
authored
Oct 21, 2014
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #277 from edx-solutions/ziafazal/api-add-org-filter-to-social-stats
added organization filter
parents
52a26bd1
97533410
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
lms/djangoapps/api_manager/courses/views.py
+15
-3
No files found.
lms/djangoapps/api_manager/courses/views.py
View file @
1133ffa4
...
...
@@ -1769,14 +1769,15 @@ class CoursesMetricsSocial(SecureListAPIView):
"""
### The CoursesMetricsSocial view allows clients to query about the activity of all users in the
forums
- URI: ```/api/users/{course_id}/metrics/social/```
- GET: Returns a list of social metrics for users in the specified course
- URI: ```/api/users/{course_id}/metrics/social/
?organization={org_id}
```
- GET: Returns a list of social metrics for users in the specified course
. Results can be filtered by organization
"""
def
get
(
self
,
request
,
course_id
):
# pylint: disable=W0613
try
:
slash_course_id
=
get_course_key
(
course_id
,
slashseparated
=
True
)
organization
=
request
.
QUERY_PARAMS
.
get
(
'organization'
,
None
)
# the forum service expects the legacy slash separated string format
data
=
get_course_social_stats
(
slash_course_id
)
course_key
=
get_course_key
(
course_id
)
...
...
@@ -1787,7 +1788,18 @@ class CoursesMetricsSocial(SecureListAPIView):
for
user_id
in
exclude_users
:
if
str
(
user_id
)
in
data
:
del
data
[
str
(
user_id
)]
total_enrollments
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
.
exclude
(
id__in
=
exclude_users
)
.
count
()
enrollment_qs
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
.
exclude
(
id__in
=
exclude_users
)
if
organization
:
enrollment_qs
=
enrollment_qs
.
filter
(
organizations
=
organization
)
users_in_org
=
enrollment_qs
.
values_list
(
'id'
,
flat
=
True
)
# extract org users
org_data
=
{}
for
user_id
in
users_in_org
:
if
str
(
user_id
)
in
data
:
org_data
.
update
({
str
(
user_id
):
data
[
str
(
user_id
)]})
data
=
org_data
total_enrollments
=
enrollment_qs
.
count
()
data
=
{
'total_enrollments'
:
total_enrollments
,
'users'
:
data
}
http_status
=
status
.
HTTP_200_OK
except
CommentClientRequestError
,
e
:
...
...
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