示例#1
0
 def add_teacher(self):  # 学校名称 姓名 班级列表 角色编号1;
     schools = self.school.myschooles
     while True:
         print(schools)
         info = input("请以逗号隔开输入教师编号(英文或数字),学校编号,教师名称(非空字符),密码\n")
         if re.fullmatch("^(\w)+[,|,]{1}(\d)+[,|,]{1}(\S)+[,|,]{1}(\S)+",
                         info):
             teacher_lis = re.split("[,|,]", info)
             if teacher_lis[1] in schools:
                 teacher_id = "T" + teacher_lis[0]
                 sch_id = teacher_lis[1]
                 sch_name = schools[teacher_lis[1]]["sch_name"]
                 teacher_name = teacher_lis[2]
                 pwd = teacher_lis[-1]
                 teacher_body = {
                     "sch_id": sch_id,
                     "sch_name": sch_name,
                     "teacher_name": teacher_name,
                     "role": 1,
                     "groups": [],
                     "pwd": pwd
                 }
                 teacher_dict = {teacher_id: teacher_body}
                 if teacher_lis[0] not in self.teachers:
                     self.teachers.update(teacher_dict)
                     print("添加教师 %s 成功" % teacher_lis[2])
                     write_datas(MYTEACHER_FILE, self.teachers)
                     break
                 else:
                     print("%s 教师已存在" % teacher_lis[0])
             else:
                 print("输入学校编号不存在,请参照提示按格式输入!")
         else:
             print("输入信息有误,请参照提示按格式输入!")
示例#2
0
 def add_stu(self):   # 学校名称 班级列表 姓名 成绩 学费状态 角色编号
     while True:
         print(self.school.myschooles)
         info = input("请以逗号隔开输入学生号(英文或数字),学校编号,学生名称(非空字符),密码\n").strip()
         if re.fullmatch("^(\w)+[,|,]{1}(\d)+[,|,]{1}(\S)+", info):
             student_lis = re.split("[,|,]", info)
             if student_lis[1] in self.school.myschooles:
                 stu_id = "S"+ student_lis[0]
                 sch_id = student_lis[1]
                 sch_name = self.school.myschooles[student_lis[1]]["sch_name"]
                 stu_name = student_lis[2]
                 pwd = student_lis[-1]
                 stu_body = {"sch_id":sch_id,"sch_name":sch_name,"stu_name":stu_name,"is_pay":0,"role":0,"pwd":pwd}
                 student_dict = {stu_id:stu_body}
                 if student_lis[0] not in self.stus:
                     self.stus.update(student_dict)
                     print("学生 %s 注册成功" % student_lis[2])
                     write_datas(MYSTUDENT_FILE, self.stus)
                     return stu_id
                 else:
                     print("%s 学生已存在" % student_lis[0])
             else:
                 print("输入学校编号不存在,请参照提示按格式输入!")
         else:
             print("输入信息有误,请参照提示按格式输入!")
示例#3
0
 def modify_stu_score(self, teacher_id):
     if not self.teachers[teacher_id]['groups']:
         print("还没有选择班级!")
         return None
     while True:
         has_stus = 0
         for k, v in self.stus.items():
             if v.get('group_id') in self.teachers[teacher_id]['groups']:
                 has_stus = 1
                 print(k, v)
         if has_stus:
             info = input("请以逗号隔开输入学生编号,成绩\n")
             if re.fullmatch("^(\w)+[,|,]{1}(\d)+", info):
                 info = re.split("[,|,]", info)
                 if info[0] in self.stus and info[1].isdigit():
                     self.stus[info[0]]["score"] = float(info[1])
                     write_datas(MYSTUDENT_FILE, self.stus)
                     print("修改 %s 的成绩为 %s 成功" %
                           (self.stus[info[0]]["stu_name"], info[1]))
                     break
                 print("选择的学生编号不存在 或 输入的成绩不是数字!")
             print("未按格式输入!")
         else:
             print("您的课程还没有加入学生!")
             break
示例#4
0
文件: group.py 项目: skylx001/oldboy2
 def add_myclass(self):  # 学校名称 班级名称 课程名 教师列表 学员列表
     courses = self.course.mycourses
     while True:
         print(courses)
         info = input("请以逗号隔开输入课程编号,班级号(英文或数字),班级名称(非空字符)\n")
         if re.fullmatch("^(\w)+[,|,]{1}(\w)+[,|,]{1}(\S)+", info):
             group_lis = re.split("[,|,]", info)
             if group_lis[0] in self.course.mycourses:
                 group_body = {}
                 group_id = group_lis[1]
                 group_body["group_name"] = group_lis[-1]
                 group_body["sch_id"] = courses[group_lis[0]]["sch_id"]
                 group_body["sch_name"] = courses[group_lis[0]]["sch_name"]
                 group_body["crs_id"] = group_lis[0]
                 group_body["crs_name"] = courses[group_lis[0]]["crs_name"]
                 group_body["teachers"] = []
                 group_body["students"] = []
                 course_dict = {group_id: group_body}
                 if group_lis[1] not in self.myclasses:
                     self.myclasses.update(course_dict)
                     print("添加班级 %s 成功" % group_body["group_name"])
                     write_datas(MYCLASS_FILE, self.myclasses)
                     break
                 else:
                     print("%s 班级编号已存在" % group_lis[2])
             else:
                 print("输入学校或课程编号不存在,请参照提示按格式输入!")
         else:
             print("输入信息有误,请参照提示按格式输入!")
示例#5
0
 def del_myschool(self):
     while True:
         info = input("请输入待删除的学校账号:\n")
         if info in self.myschooles:
             del self.myschooles[info]
             write_datas(MYSCHOOL_FILE, self.myschooles)
             print("删除学校 %s 成功!" % info)
             break
         else:
             print("学校不存在")
示例#6
0
 def del_myteacher(self):
     while True:
         info = input("请输入待删除的教师编号:\n")
         if info in self.teachers:
             del self.teachers[info]
             write_datas(MYTEACHER_FILE, self.teachers)
             print("删除教师 %s 成功!" % info)
             break
         else:
             print("教师不存在")
示例#7
0
 def del_mystudent(self):
     while True:
         info = input("请输入待删除的学生编号:\n").strip()
         if info in self.stus:
             del self.stus[info]
             write_datas(MYSTUDENT_FILE, self.stus)
             print("删除学生 %s 成功!" % info)
             break
         else:
             print("学生不存在")
示例#8
0
 def del_mycourse(self):
     while True:
         info = input("请输入待删除的课程编号:\n")
         if info in self.mycourses:
             del self.mycourses[info]
             write_datas(MYCOURSE_FILE, self.mycourses)
             print("删除课程 %s 成功!" % info)
             break
         else:
             print("课程不存在")
示例#9
0
文件: group.py 项目: skylx001/oldboy2
 def del_myclass(self):
     while True:
         info = input("请输入待删除的班级账号:\n")
         if info in self.myclasses:
             del self.myclasses[info]
             write_datas(MYCLASS_FILE, self.myclasses)
             print("删除班级 %s 成功!" % info)
             break
         else:
             print("班级不存在")
示例#10
0
 def add_myschool(self):
     while True:
         info = input("请以逗号隔开输入学校号(英文或数字),学校名称(非空字符)\n")
         if re.fullmatch("^(\w)+[,|,]{1}\S+", info):
             school_lis = re.split("[,|,]", info)
             school_dict = {school_lis[0]: {"sch_name": school_lis[1]}}
             if school_lis[0] not in self.myschooles:
                 self.myschooles.update(school_dict)
                 print("添加学校 %s 成功" % school_lis[0])
                 write_datas(MYSCHOOL_FILE, self.myschooles)
                 break
             else:
                 print("%s 学校已存在" % school_lis[0])
         else:
             print("输入信息有误,请参照提示按格式输入!")
示例#11
0
 def pay_class(self,stu_id):
     if self.stus[stu_id].get("group_id"):
         if not self.stus[stu_id]["is_pay"]:
             group_id = self.stus[stu_id]["group_id"]
             crs_id = self.group.myclasses[group_id]["crs_id"]
             course_price = self.course.mycourses[crs_id]["price"]
             while True:
                 money = input("请缴费 %s \n" % course_price).strip()
                 if money.isdigit() and float(money) == course_price:
                     self.stus[stu_id]["is_pay"] = 1
                     write_datas(MYSTUDENT_FILE, self.stus)
                     print("缴费成功!")
                     break
                 else:
                     print("缴费金额不是 %s " % course_price)
         else:
             print("学费已经交过了!")
     else:
         print("您还没添加课程!")
示例#12
0
 def choose_class(self, teacher_id):
     if not self.groups:
         print("还没有班级,请稍后!")
         return None
     while True:
         for k, v in self.groups.items():
             if v['sch_id'] == self.teachers[teacher_id]['sch_id']:
                 print(k, v)
         choice = input("请输入班级编号选择班级\n")
         if choice in self.teachers[teacher_id].get("groups"):
             print("你已经选择了班级 %s " % self.groups.get(choice)['group_name'])
             return self.groups.get(choice)
         if choice in self.groups:
             self.teachers[teacher_id].get("groups").append(choice)
             self.groups.get(choice)['teachers'].append(teacher_id)
             write_datas(MYTEACHER_FILE, self.teachers)
             write_datas(MYCLASS_FILE, self.groups)
             print("选择班级 %s 成功!" % self.groups.get(choice)['group_name'])
             return self.groups.get(choice)
         print("选择的班级编号不存在!")
示例#13
0
 def choose_class(self,stu_id):
     if self.stus[stu_id].get("group_name"):
         print("你已经选择了班级 %s " % self.stus[stu_id].get("group_name"))
         return self.stus[stu_id].get("group_name")
     if not self.group.myclasses:
         print("还没有班级,请稍后!")
         return None
     while True:
         for k,v in self.group.myclasses.items():
             print(k,v)
         choice = input("请输入班级编号选择班级\n").strip()
         if choice in self.group.myclasses:
             self.stus[stu_id]["group_id"] = choice
             self.stus[stu_id]["group_name"] = self.group.myclasses[choice]["group_name"]
             self.group.myclasses[choice]["students"].append(stu_id)
             write_datas(MYSTUDENT_FILE, self.stus)
             write_datas(MYCLASS_FILE, self.group.myclasses)
             print("选择班级 %s 成功,赶快去缴费吧!" % self.stus[stu_id]["group_name"])
             break
         print("选择的班级序号不存在!")
示例#14
0
 def add_mycourse(self):  # 学校名称 课程名 周期 价格
     while True:
         print(self.school.myschooles)
         info = input(
             "请以逗号隔开输入课程号(英文或数字),学校编号,课程名称(非空字符),周期(月为单位),价格(单位元)\n")
         if re.fullmatch(
                 "^(\w)+[,|,]{1}(\d)+[,|,]{1}(\w)+[,|,]{1}(\d)+[,|,]{1}(\d)+",
                 info):
             course_lis = re.split("[,|,]", info)
             if course_lis[1] in self.school.myschooles:
                 crs_id = course_lis[0]
                 sch_id = course_lis[1]
                 sch_name = self.school.myschooles[
                     course_lis[1]]["sch_name"]
                 crs_name = course_lis[2]
                 period = course_lis[3]
                 price = int(course_lis[4])
                 course_body = {
                     "sch_id": sch_id,
                     "sch_name": sch_name,
                     "crs_name": crs_name,
                     "period": period,
                     "price": price
                 }
                 course_dict = {crs_id: course_body}
                 if course_lis[0] not in self.mycourses:
                     self.mycourses.update(course_dict)
                     print("添加课程 %s 成功" % course_lis[2])
                     write_datas(MYCOURSE_FILE, self.mycourses)
                     break
                 else:
                     print("%s 课程已存在" % course_lis[0])
             else:
                 print("输入学校编号不存在,请参照提示按格式输入!")
         else:
             print("输入信息有误,请参照提示按格式输入!")