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
2f5f7e33
Commit
2f5f7e33
authored
Aug 12, 2014
by
Zia Fazal
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ziafazal/api-cohort-average-bug: compute average by
number of enrolments instead of number of participants
parent
0b9cdf3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
lms/djangoapps/api_manager/courses/views.py
+8
-10
No files found.
lms/djangoapps/api_manager/courses/views.py
View file @
2f5f7e33
...
...
@@ -1534,13 +1534,14 @@ class CoursesLeadersList(SecureListAPIView):
if
not
course_descriptor
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
exclude_users
=
_get_aggregate_exclusion_user_ids
(
course_key
)
queryset
=
StudentModule
.
objects
.
filter
(
course_id__exact
=
course_key
,
grade__isnull
=
False
,
max_grade__isnull
=
False
,
max_grade__gt
=
0
,
student__is_active
=
True
)
.
exclude
(
student__in
=
_get_aggregate_exclusion_user_ids
(
course_key
)
)
)
.
exclude
(
student__in
=
exclude_users
)
if
content_id
:
content_descriptor
,
content_key
,
existing_content
=
get_course_child
(
request
,
request
.
user
,
course_key
,
content_id
)
# pylint: disable=W0612
...
...
@@ -1560,9 +1561,9 @@ class CoursesLeadersList(SecureListAPIView):
data
[
'points'
]
=
user_points
points
=
queryset
.
aggregate
(
total
=
Sum
(
'grade'
))
users
=
queryset
.
filter
(
student__is_active
=
True
)
.
aggregate
(
total
=
Count
(
'student__id'
,
distinct
=
True
)
)
if
users
and
users
[
'total'
]
:
course_avg
=
round
(
points
[
'total'
]
/
float
(
users
[
'total'
]
),
1
)
users
_total
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
.
exclude
(
id__in
=
exclude_users
)
.
count
(
)
if
users
_total
:
course_avg
=
round
(
points
[
'total'
]
/
float
(
users
_total
),
1
)
data
[
'course_avg'
]
=
course_avg
queryset
=
queryset
.
filter
(
student__is_active
=
True
)
.
values
(
'student__id'
,
'student__username'
,
'student__profile__title'
,
...
...
@@ -1614,12 +1615,9 @@ class CoursesCompletionsLeadersList(SecureAPIView):
data
[
'completions'
]
=
user_completions
total_completions
=
queryset
.
filter
(
user__is_active
=
True
)
.
count
()
users
=
CourseModuleCompletion
.
objects
.
filter
(
user__is_active
=
True
)
\
.
exclude
(
user__in
=
exclude_users
)
\
.
aggregate
(
total
=
Count
(
'user__id'
,
distinct
=
True
))
if
users
and
users
[
'total'
]
>
0
:
course_avg
=
round
(
total_completions
/
float
(
users
[
'total'
]),
1
)
total_users
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
.
exclude
(
id__in
=
exclude_users
)
.
count
()
if
total_users
:
course_avg
=
round
(
total_completions
/
float
(
total_users
),
1
)
data
[
'course_avg'
]
=
course_avg
queryset
=
queryset
.
filter
(
user__is_active
=
True
)
.
values
(
'user__id'
,
'user__username'
,
'user__profile__title'
,
...
...
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