Esempio n. 1
0
def login(username: str, password: str) -> Person:
    """通过用户名和密码登录智学网

    Args:
        username (str): 用户名, 可以为准考证号, 手机号
        password (str): 密码
        user_id (str): 用户id

    Raises:
        ArgError: 参数错误
        UserOrPassError: 用户名或密码错误
        UserNotFoundError: 未找到用户
        LoginError: 登录错误
        Exception: 账号角色未知

    Returns:
        Person
    """
    session = get_session(username, password)
    if check_is_student(session):
        return Student(session).set_base_info()
    teacher = Teacher(session).set_base_info()
    if teacher.role == "headteacher":
        teacher = Headteacher(teacher)
    elif teacher.role == "headmaster":
        teacher = Headmaster(teacher)
    else:
        raise Exception("账号是未知用户")
    return teacher.set_base_info()
Esempio n. 2
0
def login_id(user_id: str, password: str) -> Person:
    """通过用户id和密码登录智学网

    Args:
        user_id (str): 用户id
        password (str): 密码

    Raises:
        UserOrPassError: 用户名或密码错误
        UserNotFoundError: 未找到用户
        LoginError: 登录错误
        RoleError: 账号角色未知

    Returns:
        Person
    """
    session = get_session_id(user_id, password)
    if check_is_student(session):
        return Student(session).set_base_info()
    teacher = Teacher(session).set_base_info()
    if teacher.role == "headteacher":
        teacher = Headteacher(teacher)
    elif teacher.role == "headmaster":
        teacher = Headmaster(teacher)
    else:
        raise RoleError()
    return teacher.set_base_info()
Esempio n. 3
0
def login_student(username: str, password: str) -> Student:
    """通过用户名和密码登录学生账号

    Args:
        username (str): 用户名, 可以为准考证号, 手机号
        password (str): 密码

    Raises:
        UserOrPassError: 用户名或密码错误
        UserNotFoundError: 未找到用户
        LoginError: 登录错误

    Returns:
        Student
    """
    session = get_session(username, password)
    student = Student(session)
    return student.set_base_info()
Esempio n. 4
0
def login_student_id(user_id: str, password: str) -> Student:
    """通过用户id和密码登录学生账号

    Args:
        user_id (str): 用户id
        password (str): 密码

    Raises:
        UserOrPassError: 用户名或密码错误
        UserNotFoundError: 未找到用户
        LoginError: 登录错误

    Returns:
        Student
    """
    session = get_session_id(user_id, password)
    student = Student(session)
    return student.set_base_info()