def main():

    file_name = "test_members.txt"

    # Test students.
    alice = Student("*****@*****.**", "AI", previous_partners=[""])
    bob = Student("*****@*****.**", "PL", previous_partners=[""])
    charlie = Student("*****@*****.**", "Sys", previous_partners=[""])
    dan = Student("*****@*****.**", "Theory", previous_partners=[""])
    students = [alice, bob, charlie, dan]

    # Save.
    save_students(students, file_name=file_name)

    # Load.
    student_list = load_existing_students(file_name=file_name)

    # Make new pairs.
    pairs, updated_student_list = make_new_pairs(student_list)

    # Save new list.
    save_students(updated_student_list, file_name=file_name)

    # Show pairings.
    print
    for k in pairs.keys():
        print k.get_name(), pairs[k].get_name()
    def testStudentRepo_statistics_students_best_situation(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")

        self._grades.add_grade(87, 56, 10)  #2
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120, 4)  #1
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.students_best_situation()
        result2 = []
        result2.append(Student(120, "Alex Cerg"))
        result2.append(Student(56, "Hill Nina"))

        self.assertEqual(result[0].studentId, result2[0].studentId)
        self.assertEqual(result[0].studentName, result2[0].studentName)

        self.assertEqual(result[1].studentId, result2[1].studentId)
        self.assertEqual(result[1].studentName, result2[1].studentName)
 def getStudentsInGroup(self, canvas_group_object):
     users = canvas_group_object.get_users()
     students = []
     for user in users:
         student = Student(user)
         student.setStudentGroup(self.ID)
         students.append(student)
         # print("Got student '", student.getName(), "' from group '", self.getName(), "'", sep='')
     return students
    def update_student(self, stud_id, new_stud_name):

        try:
            stud_id = int(stud_id)
        except ValueError:
            "Not int"

        if stud_id == None:
            raise NoneException("Id is none")
        if stud_id < 0:
            raise NegativeException("Id is negative")
        ok = False
        for stud in self._studentRepo.getAll():
            if stud.studentId == stud_id:
                ok = True
        if ok == False:
            raise NonexistentException("Nonexistent Id")
        if new_stud_name == None:
            raise NoneException("Name is none")

        old_stud = self._studentRepo.getStudentById(stud_id)
        new_stud = Student(stud_id, new_stud_name)

        self._studentRepo.update_student(new_stud)

        redo = FunctionCall(self.update_student, stud_id, new_stud_name)
        undo = FunctionCall(self.update_student, stud_id, old_stud.studentName)

        op = Operation(undo, redo)
        self._undoController.recordOperation(op)

        return new_stud
 def testStudentRepo_addStudent(self):
     self._students = StudentRepo()
     self._students.add_student(56, "Hill Nina")
     stud = self._students.getStudentById(56)
     stud2 = Student(56, "Hill Nina")
     self.assertEqual(stud.studentId, stud2.studentId)
     self.assertEqual(stud.studentName, stud2.studentName)
    def students_failing(self):
        result = []

        for stud in self._studentService.getAll():
            studDict = {}
            for dis in self._disciplineService.getAll():
                studDict[dis.disciplineId] = 0

            for grade in self._gradeService.getAll():
                if grade.studentId == stud.studentId:
                    if not (studDict[grade.disciplineId] == 0):
                        studDict[grade.disciplineId] = (
                            studDict[grade.disciplineId] +
                            grade.gradeValue) / 2
                    else:
                        studDict[grade.disciplineId] = grade.gradeValue
            fail = False
            #for clientId, daysRented in statsDict.items():
            #result.append(ClientStatistics(clientId, daysRented))
            for j in studDict.keys():
                if studDict[j] < 5 and not (studDict[j] == 0):
                    fail = True

            if fail == True:
                result.append(Student(stud.studentId, stud.studentName))

        return result
 def testStudentRepo_updateStudent(self):
     self._students = StudentRepo()
     self._students.add_student(23, "Kinder Sah")
     self._students.update_student(23, "Joy")
     stud = Student(23, "Joy")
     stud2 = self._students.getStudentById(23)
     self.assertEqual(stud.studentId, stud2.studentId)
     self.assertEqual(stud.studentName, stud2.studentName)
    def testStudentRepo_search_student_name(self):
        self.studentRepo = StudentRepo()
        self._students = StudentService(self.studentRepo)
        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        matches = []
        matches = self._students.search_student_name("h")
        matches2 = []
        matches2.append(Student(56, "Hill Nina"))
        matches2.append((Student(90, "Hol Guara")))

        self.assertEqual(matches[0].studentId, matches2[0].studentId)
        self.assertEqual(matches[0].studentName, matches2[0].studentName)

        self.assertEqual(matches[1].studentId, matches2[1].studentId)
        self.assertEqual(matches[1].studentName, matches2[1].studentName)
    def add_student(self, stud_id, stud_name):

        try:
            stud_id = int(stud_id)
        except IntException:
            "Id not integer"

        stud = Student(stud_id, stud_name)
        self._studentRepo.add_student(stud)

        redo = FunctionCall(self.add_student, stud_id, stud_name)
        undo = FunctionCall(self.remove_student, stud_id)

        op = Operation(undo, redo)
        self._undoController.recordOperation(op)

        return stud
    def _loadFile(self):

        filepath = self._fileName

        try:
            f = open(filepath, "r")
            line = f.readline().strip()
            while len(line) > 0:
                line = line.split(",")
                StudentRepo.add_student(self, Student(int(line[0]), line[1]))
                line = f.readline().strip()
            f.close()
        except IOError as e:
            """
                Here we 'log' the error, and throw it to the outer layers 
            """
            print("An error occured - " + str(e))
            raise e
def load_existing_students(file_name="members.txt"):
    '''
	Args:
		file_name (str)
	'''
    students_file = open(file_name, "r")

    students_list = []
    for line in students_file.readlines():
        line = line.strip().split(":")
        email, area, other_students = line[0], line[1], ast.literal_eval(
            line[2])

        next_student = Student(email=email,
                               area=area,
                               previous_partners=other_students)
        students_list.append(next_student)

    return students_list
예제 #12
0
    def init_students(self):
        list_of_students = ["Sara Ohn", "Helen Mill", "Rebeka Schmidt", "Tim More", "Cassie Rolling", "Orlando Beck",
        "Alexandra Dimisov", "Sandra Key", "Meredith Grey", "Dereck Shepherd", "Amelia Shepherd", "Cristina Yang",
        "Alex Karev", "Jackson Avery", "Callie Torres", "Izzie Stevens", "Mark Sloan", "April Kepner", "Andrew DeLuca",
        "Owen Hunt", "Lexie Grey", "Arizona Robbins", "Miranda Bailey", "Jo Wilson", "Maggie Pierce", "Catherine Avery",
        "George O'Malley"]

        stud_id_already_in_list = []
        stud_name_already_in_list = []

        for i in range(10):
            stud_id = random.randint(1,200)
            while stud_id in stud_id_already_in_list:
                stud_id = random.randint(1,200)

            stud_name = random.choice(list_of_students)
            while stud_name in stud_name_already_in_list:
                stud_name = random.choice(list_of_students)

            self.add_student(Student(stud_id, stud_name))

            stud_id_already_in_list.append(stud_id)
            stud_name_already_in_list.append(stud_name)
예제 #13
0
from StudentClass import Student

student1 = Student("John", "Science", 3.14, True)
student2 = Student("Johnny", "Commerce", 3.14, True)
student3 = Student("Janardan", "Arts", 3.14, True)
print(student1.name)
print(student2.name)
print(student3.name)
예제 #14
0

##########################################################
# Validate age - validates input is integer and a reasonable range
##########################################################
def validateAge(intAge):
    try:
        intAge = int(intAge)
    except ValueError:
        intAge = validateAge(input("Enter a numerical value: "))
    if intAge <= 0 or intAge > 200:
        intAge = validateAge(input("Enter a valid age: "))
    return intAge


##########################################################
# Main
##########################################################
arrStudents = []
while len(arrStudents) < 5:
    strFirstName = input("Enter a first name: ")
    strLastName = input("Enter last name: ")
    strGender = validateGender((input("Enter Gender: ")).upper())
    dblGPA = validateGPA(input("Enter GPA: "))
    intAge = validateAge(input("Enter age: "))
    arrStudents.append(
        Student(strFirstName, strLastName, strGender, dblGPA, intAge))
Student.displayCount()
Student.displayGenders()
Student.displayAverageGPA()
Student.displayAverageAge()
예제 #15
0
from StudentClass import Student


class TestClass:
    def __init__(self, name):
        self.name = name


# 1 创建学校
school1 = School("北京it学院", "北京市海淀区", "beijing")
school2 = School("上海it学院", "上海浦东区", "shanghai")
# print(school1)
# print(school2)

# 创建课程
course1 = Course("linux", "20周", "1M")
course2 = Course("go", "22周", "1.5M")
course3 = Course("python", "25周", "1.2M")
# print(course1)
# print(course2)
# print(course3)
school1.AddCourse(course1)
school1.AddCourse(course2)
for c in school1.course:
    print(c)

# 创建老师及学生
student1 = Student("casablanca", 29, "M", "1001", "打篮球")

teacher = Teacher("drno", 31, "M")
예제 #16
0
def populate():
    students = []
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(
        Student(email="*****@*****.**",
                area="Natural Language Processing"))
    students.append(
        Student(email="*****@*****.**", area="Data Science"))
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="Computer Vision"))
    students.append(Student(email="*****@*****.**",
                            area="AI/ML/Robotics"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(
        Student(email="*****@*****.**",
                area="Algorithms and Theory"))
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="Computing Education"))
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**", area="Systems"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(
        Student(email="*****@*****.**",
                area="Security and Cryptography"))
    students.append(Student(email="*****@*****.**"))
    students.append(
        Student(email="*****@*****.**",
                area="Algorithms and Theory"))
    students.append(
        Student(email="*****@*****.**", area="Computer Vision"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(Student(email="*****@*****.**"))
    students.append(
        Student(email="*****@*****.**", area="Data Science"))
    students.append(
        Student(email="*****@*****.**",
                area="Security and Cryptography"))
    students.append(
        Student(email="*****@*****.**", area="AI/ML/Robotics"))
    students.append(
        Student(email="*****@*****.**",
                area="Security and Cryptography"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**"))
    students.append(Student(email="*****@*****.**"))

    return students
예제 #17
0
# Refer to the StudentClass.py file before reading this file.
from StudentClass import Student

student1 = Student(
    'Ankit', 'Business', 3.3,
    False)  # Here we created a student1, which is an object in Student class.
student2 = Student('Ram', 'Finance', 3.8, True)
print(student1.gpa)  # We can print information about the students like this
print(student1.is_on_probation)
예제 #18
0
from StudentClass import Student

student_1 = Student('Raju', section='C', grade='6', Rollno='45')
예제 #19
0
def GetStudentInfo():
    name = input('What is their name? ')
    age = int(input('How old are they? '))
    home = input('Where do they live? ')
    food = input('What do they like to eat? ')
    return Student(name, food, home, age)
예제 #20
0
#This would create first object from the Student class"
Graduate1 = Graduate("Bill", "Zara", "Male", 20, 3.25, 2019, "Y")

#"This would create second object from the Student class"
Graduate2 = Graduate("Betty", "Tara", "Female", 25, 2.25, 2018, "N")

#"This would create third object from the Student class"
Graduate3 = Graduate("Sydney", "Nye", "Female", 30, 3.75, 2018, "Y")

#"This would create forth object from the Student class"
Graduate4 = Graduate("Jake", "Leedom", "Male", 35, 2.75, 2017, "N")

#"This would create fifth object from the Student class"
Graduate5 = Graduate("Alex", "Jacobs", "Male", 21, 3.55, 2010, "Y")

Student1 = Student("Jim", "Beam", "M", 21, 4.0)

print(Graduate5)
print(Student1)
Graduate.schoolStatus(Graduate1)
Student.schoolStatus(Graduate1)
Person.schoolStatus(Graduate1)
print("Average GPA of all Students is  ",
      Student.stuGPATotal / Student.stuStudentCount)
print("Average Age of Male Students is  ",
      Student.stuMaleAgeTotal / Student.stuMaleCount)
print("Average Age of Female Students is  ",
      Student.stuFemaleAgeTotal / Student.stuFemaleCount)
print("Number of employed male students is ", Graduate.gradEmployedMaleCount)
print("Number of employed female students is ",
      Graduate.gradEmployedFemaleCount)
 def testStudent_CreateStudent(self):
     stud_id = 56
     stud_name = "Will Smith"
     stud = Student(stud_id, stud_name)
     self.assertEqual(stud.studentId, 56)
     self.assertEqual(stud.studentName, "Will Smith")
예제 #22
0
from StudentClass import Student
from datetime import datetime

d = datetime.today()

student = Student(892448163, "Evan McKinney", "07-01-1999", "Freshman")
# print(student.getStudent())

print(student.registerDate())
print(student.current_age(1999))
예제 #23
0
from StudentClass import Student

student1 = Student("Oscar", "Accounting", 3.1)
student2 = Student("Phyllis", "Business", 3.8)

print(student2.on_honor_roll())