Ejemplo n.º 1
0
def updateCidBylessonid(cid):
    data = request.get_json(force=True)
    courseid = int(cid)
    # step1 reset courseid to 0 for current all lesson
    # courseid = 0 , it mean no correlation for this lesson
    for lesson in LessonModel.GetLessonsByCourseid(courseid):
        LessonModel.UpdateCidByLid(0, lesson['id'])

    # step2 update courseid according to lessonid
    for lid in data['corLessonids']:
        errcode = LessonModel.UpdateCidByLid(courseid, int(lid))
    return utils.jsonresp(jsonobj={'errcode': errcode})
Ejemplo n.º 2
0
def get_courses():
    limit = int(request.args.get('limit'))
    page = int(request.args.get('page'))
    name = request.args.get('name')
    if name:
        total, courses = CourseModel.SearchCourseByName(page, limit, name)
    else:
        total, courses = CourseModel.GetCourses(page, limit)
    # get relation lessons information
    for i in range(len(courses)):
        courses[i]['lessonInfo'] = []
        #query student according members[i]['id']
        lessons = LessonModel.GetLessonsByCourseid(courses[i]['id'])
        for lesson in lessons:
            # get lesson information
            courses[i]['lessonInfo'].append(lesson)
        courses[i]['teacherInfo'] = []
        teachers = CTeacherModel.GetTeacherByCourseid(courses[i]['id'])
        for th in teachers:
            courses[i]['teacherInfo'].append({'teacher_id':th['teacher_id'],'teacher_name':th['teacher_name'],'teacher_mobile':th['teacher_mobile']})
    return utils.jsonresp(jsonobj={'total':total, 'limit':limit, 'courses':courses})