Пример #1
0
def main():
    student1 = Student('Alice', 22)
    student2 = Student('Bob', 42)
    student3 = Student('Kate', 18)

    student3.accept_task(1)
    student3.accept_task(3)
    student3.accept_task(2)
    student3.accept_task(5)
    student1.accept_task_v2(6, 7, 8)

    student1.pretty_print()

    student2.pretty_print()

    student3.pretty_print()

    # pprint.pprint(student1.__dict__)
    # pprint.pprint(student2.__dict__)

    # student1.__dict__['name'] = 'ALICE'
    # print(student1.name)

    professor1 = Professor("Garry", 56)
    professor1.set_email("*****@*****.**")
    professor1.pretty_print()
    print("======")
Пример #2
0
    def create_students(self):
        stud_01 = Student('male', rd(), 'Vasilij', 'Informatics', 'Rumnerden')
        self.students.append(stud_01)

        stud_02 = Student('male', rd(), 'Ivan', 'Economics')
        self.students.append(stud_02)

        stud_03 = Student('female', rd(), 'Olga', 'Arts')
        self.students.append(stud_03)
    def merge_csv(self, overdue_books_csv, fines_csv):
        """

        :param overdue_books_csv: Overdue books CSV generated by AccessIt
        :param fines_csv: Fines CSV generated by AccessIt
        :return:
        """

        with open(overdue_books_csv) as csv_file:
            read_csv = list(csv.reader(csv_file, delimiter=','))

            # Get each pair of lines and shape their info into Student and
            # Offense classes
            for author_info, student_info in zip(
                    list(filter(match_criteria, read_csv[::2])),
                    list(filter(match_criteria, read_csv[1::2]))):

                # Extract student information
                form_class = student_info[1].strip()
                student_id = int(author_info[2].strip())
                name = student_info[2].strip()

                # Create new Student if not already in dictionary
                if student_id not in self.list_of_offenders.keys():
                    self.list_of_offenders[student_id] = Student(
                        form_class, student_id, name)
                    student = self.list_of_offenders[student_id]
                else:
                    student = self.list_of_offenders[student_id]

                # Add the corresponding overdue book to the student's record
                create_offense_from_overdue(author_info, student_info, student)

        with open(fines_csv) as csv_file:
            read_csv = list(csv.reader(csv_file, delimiter=','))

            # Get each pair of lines and shape their info into Student and
            # Offense classes
            for student_info, fine_info in zip(
                    list(filter(match_criteria, read_csv[::2])),
                    list(filter(match_criteria, read_csv[1::2]))):

                # Extract student information
                form_class = student_info[2].strip()
                student_id = int(student_info[1].strip())
                name = fine_info[1]

                # Create new Student if not already in dictionary
                if student_id not in self.list_of_offenders.keys():
                    self.list_of_offenders[student_id] = Student(
                        form_class, student_id, name)
                    student = self.list_of_offenders[student_id]
                else:
                    student = self.list_of_offenders[student_id]

                # Add the corresponding fine to the student's record
                create_offense_from_fine(student_info, fine_info, student)
Пример #4
0
    def read_file(f_name):
        students = []
        f = None
        try:
            f = open(f_name, 'r')
            for line in f.readlines():
                std_data = {}
                items = line.split('; ')
                # DEBUG
                # print('items -> {}'.format(items))
                for item in items:
                    params = item.split(': ')
                    # DEBUG
                    # print('params -> {}'.format(params))
                    std_data[params[0]] = params[1].strip()

                try:
                    # DEBUG
                    # print('std_data -> {}'.format(std_data))
                    students.append(Student(std_data))
                except Exception as e:
                    print(e)  # print error
                    # Debug:
                    # print(type(std_data))
                    for d in std_data.items():
                        print(d)
                    print()

        except Exception as e:
            print(e)
        finally:
            if f is not None:
                f.close()
            return students
Пример #5
0
    def load_students_and_teachers_and_courses(self):
        """
        Return a tuple containing a list of Teacher and Student objects.
        This loads the courses and adds them to the objects request/qualification
        lists.
        """

        # load the raw data
        # TODO: load from a file of some sort
        num_courses = 5
        student_requests = [
                        [0, 1, 3],
                        [0, 2, 3],
                        [0, 2, 4],
                        [1, 3, 4],
                        [0, 1, 2],
                        [1, 2, 3]
        ]

        teacher_qualifs = [
                        [0, 1, 3],
                        [0, 2, 4],
                        [1, 2, 3]
        ]

        rawCourses = [(str(i), CourseType.CORE) for i in range(num_courses)] # example course already in list
        rawStudentRequests = {i: reqs for i, reqs in enumerate(student_requests)} # map student name to requests (strings)
        rawStudentGrades = {i: 12 for i in range(len(student_requests))} # map student name to the grade they're in
        rawTeacherQualifications = {i: qualifs for i, qualifs in enumerate(teacher_qualifs)} # map teacher name to qualifications (strings)
        rawTeacherRequestedOpenPeriods = {i: 0 for i in range(len(teacher_qualifs))} # map teacher name to requested open periods

        # create tag generator
        tg = tag_generator()

        # create Courses, Students, and Teachers
        courses = {} # maps course name to object
        for c in rawCourses:
            courses[c[0]] = Course(*c)
        allCourses = list(courses.values())

        students = []
        for index, requestList in rawStudentRequests.items():
            student = Student(next(tg), allCourses)
            # set student grade to rawStudentGrades[index]
            students.append(student)
            student.requestAll([courses[str(c)] for c in requestList])

        teachers = []
        for index, qualifications in rawTeacherQualifications.items():
            qualifications_with_course_objects = [courses[str(q)] for q in qualifications]
            teacher = Teacher(next(tg), allCourses)
            teacher.addQualifications(qualifications_with_course_objects)
            # TODO: add open period requests from rawTeacherRequestedOpenPeriods[index]
            teachers.append(teacher)

        return students, teachers, list(courses.values())
Пример #6
0
async def auth(request):
    req_data = await get_request(request)

    global STUDENTS

    result = NSTUAPI().auth_user(
        req_data["username"],
        req_data["password"]
    )
    if len(result) > 1:
        STUDENTS.append(Student(req_data["username"], result[1]))

    return get_response(result, True)
Пример #7
0
def students_page():
    if request.method == "POST":
        new_student_id = request.form.get("student-id", "")
        new_student_name = request.form.get("name", "")
        new_student_last_name = request.form.get("last-name", "")

        new_student = Student(name=new_student_name,
                              student_id=new_student_id,
                              lastname=new_student_last_name)
        students.append(new_student)

        print(students)

        return redirect(url_for("students_page"))
    return render_template("index.html", students=students)
                ["{}".format(student) for student in self.students])
            return "Student Preferences\n============\n{}".format(student_str)


if __name__ == "__main__":
    random.seed(1)
    company_list = [
        "Oakley", "Reddit", "Burton", "Google", "Apple", "Microsoft"
    ]
    student_list = ["Joel", "Rhia", "Dave", "Andy", "Ryan", "Triston", "Lorin"]

    # Create list of Student objects
    students = []
    for student in student_list:
        comps = random.sample(company_list, 6)
        students.append(Student(student, ranks=comps))

    # Create list of Company objects
    companies = []
    for company in company_list:
        companies.append(Company(company, available_slots=3))
    companies.append

    # Initialize and run matching algorithm
    matcher = InterviewMatch(students, companies)
    print matcher
    matcher.fit()

    # Check results
    print matcher
Пример #9
0
from classes.student import Student

student = Student("Joni", "Mitchell")
print(student)
Пример #10
0
    def register_student(self):
        std_data = {}
        first_name = None
        last_name = None
        student_id = None
        personal_id = None

        while first_name is None:
            print('Please enter student first name:')
            first_name = input()
            if len(first_name) < 2:
                print(
                    "ERROR: first name must be at least 2 chars long. Please reenter."
                )
                first_name = None
            else:
                if not first_name.isalpha():
                    print(
                        "ERROR: first name must contain alphabetic chars only. Please reenter."
                    )
                    first_name = None
                else:
                    std_data['_first_name'] = first_name

        while last_name is None:
            print('Please enter student last name:')
            last_name = input()
            if len(last_name) < 2:
                print(
                    "ERROR: last name must be at least 2 chars long. Please reenter."
                )
                last_name = None
            else:
                if not last_name.isalpha():
                    print(
                        "ERROR: last name must contain alphabetic chars only. Please reenter."
                    )
                    last_name = None
                else:
                    std_data['_last_name'] = last_name

        while student_id is None:
            print('Please enter student id:')
            student_id = input()
            if len(student_id) != 9:
                print(
                    "ERROR: student id must contain 9 digits. Please reenter.")
                student_id = None
            else:
                try:
                    # student_id = int(student_id)
                    is_doubled = False
                    for std in self._students:
                        # print(std)
                        # DEBUG:
                        # print("{} <> {}".format(std.get_param('_student_id'), student_id))
                        if int(std.get_param('_student_id')) == student_id:
                            print(
                                "ERROR: student id is already exists: {}. Please reenter."
                                .format(student_id))
                            student_id = None
                            is_doubled = True

                    if is_doubled is False:
                        std_data['_student_id'] = student_id
                except Exception as e:
                    print(
                        "ERROR: student id must contain digits only. Please reenter."
                    )
                    print(e)
                    student_id = None

        while personal_id is None:
            print('Please enter personal id:')
            personal_id = input()
            if len(personal_id) != 9:
                print(
                    "ERROR: personal id must contain 9 digits. Please reenter."
                )
                personal_id = None
            else:
                try:
                    # personal_id = int(personal_id)
                    is_doubled = False
                    for std in self._students:
                        # print(std)
                        # DEBUG
                        # print("{} <> {}".format(std.get_param('_personal_id'), personal_id))
                        if int(std.get_param('_personal_id')) == personal_id:
                            print(
                                "ERROR: personal id is already exists: {}. Please reenter."
                                .format(personal_id))
                            personal_id = None
                            is_doubled = True

                    if is_doubled is False:
                        std_data['_personal_id'] = personal_id
                except Exception as e:
                    print(
                        "ERROR: personal id must contain digits only. Please reenter."
                    )
                    print(e)
                    personal_id = None
        try:
            # DEBUG:
            print(std_data)
            return Student(std_data)
        except Exception as e:
            print(e)
import csv

from classes.admin import Admin
from classes.student import Student
from classes.user import User

# create list of class object from database
users_list = []
admins_list = []
students_list = []

with open('../databases/users_db/hash_users_db.csv', 'r', newline='') as csv_file:
    csv_reader = csv.DictReader(csv_file)
    for user in csv_reader:
        user_obj = User(user['username'], user['password'], int(user['user_id']), user['firstname'], user['lastname'],
                        int(user['user_type']), user['field_name'], int(user['field_code']))
        users_list.append(user_obj)
        # if user is student :
        if user['user_type'] == "0":
            student = Student(user['username'], user['password'], int(user['user_id']),
                              user['firstname'], user['lastname'],
                              int(user['user_type']), user['field_name'], int(user['field_code']))
            students_list.append(student)
        # if user is admin
        else:
            admin = Admin(user['username'], user['password'], int(user['user_id']), user['firstname'], user['lastname'],
                          int(user['user_type']), user['field_name'], int(user['field_code']))
            admins_list.append(admin)
Пример #12
0
 def add_student(self, student_data):
     self.students.append(Student(**student_data))
     self.save()
Пример #13
0
from classes.student import Student
from classes.person import Person

pappu = Student("Pappu", 7)
print(pappu)
pappu = Student("Pappu", grade=7)
print(pappu)
print(pappu.whoami)

munnu = Person("Munnu")

print(munnu)
print(munnu.name)

print(munnu.whoami)
# print(pappu.name)
Пример #14
0
 def getOldStudent(self, name):
     print(name)
     self.student = Student(name, self, False, self.gui)
Пример #15
0
 def createStudent(self, name):
     print(name)
     self.student = Student(name, self, True, self.gui)
Пример #16
0
from utils.math_utils import max_average
from classes.student import Student

agoni = Student("Agon", "Cecelia", "*****@*****.**", "127488", 7.89)
bislimi = Student("Bislim", "Bislimi", "*****@*****.**", "127388", 6.78)
ahmeti = Student("Ahmet", "Ahmeti", "*****@*****.**", "127332", 7.12)

lista = []
lista.append(agoni)
lista.append(bislimi)
lista.append(ahmeti)

max_avg_student = max_average(lista)

print("{} {} me mesataren: {}".format(max_avg_student.first_name, max_avg_student.last_name, max_avg_student.average))