Esempio n. 1
0
def cho_tec_course(obj, course1, t_class):
    #更改老师教课列表
    obj.course.append(course1)
    #更改老师教课班级
    obj.classes.append(t_class)
    DB_handler.save_obj_to_file(obj)
    return
Esempio n. 2
0
def student_resister(name, password):
    # 要判断是否存在这个学生
    filenames = DB_handler.get_all_filename(Student.__name__.lower())
    if not filenames:
        student = Student(name, password)
        DB_handler.save_obj_to_file(student)
        return student
    if name in filenames:
        return
    # 处理数据并且完成存储
    student = Student(name, password)
    DB_handler.save_obj_to_file(student)
    return student
Esempio n. 3
0
def admin_resister(name, password):
    # 要判断是否存在这个管理员,返回管理员列表
    filenames = DB_handler.get_all_filename(Admin.__name__.lower())
    if not filenames:
        #生成管理员对象
        admin = Admin(name, password)
        DB_handler.save_obj_to_file(admin)
        return admin
    if name in filenames:
        return
    # 处理数据并且完成存储
    admin = Admin(name, password)
    DB_handler.save_obj_to_file(admin)
Esempio n. 4
0
def admin_create_school(name, address, telephone):
    #获得学校列表
    filenames = DB_handler.get_all_filename(School.__name__.lower())
    if not filenames:
        #生成学习对象
        school = School(name, address, telephone)
        #保存学校对象
        DB_handler.save_obj_to_file(school)
        return school
    if name in filenames:
        return
    school = School(name, address, telephone)
    DB_handler.save_obj_to_file(school)
    return school
Esempio n. 5
0
def admin_create_classes(course_school, course_class):
    # 生成创建班级的路径,是不同学校可以创建相同班级
    file_path = os.path.join(settings.DB_DIR, Classes.__name__.lower(),
                             course_school)
    filenames = DB_handler.get_all_filename(file_path)
    if not filenames:
        #生成班级对象
        classes = Classes(course_class)
        DB_handler.save_obj_to_file(classes, file_path)
        return
    if course_class in filenames:
        return course_class
    classes = Classes(course_class)
    DB_handler.save_obj_to_file(classes, file_path)
    return
Esempio n. 6
0
def admin_create_course(schol_name, course_name, course_time, course_money):
    #生成创建课程的路径,是不同学校可以创建相同课程
    filenames_path = os.path.join(settings.DB_DIR, Course.__name__.lower(),
                                  schol_name)
    #获得课程列表
    filenames = DB_handler.get_all_filename(filenames_path)
    if not filenames:
        #生成课程对象
        course = Course(course_name, course_time, course_money)
        DB_handler.save_obj_to_file(course, filenames_path)
        return
    if course_name in filenames:
        return course_name
    course = Course(course_name, course_time, course_money)
    DB_handler.save_obj_to_file(course, filenames_path)
    return
Esempio n. 7
0
def teacher_resister(name, password):
    # 要判断是否存在这个老师
    filenames = DB_handler.get_all_filename(Teacher.__name__.lower())
    school = input("请选择学校:").strip()
    #回去所有学校列表
    school_name = DB_handler.get_all_filename(School.__name__.lower())
    if school not in school_name:
        return "该学校不存在"
    # 第一次没有相对目录filenames为None
    if not filenames:
        #生成老师对象
        teacher = Teacher(name, password, school)
        DB_handler.save_obj_to_file(teacher)
        return
    if name in filenames:
        return "该老师已存在"
    # 处理数据并且完成存储
    teacher = Teacher(name, password, school)
    DB_handler.save_obj_to_file(teacher)
    return
Esempio n. 8
0
def student_attr_set(st_obj, name, choice_obj):
    if type(choice_obj) != str and type(choice_obj) != int:
        setattr(st_obj, name, choice_obj.name)
        DB_handler.save_obj_to_file(st_obj)
        return
    elif type(choice_obj) == str or type(choice_obj) == int:
        setattr(st_obj, name, choice_obj)
        DB_handler.save_obj_to_file(st_obj)
        return
    else:
        s = getattr(st_obj, name)
        s.append(choice_obj)
        DB_handler.save_obj_to_file(st_obj)
        return
Esempio n. 9
0
def set_tec_grade(st_obj, chengji):
    #将学生对象的成绩的值改为多少
    setattr(st_obj, "grade", chengji)
    DB_handler.save_obj_to_file(st_obj)