Beispiel #1
0
def create_student():
    classes_list = Classes.get_obj_list()
    for k, obj in enumerate(classes_list):
        print(
            k, '\033[33;1m班级名:[%s] 学校:[%s] 地址:[%s] 课程:[%s] 讲师:[%s]\033[0m ' %
            (obj.name, obj.school_id.get_obj_uuid().name,
             obj.school_id.get_obj_uuid().addr,
             obj.course_teacher_id.get_obj_uuid().
             course_id.get_obj_uuid().name, obj.course_teacher_id.get_obj_uuid(
             ).teacher_id.get_obj_uuid().name))
    choose = input('选择班级 >> ').strip()
    if choose.isdigit():
        choose = int(choose)
        if choose < len(Classes.get_obj_list()):
            choose_classes = classes_list[choose]
            name = input('输入学生名字 >> ').strip()
            pas = input('输入学生密码 >> ').strip()
            age = input('输入学生年龄 >> ').strip()
            student_list = [obj.name for obj in Student.get_obj_list()]
            if name in student_list:
                print('\033[31;学生 [%s] 已存在,不可重复创建0m\033[0m' % name)
            else:
                student = Student(name, pas, age,
                                  choose_classes.nid)  # 需要存一个nid
                student.save()
                print('\033[32;1m学生 [%s] 创建成功\033[0m' % name)
        else:
            print('\033[31;1m 没有此班级,请重新选择\033[0m')
Beispiel #2
0
def show_classes():
    for obj in Classes.get_obj_list():
        print('\033[33;1m班级名:[%s] 学校:[%s] 地址:[%s] 课程:[%s] 讲师:[%s]\033[0m ' % (
            obj.name, obj.school_id.get_obj_uuid().name,
            obj.school_id.get_obj_uuid().addr,
            obj.course_teacher_id.get_obj_uuid().course_id.get_obj_uuid().name,
            obj.course_teacher_id.get_obj_uuid().teacher_id.get_obj_uuid().name
        ))
Beispiel #3
0
 def show_classes_info(self):
     # username = input(' username >> ')
     classes_info = Classes.get_obj_list()
     count = 0
     for obj in classes_info:
         teacher = obj.course_teacher_id.get_obj_uuid().teacher_id.get_obj_uuid().name
         if self.username == teacher:
             print('\033[36;1m讲师:%s 班级:%s 学校[%s]-地址[%s] 课程:[%s]\033[0m' % (teacher, obj.name, obj.school_id.get_obj_uuid().name, obj.school_id.get_obj_uuid().addr,
                   obj.course_teacher_id.get_obj_uuid().course_id.get_obj_uuid().name))
             count += 1
     print('\033[32;1m count: %s\033[0m' % count)
Beispiel #4
0
def create_classes():
    school_list = School.get_obj_list()  # 所有学校列表
    for k, obj in enumerate(school_list):
        print(k, '学校:[%s]  地址:[%s]' % (obj.name, obj.addr))
    choose = input('选择学校 >> ').strip()
    if choose.isdigit():
        choose = int(choose)
        if choose < len(School.get_obj_list()):
            choose_school = school_list[choose]  # 选择的学校
            name = input('请输入班级名字 >> ')
            classes_list = [obj.name for obj in Classes.get_obj_list()]
            if name in classes_list:
                print('\033[31;1m班级[%s] 已存在\033[0m' % name)
            else:
                course_teacher_list = Course_teacher.get_obj_list()
                for j, ct in enumerate(course_teacher_list):
                    print(j,
                          ct.course_id.get_obj_uuid().name,
                          ct.teacher_id.get_obj_uuid().name)
                choose_course_teacher = input('选择关联的课程讲师 >> ').strip()
                choose_ct_id = course_teacher_list[int(choose_course_teacher)]
                classes = Classes(name, choose_school.nid, choose_ct_id.nid)
                classes.save()
                print('\033[32;1m班级[%s] 创建成功\033[0m' % name)