Beispiel #1
0
 def createStudent(self, studentId, msg):
     logInfo('{0} could not find student with id: {1} in database.  Creating new student'.format(self.serviceName, studentId), 3)
     studentUUID = str(uuid4())
     student = DBStudent(id=studentUUID, studentId=studentId, sessionIds=[], oAuthIds={}, studentModelIds={}, kcGoals={})
     student.save()
     self.studentCache[studentId] = student
     newStudentAlias = DBStudentAlias(trueId=studentUUID, alias=studentId)
     newStudentAlias.save()
     return student
 def createNewStudentModel(self, studentId):
     #DBStudentAlias List
     studentsWithId = DBStudentAlias.find_by_index("AliasIndex", studentId)
     
     if len(studentsWithId) == 0:
         logInfo('failed to find student alias {0}'.format(studentId), 1)
         student = self.createStudent(studentId, None)
         return WeightedStudentModelFactory().buildStudentModel(student)
     
     for studentAlias in studentsWithId:
         student = DBStudent.find_one(studentAlias.trueId)
         
         if student is None:
             logInfo('failed to find student with Id: {0} and alias {1}'.format(studentAlias.trueId, studentAlias.alias), 1)
             student = self.createStudent(studentId, None)
             return WeightedStudentModelFactory().buildStudentModel(student)
         else:
             return WeightedStudentModelFactory().buildStudentModel(student)
Beispiel #3
0
    def createNewStudentModel(self, studentId):
        #DBStudentAlias List
        studentsWithId = DBStudentAlias.find_by_index("AliasIndex", studentId)

        if len(studentsWithId) == 0:
            logInfo('failed to find student alias {0}'.format(studentId), 1)
            student = self.createStudent(studentId, None)
            return WeightedStudentModelFactory().buildStudentModel(student)

        for studentAlias in studentsWithId:
            student = DBStudent.find_one(studentAlias.trueId)

            if student is None:
                logInfo(
                    'failed to find student with Id: {0} and alias {1}'.format(
                        studentAlias.trueId, studentAlias.alias), 1)
                student = self.createStudent(studentId, None)
                return WeightedStudentModelFactory().buildStudentModel(student)
            else:
                return WeightedStudentModelFactory().buildStudentModel(student)
Beispiel #4
0
 def retrieveStudentFromCacheOrDB(self, studentId, msg, useCache=True):
     logInfo("Entering retrieveStudentFromCacheOrDB", 5)
     student = self.studentCache.get(studentId)
     if student is not None and useCache:
         logInfo('{0} found student object with id:{1}'.format(self.serviceName, studentId), 4)
         return student
     else:
         logInfo('{0} could not find cached student object with id: {1}.  Falling back to database.'.format(self.serviceName, studentId), 3)
         studentAliasList = DBStudentAlias.find_by_index("AliasIndex", studentId)
         
         if len(studentAliasList) > 0:
             #there should only be one object returned, should put it a log statement if that isn't correct.
             for studentAlias in studentAliasList:
                 student = studentAlias.getStudent()
                 
         if student is None:
             student = self.createStudent(studentId, msg)
         #Cache the result so we don't need to worry about looking it up again.
         self.studentCache[studentId] = student
         return student