Example #1
0
    def test_remove(self):
        self.repo.append(Student(1, "Name", 1))

        del self.repo[0]

        with self.assertRaises(Exception):
            self.assertEqual(self.repo[0], Student(1, "Name", 1))
Example #2
0
 def __init__(self, Student):
     self.student = Student(
         id=Student["id"],
         cpf=Student["cpf"],
         firstName=Student["firstName"],
         lastName=Student["lastName"],
         birthDate=Student["birthDate"])
    def test_remove(self):
        self.repo.append(Student(1, "Name", 1))

        self.repo.remove(1)

        with self.assertRaises(Exception):
            self.assertEqual(self.repo.get(1), Student(1, "Name", 1))
Example #4
0
def verify_password(username_or_token, password):
    # first try to authenticate by token
    user = Student.verify_auth_token(username_or_token)
    if not user:
        # try to authenticate with username/password
        try:
            user = Student.get(Student.student_number == username_or_token)
        except:
            user = None
        if not user or not user.verify_password(password):
            return False
    g.user = user
    return True
Example #5
0
def add_students():
    students.append(
        Student(code="1",
                fio="Васильев Сарыал Иннокентьевич",
                birthdate="12.07.1998",
                email="*****@*****.**",
                phone="+79969141275",
                group=groups[0],
                brs_points=[]))
    students.append(
        Student(code="2",
                fio="Иванов Иван Иванович",
                birthdate="11.01.2002",
                email="*****@*****.**",
                phone="+71234567890",
                group=groups[3],
                brs_points=[]))
 def create_student(self, id, name, group):
     '''
     Create a student object
     :param id: int ID of the student
     :param name: string Name
     :param group: int ID of group
     :return: Student object
     '''
     return Student(id, name, group)
Example #7
0
    def getStudentsByClassId(self, classId):
        sql = "SELECT * FROM student WHERE ClassId = %s"
        value = (classId, )

        self.cursor.execute(sql, value)

        try:
            obj = self.cursor.fetchall()
            return Student.CreateStudent(obj)
        except mysql.connector.Error as err:
            print("Error : ", err)
Example #8
0
    def getStudentById(self, id):
        sql = "SELECT * FROM student WHERE Id = %s"
        value = (id, )

        self.cursor.execute(sql, value)

        try:
            obj = self.cursor.fetchone()
            return Student.CreateStudent(obj)
        except mysql.connector.Error as err:
            print("Error : ", err)
Example #9
0
def create_student(code, name, birthdate, email, phone, group):
    check_input_on_empty(code)
    check_input_on_empty(name)
    check_input_on_empty(birthdate)
    check_input_on_empty(email)
    check_input_on_empty(phone)
    check_input_on_empty(group)
    code = convert_input_to_int(code)
    birthdate = convert_input_to_int(birthdate)
    phone = convert_input_to_int(phone)
    return Student(code=code,
                   fio=name,
                   birthdate=birthdate,
                   email=email,
                   phone=phone,
                   group=group,
                   brs_points=[])
Example #10
0
    def addStudent(self):
        self.displayClasses()
        classid = int(input("hangi sınıf :"))
        studentNumber = input("Numara: ")
        name = input("Ad: ")
        surname = input("Soyad: ")

        year = int(input("Doğum Tarihi Yılı: "))
        month = int(input("Doğum Tarihi Ay: "))
        day = int(input("Doğum Tarihi Gün: "))
        birthdate = datetime(year, month, day)

        gender = input("Cinsiyet (E/K): ")

        student = Student(None, studentNumber, name, surname, birthdate,
                          gender, classid)
        self.db.addStudent(student)
Example #11
0
    def add_student(self, name):
        '''
        Create and add a student.

        Args:
            name (str): The name of the new student.

        Raises:
            ValueError: If the name of the student is invalid.

        Returns:
            Student: The new student.
        '''
        self.__validator.validate_name(name)

        id_ = self.__students.get_available_id()
        student = Student(id_, name)
        return self.__students.add(student)
 def json_to_obj(self, json):
     try:
         if len(json) is not 0:
             if self.__method == "student":
                 return Student(json["id"], json["name"].strip(),
                                int(json["group"]))
             elif self.__method == "assignment":
                 date = json["date"].strip().split("/")
                 return Assignment(
                     json["id"], json["descr"],
                     datetime(int(date[2]), int(date[1]), int(date[0])))
             elif self.__method == "grade":
                 return Grade(json["stud_id"], json["assign_id"],
                              float(json["grade"]))
             else:
                 raise RepositoryError("Data file is corrupted")
         else:
             raise RepositoryError("Data file is corrupted")
     except IndexError as E:
         raise RepositoryError(
             "Data file corrupted or wrong conversion method")
Example #13
0
 def string_to_obj(self, line):
     try:
         if len(line) is not 0:
             sline = line.split(",")
             if len(sline) == 3:
                 if self.__method == "student":
                     return Student(int(sline[0].strip()), sline[1].strip(),
                                    int(sline[2].strip()))
                 elif self.__method == "assignment":
                     date = sline[2].strip().split("/")
                     return Assignment(
                         int(sline[0].strip()), sline[1],
                         datetime(int(date[2]), int(date[1]), int(date[0])))
                 elif self.__method == "grade":
                     return Grade(int(sline[0].strip()),
                                  int(sline[1].strip()),
                                  float(sline[2].strip()))
                 else:
                     raise RepositoryError("Data file is corrupted")
         else:
             raise RepositoryError("Data file is corrupted")
     except IndexError as E:
         raise RepositoryError(
             "Data file corrupted or wrong conversion method")
Example #14
0
class StudentDomain():
    def __init__(self, Student):
        self.student = Student(
            id=Student["id"],
            cpf=Student["cpf"],
            firstName=Student["firstName"],
            lastName=Student["lastName"],
            birthDate=Student["birthDate"])

    def getByClassId(self, classId):
        return self.student.getByClassId

    def update(self):
        self.student.update()

    def add(self):
        self.student.add()

    def delete(self):
        self.student.delete()
Example #15
0
def student_seed():
    successful = 0

    student = Student()
    student.firstname = 'حسین'
    student.lastname = 'مقدم'
    student.father = 'فرزاد'
    student.brithday = '1374-09-20'
    student.location_brith = 'طهران'
    student.phone = '0938094831'
    student.mobile = '02623588'
    student.national_code = '1234'
    student.status = 'active'
    student.entry_semester = '1396-تیر'
    student.img = 'ندارد'
    student.address = 'قاین'
    student.student_number = 3963001
    student.id = 1
    student.password = bcrypt.hash('1234')
    successful = successful + 1 if student.save() else successful

    student = Student()
    student.firstname = 'علی'
    student.lastname = 'یداللهی'
    student.father = 'عظاالدین'
    student.brithday = '1374-09-23'
    student.location_brith = 'طهران'
    student.phone = '09137304084'
    student.mobile = '02623588'
    student.national_code = '4321'
    student.status = 'active'
    student.entry_semester = '1396-تیر'
    student.img = 'ندارد'
    student.address = 'اصفهان'
    student.student_number = 3963002
    student.id = 2
    student.password = bcrypt.hash('1234')
    successful = successful + 1 if student.save() else successful

    print(str(successful) + ' Students created successfully')
    def test_check_points(self):
        group1 = Group("М-ФИИТ-20", 2020)
        group2 = Group("М-ФИИТ-19", 2019)

        year1 = EducationYear(2020, 2021)

        subject1 = Subject("321", "Психология")
        subject3 = Subject("323", "Английский")

        cross_section1 = CrossSection.FirstSection
        cross_section2 = CrossSection.SecondSection
        cross_section3 = CrossSection.FinalSection

        student1 = Student(code=123,
                           fio="Егоров Алексей Васильевич",
                           birthdate="01. 04. 1996",
                           email="*****@*****.**",
                           phone="+79244669579",
                           group=group1)
        student2 = Student(code=124,
                           fio="Иванов Иван Иванович",
                           birthdate="30. 12. 2000",
                           email="*****@*****.**",
                           phone="+79991112233",
                           group=group2)

        EgorovAV_cs1 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section1,
                                 points=33,
                                 student=student1)
        EgorovAV_cs2 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section2,
                                 points=66,
                                 student=student1)
        EgorovAV_cs3 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section3,
                                 points=99,
                                 student=student1)

        IvamovII_cs1 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section1,
                                 points=20,
                                 student=student2)
        IvamovII_cs2 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section2,
                                 points=20,
                                 student=student2)
        IvamovII_cs3 = BRSPoints(subject=subject1,
                                 year=year1,
                                 cross_section=cross_section3,
                                 points=20,
                                 student=student2)

        EgorovAV_cs1_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section1,
                                       points=101,
                                       student=student1)
        EgorovAV_cs2_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section2,
                                       points=0,
                                       student=student1)
        EgorovAV_cs3_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section3,
                                       points=0,
                                       student=student1)

        IvamovII_cs1_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section1,
                                       points=65,
                                       student=student2)
        IvamovII_cs2_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section2,
                                       points=60,
                                       student=student2)
        IvamovII_cs3_wrong = BRSPoints(subject=subject3,
                                       year=year1,
                                       cross_section=cross_section3,
                                       points=30,
                                       student=student2)

        Egorov_subject1_2020_2021 = [EgorovAV_cs1, EgorovAV_cs2, EgorovAV_cs3]
        Egorov_subject3_2020_2021_wrong = [
            EgorovAV_cs1_wrong, EgorovAV_cs2_wrong, EgorovAV_cs3_wrong
        ]

        Ivanov_subject1_2020_2021 = [IvamovII_cs1, IvamovII_cs2, IvamovII_cs3]
        Ivanov_subject1_2020_2021_wrong = [
            IvamovII_cs1_wrong, IvamovII_cs2_wrong, IvamovII_cs3_wrong
        ]

        self.assertEqual(
            Checker.check_points(Egorov_subject1_2020_2021, cross_section3,
                                 EgorovAV_cs3.points), True)
        self.assertEqual(
            Checker.check_points(Ivanov_subject1_2020_2021, cross_section3,
                                 IvamovII_cs3.points), True)

        self.assertEqual(
            Checker.check_points(Egorov_subject3_2020_2021_wrong,
                                 cross_section1, EgorovAV_cs1_wrong.points),
            False)
        self.assertEqual(
            Checker.check_points(Ivanov_subject1_2020_2021_wrong,
                                 cross_section3, IvamovII_cs3_wrong.points),
            False)
Example #17
0
 def test_append(self):
     self.repo.append(Student(1, "Name 1", 1))
     self.repo.append(Student(1, "Name 2", 2))
Example #18
0
    def test_set(self):
        self.repo.append(Student(1, "Name", 1))
        self.repo[0] = Student(1, "Name2", 1)

        self.assertEqual(self.repo[0], Student(1, "Name2", 1))
Example #19
0
def verify_token(token):
    user = Student.verify_auth_token(token)
    if user:
        g.user = user
        return True
    return False
Example #20
0
from Models.Student import Student
from Models.Professor import Professor
from Models.Course import Course

ml = Course(40441, 'Machine Learning', 'ce')
deep = Course(40123, 'Deep Learning', 'ce')
parham = Student(94109562, 'Parham Hessabi', 'ce')
soleimani = Professor(4112412, 'Mahdie Soleimani', 123, 132)
soleimani.present_course(ml)
soleimani.present_course(deep)

parham.enroll(ml, soleimani)
parham.enroll(deep, soleimani)
parham.finish("Machine Learning", 9)
parham.finish("Deep Learning", 15)

print(parham.grade("Machine Learning"))
print(parham.grade("Deep Learning"))
print(soleimani.salary)
print(parham.average)
def choicecourse_seed():
    successful = 0

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(0)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(0)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(1)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(0)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(0)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(1)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(1)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(1)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(0)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(2)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(1)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(2)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(0)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(3)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(1)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(3)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(0)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(4)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    choicecourse = ChoiceCourse()
    choicecourse.Student_student_number_id = Student.select().offset(1)[0].student_number
    choicecourse.status = 'accept'
    choicecourse.status_pay = 'yes'
    choicecourse.score = 5.0
    choicecourse.semeter = '1'
    choicecourse.Group_Course_code_course_id = GroupCourse.select().offset(5)[0].id
    successful = successful + 1 if choicecourse.save() else successful

    print(str(successful) + ' GroupCourses created successfully')
Example #22
0
    def test_len(self):
        self.repo.append(Student(1, "Name", 1))

        self.assertEqual(len(self.repo), 1)
    def test_get(self):
        self.repo.append(Student(1, "Name", 1))

        self.assertEqual(self.repo.get(1), Student(1, "Name", 1))
 def test_Append(self):
     with self.assertRaises(RepositoryError):
         self.repo.append(Student(1, "Name 1", 1))
         self.repo.append(Student(1, "Name 2", 2))
Example #25
0
 def test_create(self):
     student = Student(0, 'Gigel')
     self.assertEqual(student.get_id(), 0)
     self.assertEqual(student.get_name(), 'Gigel')
Example #26
0
 def test_set(self):
     student = Student(0, 'Gigel')
     student.set_name('Gigi')
     self.assertEqual(student.get_name(), 'Gigi')