Пример #1
0
def processCerts(dir):
    '''
    Construct a dictionary of certificate recipients for a course,
    given the directory of the certificates.csv file

    Parameters
    -----------
    dir: A string corresponding to the directory of the certificates.csv
    '''

    try:
        f = open(dir + "/certificates.csv", 'r')
    except IOError:
        return None

    infile = csv.reader(f)
    certDict = certificates.builddict(infile)

    return certDict
Пример #2
0
def processCerts(dir):
    '''
    Construct a dictionary of certificate recipients for a course,
    given the directory of the certificates.csv file

    Parameters
    -----------
    dir: A string corresponding to the directory of the certificates.csv
    '''

    try:
        f = open(dir+"/certificates.csv", 'r')
    except IOError:
        return None

    infile = csv.reader(f)
    certDict = certificates.builddict(infile)

    return certDict
Пример #3
0
dump2 = 'harvardx-2013-06-16'
dump1 = 'harvardx-2013-06-02'
userFile = '/' + ck_course + '/users.csv'
certFile = '/' + ck_course + '/certificates.csv'
enroll = '/' + ck_course + '/enrollment.csv'
uf1 = csv.reader(open(dump1 + userFile, 'r'))
uf2 = csv.reader(open(dump2 + userFile, 'r'))
cf1 = csv.reader(open(dump1 + certFile, 'r'))
cf2 = csv.reader(open(dump2 + certFile, 'r'))
ef1 = csv.reader(open(dump1 + enroll, 'r'))
ef2 = csv.reader(open(dump2 + enroll, 'r'))

u1dict = user.builddict(uf1)
u2dict = user.builddict(uf2)
c1dict = certificates.builddict(cf1)
c2dict = certificates.builddict(cf2)
e1dict = course_enrollment.builddict(ef1)
e2dict = course_enrollment.builddict(ef2)

OneNotTwo = compareUsers(u1dict, u2dict)
TwoNotOne = compareUsers(u2dict, u1dict)

for u in iter(OneNotTwo):
    if u in c1dict and c1dict[u].status =='downloadable':
        OneNotTwo[u] = 'y'

for u in iter(TwoNotOne):
    if u in c2dict and c2dict[u].status == 'downloadable':
        TwoNotOne[u] = 'y'
Пример #4
0
#!/usr/bin/env python

import user
import certificates
import os
import csv


def getFileName(prompt):
    while (True):
        fname = raw_input("Please enter file name for " + prompt + ' : ')
        if os.path.exists(fname):
            return fname
        else:
            print("file entered does not exist, please retry")


if __name__ == '__main__':
    f1name = getFileName('Enter name of the user file')
    f1 = csv.reader(open(f1name, 'r'))
    f2name = getFileName('Enter the name of the certificates file')
    f2 = csv.reader(open(f2name, 'r'))
    udict = user.builddict(f1)
    cdict = certificates.builddict(f2)
    out1 = open('allmail', 'w')
    out2 = open('certMail', 'w')
    for u in iter(udict):
        out1.write(udict[u].email + '\n')
        if u in cdict:
            out2.write(udict[u].email + '\n')
Пример #5
0
#!/usr/bin/env python

import user
import certificates
import os
import csv


def getFileName(prompt):
    while True:
        fname = raw_input("Please enter file name for " + prompt + " : ")
        if os.path.exists(fname):
            return fname
        else:
            print("file entered does not exist, please retry")


if __name__ == "__main__":
    f1name = getFileName("Enter name of the user file")
    f1 = csv.reader(open(f1name, "r"))
    f2name = getFileName("Enter the name of the certificates file")
    f2 = csv.reader(open(f2name, "r"))
    udict = user.builddict(f1)
    cdict = certificates.builddict(f2)
    out1 = open("allmail", "w")
    out2 = open("certMail", "w")
    for u in iter(udict):
        out1.write(udict[u].email + "\n")
        if u in cdict:
            out2.write(udict[u].email + "\n")
Пример #6
0
out_name = sys.argv[1] + 'anonProfile.csv'
o1 = csv.writer(open(out_name, 'w'))

ufile = csv.reader(open(sys.argv[2], 'r'))
uprof = prof.builddict(ufile)

udfile = csv.reader(open(sys.argv[3], 'r'))
udict = user.builddict(udfile)

countryFile = csv.reader(open(sys.argv[4], 'r'))
locDict = geo.builddict(countryFile)

certs = False
if (len(sys.argv) > 5):
    certfile = csv.reader(open(sys.argv[5], 'r'))
    certDict = cs.builddict(certfile)
    certs = True

students = uprof.keys()
for s in students:
    p = uprof[s]
    if (s in udict):
        usrName = udict[s].username
        if (usrName in locDict):
            loc = locDict[usrName]
        else:
            loc = ''
    else:
        loc = ''

    if (certs):
Пример #7
0
dump2 = 'harvardx-2013-06-16'
dump1 = 'harvardx-2013-06-02'
userFile = '/' + ck_course + '/users.csv'
certFile = '/' + ck_course + '/certificates.csv'
enroll = '/' + ck_course + '/enrollment.csv'
uf1 = csv.reader(open(dump1 + userFile, 'r'))
uf2 = csv.reader(open(dump2 + userFile, 'r'))
cf1 = csv.reader(open(dump1 + certFile, 'r'))
cf2 = csv.reader(open(dump2 + certFile, 'r'))
ef1 = csv.reader(open(dump1 + enroll, 'r'))
ef2 = csv.reader(open(dump2 + enroll, 'r'))

u1dict = user.builddict(uf1)
u2dict = user.builddict(uf2)
c1dict = certificates.builddict(cf1)
c2dict = certificates.builddict(cf2)
e1dict = course_enrollment.builddict(ef1)
e2dict = course_enrollment.builddict(ef2)

OneNotTwo = compareUsers(u1dict, u2dict)
TwoNotOne = compareUsers(u2dict, u1dict)

for u in iter(OneNotTwo):
    if u in c1dict and c1dict[u].status == 'downloadable':
        OneNotTwo[u] = 'y'

for u in iter(TwoNotOne):
    if u in c2dict and c2dict[u].status == 'downloadable':
        TwoNotOne[u] = 'y'
Пример #8
0
out_name = sys.argv[1] + 'anonProfile.csv'
o1 = csv.writer(open(out_name, 'w'))

ufile = csv.reader(open(sys.argv[2], 'r'))
uprof = prof.builddict(ufile)

udfile = csv.reader(open(sys.argv[3], 'r'))
udict = user.builddict(udfile)

countryFile = csv.reader(open(sys.argv[4], 'r'))
locDict = geo.builddict(countryFile)

certs = False
if (len(sys.argv) > 5):
    certfile = csv.reader(open(sys.argv[5], 'r'))
    certDict = cs.builddict(certfile)
    certs = True
    

students = uprof.keys()
for s in students:
    p = uprof[s]
    if (s in udict):
        usrName = udict[s].username
        if (usrName in locDict):
            loc = locDict[usrName]
        else:
            loc = ''
    else:
        loc = ''
        
Пример #9
0
the total number of students, the number who were awarded a certificate,
those that did not receive a certificate, and those that are restricted 
from receiving a certificate (because of being in an embargoed country)
Created on Feb 20, 2013

@author: waldo
"""

import certificates
import csv
import sys

if __name__ == '__main__':
    infile = csv.reader(open(sys.argv[1], 'r'))
    infile.next()
    certDict = certificates.builddict(infile)
    passed = unfinished = restrict = total = unknown = 0
    citer = iter(certDict)
    for c in citer:
        if certDict[c].status == "downloadable":
            passed += 1
        elif certDict[c].status == 'notpassing':
            unfinished += 1
        elif certDict[c].status == 'restricted':
            restrict += 1
        else:
            print certDict[c].status
            unknown += 1
        total += 1
    
    print "Total records = " + str(total)
Пример #10
0
the total number of students, the number who were awarded a certificate,
those that did not receive a certificate, and those that are restricted 
from receiving a certificate (because of being in an embargoed country)
Created on Feb 20, 2013

@author: waldo
"""

import certificates
import csv
import sys

if __name__ == '__main__':
    infile = csv.reader(open(sys.argv[1], 'r'))
    infile.next()
    certDict = certificates.builddict(infile)
    passed = unfinished = restrict = total = unknown = 0
    citer = iter(certDict)
    for c in citer:
        if certDict[c].status == "downloadable":
            passed += 1
        elif certDict[c].status == 'notpassing':
            unfinished += 1
        elif certDict[c].status == 'restricted':
            restrict += 1
        else:
            print certDict[c].status
            unknown += 1
        total += 1

    print "Total records = " + str(total)
Пример #11
0
#!/usr/bin/env python
'''
Looks for differences between the user listed in the users file and those in the certificates file

In particular, looks for any users not found in the users file who have received a certificate.
'''
import csv
import certificates
import user

ufile = csv.reader(open('users.csv', 'r'))
udict = user.builddict(ufile)
cfile = csv.reader(open('certificates.csv', 'r'))
cDict = certificates.builddict(cfile)

certsMissing = []

for c in iter(cDict):
    if (cDict[c].status == 'downloadable') and (c not in udict):
        certsMissing.append(c)

if len(certsMissing) > 0:
    print 'found ' + str(
        len(certsMissing)) + ' certificates with no associated user'
    outfile = csv.writer(open('certsAndusers.csv', 'w'))
    outfile.writerow(['Missing user ids that have certificates'])
    for u in certsMissing:
        outfile.writerow([u])
Пример #12
0
#!/usr/bin/env python

'''
Looks for differences between the user listed in the users file and those in the certificates file

In particular, looks for any users not found in the users file who have received a certificate.
'''
import csv
import certificates
import user

ufile = csv.reader(open('users.csv', 'r'))
udict = user.builddict(ufile)
cfile = csv.reader(open('certificates.csv', 'r'))
cDict = certificates.builddict(cfile)

certsMissing = []

for c in iter(cDict):
    if (cDict[c].status == 'downloadable') and (c not in udict):
        certsMissing.append(c)

if len(certsMissing) > 0:
    print 'found ' + str(len(certsMissing)) + ' certificates with no associated user'
    outfile = csv.writer(open('certsAndusers.csv', 'w'))
    outfile.writerow(['Missing user ids that have certificates'])
    for u in certsMissing:
        outfile.writerow([u])