Ejemplo n.º 1
0
def student():
    if request.method == "GET":
        print(session['username'])
        stu_ID = session['username']
        stu_data = models.search_student(stu_ID)
        print(stu_data)
        stu_course = stu_data[10]
        session['course_id1'] = stu_course[0:7]
        session['course_id2'] = stu_course[8:15]
        session['course_id3'] = stu_course[16:23]
        #session['course_id'] = stu_data[10]
        #print(session['course_id3'])
        ID_1 = session['course_id1']
        ID_2 = session['course_id2']
        ID_3 = session['course_id3']
        course_data_1 = models.search_course(ID_1)
        course_data_2 = models.search_course(ID_2)
        course_data_3 = models.search_course(ID_3)
        homework_data_1 = models.search_homework(ID_1, "1")
        homework_data_2 = models.search_homework(ID_2, "1")
        homework_data_3 = models.search_homework(ID_3, "1")
    return render_template('student_home.html',
                           course_data_1=course_data_1,
                           course_data_2=course_data_2,
                           course_data_3=course_data_3,
                           homework_data_1=homework_data_1,
                           homework_data_2=homework_data_2,
                           homework_data_3=homework_data_3)
Ejemplo n.º 2
0
def allhomework():
    if request.method == "GET":
        ID_1 = session['course_id1']
        ID_2 = session['course_id2']
        ID_3 = session['course_id3']
        course_data_1 = models.search_course(ID_1)
        course_data_2 = models.search_course(ID_2)
        course_data_3 = models.search_course(ID_3)
        homework_data_1 = models.search_homework(ID_1, "1")
        homework_data_2 = models.search_homework(ID_2, "1")
        homework_data_3 = models.search_homework(ID_3, "1")
        return render_template('student_allhomework.html',
                               course_data_1=course_data_1,
                               course_data_2=course_data_2,
                               course_data_3=course_data_3,
                               homework_data_1=homework_data_1,
                               homework_data_2=homework_data_2,
                               homework_data_3=homework_data_3)
Ejemplo n.º 3
0
def api_find_course_3():
    session['course_id'] = session['course_id3']
    print(session['course_id'])
    ID = session['course_id']
    data = models.search_course(ID)
    homework = models.search_homework(ID, "1")
    # Str = data['CourseName']
    # print(Str)
    # file = '1.jpg'
    # download(file)
    return render_template('student_course.html', Str=data, homework=homework)
Ejemplo n.º 4
0
def api_upload_slides():
    ID = session['course_id']
    data = models.search_course(ID)
    homework = models.search_homework(ID, "1")
    # homework[5] = 'Red-Black Trees'
    file_dir = os.path.join(basedir,
                            app.config['UPLOAD_SLIDES_FOLDER'])  # 拼接成合法文件夹地址
    if not os.path.exists(file_dir):
        os.makedirs(file_dir)  # 文件夹不存在就创建
    f = request.files['myfile']  # 从表单的file字段获取文件,myfile为该表单的name值
    if f and allowed_file(f.filename):  # 判断是否是允许上传的文件类型
        f.save(os.path.join(file_dir, f.filename))  # 保存文件到upload目录
        return render_template('course-single.html',
                               Str=data,
                               homework=homework)
Ejemplo n.º 5
0
def api_upload():
    file_dir = os.path.join(basedir, app.config['UPLOAD_FOLDER'])  # 拼接成合法文件夹地址
    if not os.path.exists(file_dir):
        os.makedirs(file_dir)  # 文件夹不存在就创建
    f = request.files['myfile']  # 从表单的file字段获取文件,myfile为该表单的name值
    if f and allowed_file(f.filename):  # 判断是否是允许上传的文件类型
        fname = f.filename
        ext = fname.rsplit('.', 1)[1]  # 获取文件后缀
        unix_time = int(time.time())
        new_filename = str(unix_time) + '.' + ext  # 修改文件名
        f.save(os.path.join(file_dir, new_filename))  #保存文件到upload目录
        #ID = session['course_id1']
        #data = models.search_course(ID)
        session['course_id'] = session['course_id1']
        print(session['course_id'])
        ID = session['course_id']
        data = models.search_course(ID)
        homework = models.search_homework(ID, "1")
        return render_template('student_course.html',
                               Str=data,
                               homework=homework)
Ejemplo n.º 6
0
def api_tfind_course_3():
    session['course_id'] = session['course_id3']
    ID = session['course_id']
    data = models.search_course(ID)
    homework = models.search_homework(ID, "1")
    return render_template('course-single.html', Str=data, homework=homework)
Ejemplo n.º 7
0
def api_find_homework_3():
    courseid = session['course_id3']
    number = "1"
    data = models.search_homework(courseid, number)
    return render_template('student_homework.html', Str=data)
Ejemplo n.º 8
0
def student_homework():
    if request.method == "GET":
        courseid = session['course_id']
        number = "1"
        data = models.search_homework(courseid, number)
    return render_template('student_homework.html', Str=data)