def create_teacher(self, teacher_name): # 学校创建讲师 讲师关联学校 teacher_obj = teacher.Teacher(teacher_name, self.name) self.teacher_list.append(teacher_obj) with open(startxuanke.BASE_DIR + "\\db\\%s_teacher_obj.txt" % self.name, "wb+") as f: f.write(pickle.dumps(self.teacher_list)) f.close() return teacher_obj
def teacher_view(): """教师视图""" teacher_name = input("输入老师姓名:") teachers = teacher.Teacher(teacher_name) while True: choice = input("1.增加课程,2.增加上课记录,3.把学生增加到班级,4.修改学生成绩") if choice == "1": grade_name = input("课程名称:") ret = teachers.add_grade(grade_name) print(ret) elif choice == "2": grade_name = input("课程名称:") ret = teachers.add_grade_record(grade_name) print(ret) elif choice == "3": qq = input("请输入学生qq号:") grade_name = input("课程名称:") ret = teachers.add_student_to_grade(qq, grade_name) print(ret) elif choice == "4": qq = input("请输入学生qq号:") grade_name = input("课程名称:") date = input("上课时间:") score = input("成绩:") ret = teachers.modify_score(grade_name, qq, date, score) print(ret) else: print("请输入正确的选项") exit()
def create_teacher(self): print('\033[1;31;44m创建讲师\033[0m') teacher_name = input('teacher name:').strip() teacher_password = input('teacher password:'******'sex:').strip() # age = input('age:').strip() with open(settings.path_school_info, 'rb') as f: while True: try: school_obj = pickle.load(f) print(f"已创建的学校名单:{school_obj.name}") except EOFError: break tea_school = input('school(上海 or 北京):').strip() teacher_auth = f"\n{teacher_name}|{teacher_password}|Teacher" teacher_obj = teacher.Teacher(teacher_name) teacher_obj.school.append(tea_school) with open(settings.path_teacher_info, 'ab') as f: pickle.dump(teacher_obj, f) print(f'-----讲师{teacher_name}创建成功------') with open(settings.path_account, 'a', encoding='utf-8') as f: f.write(teacher_auth)
def create_teacher(self): # 输入老师用户名密码存入登陆信息到db print('---创建讲师---') name = input("输入讲师姓名:").strip() password = input("输入讲师密码:").strip() config.user_dic[name] = [password, 'teacher'] rw.write(config.userinfo, config.user_dic) # 输入老师所在学校 用户名 身份 学校 t = teacher.Teacher(name) rw.write("%s%s" % (config.teacher, name), t.__dict__)
ret = login() if ret['result']: print('登录成功') if ret['id'] == 'Admin': obj = admin.Admin(ret['name']) for id, item in enumerate(admin.Admin.operate_lst, 1): print(id, item[0]) func_str = admin.Admin.operate_lst[int(input('>>>')) - 1][1] if hasattr(obj, func_str): getattr(obj, func_str)() elif ret['id'] == 'Student': obj = student.Student(ret['name']) for id, item in enumerate(student.Student.operate_lst, 1): print(id, item[0]) func_str = student.Student.operate_lst[int(input('>>>')) - 1][1] if hasattr(obj, func_str): getattr(obj, func_str)() elif ret['id'] == 'Teacher': obj = teacher.Teacher(ret['name']) for id, item in enumerate(teacher.Teacher.operate_lst, 1): print(id, item[0]) func_str = teacher.Teacher.operate_lst[int(input('>>>')) - 1][1] if hasattr(obj, func_str): getattr(obj, func_str)() else: print('----输入错误-----') else: print('----输入错误,请重新输入-----') ret = login()