コード例 #1
0
ファイル: exam_list_web.py プロジェクト: acmchen/OnlineTest
def show_exam(id):
    if request.method == 'GET':
        user_info = {}
        if current_user.user_level > 1:
            condition = ExamConditionService.get_user_exam_condition_by_examid(
                id)
            for con in condition:
                user_info[con.sutdent_id] = UserService.get_userinfo_by_id(
                    con.sutdent_id)
            condition = zip(condition, range(1, len(condition) + 1))
            return render_template('web/exam/look_exam.html',
                                   condition=condition,
                                   user_info=user_info,
                                   current_user=current_user)

        elif current_user.user_level == 1:
            user_info_dict = {}
            condition_list = []
            condition = ExamConditionService.get_user_exam_condition_by_userid(
                id, current_user.user_id)
            user_info = UserService.get_userinfo_by_id(current_user.user_id)
            user_info_dict[condition.student_id] = user_info
            condition_list.append(condition)
            condition_list = zip(condition_list,
                                 range(1,
                                       len(condition_list) + 1))
            return render_template('web/exam/look_exam.html',
                                   condition=condition_list,
                                   user_info=user_info_dict,
                                   current_user=current_user)
コード例 #2
0
ファイル: auth.py プロジェクト: acmchen/OnlineTest
def load_user(id):
    if id is None:
        redirect(url_for('web.login'))
    userinfo = UserService.get_userinfo_by_id(id)
    user = UserLog(userinfo.user_id, userinfo.user_name, userinfo.level)
    if user.is_active:
        return user
    else:
        return None
コード例 #3
0
ファイル: exam_manage_web.py プロジェクト: acmchen/OnlineTest
def add_exam_member_single(id,user_id,page=1,values=''):
    try:
        if UserService.get_userinfo_by_id(user_id).status:
            ExamService.add_exam_member_single(id,user_id)
            ExamConditionService.add_user_exam_condition(id, user_id)
            flash('success')
        else:
            flash('failed')
    except:
        flash('failed')

    if values == '':
        return redirect(url_for('web.exam_add_member', id=id, page=page))

    return redirect(url_for('web.exam_add_member',id=id,page=page,values=values))
コード例 #4
0
ファイル: exam_manage.py プロジェクト: acmchen/OnlineTest
def exam_member(id):
    form = ExamStudentSearchForm()
    apply_num = ExamService.get_apply_num_by_id(id)
    member_list = []
    for student in apply_num:
        member_list.append(UserService.get_userinfo_by_id(student))

    if request.method == 'GET':
        return render_template('admin/exam/exam_member.html',
                               id = id,
                               form = form,
                               member_list = member_list,
                               status=Config.STATUS,
                               active=Config.ADMIN_PAGE_ACTIVE['exam'])
    #对当前页面中用户进行筛选
    filter = []
    if form.validate_on_submit():

        if form.username.data:
            username = re.compile('.*'+form.username.data+'.*')
        if form.nickname.data:
            nickname = re.compile('.*'+form.nickname.data+'.*')
        if form.college.data:
            college = re.compile('.*'+form.college.data+'.*')
        if form.major.data:
            major = re.compile('.*'+form.major.data+'.*')
        for item in member_list:
            if username and username.search(item.user_name):
                filter.append(item)
                continue
            if nickname and nickname.search(item.nick_name):
                filter.append(item)
                continue
            if college and college.search(item.college_name):
                filter.append(item)
                continue
            if major and major.search(item.major_name):
                filter.append(item)
                continue
            if item.grade == form.grade.data or item.classnum == form.classnum.data:
                filter.append(item)
                continue

    return render_template('admin/exam/exam_member.html',
                           id=id,
                           form=form,
                           member_list=filter,
                           active=Config.ADMIN_PAGE_ACTIVE['exam'])
コード例 #5
0
ファイル: auth.py プロジェクト: acmchen/OnlineTest
def update_info():
    form = AuthUpdateForm()

    if request.method == 'GET':
        userinfo = UserService.get_userinfo_by_id(current_user.user_id)
        form.nickname.data = userinfo.nick_name
        form.email.data = userinfo.email
        form.college.data = userinfo.college_name
        form.major.data = userinfo.major_name
        form.grade.data = userinfo.grade
        form.classnum.data = userinfo.classnum
        return render_template('web/auth/update_info.html', form=form)

    if form.validate_on_submit():
        try:
            UserService.update_userinfo_auth(form, current_user.user_id)
            flash('Update Success')
        except:
            flash('Update Failed')

    return render_template('web/auth/update_info.html', form=form)
コード例 #6
0
ファイル: auth.py プロジェクト: acmchen/OnlineTest
def user_info():
    if request.method == 'GET':
        userinfo = UserService.get_userinfo_by_id(current_user.user_id)
        return render_template('web/auth/info.html', user_info=userinfo)