def teacher_view(): """教师视图""" teacher_name = input("输入老师姓名:") teacher = Teacher(teacher_name) while True: choice = input("1.增加课程,2.增加上课记录,3.把学生增加到班级,4.修改学生成绩") if choice == "1": grade_name = input("课程名称:") ret = teacher.add_grade(grade_name) print(ret) elif choice == "2": grade_name = input("课程名称:") ret = teacher.add_grade_record(grade_name) print(ret) elif choice == "3": qq = input("请输入学生qq号:") grade_name = input("课程名称:") ret = teacher.add_student_to_grade(qq, grade_name) print(ret) elif choice=="4": qq = input("请输入学生qq号:") grade_name = input("课程名称:") date = input("上课时间:") score = input("成绩:") ret = teacher.modify_score(grade_name, qq, date, score) print(ret) else: print("请输入正确的选项")
def create_teacher(self): """ 创建讲师 输入讲师的名称, 1.讲师对象存到 userinfo.pkl 用来登录判断 2.讲师对象存到 teacher.pkl 用来后续使用 eg:添加班级 一个讲师可以有多个班级 """ password_salt = salt.create_salt() name = input('teacher_name>>>:').strip() tea = Teacher(name,password_salt) self.userinfo_path.dump(tea) self.teacher_path.dump(tea) print('讲师:%s 创建成功'.center(30, '-')%name)
def born_teacher(role, ID): ''' 从文件中读取信息实例化老师对象 :param role: :param ID: :return: ''' teacher_data = Module.get_data(role, ID) # 从文件中读取课程信息 teacher = Teacher(teacher_data['teacher_name'], teacher_data['teacher_age'], teacher_data['school'], teacher_data['teacher_id'], teacher_data['teacher_course'], teacher_data['phone'], teacher_data['student_id'], teacher_data['password'], teacher_data['teacher_class']) return teacher
def create_teacher(self): """创建老师""" teacher_name = input("请输入要创建的老师名称,返回请输入b:") if teacher_name.upper() == "B": return teacher_passwd = input("请输入要创建的老师的密码:") for i, school_obj in enumerate(self.school_pickle_obj.p_load(), 1): # 读取目前存在的学校 print(i, school_obj.name) teacher_school = input("请输入老师所属学校:") for school_obj in self.school_pickle_obj.p_load(): # 读取目前存在的学校 if teacher_school == school_obj.name: break else: print("你输入的学校不存在,请重新输入!") return teacher_msg = "%s|%s|1" % (teacher_name, teacher_passwd) HandleDb.write_db(teacher_msg) # 将账号写入用户信息文件 self.teacher_pickle_obj.p_dump(Teacher(teacher_name, teacher_school)) print("创建老师成功!")
def run(): """主函数""" print('\033[1;42m欢迎您登陆选课系统\033[0m') auth_msg = auth.login() # 接收登录之后的用户信息 if auth_msg: if auth_msg['roleid'] == 0: # 0表示管理员 obj = Manager(auth_msg['username']) # 实例化管理员对象 while True: for i, func in enumerate(Manager.menu, 1): # 取出类变量进行打印 print(i, func[1]) try: func_num = int(input("请输入功能序号:")) getattr(obj, Manager.menu[func_num - 1][0])() # 根据字符串从对象中找到对应的方法并执行(反射) except Exception as e: print("你输入的内容有误") elif auth_msg['roleid'] == 1: # 1表示讲师 obj = Teacher(auth_msg['username']) # 实例化管理员对象 while True: for i, func in enumerate(Teacher.menu, 1): # 取出类变量进行打印 print(i, func[1]) try: func_num = int(input("请输入功能序号:")) getattr(obj, Teacher.menu[func_num - 1][0])() # 根据字符串从对象中找到对应的方法并执行(反射) except Exception as e: print("你输入的内容有误") elif auth_msg['roleid'] == 2: # 2表示学生 obj = Student(auth_msg['username']) # 实例化管理员对象 for i, func in enumerate(Student.menu, 1): # 取出类变量进行打印 print(i, func[1]) try: func_num = int(input("请输入功能序号:")) getattr(obj, Student.menu[func_num - 1][0])() # 根据字符串从对象中找到对应的方法并执行(反射) except Exception as e: print("你输入的内容有误") else: print("你的角色出了问题,请联系管理员")
def creat_teacher(): ''' 创建老师对象 :return: ''' while True: teacher_name = input('老师姓名>>(b退出):').strip() if len(teacher_name) != 0: teacher_age = input('年龄>>:').strip() phone = input('电话>>:').strip() school = None password = Module.encrypt('123') teacher_course = None teacher_class = [] student_id = [] teacher_id = None obj = Teacher(teacher_name, teacher_age, school, teacher_id, teacher_course, phone, student_id, password, teacher_class) # 实例化老师对象 return obj elif teacher_name == 'b': break
def render_booking(teacher_id, weekday, time): form = BookingForm(teacher_id=teacher_id, weekday=weekday, time=time) teacher = Teacher(teacher_id) if request.method == "POST" and form.validate_on_submit(): return redirect(url_for('render_booking_done')) return render_template('booking.html', form=form, teacher=teacher)
def render_profile(teacher_id): teacher = Teacher(teacher_id) return render_template('profile.html', teacher=teacher.data, free_time=teacher.free_time)
def teacher_view(): """教师视图""" teacher_name = input("输入老师姓名:") teacher = Teacher(teacher_name) stu_obj = teacher.get_teacher_name() if stu_obj == None: print("查无此人:{},请重新输入。".format(teacher_name)) teacher_view() else: print("你好,{}老师.欢迎进入学员管理系统。请选择你要执行的操作。".format(teacher.name)) while True: msg = ''' 1.增加课程 2.把学生增加到班级 3.增加上课记录 4.修改学生成绩 q.退出 ''' print(msg) choice = input(">>") if choice == "1": #增加课程 current_sub = [] res = teacher.get_current_subject() for item in res: current_sub.append(item.name.lower()) print("当前已有课程:{}".format(current_sub)) print("请输入需要添加的课程:") subject_name = input(">>") #判断输入的课程是否与已有的课程重名,有重名则不必添加。 if subject_name.lower() in current_sub: print("已经有这个课程了。") else: #执行增加课程的方法。 ret = teacher.add_subject(subject_name) print(ret) elif choice == "2": #把学生增加到班级 print("请输入学生qq号:") qq = input(">>") print("请输入课程名称:") subject_name = input(">>") #执行增加学员到课程中的方法。 teacher.add_student_to_subject(qq, subject_name) elif choice == "3": #增加上课记录 current_sub = [] res = teacher.get_current_subject() for item in res: current_sub.append(item.name) print("当前已有课程:{}".format(current_sub)) print("请输入需要添加上课记录的课程:") subject_name = input(">>") #判断输入的课程是否为已有的课程。 if subject_name in current_sub: #执行增加上课记录的方法。 teacher.add_study_record(subject_name) else: print("输入有误.") elif choice == "4": #修改学生成绩 qq = input("请输入学生qq号:") subject_name = input("课程名称:") ret = teacher.modify_score(subject_name, qq) elif choice == "q": run() else: print("请输入正确的选项")
def teacher_op(name): teacher = Teacher(name) print(''' 1.create a student 2.create a class 3.create a course 4.create a teacher 5.manage students in my class 6.active a class 7.have a lesson 8.review homework 9.exit ''') while True: inp = input("Input function>>:") if inp == '1': teacher.create_student() elif inp == '2': teacher.create_class() elif inp == '3': teacher.create_course() elif inp == '4': teacher.create_teacher() elif inp == '5': teacher.manage_student() elif inp == '6': teacher.active_class() elif inp == '7': teacher.having_lession() elif inp == '8': teacher.review_homework() elif inp == '9': break else: print("Invalid!")