-
Notifications
You must be signed in to change notification settings - Fork 37
/
metrics.py
794 lines (667 loc) · 27.5 KB
/
metrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
"""
We're starting with doing monthly metrics. Then we will refactor to provide
programmatic timespans
Design note:
prefer querying metrics models (if the data are available there) over querying
edx-platform models with the exception of CourseOverview
NOTE: We're starting to grow this module enough that we want to
* refactor into a module directory
* create separate metrics submodule files for functional areas
* Add public facing submodule object and function declarations to metrics/__init__.py
Security note: This module does NOT perform user authorization. THEREFORE make
sure that any code that calls these methods is properly authorizing the user
After initial production release, We will follow on with adding 'site' as a
parameter to support multi-tenancy
"""
import datetime
from decimal import Decimal
import math
from django.contrib.auth import get_user_model
from django.db.models import Avg, Max
from courseware.courses import get_course_by_id # pylint: disable=import-error
from courseware.models import StudentModule # pylint: disable=import-error
from figures.compat import (
GeneratedCertificate,
chapter_grade_values,
course_grade,
)
from figures.helpers import (
as_course_key,
as_date,
as_datetime,
days_in_month,
next_day,
prev_day,
previous_months_iterator,
first_last_days_for_month,
)
from figures.mau import get_mau_from_site_course
from figures.models import (
CourseDailyMetrics,
SiteDailyMetrics,
SiteMonthlyMetrics,
)
import figures.sites
#
# Helpers (consider moving to the ``helpers`` module
#
def period_str(month_tuple, fmt='%Y/%m'):
"""Returns display date for the given month tuple containing year, month, day
"""
return datetime.date(*month_tuple).strftime(fmt)
#
# Learner specific data/metrics
#
class LearnerCourseGrades(object):
"""
Extracts a learner's progress data for a specific course
This class does not need to be site aware as it is specific to the learner
and course. We may want to either add a classmethod ``from_course_enrollment``
to instantiate or provide ``CourseEnrollment`` as a constructor param
This class should be in the pipeline
TODO: create a figures.pipeline.learner module and add this class there
TODO: Then enable a default learner course grade extractor that can be
overridden.
Create an abstract base class and rework this class to be derived. Then
Members
self.course: xblock.internal.CourseDescriptorWithMixins
self.course_grade: lms.djangoapps.grades.new.course_grade.CourseGrade
course_grade.chapter_grades is an OrderedDict of
keys:
BlockUsageLocator(CourseLocator(u'edX', u'DemoX', u'Demo_Course', None, None)
values:
TODO: Make convenience method to instantiate from a GeneratedCertificate
"""
def __init__(self, user_id, course_id, **_kwargs):
"""
If figures.compat.course_grade is unable to retrieve the course blocks,
raises:
django.core.exceptions.PermissionDenied(
"User does not have access to this course")
"""
self.learner = get_user_model().objects.get(id=user_id)
self.course = get_course_by_id(course_key=as_course_key(course_id))
self.course._field_data_cache = {} # pylint: disable=protected-access
self.course.set_grading_policy(self.course.grading_policy)
self.course_grade = course_grade(self.learner, self.course)
def __str__(self):
return u'{} - {} - {} '.format(
self.course.id, self.learner.id, self.learner.username)
@staticmethod
def from_course_enrollment(course_enrollment):
return LearnerCourseGrades(
user_id=course_enrollment.user.id,
course_id=course_enrollment.course_id)
@property
def chapter_grades(self):
"""Convenience wrapper, mostly as a reminder
"""
return self.course_grade.chapter_grades
def certificates(self):
return GeneratedCertificate.objects.filter(
user=self.learner).filter(course_id=self.course.id)
def learner_completed(self):
return self.certificates().count() != 0
# Can be a class method instead of instance
def is_section_graded(self, section):
# just being defensive, might not need to check if
# all_total exists and if all_total.possible exists
return bool(
hasattr(section, 'all_total')
and hasattr(section.all_total, 'possible')
and section.all_total.possible > 0
)
def sections(self, only_graded=False, **_kwargs):
"""
yields objects of type:
lms.djangoapps.grades.new.subsection_grade.SubsectionGrade
Compatibility:
In Ficus, at least in the default devstack data, chapter_grades is a list
of dicts
"""
for chapter_grade in chapter_grade_values(self.course_grade.chapter_grades):
for section in chapter_grade['sections']:
if not only_graded or (only_graded and self.is_section_graded(section)):
yield section
def sections_list(self, only_graded=False):
"""Convenience method that returns a list by calling the iterator method,
``sections``
"""
return [section for section in self.sections(only_graded=only_graded)]
def progress(self):
"""
TODO: FIGURE THIS OUT
There are two ways we can go about measurig progress:
The percentage grade points toward the total grade points
OR
the number of sections completed toward the total number of sections
"""
count = points_possible = points_earned = sections_worked = 0
for section in self.sections(only_graded=True):
if section.all_total.earned > 0:
sections_worked += 1
points_earned += section.all_total.earned
count += 1
points_possible += section.all_total.possible
return dict(
points_possible=points_possible,
points_earned=points_earned,
sections_worked=sections_worked,
count=count,
)
def progress_percent(self, progress_details=None):
"""
TODO: This func needs work
"""
if not progress_details:
progress_details = self.progress()
if not progress_details['count']:
return 0.0
else:
return float(progress_details['sections_worked']) / float(
progress_details['count'])
@staticmethod
def course_progress(course_enrollment):
lcg = LearnerCourseGrades(
user_id=course_enrollment.user.id,
course_id=course_enrollment.course_id,
)
course_progress_details = lcg.progress()
return dict(
course_progress_details=course_progress_details,
progress_percent=lcg.progress_percent(course_progress_details))
# Support Methods for Both Course and Site-wide Aggregate Metrics
#
# Note the common theme in many of these methods in filtering on a date range
# Also note that some methods have two inner methods. One to retrieve raw data
# from the original model, the other to retrieve from the Figures metrics model
# The purpose of this is to be able to switch back and forth in development
# The metrics model may not be populated in devstack, but we want to exercize
# the code.
# Retrieving from the Figures metrics models should be much faster
#
# We may refactor these into a base class with the contructor params of
# start_date, end_date, site
# -----------------------
# Site metrics collectors
# -----------------------
#
# TODO: move these to `figures.metrics.site` module
#
def get_site_mau_history_metrics(site, months_back):
"""Quick adaptation of `get_monthly_history_metric` for site MAU
The `months_back` gets the previous N months back not including current
month because we do not capture the current month until it is over. Meaning
we wait until the next month to create a `SiteMonthlyMetrics` record for
that month's data
"""
history = []
# We will not have the current month's data because metrics are calculated
# after the month is over
for rec in SiteMonthlyMetrics.objects.filter(site=site).order_by('-month_for')[:months_back]:
period = '{year}/{month}'.format(year=rec.month_for.year,
month=str(rec.month_for.month).zfill(2))
history.append(dict(period=period, value=rec.active_user_count))
# Hack to set current month data in the history list
current_month_active = get_site_mau_current_month(site)
if history:
# reverse the list because it is currently in reverser chronological order
history.reverse()
current_month = datetime.datetime.utcnow().date()
period = '{year}/{month}'.format(year=current_month.year,
month=str(current_month.month).zfill(2))
history.append(dict(period=period, value=current_month_active))
return dict(current_month=current_month_active, history=history)
def get_site_mau_current_month(site):
"""Specific function to get the live active users for the current month
Developers note: We're starting with the simple aproach for MAU 1G, first
generation. When we update for MAU 2G, we will be able to make the query
more efficient by pulling unique users from a single table used for live
capture.
"""
month_for = datetime.datetime.utcnow()
site_sm = figures.sites.get_student_modules_for_site(site)
curr_sm = site_sm.filter(modified__year=month_for.year,
modified__month=month_for.month)
return curr_sm.values('student__id').distinct().count()
def get_active_users_for_time_period(site, start_date, end_date, course_ids=None):
"""
Returns the number of users active in the time period.
This is determined by finding the unique user ids for StudentModule records
modified in a time period
We don't do this only because it raises timezone warnings
modified__range=(as_date(start_date), as_date(end_date)),
"""
# Get list of learners for the site
user_ids = figures.sites.get_user_ids_for_site(site)
filter_args = dict(
modified__gt=as_datetime(prev_day(start_date)),
modified__lt=as_datetime(next_day(end_date)),
student_id__in=user_ids,
)
if course_ids:
filter_args['course_ids__in'] = course_ids
return StudentModule.objects.filter(
**filter_args).values('student__id').distinct().count()
def get_total_site_users_for_time_period(site, start_date, end_date, **kwargs):
"""
Returns the maximum number of users who joined before or on the end date
Even though we don't need the start_date, we follow the method signature
for the other metrics functions so we can use the same handler method,
``get_monthly_history_metric``
TODO: Consider first trying to get the data from the SiteDailyMetrics
model. If there are no records, then get the data from the User model
"""
def calc_from_user_model():
filter_args = dict(
date_joined__lt=as_datetime(next_day(end_date)),
)
users = figures.sites.get_users_for_site(site)
return users.filter(**filter_args).count()
def calc_from_site_daily_metrics():
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date))
qs = SiteDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(maxval=Max('total_user_count'))['maxval']
else:
return 0
if kwargs.get('calc_from_sdm'):
return calc_from_site_daily_metrics()
else:
return calc_from_user_model()
def get_total_site_users_joined_for_time_period(site, start_date, end_date,
course_ids=None): # pylint: disable=unused-argument
"""returns the number of new enrollments for the time period
NOTE: Untested and not yet used in the general site metrics, but we'll want to add it
"""
def calc_from_user_model():
filter_args = dict(
date_joined__gt=as_datetime(prev_day(start_date)),
date_joined__lt=as_datetime(next_day(end_date)),
)
users = figures.sites.get_users_for_site(site)
return users.filter(**filter_args).values('id').distinct().count()
# We don't yet have this info directly in SiteDailyMetrics
# We can calculate this for days after the initial day
# So we're going to defer implementing it for now
return calc_from_user_model()
def get_total_enrollments_for_time_period(site, start_date, end_date,
course_ids=None): # pylint: disable=unused-argument
"""Returns the maximum number of enrollments
This returns the count of unique enrollments, not unique learners
"""
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
)
qs = SiteDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(maxval=Max('total_enrollment_count'))['maxval']
else:
return 0
def get_total_site_courses_for_time_period(site, start_date, end_date, **kwargs):
"""
Potential fix:
get unique course ids from CourseEnrollment
"""
def calc_from_site_daily_metrics():
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
)
qs = SiteDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(maxval=Max('course_count'))['maxval']
else:
return 0
def calc_from_course_enrollments():
filter_args = dict(
created__gt=prev_day(start_date),
created__lt=next_day(end_date),
)
# First get all the course enrollments for the site
ce = figures.sites.get_course_enrollments_for_site(site)
# Then filter on the time period
return ce.filter(
**filter_args).values('course_id').distinct().count()
if kwargs.get('calc_raw'):
return calc_from_course_enrollments()
else:
return calc_from_site_daily_metrics()
def get_total_course_completions_for_time_period(site, start_date, end_date):
"""
This metric is not currently captured in SiteDailyMetrics, so retrieving from
course dailies instead
"""
def calc_from_course_daily_metrics():
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
)
qs = CourseDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(maxval=Max('num_learners_completed'))['maxval']
else:
return 0
return calc_from_course_daily_metrics()
# -------------------------
# Course metrics collectors
# -------------------------
#
# TODO: move these to `figures.metrics.course` module
#
# TODO: Consider moving these aggregate queries to the
# CourseDailyMetricsManager class (not yet created)
def get_course_enrolled_users_for_time_period(site, start_date, end_date, course_id):
"""
"""
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
course_id=course_id
)
qs = CourseDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(maxval=Max('enrollment_count'))['maxval']
else:
return 0
def get_course_average_progress_for_time_period(site, start_date, end_date, course_id):
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
course_id=course_id
)
qs = CourseDailyMetrics.objects.filter(**filter_args)
if qs:
value = qs.aggregate(average=Avg('average_progress'))['average']
return float(Decimal(value).quantize(Decimal('.00')))
else:
return 0.0
def get_course_average_days_to_complete_for_time_period(site, start_date, end_date, course_id):
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
course_id=course_id
)
qs = CourseDailyMetrics.objects.filter(**filter_args)
if qs:
return int(math.ceil(
qs.aggregate(average=Avg('average_days_to_complete'))['average']
))
else:
return 0
def get_course_num_learners_completed_for_time_period(site, start_date, end_date, course_id):
"""
We're duplicating some code.
"""
filter_args = dict(
site=site,
date_for__gt=prev_day(start_date),
date_for__lt=next_day(end_date),
course_id=course_id
)
qs = CourseDailyMetrics.objects.filter(**filter_args)
if qs:
return qs.aggregate(max=Max('num_learners_completed'))['max']
else:
return 0
def get_course_mau_history_metrics(site, course_id, date_for, months_back):
"""Quick copy/modification of 'get_monthly_history_metric' for Course MAU
"""
date_for = as_date(date_for)
history = []
for year, month, _ in previous_months_iterator(month_for=date_for,
months_back=months_back,):
period = '{year}/{month}'.format(year=year, month=str(month).zfill(2))
active_users = get_mau_from_site_course(site=site,
course_id=course_id,
year=year,
month=month)
history.append(dict(period=period, value=active_users.count(),))
if history:
# use the last entry
current_month = history[-1]['value']
else:
# This should work for float too since '0 == 0.0' resolves to True
current_month = 0
return dict(current_month=current_month, history=history)
def get_monthly_history_metric(func, site, date_for, months_back,
include_current_in_history=True): # pylint: disable=unused-argument
"""Convenience method to retrieve current and historic data
Convenience function to populate monthly metrics data with history. Purpose
is to provide a time series list of values for a particular metrics going
back N months
:param func: the function we call for each time point
:param date_for: The most recent date for which we generate data. This is
the "current month"
:param months_back: How many months back to retrieve data
:param include_current_in_history: flag to include the current month as well
as previous months
:type func: Python function
:type date_for: datetime.datetime, datetime.date, or date as a string
:type months_back: integer
:type include_current_in_history: boolean
:return: a dict with two keys. ``current_month`` contains the monthly
metrics for the month in ``date_for``. ``history`` contains a list of metrics
for the current period and perids going back ``months_back``
:rtype: dict
Each list item contains two keys, ``period``, containing the year and month
for the data and ``value`` containing the numeric value of the data
"""
date_for = as_date(date_for)
history = []
for month in previous_months_iterator(month_for=date_for, months_back=months_back,):
period = period_str(month)
value = func(
site=site,
start_date=datetime.date(month[0], month[1], 1),
end_date=datetime.date(month[0], month[1], month[2]),
)
history.append(dict(period=period, value=value,))
if history:
# use the last entry
current_month = history[-1]['value']
else:
# This should work for float too since '0 == 0.0' resolves to True
current_month = 0
return dict(
current_month=current_month,
history=history,)
def get_month_course_metrics(site, course_id, month_for, **_kwargs):
"""Returns a dict with the metrics for the given site, course, month
This function provides first generation metrics
Initially this function returns a partial set of the course monthly metrics:
* active users
* course enrollments
* number of learners completed
"""
# TODO: handle invalid "month_for" exception
# month, year = [int(val) for val in month_for.split('/')]
# start_date = datetime.date(year=year, month=month, day=1)
# end_date = datetime.date(year=year, month=month, day=days_in_month(start_date))
first_day, last_day = first_last_days_for_month(month_for)
params_dict = dict(site=site,
course_id=course_id,
start_date=first_day,
end_date=last_day)
active_users = get_mau_from_site_course(site=site,
course_id=course_id,
year=first_day.year,
month=first_day.month)
course_enrollments = get_course_enrolled_users_for_time_period(**params_dict)
num_learners_completed = get_course_num_learners_completed_for_time_period(**params_dict)
avg_days_to_complete = get_course_average_days_to_complete_for_time_period(**params_dict)
avg_progress = get_course_average_progress_for_time_period(**params_dict)
return dict(
course_id=course_id,
month_for=month_for,
active_users=active_users.count(),
course_enrollments=course_enrollments,
num_learners_completed=num_learners_completed,
avg_days_to_complete=avg_days_to_complete,
avg_progress=avg_progress,
)
def get_current_month_site_metrics(site, **_kwargs):
"""
TODO: put the metric names and functions in a dict and iterate. This then
will let up dynamically retrieve fields for the monthly metrics this function
returns
"""
date_for = datetime.datetime.utcnow().date()
start_date = datetime.date(year=date_for.year, month=date_for.month, day=1)
end_date = datetime.date(year=date_for.year,
month=date_for.month,
day=days_in_month(date_for))
active_users = get_active_users_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
registered_users = get_total_site_users_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
new_users = get_total_site_users_joined_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
site_courses = get_total_site_courses_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
course_enrollments = get_total_enrollments_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
course_completions = get_total_course_completions_for_time_period(site=site,
start_date=start_date,
end_date=end_date)
return dict(active_users=active_users,
registered_users=registered_users,
new_users=new_users,
site_courses=site_courses,
course_enrollments=course_enrollments,
course_completions=course_completions)
def get_monthly_site_metrics(site, date_for=None, **kwargs):
"""Gets current metrics with history
:param site: The site object for which to collect site metrics
:param date_for: The date for which to collect site metrics. Optional.
Defaults to current system date if not specified
:type site: django.contrib.sites.models.Site
:type date_for: datetime.datetime, datetime.date, or date as a string
:return: Site metrics for a a month ending on the ``date_for`` or "today"
if date_for is not specified
:rtype: dict
{
"monthly_active_users": {
"current_month": 1323,
"history": [
{
"period": "April 2018 (best to be some standardised Date format that I can parse)",
"value": 1022,
},
{
"period": "March 2018",
"value": 1022,
},
...
]
},
"total_site_users": {
// represents total number of registered users for org/site
"current": 4931,
"history": [
{
"period": "April 2018",
"value": 4899,
},
...
]
},
"total_site_courses": {
"current": 19,
"history": [
{
"period": "April 2018",
"value": 17,
},
...
]
},
"total_course_enrollments": {
// sum of number of users enrolled in all courses
"current": 7911,
"history": [
{
"period": "April 2018",
"value": 5911,
},
...
]
},
"total_course_completions": {
// number of times user has completed a course in this month
"current": 129,
"history": [
{
"period": "April 2018",
"value": 101,
},
...
]
}
}
"""
if date_for:
date_for = as_date(date_for)
else:
date_for = datetime.datetime.utcnow().date()
months_back = kwargs.get('months_back', 6) # Warning: magic number
##
# Brute force this for now. Later, refactor to define getters externally,
# and rely more on the serializers to stitch data together to respond
##
# Then, we can put the method calls into a dict, load the dict from
# settings, for example, or a Django model
# We are retrieving data here in series before constructing the return dict
# This makes it easier to inspect
monthly_active_users = get_monthly_history_metric(
func=get_active_users_for_time_period,
site=site,
date_for=date_for,
months_back=months_back,
)
total_site_users = get_monthly_history_metric(
func=get_total_site_users_for_time_period,
site=site,
date_for=date_for,
months_back=months_back,
)
total_site_courses = get_monthly_history_metric(
func=get_total_site_courses_for_time_period,
site=site,
date_for=date_for,
months_back=months_back,
)
total_course_enrollments = get_monthly_history_metric(
func=get_total_enrollments_for_time_period,
site=site,
date_for=date_for,
months_back=months_back,
)
total_course_completions = get_monthly_history_metric(
func=get_total_course_completions_for_time_period,
site=site,
date_for=date_for,
months_back=months_back,
)
return dict(
monthly_active_users=monthly_active_users,
total_site_users=total_site_users,
total_site_courses=total_site_courses,
total_course_enrollments=total_course_enrollments,
total_course_completions=total_course_completions,
)