예제 #1
0
def processCerts(direct):
    """
    Construct a dictionary of certificate recipients for a course,
    given the directory of the certificates.csv file

    Parameters
    -----------
    direct: A string corresponding to the directory of the certificates.csv
    """

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

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

    return certDict
예제 #2
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. This
was used for basic sanity testing on the invariant that if a user received a certificate, he or she
should also be in the users file. There are odd cases where this may not be the case, caused by the
habit of the edX group to delete a user (which may have been changed, we have asked for this), but
if there are large numbers (order 10s) then something is probably wrong.
'''
import csv
from classData import certificates, user

if __name__ == '__main__':
    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])
예제 #3
0
    wk1 = sys.argv[2]
    wk2 = sys.argv[3]
    week1 = wk1 + '/' + ck_course
    week2 = wk2 + '/' + ck_course
    userFile = '/users.csv'
    certFile = '/certificates.csv'
    enroll = '/enrollment.csv'
    uf1 = csv.reader(open(week2 + userFile, 'r'))
    uf2 = csv.reader(open(week1 + userFile, 'r'))
    cf1 = csv.reader(open(week2 + certFile, 'r'))
    cf2 = csv.reader(open(week1 + certFile, 'r'))
    ef1 = csv.reader(open(week2 + enroll, 'r'))
    ef2 = csv.reader(open(week1 + 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'

    outfile = csv.writer(open('userDiff06020616' + ck_course + '.csv', 'w'))
    outfile.writerow(['Users in ' + wk1 + ' list but not in ' + wk2 + ' list'])
예제 #4
0
#!/usr/bin/env python
"""
A simple interactive program to compare the ids in a file with those in a 
certificates file

This program will prompt the user for the name of a csv file containing
only user ids, and a csv of a certificates file, and see if there are any 
ids in the first file that correspond to entries in the certificates file.
"""

import csv
import sys
from classData import certificates
import utils

if __name__ == '__main__':
    if len(sys.argv) > 2:
        f1name = sys.argv[1]
        f2name = sys.argv[2]
    else:
        f1name = utils.getFileName('Enter csv file with ids : ')
        f2name = utils.getFileName('Enter certificates csv file name : ')
    f1 = csv.reader(open(f1name, 'r'))
    f2 = csv.reader(open(f2name, 'r'))
    certdict = certificates.builddict(f2)
    f1.readrow()
    for [ident] in f1:
        if ident in certdict:
            print 'found new identifier ' + ident + ' in certificates file'
예제 #5
0
'''

import csv
import sys
from classData import certificates, user

if __name__ == '__main__':
    f1 = csv.reader(open(sys.argv[1], 'r'))
    f2 = csv.reader(open(sys.argv[2], 'r'))
    f3 = csv.writer(open('additions.csv', 'w'))
    f4 = csv.reader(open('certificates.csv', 'r'))
    f3.writerow(['id', 'in certificate file'])
    f3.writerow(['User ids in first file, not in second'])
    u1 = user.builddict(f1)
    u2 = user.builddict(f2)
    cdict = certificates.builddict(f4)
    for key in u1.iterkeys():
        if u1[key].id not in u2:
            if key in cdict:
                f3.writerow([key, 'Yes'])
            else:
                f3.writerow([key, 'No'])

    f3.writerow(['User ids in second file, not in first'])
    for key in u2.iterkeys():
        if u2[key].id not in u1:
            if key in cdict:
                f3.writerow([key, 'Yes'])
            else:
                f3.writerow([key, 'No'])
예제 #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 = ''
        
예제 #7
0
 wk1 = sys.argv[2]
 wk2 = sys.argv[3]
 week1 = wk1 + '/' + ck_course
 week2 = wk2 + '/' + ck_course
 userFile = '/users.csv'
 certFile = '/certificates.csv'
 enroll = '/enrollment.csv'
 uf1 = csv.reader(open(week2 + userFile, 'r'))
 uf2 = csv.reader(open(week1 + userFile, 'r'))
 cf1 = csv.reader(open(week2 + certFile, 'r'))
 cf2 = csv.reader(open(week1 + certFile, 'r'))
 ef1 = csv.reader(open(week2 + enroll, 'r'))
 ef2 = csv.reader(open(week1 + 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'
 
 outfile = csv.writer(open('userDiff06020616' + ck_course + '.csv', 'w'))
 outfile.writerow(['Users in ' + wk1 + ' list but not in ' + wk2 + ' list'])
예제 #8
0
A simple interactive program to compare the ids in a file with those in a 
certificates file

This program will prompt the user for the name of a csv file containing
only user ids, and a csv of a certificates file, and see if there are any 
ids in the first file that correspond to entries in the certificates file.
"""


import csv
import sys
from classData import certificates
import utils

if __name__ == '__main__':
    if len(sys.argv) > 2:
        f1name = sys.argv[1]
        f2name = sys.argv[2]
    else:
        f1name = utils.getFileName('Enter csv file with ids : ')
        f2name = utils.getFileName('Enter certificates csv file name : ')
    f1 = csv.reader(open(f1name, 'r'))
    f2 = csv.reader(open(f2name, 'r'))
    certdict = certificates.builddict(f2)
    f1.readrow()
    for [ident] in f1:
        if ident in certdict:
            print 'found new identifier ' + ident + ' in certificates file'

    
예제 #9
0
'''

import csv
import sys
from classData import certificates, user

if __name__ == '__main__':
    f1 = csv.reader(open(sys.argv[1], 'r'))
    f2 = csv.reader(open(sys.argv[2], 'r'))
    f3 = csv.writer(open('additions.csv', 'w'))
    f4 = csv.reader(open('certificates.csv', 'r'))
    f3.writerow(['id', 'in certificate file'])
    f3.writerow(['User ids in first file, not in second'])
    u1 = user.builddict(f1)
    u2 = user.builddict(f2)
    cdict = certificates.builddict(f4)
    for key in u1.iterkeys():
        if u1[key].id not in u2:
            if key in cdict:
                f3.writerow([key, 'Yes'])
            else:
                f3.writerow([key, 'No'])
    
    f3.writerow(['User ids in second file, not in first'])
    for key in u2.iterkeys():
        if u2[key].id not in u1:
            if key in cdict:
                f3.writerow([key, 'Yes'])
            else:
                f3.writerow([key, 'No'])