@@ -0,0 +1,932 @@
+'''%0AThis module extracts the student IDs from the collection certificates_generatedcertificate%0Aof the students who completed the course and achieved a certificate. The ids%0Aare then used to extract the usernames of the course completers%0A%0AUsage:%0A%0Apython course_completers.py%0A%0A'''%0A%0Afrom collections import defaultdict%0A%0Afrom base_edx import EdXConnection%0Afrom generate_csv_report import CSV%0A%0Aconnection = EdXConnection('certificates_generatedcertificate', 'auth_user')%0Acollection = connection.get_access_to_collection()%0A%0Acompleters = collection%5B'certificates_generatedcertificate'%5D.find(%7B'status' : 'downloadable'%7D)%0A%0Aresult = %5B%5D%0Afor document in completers:%0A    user_document = collection%5B'auth_user'%5D.find_one(%7B%22id%22 : document%5B'user_id'%5D%7D)%0A    result.append(%5Buser_document%5B'username'%5D, document%5B'name'%5D, document%5B'grade'%5D%5D)%0A%0Aoutput = CSV(result, %5B'Username', 'Name', 'Grade'%5D, output_file='course_completers.csv')%0Aoutput.generate_csv()%0A

Add course_completers.py to extract course completers