示例#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})
示例#2
0
def get_lessons():
    limit = int(request.args.get('limit'))
    page = int(request.args.get('page'))
    name = request.args.get('lessonname')
    if name:
        total, lessons = LessonModel.SearchLessonByName(page, limit, name)
    else:
        total, lessons = LessonModel.GetLessons(page, limit)
    return utils.jsonresp(jsonobj={
        'total': total,
        'limit': limit,
        'lessons': lessons
    })
示例#3
0
def delete_lessons(names):
    errcode = 0
    #nameList = names.split(',')
    for name in names.split(','):
        ret = LessonModel.DeleteLessonByname(name)
        if ret != 0:
            errcode = 1

    return utils.jsonresp(jsonobj={'errcode': errcode})
示例#4
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})
示例#5
0
def delete_lesson(name):
    errcode = LessonModel.DeleteLessonByname(name)
    return utils.jsonresp(jsonobj={'errcode': errcode})
示例#6
0
def update_lesson(name):
    data = request.get_json(force=True)
    errcode = LessonModel.UpdateLessonByName(data)
    return utils.jsonresp(jsonobj={'errcode': errcode})
示例#7
0
def create_lesson():
    data = request.get_json('content')
    errcode = LessonModel.CreateLesson(data)
    return utils.jsonresp(jsonobj={'errcode': errcode})
示例#8
0
def get_lessonsByName(name):
    lessons = LessonModel.GetLessonsByName(name)
    for i in range(len(lessons)):
        cName = CourseModel.GetNameById(lessons[i]['course_id'])
        lessons[i]['coursename'] = cName
    return utils.jsonresp(jsonobj={'lessons': lessons})
示例#9
0
def get_lessonById(lid):
    return utils.jsonresp(
        jsonobj={'lesson': LessonModel.GetLessonsBylessonid(lid)})