Ejemplo n.º 1
0
def choose_class(teacher, teacher_list):
    """
    :param teacher: 当前登录系统的老师
    :param teacher_list: 所有老师的列表
    :return:
    """
    # 加载所有的Course
    course_list = UserDb.load_from_memory('Course')
    for c in course_list:
        if not c.course_teacher:
            print(c)
    choice = input('请选择要教授的课程:\n')
    if choice in set([c.course_name for c in course_list]):
        # 找到教师要教授课程的索引位置,并将老师姓名加入到课程中
        index = -1
        for t in course_list:
            index += 1
            if t.course_name == choice:
                break
        course_list[index].course_teacher = teacher.name

        UserDb.write_to_memory('Course', course_list)
        choose_course = course_list[index]
        # 找到老师列表中国老师的索引位置,并将课程加入到列表中
        index = -1
        for t in teacher_list:
            index += 1
            if t.name == teacher.name:
                break
        teacher_list[index].course_list.append(choose_course)
        UserDb.write_to_memory('Teacher', teacher_list)
Ejemplo n.º 2
0
def choose_class(local_student):
    # 加载课程列表,输出所有没有老师上课的课程
    course_list = UserDb.load_from_memory('Course')
    for c in course_list:
        if c.course_teacher:
            print(c)
    choice = input('请选择要教授的课程:\n')
    if choice in set([c.course_name for c in course_list]):
        student_list = UserDb.load_from_memory('Student')
        # 找到当前学生在学生列表中的位置,并增加选课信息
        index = -1
        for t in student_list:
            index += 1
            if t.name == local_student.name:
                break
        student_list[index].add_course(choice)
        # 找到当前课程在课程列表中的位置,并增加学生信息
        index = -1
        for t in course_list:
            index += 1
            if t.course_name == choice:
                break
        course_list[index].course_student.append(
            StudentScore(local_student.name, '-1'))
        # 将Course和Student列表存入到文件中
        UserDb.write_to_memory('Course', course_list)
        UserDb.write_to_memory('Student', student_list)
Ejemplo n.º 3
0
 def add_course(self):
     course_name = input('请输入课程名称:\n').strip()
     course_loc = input('请输入课程位置:\n').strip()
     course_price = input('请输入课程价格:\n').strip()
     course_time = input('请输入课程时间:\n').strip()
     c = Course(course_name, course_loc, course_price, course_time)
     self.course_list.append(c)
     UserDb.write_to_memory('Course', self.course_list)
     print(c)
Ejemplo n.º 4
0
def scoring(teacher):
    """
    :param teacher: 当前登录系统的老师
    :return:
    """
    course_list = UserDb.load_from_memory('Course')
    c_index = -1
    for c in course_list:
        c_index += 1  # 记录当前老师教授课程在课程列表中的位置
        if c.course_teacher == teacher.name:
            print('请给学生打分:\n')
            s_index = 0
            # 遍历选该课程的所有学生并打分
            for sc in c.course_student:
                score = input(sc.student_name + ":的分数为\n")
                course_list[c_index].course_student[s_index].score = score
                print(sc.student_name + ":分数为" + score)
    UserDb.write_to_memory('Course', course_list)
Ejemplo n.º 5
0
 def add_teacher(self):
     teacher_name = input('请输入老师的名称:\n').strip()
     t = Teacher(teacher_name)
     self.teacher_list.append(t)
     UserDb.write_to_memory('Teacher', self.teacher_list)
     print('增加教师:' + t.name)