Commit 263cf647 by Han Su Kim

Added totals for different student tracks

sorted the output, easier to read

Add is_active filter to only generate for students enrolled

Adding back total_enrollment

Removing active filter

Certs will generate for all users in the course, not just those "active"

Typo

Renaming headings to make more sense

Renaming variables to match headings
parent 00fb23d5
......@@ -61,11 +61,23 @@ class Command(BaseCommand):
# find students who are active
# enrolled students are always downloable + notpassing
print "Looking up certificate states for {0}".format(course_id)
active_students = User.objects.filter(
enrolled_current = User.objects.filter(
courseenrollment__course_id=course_id,
courseenrollment__is_active=True)
cert_data[course_id] = {'active': active_students.count()}
enrolled_total = User.objects.filter(
courseenrollment__course_id=course_id)
verified_enrolled = GeneratedCertificate.objects.filter(
course_id__exact=course_id, mode__exact='verified')
honor_enrolled = GeneratedCertificate.objects.filter(
course_id__exact=course_id, mode__exact='honor')
audit_enrolled = GeneratedCertificate.objects.filter(
course_id__exact=course_id, mode__exact='audit')
cert_data[course_id] = {'enrolled_current': enrolled_current.count(),
'enrolled_total': enrolled_total.count(),
'verified_enrolled': verified_enrolled.count(),
'honor_enrolled': honor_enrolled.count(),
'audit_enrolled': audit_enrolled.count()}
status_tally = GeneratedCertificate.objects.filter(
course_id__exact=course_id).values('status').annotate(
......@@ -83,21 +95,21 @@ class Command(BaseCommand):
for mode in mode_tally})
# all states we have seen far all courses
status_headings = set(
status_headings = sorted(set(
[status for course in cert_data
for status in cert_data[course]])
for status in cert_data[course]]))
# print the heading for the report
print "{:>20}".format("course ID"),
print ' '.join(["{:>12}".format(heading)
print "{:>26}".format("course ID"),
print ' '.join(["{:>16}".format(heading)
for heading in status_headings])
# print the report
for course_id in cert_data:
print "{0:>20}".format(course_id[0:18]),
print "{0:>26}".format(course_id[0:24]),
for heading in status_headings:
if heading in cert_data[course_id]:
print "{:>12}".format(cert_data[course_id][heading]),
print "{:>16}".format(cert_data[course_id][heading]),
else:
print " " * 12,
print " " * 16,
print
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment