def login(): common.show_green('登陆') if COOKIES['session_id']: common.show_red('用户不能重复登录') return while True: name = common.input_string('用户名') password = common.input_string('密码') params = { 'api': 'login', 'session_id': None, 'data_size': None, 'is_file': False, 'role': 'admin', 'name': name, 'password': password } res = client.send_data(params) if res['flag']: COOKIES['session_id'] = res['session_id'] COOKIES['name'] = name common.show_green(res['message']) return else: common.show_red(res['message'])
def create_school(): common.show_green('创建学校') while True: name = common.input_string('学校名称') if name == 'q': break address = common.input_string('学校地址') if address == 'q': break flag, msg = admin_api.create_school(CURRENT_USER, name, address) if not flag: common.show_red(msg) continue common.show_green(msg) return
def create_school(): print('\033[32m创建学校\033[0m') while True: name = common.input_string('学校名称') if name == 'q': break address = common.input_string('学校地址') if address == 'q': break flag, msg = admin_api.create_school(CURRENT_USER, name, address) if flag: print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def change_student_score(): print('\033[32m修改学员成绩\033[0m') while True: name = common.input_string('请输入学生名字') course = choose_student_course(name) if not course: continue score = common.input_string('请输入学生分数') flag, msg = teacher_api.change_student_score(CURRENT_USER, name, course, score) if flag: print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def run(): menu = { '1': [login, '登陆'], '2': [register, '注册'], '3': [check_school, '查看学校'], '4': [check_teacher, '查看老师'], '5': [check_course, '查看课程'], '6': [create_school, '创建学校'], '7': [create_teacher, '创建老师'], '8': [create_course, '创建课程'] } while True: print('=' * 30) for k, v in menu.items(): print('%-4s %-10s' % (k, v[1])) print('=' * 30) choice = common.input_string('请选择操作编号') if choice == 'q': if CURRENT_USER: logout() return if choice not in menu: print('\033[31m选择编号非法!\033[0m') continue menu[choice][0]()
def set_student_score(): common.show_green('修改学生成绩') while True: name = common.input_string('学生名字') if name == 'q': break course = common.input_string('学习课程') if course == 'q': break score = common.input_integer('课程成绩', is_float=True) if score == 'q': break flag, msg = teacher_api.set_student_score(CURRENT_USER, name, course, score) if not flag: common.show_red(msg) continue common.show_green(msg) return
def login(): global CURRENT_USER common.show_green('登陆') if CURRENT_USER: common.show_red('用户不能重复登录!') return while True: name = common.input_string('用户名') if name == 'q': break password = common.input_string('密码') if password == 'q': break flag, msg = teacher_api.login(name, password) if not flag: common.show_red(msg) continue CURRENT_USER = name common.show_green(msg) return
def create_course(): common.show_green('创建课程') while True: school_name = common.get_object_name(type_name='school') if not school_name: return name = common.input_string('课程名称') if name == 'q': break price = common.input_string('课程价格') if price == 'q': break cycle = common.input_string('课程周期') if cycle == 'q': break flag, msg = admin_api.create_course(CURRENT_USER, name, price, cycle, school_name) if not flag: common.show_red(msg) continue common.show_green(msg) return
def create_teacher(): common.show_green('创建老师') while True: name = common.input_string('老师名字') if name == 'q': break flag, msg = admin_api.create_teacher(CURRENT_USER, name) if not flag: common.show_red(msg) continue common.show_green(msg) return
def release_announcement(): common.show_green('发布公告') while True: announcement = common.input_string('公告名') content = common.input_string('公告内容') params = { 'api': 'release_announcement', 'session_id': COOKIES['session_id'], 'data_size': None, 'is_file': False, 'role': 'admin', 'announcement': announcement, 'content': content } res = client.send_data(params) if res['flag']: common.show_green(res['message']) return else: common.show_red(res['message'])
def login(): global CURRENT_USER print('\033[32m登陆\033[0m') if CURRENT_USER: print('\033[31m不能重复登录!\033[0m') return while True: name = common.input_string('登陆用户名') if name == 'q': break password = common.input_string('登陆密码') if password == 'q': break flag, msg = common_api.login(name, password, ROLE) if flag: CURRENT_USER = name print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def register(): common.show_green('注册') if CURRENT_USER: common.show_red('已登录,不能注册!') return while True: name = common.input_string('注册用户名') if name == 'q': break password = common.input_string('注册密码') if password == 'q': break password2 = common.input_string('确认密码') if password2 == 'q': break if password != password2: common.show_red('两次密码出入不一致!') continue flag, msg = admin_api.register(name, password) if not flag: common.show_red(msg) continue common.show_green(msg) return
def create_teacher(): print('\033[32m创建老师\033[0m') while True: name = common.input_string('老师名字') if name == 'q': break flag, msg = admin_api.create_teacher(CURRENT_USER, name) if flag: print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def register(): print('\033[32m注册\033[0m') while True: name = common.input_string('注册用户名') if name == 'q': break password = common.input_string('注册密码') if password == 'q': break password2 = common.input_string('确认密码') if password2 == 'q': break if password != password2: print('\033[31m两次输入密码不一致!\033[0m') continue flag, msg = student_api.register(name, password) if flag: print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def create_course(): print('\033[32m创建课程\033[0m') while True: school_name = choose_school() if not school_name: return name = common.input_string('课程名称') if name == 'q': break price = common.input_string('课程价格') if price == 'q': break cycle = common.input_string('课程周期') if cycle == 'q': break flag, msg = admin_api.create_course(CURRENT_USER, name, price, cycle, school_name) if flag: print('\033[32m%s\033[0m' % msg) return else: print('\033[31m%s\033[0m' % msg)
def run(): menu = {'1': [admin, '管理端'], '2': [user, '用户端']} while True: common.show_red('按"e"结束程序') common.show_menu(menu) choice = common.input_string('请输入平台编号') if choice == 'e': common.show_red('Goodbye!') return if choice not in menu: common.show_red('选择编号非法!') continue menu[choice][0].run()
def register(): common.show_green('注册') while True: name = common.input_string('注册用户名') password = common.input_string('注册密码') password2 = common.input_string('确认密码') if password != password2: common.show_red('两次输入密码不一致!') continue params = { 'api': 'register', 'session_id': None, 'data_size': None, 'is_file': False, 'role': 'admin', 'name': name, 'password': password } res = client.send_data(params) if res['flag']: common.show_green(res['message']) return else: common.show_red(res['message'])
def run(): menu = { '1': [admin, '管理端'], '2': [teacher, '教师端'], '3': [student, '学生端'], } while True: common.show_red('按"e"结束程序') common.show_menu(menu) choice = common.input_string('请选择平台编号') if choice == 'q': continue if choice == 'e': common.show_red('Goodbye!') return if choice not in menu: common.show_red('选择编号非法!') continue menu[choice][0].run()
def run(): menu = { '1': [login, '登陆'], '2': [check_teach_course, '查看教授课程'], '3': [check_teach_course_student, '查看教授课程学生'], '4': [choose_teach_course, '选择教授课程'], '5': [set_student_score, '修改学生成绩'] } while True: common.show_green('按"q"退出视图') common.show_menu(menu) choice = common.input_string('请选择操作编号') if choice == 'q': if CURRENT_USER: logout() return if choice not in menu: common.show_red('选择编号非法!') continue menu[choice][0]()
def run(): menu = { '1': [admin, '管理端'], '2': [teacher, '教师端'], '3': [student, '学生端'], } while True: print('=' * 30) for k, v in menu.items(): print('%-4s %-10s' % (k, v[1])) print('=' * 30) choice = common.input_string('请选择操作编号') if choice == 'q': print('\033[31m输入"e"结束程序!\033[0m') continue if choice == 'e': break if choice not in menu: print('\033[31m选择编号非法!\033[0m') continue menu[choice][0].run()
def run(): global client client = tcpClient.TcpClient(settings.server_address) menu = { '1': [login, '登陆'], '2': [register, '注册'], '3': [release_announcement, '发布公告'], '4': [upload_video, '上传视频'], '5': [remove_video, '删除视频'] } while True: common.show_green('按"q"登出') common.show_menu(menu) choice = common.input_string('请输入平台编号') if choice == 'q': common.show_red('logout!') return if choice not in menu: common.show_red('选择编号非法!') continue menu[choice][0]()
def run(): menu = { '1': [login, '登陆'], '2': [register, '注册'], '3': [check_course, '查看所有课程'], '4': [check_learn_course, '查看个人课程'], '5': [choose_course, '选择课程'], '6': [check_score, '查看成绩'] } while True: print('=' * 30) for k, v in menu.items(): print('%-4s %-10s' % (k, v[1])) print('=' * 30) choice = common.input_string('请选择操作编号') if choice == 'q': if CURRENT_USER: logout() return if choice not in menu: print('\033[31m选择编号非法!\033[0m') continue menu[choice][0]()
def run(): menu = { '1': [login, '登陆'], '2': [check_course, '查看所有课程'], '3': [check_teach_course, '查看教授课程'], '4': [choose_teach_course, '选择教授课程'], '5': [check_course_student, '查看课程学员'], '6': [change_student_score, '修改学生成绩'], } while True: print('=' * 30) for k, v in menu.items(): print('%-4s %-10s' % (k, v[1])) print('=' * 30) choice = common.input_string('请选择操作编号') if choice == 'q': if CURRENT_USER: logout() return if choice not in menu: print('\033[31m选择编号非法!\033[0m') continue menu[choice][0]()
def run(): menu = { '1': [login, '登陆'], '2': [register, '注册'], '3': [check_all_school, '查看所有学校'], '4': [check_all_teacher, '查看所有老师'], '5': [check_all_course, '查看所有课程'], '6': [create_school, '创建学校'], '7': [create_teacher, '创建老师'], '8': [create_course, '创建课程'] } while True: common.show_green('按"q"退出视图') common.show_menu(menu) choice = common.input_string('请选择操作编号') if choice == 'q': if CURRENT_USER: logout() return if choice not in menu: common.show_red('选择编号非法!') continue menu[choice][0]()