def getBonusState(self): # Connecte with the database. self.db = Database.DatabaseOperations() # Get the bonus state. self.state = self.db.getLeaderInfo(self.userID, self.teamID)[0][3] # Disconnect with the database. self.db.__del__() # Return the state. return self.state
def setBonusState(self, teampBonus): # Connecte with the database. self.db = Database.DatabaseOperations() # Set the bonus state. self.result = self.db.setTempBonus(self.userID, self.teamID, teampBonus) # Disconnect with the database. self.db.__del__() # Return the result. return self.result
def __init__(self, userID, teamID): # Set the super class constructor. super(Leader, self).__init__(userID, teamID) # Get the member variables. self.teamID = teamID # Connecte with the database. self.db = Database.DatabaseOperations() # Get the bonus. self.bonus = self.db.getLeaderInfo(userID, teamID)[0][2] # Disconnect with the database. self.db.__del__()
def __init__(self, userID, teamID): # Set the super class constructor. super(Member, self).__init__(userID) # Get the member variables. self.teamID = teamID # Connecte with the database. self.db = Database.DatabaseOperations() # Get the contribution. self.contribution = self.db.getMemberInfo(userID, teamID)[0][3] # Disconnect with the database. self.db.__del__()
def calculateContribution(self, contribution): # Connecte with the database. self.db = Database.DatabaseOperations() result = self.db.calculateContribution(self.userID, self.teamID, contribution) # Check whether the save successful or not. if result: # If yes. # Disconnect with the database. self.db.__del__() return "Modify Successful!", True else: # Disconnect with the database. self.db.__del__() return "Database Error!", False
def calculateBonus(self): # Get the temp bonus. self.tempBonus = eval(self.getBonusState()) # Update the bonus. self.bonus = sum(self.tempBonus.values()) / len(self.tempBonus) # Connecte with the database. self.db = Database.DatabaseOperations() result = self.db.setLeaderBonus(self.userID, self.teamID, self.bonus) # Test whether the update is successful. if result: # Disconnect with the database. self.db.__del__() return "Assess Successful!", True else: # Disconnect with the database. self.db.__del__() return "Database Error!", False
def __init__(self, userID): # Connecte with the database. self.db = Database.DatabaseOperations() # Get the student info. self.info = self.db.getStudentInfo(userID) # Set the super class constructor. super(Student, self).__init__(self.info[0][1], self.info[0][2], self.info[0][3], self.info[0][0], self.info[0][4], self.info[0][5], self.info[0][6]) # Set the member variables. self.GPA = self.info[0][7] # Clear the list. self.courseList = [] # Get the course from the database. self.temp = self.db.getCourseListForStudent(self.userID) for courseName in self.temp: self.courseList.append(courseName[0]) # Disconnect with the database. self.db.__del__()
def setPassword(self, password): # Check whether the password is valid. if re.match(r'^[0-9A-Za-z]{6,16}$', password, 0): if self.password != password: self.password = password # Connecte with the database. self.db = Database.DatabaseOperations() # Change the password. result = self.db.modifyPasswordForStudent( self.getID(), password) # Test whether the modify successful or not. if result: # If success. # Disconnect with the database. self.db.__del__() return "Modify Successful!", True else: # If fail. # Disconnect with the database. self.db.__del__() return "Database Error", False else: return "The password is the same as before.", False else: return "The password should only be numbers and letters and the length is between 8 and 16 symbols.", False