コード例 #1
0
def create_classes():
    try:
        print('创建班级'.center(60, '-'))
        course_list = Course.get_all_obj_list()
        for k, obj in enumerate(course_list):
            print(k, obj, obj.name)
        sid = int(input('请选择课程:'))
        course_obj = course_list[sid]
        name = input('请输入班级名:').strip()
        tuition = input('请输入学费:').strip()

        classes_name_list = [obj.name for obj in Classes.get_all_obj_list()]
        if name in classes_name_list:
            raise Exception('\033[43;1m班级[%s] 已存在,不可重复创建\033[0m' % name)
        obj = Classes(name, tuition, course_obj.nid)
        obj.save()
        status = True
        error = ''
        data = '\033[33;1m班级[%s] 学费[%s] 创建成功\033[0m' % (obj.name, obj.tuition)

    except Exception as e:
        status = False
        error = str(e)
        data = ''
    return {'status': status, 'error': error, 'data': data}
コード例 #2
0
def create_course_to_teacher():

    print('课程导师'.center(60, '='))
    course_list = Course.get_all_obj_list()
    for k, obj in enumerate(course_list):
        print(k, obj, obj.name)
    sid = int(input('请选择课程: '))
    course_obj = course_list[sid]

    teacher_list = Teacher.get_all_obj_list()
    for k, obj in enumerate(teacher_list):
        print(k, obj, obj.name)
    sid = int(input('请选择关联导师: '))
    teacher_obj = teacher_list[sid]

    classes_list = Classes.get_all_obj_list()
    for k, obj in enumerate(classes_list):
        print(k, obj, obj.name)
    sid = int(input('请选择负责班级: '))
    classes_obj = classes_list[sid]

    obj = Course_to_teacher(course_obj.nid, teacher_obj.nid, classes_obj.nid)
    obj.save()
    status = True
    error = ''
    data = '\033[33;1m课程[%s] 班级[%s] 导师[%s] 分配成功\033[0m' % (
        course_obj.name, classes_obj.name, teacher_obj.name)
    return {'status': status, 'error': error, 'data': data}
コード例 #3
0
def create_student():

    print('新生入学'.center(60, '-'))
    classes_list = Classes.get_all_obj_list()
    for k, obj in enumerate(classes_list):
        print(k, obj, obj.name)
    sid = int(input('请选择班级:'))
    classes_obj = classes_list[sid]

    name = input('请输入学生姓名:').strip()
    password = input('请输入登陆密码:').strip()
    age = input('请输入学生年龄:').strip()
    qq = input('请输入学生QQ:').strip()
    score_obj = Score(0)
    score_obj.save()
    obj = Student(name, password, age, qq, classes_obj.nid, score_obj.nid)
    obj.save()
    status = True
    error = ''
    data = '\033[33;1m学生[%s] age[%s] QQ[%s] 录取成功 \033[0m' % (obj.name, obj.age,
                                                             obj.qq)

    return {'status': status, 'error': error, 'data': data}
コード例 #4
0
def show_classes():
    for obj in Classes.get_all_obj_list():
        print('\033[33;1m [%s]课程 班级[%s] 学费[%s]\033[0m'.center(60,'-') \
              %(obj.course_nid.get_obj_by_uuid().name,obj.name,obj.tuition))