Example #1
0
def save_page(id,count):

    try:
        answer_json = request.json
        print  answer_json
        # 在进入页面时loginfo列表添加了新的一项此时为对应下标应-1
        ExamConditionService.save_page(id,current_user.user_id,None,answer_json,count)
        return json.dumps({'key':'success'})
    except:
        return json.dumps({'key':'failed'})
Example #2
0
def examing(id,count):
    if request.method == 'GET':
        #记录登入信息,更新参考用户
        login_ip = request.remote_addr
        ExamConditionService.update_exam_condition_begin(id,current_user.user_id,login_ip)
        #生成考试页面存储到my_answer里
        page_dict = create_page(id)
        page_dict['now_time'] = int(time.time())
        page_dict['end_time'] = page_dict['now_time'] + page_dict['times'] * 60
        exam_page_json = json.dumps(page_dict)
        ExamConditionService.save_page(id, current_user.user_id, exam_page_json, None, count)
        return render_template('web/exam/exam.html',id=id)
Example #3
0
def exam_finish(id,count):
    exam_answer = request.json
    ExamConditionService.save_page(id,current_user.user_id,None,exam_answer,count)
    print exam_answer
    logout_ip = request.remote_addr
    ExamConditionService.update_exam_condition(id,current_user.user_id,logout_ip,count)

    grade = 0
    problem_condition_dict = ExamService.get_problem_condition_dict_byid(id)

    for pid, answer in exam_answer['choice'].items():
        problem = ProLibService.get_problem_detailed_info(pid)
        if answer == problem.answer:
            grade += problem_condition_dict['choice']['score']

    ExamConditionService.update_user_exam_grade(id, current_user.user_id, grade, count)

    return json.dumps({'key':'success'})