Skip to content

Commit

Permalink
Fixing edx#1
Browse files Browse the repository at this point in the history
  • Loading branch information
viadanna committed Nov 29, 2018
1 parent 40c2273 commit d3531a1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions edx_solutions_api_integration/courses/views.py
Expand Up @@ -329,7 +329,7 @@ def _cache_static_tab_contents(cache_key, contents):
cache.set(cache_key, contents, cache_expiration)


def _get_course_progress_metrics(course_key, user_id=None, exclude_users=None, org_ids=None, group_ids=None):
def _get_course_progress_metrics(course_key, **kwargs):
"""
returns a dict containing these course progress metrics
`course_avg`: average progress in course
Expand All @@ -342,20 +342,16 @@ def _get_course_progress_metrics(course_key, user_id=None, exclude_users=None, o
data = {'course_avg': course_avg}
course_metadata = CourseAggregatedMetaData.get_from_id(course_key)
total_possible_completions = float(course_metadata.total_assessments)
total_actual_completions = get_total_completions(
course_key,
exclude_users=exclude_users,
org_ids=org_ids,
group_ids=group_ids
)
if user_id:
data.update(get_user_position(course_key, user_id, exclude_users=exclude_users))

total_users_qs = CourseEnrollment.objects.users_enrolled_in(course_key).exclude(id__in=exclude_users)
if org_ids:
total_users_qs = total_users_qs.filter(organizations__in=org_ids)
if group_ids:
total_users_qs = total_users_qs.filter(groups__in=group_ids).distinct()
total_actual_completions = get_total_completions(course_key, **kwargs)
if kwargs.get('user_id'):
data.update(get_user_position(course_key, **kwargs))

total_users_qs = CourseEnrollment.objects.users_enrolled_in(course_key).exclude(
id__in=kwargs.get('exclude_users'))
if kwargs.get('org_ids'):
total_users_qs = total_users_qs.filter(organizations__in=kwargs.get('org_ids'))
if kwargs.get('group_ids'):
total_users_qs = total_users_qs.filter(groups__in=kwargs.get('group_ids')).distinct()
total_users = total_users_qs.count()
if total_users and total_actual_completions and total_possible_completions:
course_avg = total_actual_completions / float(total_users)
Expand Down

0 comments on commit d3531a1

Please sign in to comment.