Beispiel #1
0
 def __init__(self, instructorNuids = [], graderNuids = []):
     self.instructorNuids = instructorNuids
     self.graderNuids = graderNuids
     # 1. load full roster from canvas
     self.roster = roster
     # 2. get as many cse logins as possible
     # 2a. dump NUIDs to map
     nuids = [p.nuid for p in self.roster]
     nuidsToCseLogins = dict(zip(nuids, [None for x in nuids]))
     # 2b. update
     nuidsToCseLogins = udb.mapNuidsToCseLogins(nuidsToCseLogins,config.nuidToCseLoginPickle)
     # 2c. update roster instances
     for p in self.roster:
         if p.nuid in nuidsToCseLogins and nuidsToCseLogins[p.nuid] is not None:
             p.cseLogin = nuidsToCseLogins[p.nuid]
             p.cseEmail = p.cseLogin + "@cse.unl.edu"
             
     #3. filter into the appropriate group
     #   This is done manually as the "role" is not available from canvas 
     #   using the canvas API and we want more fine-grained control anyway
     #   - If there is no cse login, they are ignored
     #   - Otherwise, they are either a student XOR instructor/grader
     #     - instructors can be graders
     for p in self.roster:
         if p.cseLogin is None:
             self.orphans[p.nuid] = p
         else:
             if p.nuid in instructorNuids or p.nuid in graderNuids:
                 if p.nuid in instructorNuids: 
                     self.instructors[p.nuid] = p
                 if p.nuid in graderNuids: 
                     self.graders[p.nuid] = p
             else:
                 self.students[p.nuid] = p
 def __init__(self, instructorNuids = [], graderNuids = []):
     self.instructorNuids = instructorNuids
     self.graderNuids = graderNuids
     # 1a. load full roster from canvas
     self.roster = roster
     # 2. get as many cse logins as possible
     # 2a. dump NUIDs to map
     nuids = [p.nuid for p in self.roster]
     nuidsToCseLogins = dict(zip(nuids, [None for x in nuids]))
     # 2b. update
     nuidsToCseLogins = udb.mapNuidsToCseLogins(nuidsToCseLogins,config.nuidToCseLoginPickle)
     # 2c. update roster instances
     for p in self.roster:
         if p.nuid in nuidsToCseLogins and nuidsToCseLogins[p.nuid] is not None:
             p.cseLogin = nuidsToCseLogins[p.nuid]
             
     #3. filter into the appropriate group
     #   This is done manually as the "role" is not available from canvas 
     #   using the canvas API and we want more fine-grained control anyway
     #   - If there is no cse login, they are ignored
     #   - Otherwise, they are either a student XOR instructor/grader
     #     - instructors can be graders
     for p in self.roster:
         if p.cseLogin is None:
             self.orphans[p.nuid] = p
         else:
             if p.nuid in instructorNuids or p.nuid in graderNuids:
                 if p.nuid in instructorNuids: 
                     self.instructors[p.nuid] = p
                 if p.nuid in graderNuids: 
                     self.graders[p.nuid] = p
             else:
                 self.students[p.nuid] = p
     #4. Update the groups so that every student is in a group
     #   For those in a canvas group of 2 or more or in their
     #   own "group of one"
     #   self.groups data model:
     #   [(groupId, 'Group Name', [canvasIds])]
     canvasGroups = groups
     self.groups = []
     for group in canvasGroups:
         #canvasGroupId, canvasGroupname
         g = Group(group[0], group[1])
         members = []
         for memberCanvasId in group[2]:
             for p in self.roster:
                 if p.canvasId == memberCanvasId:
                     members.append(p)
                     p.group = g;
                     break
         g.addMembers(members)
         self.groups.append(g)
     # iterate through students and create "group of one"
     for nuid,s in self.students.items():
         if s.group is None:
             g = Group()
             g.addMembers([s])
             s.group = g 
             self.groups.append(g)
    def __init__(self, instructorNuids=[], graderNuids=[]):
        self.instructorNuids = instructorNuids
        self.graderNuids = graderNuids
        # 1. load full roster from canvas
        # {NUID => Person}
        self.roster = roster
        # 2. get as many cse logins as possible
        # 2a. dump NUIDs to map
        nuids = self.roster.keys()
        nuidsToCseLogins = dict(zip(nuids, [None for x in nuids]))
        # 2b. update from UDB
        nuidsToCseLogins = udb.mapNuidsToCseLogins(nuidsToCseLogins,
                                                   config.nuidToCseLoginPickle)
        # 2c. update cse logins for all roster instances
        for nuid, p in self.roster.items():
            if nuid in nuidsToCseLogins and nuidsToCseLogins[nuid] is not None:
                p.cseLogin = nuidsToCseLogins[nuid]

        #3. filter into the appropriate group
        #   This is done manually as the "role" is not available from canvas
        #   using the canvas API and we want more fine-grained control anyway
        #   - If there is no cse login, they are "orphaned"
        #   - Otherwise, they are either a student XOR instructor/grader
        #     - instructors can be graders
        for nuid, p in self.roster.items():
            if p.cseLogin is None:
                self.orphans[nuid] = p
            else:
                if nuid in instructorNuids or nuid in graderNuids:
                    if nuid in instructorNuids:
                        self.instructors[nuid] = p
                    if nuid in graderNuids:
                        self.graders[nuid] = p
                else:
                    self.students[nuid] = p
        # update groups to exclude instructors and graders [Group]
        self.groups = []
        # for each group in canvas.groups:
        for g in groups:
            # if the group leader (first listed) is a student, then add them
            if g.members[0].nuid in self.students:
                self.groups.append(g)