Exemple #1
0
def upExamStatusFour(delay,ex_id):
    while 1:
        # print "four"
        time.sleep(delay)
        exam = model.Exam_model.getByPK(ex_id)
        informations = model.Information_model.getByArgs(exam_ex_id=ex_id)
        flag = 0
        for information in informations:
            information.in_score = util.upInformationScore(information.in_id)
            if information.in_score ==-1:
                flag = 1
                break
            else:
                information.update()
        if flag==0:
            exam.ex_state='4'
            exam.update()
            break
Exemple #2
0
#!/usr/bin/env python
Exemple #3
0
#!/usr/bin/env python
Exemple #4
0
    def POST(self):
        web.header("Access-Control-Allow-Origin", "*")
        params = web.input()
        information = model.Information_model()

        session = web.ctx.session
        information_data = information.query(
            'SELECT * FROM information WHERE \
            student_st_id=%s and exam_ex_id=%s' %
            (session.student_id, session.ex_id))
        information = model.Information_model(**information_data[0])
        information.in_score = util.upInformationScore(information.in_id)
        information.update()
        exam_question = model.Exam_question_model.getByArgs(
            information_in_id=information.in_id)
        choice_question = []
        judge_question = []
        # filla是读程序写结果
        filla_question = []
        fillb_question = []
        coding_question = []
        for item in exam_question:
            if item.eq_get_score == -2:
                item.eq_get_score = u'未出分'
            if item.eq_qt_type == 'choice':
                question_data = model.Question_model.getByPK(item.qt_id)
                choice_data = model.Choice_model.getByPK(item.qt_id)
                item = dict(item, **choice_data)
                item = dict(item, **question_data)
                choice_question.append(item)
            elif item.eq_qt_type == 'judge':
                question_data = model.Question_model.getByPK(item.qt_id)
                judge_data = model.Judge_model.getByPK(item.qt_id)
                item = dict(item, **judge_data)
                item = dict(item, **question_data)
                judge_question.append(item)
            elif item.eq_qt_type == 'filla':
                question_data = model.Question_model.getByPK(item.qt_id)
                filla_data = model.Filla_model.getByPK(item.qt_id)
                item = dict(item, **filla_data)
                item = dict(item, **question_data)
                filla_question.append(item)
            elif item.eq_qt_type == 'coding':
                question_data = model.Question_model.getByPK(item.qt_id)
                coding_data = model.Coding_model.getByPK(item.qt_id)
                item = dict(item, **coding_data)
                item = dict(item, **question_data)
                coding_question.append(item)
        fillb_qt = model.Exam_question_model.query(
            'select distinct(qt_id),\
                                                eq_pre_score from exam_question where information_in_id = %s \
                                                and eq_qt_type = %s' %
            (information.in_id, "'" + 'fillb' + "'"))
        for item in fillb_qt:
            question_data = model.Question_model.getByPK(item['qt_id'])
            fillb_data = model.Fillb_model.getByPK(item['qt_id'])
            eq_id_data = model.Exam_question_model.query('select eq_id,eq_answer,eq_get_score from \
                                                    exam_question where qt_id = %s and information_in_id = %s' \
                                                         % (item['qt_id'], information.in_id))
            eq_id_data = [
                model.Exam_question_model(**items) for items in eq_id_data
            ]
            for question in eq_id_data:
                if question.eq_get_score < 0:
                    question.eq_get_score = u'未出分'
            item = dict(item, **fillb_data)
            item = dict(item, **question_data)
            fillb = []
            fillb.append(item)
            fillb.append(eq_id_data)
            fillb_question.append(fillb)
        question_list = []
        question_list.append(choice_question)
        question_list.append(judge_question)
        question_list.append(filla_question)
        question_list.append(fillb_question)
        question_list.append(coding_question)
        student = model.Student_model.getByPK(session.student_id)
        exam = model.Exam_model.getByPK(session.ex_id)
        student['exam_name'] = exam.ex_name
        if information['in_score'] == -1:
            student['in_score'] = u'未出分,请稍后刷新该页面'
        else:
            student['in_score'] = information['in_score']
        question_list.append(student)
        time = information.in_endtime - datetime.datetime.now()
        count = time.seconds * 1000
        response = util.Response(status=util.Status.__success__,
                                 body=question_list,
                                 message=count)
        return util.objtojson(response)