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
0a7d8ce8
Commit
0a7d8ce8
authored
Nov 14, 2014
by
Zia Fazal
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ziafazal/api-fix-progress-avg-greater-than-100: fix progress value more than 100
parent
8b1589d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
lms/djangoapps/api_manager/courses/serializers.py
+1
-1
lms/djangoapps/api_manager/courses/tests.py
+17
-0
lms/djangoapps/api_manager/courses/views.py
+2
-2
No files found.
lms/djangoapps/api_manager/courses/serializers.py
View file @
0a7d8ce8
...
...
@@ -36,7 +36,7 @@ class CourseCompletionsLeadersSerializer(serializers.Serializer):
completions
=
obj
[
'completions'
]
or
0
completion_percentage
=
0
if
total_completions
>
0
:
completion_percentage
=
100
*
(
completions
/
float
(
total_completions
)
)
completion_percentage
=
min
(
100
*
(
completions
/
float
(
total_completions
)),
100
)
return
completion_percentage
...
...
lms/djangoapps/api_manager/courses/tests.py
View file @
0a7d8ce8
...
...
@@ -1748,6 +1748,7 @@ class CoursesApiTests(ModuleStoreTestCase):
# Make last user as observer to make sure that data is being filtered out
allow_access
(
course
,
users
[
USER_COUNT
-
1
],
'observer'
)
contents
=
[]
for
i
in
xrange
(
1
,
26
):
local_content_name
=
'Video_Sequence{}'
.
format
(
i
)
local_content
=
ItemFactory
.
create
(
...
...
@@ -1756,6 +1757,7 @@ class CoursesApiTests(ModuleStoreTestCase):
data
=
self
.
test_data
,
display_name
=
local_content_name
)
contents
.
append
(
local_content
)
if
i
<
3
:
user_id
=
users
[
0
]
.
id
elif
i
<
10
:
...
...
@@ -1828,6 +1830,21 @@ class CoursesApiTests(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
data
[
'position'
],
0
)
self
.
assertEqual
(
response
.
data
[
'completions'
],
0
)
# test a case where completions are greater than total course modules. it should not be more than 100
contents
.
append
(
self
.
course_content
)
for
content
in
contents
[
2
:]:
user_id
=
users
[
0
]
.
id
content_id
=
unicode
(
content
.
scope_ids
.
usage_id
)
completions_data
=
{
'content_id'
:
content_id
,
'user_id'
:
user_id
}
response
=
self
.
do_post
(
completion_uri
,
completions_data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
test_uri
=
'{}?user_id={}'
.
format
(
leaders_uri
,
users
[
0
]
.
id
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
'{0:.3f}'
.
format
(
response
.
data
[
'completions'
]),
'100.000'
)
def
test_courses_metrics_grades_list_get
(
self
):
# Retrieve the list of grades for this course
# All the course/item/user scaffolding was handled in Setup
...
...
lms/djangoapps/api_manager/courses/views.py
View file @
0a7d8ce8
...
...
@@ -1737,7 +1737,7 @@ class CoursesMetricsCompletionsLeadersList(SecureAPIView):
user_completions
=
user_data
[
'completions'
]
completion_percentage
=
0
if
total_possible_completions
>
0
:
completion_percentage
=
100
*
(
user_completions
/
total_possible_completions
)
completion_percentage
=
min
(
100
*
(
user_completions
/
total_possible_completions
),
100
)
data
[
'completions'
]
=
completion_percentage
total_users_qs
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
.
exclude
(
id__in
=
exclude_users
)
...
...
@@ -1746,7 +1746,7 @@ class CoursesMetricsCompletionsLeadersList(SecureAPIView):
total_users
=
total_users_qs
.
count
()
if
total_users
and
total_actual_completions
:
course_avg
=
total_actual_completions
/
float
(
total_users
)
course_avg
=
100
*
(
course_avg
/
total_possible_completions
)
# avg in percentage
course_avg
=
min
(
100
*
(
course_avg
/
total_possible_completions
),
100
)
# avg in percentage
data
[
'course_avg'
]
=
course_avg
if
not
skipleaders
:
...
...
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