示例#1
0
    def POST(self):
        mydata = web.input()
        print("删除题库", mydata)
        qb = model.Questions_bank_model()
        must_params = set(['qb_id'])
        web.header("Access-Control-Allow-Origin", "*")
        session = web.ctx.session
        # util.getFileRotatingLog().debug(session.password)           # 写入到log文件
        if (util.paramsok(must_params, mydata) == 2):
            response = util.Response(status=util.Status.__params_not_ok__)
            return util.objtojson(response)
        elif str(mydata.deletepassword) == session.password:
            qb.qb_id = mydata.qb_id
            result = model.Questions_bank_has_question_model.getByArgs( \
                questions_bank_qb_id = qb.qb_id)
            for item in result:
                questions_bank_has_question = model.Questions_bank_has_question_model(
                )
                questions_bank_has_question.qbhq_id = item.qbhq_id
                questions_bank_has_question.delete()

            if qb.delete():
                response = util.Response(status=util.Status.__success__)
                return util.objtojson(response)
            else:
                response = util.Response(status=util.Status.__error__,
                                         message="删除失败")
                return util.objtojson(response)
        else:
            response = util.Response(status=util.Status.__error__,
                                     message="密码错误")
            return util.objtojson(response)
        response = util.Response(status=util.Status.__error__, message="删除失败")
        return util.objtojson(response)
示例#2
0
 def GET(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     try:
         # session = web.ctx.session
         # username = ""
         if not username:
             print("not login")
             response = util.Response(status=util.Status.__not_login__,
                                      message='4')
             return util.objtojson(response)
     except Exception as e:
         print(e)
         response = util.Response(status=util.Status.__not_login__,
                                  message='4')
         return util.objtojson(response)
     teacher = model.Teacher_model.getByArgs(tc_id=session.username)
     if teacher[0].tc_level == '管理员':
         response = util.Response(status=util.Status.__success__,
                                  message='1')
         return util.objtojson(response)
     else:
         response = util.Response(status=util.Status.__success__,
                                  message='2')
         return util.objtojson(response)
示例#3
0
 def POST(self):
     mydata = web.input()
     print mydata
     web.header("Access-Control-Allow-Origin", "*")
     must_params = set({
         'cl_name',
         'currentPage',
     })
     if (util.paramsok(must_params, mydata) == 2):
         response = util.Response(status=util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         print 222
         currentPage = int(mydata.currentPage) - 1
         print mydata.cl_name
         result = orm.db.query(
             'select * from Class where cl_name like \'%%%s%%\'\
             order by cl_id limit %s,%s' %
             (mydata.cl_name, currentPage * 10, 10))
         result = [Class_model(**item) for item in result]
         Class = Class_model()
         result1 = Class.query(
             'select count(*) from Class where cl_name like \'%%%s%%\'' %
             (mydata.cl_name))
         count = result1[0]['count(*)']
         page = util.Page(data=result,
                          totalRow=count,
                          currentPage=int(mydata.currentPage),
                          pageSize=10,
                          status=util.Status.__success__,
                          message="未知")
         response = util.Response(status=util.Status.__success__, body=page)
         return util.objtojson(response)
示例#4
0
 def POST(self):
     mydata = web.input()
     print mydata
     web.header("Access-Control-Allow-Origin", "*")
     must_params = set({'qt_stem','currentPage',})
     question = model.Question_model()
     Knowledge = model.Knowledge_model() 
     currentPage = int(mydata.currentPage)-1;
     if(util.paramsok(must_params,mydata) == 2):
         response = util.Response(status = util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         print 222
         result = orm.db.query('select * from question where qt_stem like \'%%%s%%\'\
             order by qt_id limit %s,%s'%(mydata.qt_stem,currentPage*10,10))
         # result = orm.db.query('select * from question where qt_stem like \'%%%s%%\''%(mydata.qt_stem))
         questionlist = []
         result = [model.Question_model(**item) for item in result ]
         print result
         result1= question.query('select count(*) from question where qt_stem like \'%%%s%%\''%(mydata.qt_stem))
         count = result1[0]['count(*)']
         for params in result:
             qt = params
             qt['qt_type']=util.type[qt.qt_type]
             Knowledge = model.Knowledge_model()
             KnowledgeData = Knowledge.getByPK(qt.knowledge_kl_id) 
             qt['kl_name'] = KnowledgeData.kl_name 
             questionlist.append(qt)
         # response = util.Response(status=util.Status.__success__,body = questionlist)
         # return util.objtojson(response)
         page = util.Page(data = questionlist, totalRow = count, currentPage = int(mydata.currentPage), pageSize = 10, status=util.Status.__success__, message = "未知")
         response = util.Response(status=util.Status.__success__,body=page)
         return util.objtojson(response) 
示例#5
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     information = model.Information_model()
     information_data = information.query('SELECT * FROM information WHERE \
                 class_cl_id=%s and exam_ex_id=%s' % (params.class_cl_id, params.ex_id))
     information_data = [model.Information_model(**item) for item in information_data]
     exam = model.Exam_model.getByPK(params.ex_id)
     if exam.ex_type=="0":
         for information in information_data:
             information.in_endtime = datetime.datetime.now()
             information.in_state = '2'
             information.in_temp_ip = None
             db.update('exam_question', where="information_in_id = %s" % (information.in_id), eq_get_score='-2', )
             information.update()
         response = util.Response(status=util.Status.__success__, )
         return util.objtojson(response)
     else:
         if exam.ex_auto =="1":
             for information in information_data:
                 information.in_endtime = datetime.datetime.now()
                 if information.in_state=='1':
                     information.in_state = '2'
                     information.in_temp_ip = None
                     db.update('exam_question', where="information_in_id = %s" % (information.in_id),
                           eq_get_score='-2', )
                     information.update()
                     thread.start_new(util.GetScore, (1,information.in_id))
         response = util.Response(status=util.Status.__success__, )
         return util.objtojson(response)
示例#6
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     # str=os.path.abspath("test.docx")
     # str = str.decode('gbk')
     # print str
     classname = model.Class_model.getByPK(params.class_cl_id)
     examname = model.Exam_model.getByPK(params.ex_id)
     try:
         os.mkdir('%s/%s_%s' %
                  (exampage_source, params.class_cl_id, params.ex_id))
     except:
         shutil.rmtree('%s/%s_%s' %
                       (exampage_source, params.class_cl_id, params.ex_id))
     try:
         student = model.Student_has_class_model.getByArgs(
             class_cl_id=params.class_cl_id)
         for student_id in student:
             filepath = str('%s/%s_%s/%s.docx' %
                            (exampage_source, params.class_cl_id,
                             params.ex_id, student_id.student_st_id))
             # print filepath
             util.word(student_id.student_st_id, params.ex_id, filepath)
         util.zip_path(
             '%s/%s_%s' %
             (exampage_source, params.class_cl_id, params.ex_id),
             '%s' % (exampage_source),
             u'%s_%s.zip' % (params.class_cl_id, params.ex_id))
     except:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__, message=str)
     return util.objtojson(response)
示例#7
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     exam = model.Exam_model()
     must_params = exam.__notnull__
     if (util.paramsok(must_params, params) == 2):
         response = util.Response(status=util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         exam = model.Exam_model(**params)
         if exam.insert():
             result = exam.query("select max(ex_id) from exam")
             lastExamId = int(result[0]['max(ex_id)'])
             # 获取教务班学生id
             stuHasClass = model.Student_has_class_model()
             classId = params['class_cl_id'].encode('utf-8')
             classId = classId.split(',')
             for k in range(1, len(classId) - 1):
                 listStuid = stuHasClass.getByArgs(class_cl_id=classId[k])
                 for stuID in listStuid:
                     informationArgs = dict(
                         student_st_id=stuID.student_st_id,
                         exam_ex_id=lastExamId,
                         class_cl_id=classId[k],
                         sg_id=exam.strategy_sg_id)
                     information = model.Information_model(
                         **informationArgs)
                     information.insert()
             response = util.Response(status=util.Status.__success__)
             return util.objtojson(response)
         else:
             response = util.Response(status=util.Status.__error__)
             return util.objtojson(response)
示例#8
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     class_ = model.Class_model.getByPK(params.class_cl_id)
     exam = model.Exam_model.getByPK(params.ex_id)
     ex, cl = exam.ex_id, class_.cl_id
     ex_cl = u'%s_%s' % (ex, cl)
     examDir = u'%s/%s' % (exampage_source, ex_cl)
     try:
         os.mkdir(examDir)
     except:
         shutil.rmtree(examDir)
         os.mkdir(examDir)
     try:
         student = model.Student_has_class_model.getByArgs(
             class_cl_id=params.class_cl_id)
         for student_id in student:
             filepath = examDir + u'/%s.docx' % (student_id.student_st_id)
             print filepath
             util.word(student_id.student_st_id, params.ex_id, filepath)
         zip_path = u'/source/exampage/%s.zip' % (ex_cl)
         util.zip_path(examDir, u'%s' % (exampage_source),
                       u'%s.zip' % (ex_cl))
     except:
         print("e")
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__,
                              message=zip_path)
     return util.objtojson(response)
示例#9
0
    def POST(self):
        mydata = web.input()
        qb = model.Questions_bank_model()
        must_params = set (['qb_id'])
        web.header("Access-Control-Allow-Origin", "*")
        if(util.paramsok(must_params,mydata) == 2):
            response = util.Response(status = util.Status.__params_not_ok__)
            return util.objtojson(response)
        elif str(mydata.deletepassword) == '123456':
            qb.qb_id = mydata.qb_id
            result = model.Questions_bank_has_question_model.getByArgs( \
                questions_bank_qb_id = qb.qb_id)
            for item in result:
                questions_bank_has_question = model.Questions_bank_has_question_model()
                questions_bank_has_question.qbhq_id = item.qbhq_id
                questions_bank_has_question.delete()

            if qb.delete():
                response = util.Response(status=util.Status.__success__)
                return util.objtojson(response)
            else:
                response = util.Response(status=util.Status.__error__)
                return util.objtojson(response)
        response = util.Response(status=util.Status.__error__)
        return util.objtojson(response)
示例#10
0
    def POST(self):
        web.header("Access-Control-Allow-Origin", "*")
        must_params = ('st_id', 'st_name', 'cl_id')
        params = web.input()

        if util.paramsok(must_params, params) == Status.__params_not_ok__:
            response = util.Response(Status.__params_not_ok__, message='参数错误!')
            return util.objtojson(response)
        st_has_cl = Student_has_class_model(student_st_id=params.st_id,
                                            class_cl_id=params.cl_id)
        # del  params.cl_id
        s = Student_model(st_id=params.st_id)
        try:
            st_exist = s.getByArgs(**s)
            if st_exist:
                if st_has_cl.insert():
                    information = model.Information_model.query('select \
                                         distinct(exam_ex_id),sg_id from information where \
                                         class_cl_id = %s' % (params.cl_id))
                    if information != None:
                        information = [
                            model.Information_model(**item)
                            for item in information
                        ]
                        for item in information:
                            item.class_cl_id = params.cl_id
                            item.student_st_id = params.st_id
                            item.insert()
                    else:
                        print "none"
                    response = util.Response(Status.__success__,
                                             message="该学生已添加进课程班级")
                    return util.objtojson(response)
                response = util.Response(Status.__success__,
                                         message="该学生已存在于课程班级,不能重复添加!")
                return util.objtojson(response)
            else:
                s = Student_model(**params)
                s.insert()
                st_has_cl.insert()
                information = model.Information_model.query('select \
                    distinct(exam_ex_id),sg_id from information where \
                    class_cl_id = %s' % (params.cl_id))
                if information != None:
                    information = [
                        model.Information_model(**item) for item in information
                    ]
                    for item in information:
                        item.class_cl_id = params.cl_id
                        item.student_st_id = params.st_id
                        item.insert()
                else:
                    print "none"
                response = util.Response(Status.__success__,
                                         message="该学生已添加进课程班级!")
                return util.objtojson(response)
        except Exception as e:
            response = util.Response(Status.__error__, message="error")
            return util.objtojson(response)
示例#11
0
    def POST(self):
        web.header("Access-Control-Allow-Origin", "*")
        params = web.input()
        exam = model.Exam_model()
        must_params = exam.__notnull__
        if (util.paramsok(must_params, params) == 2):
            response = util.Response(status=util.Status.__params_not_ok__)
            return util.objtojson(response)
        else:
            exam = model.Exam_model(**params)
            if exam.update():
                # 获取教务班学生id
                stuHasClass = model.Student_has_class_model()
                classId = params['add_class_cl_id'].encode('utf-8')
                classId = classId.split(',')
                print 'add_class_cl_id'
                print classId
                for k in range(1, len(classId) - 1):
                    print 1234567
                    print classId[k]
                    listStuid = stuHasClass.getByArgs(class_cl_id=classId[k])
                    for stuID in listStuid:
                        informationArgs = dict(
                            student_st_id=stuID.student_st_id,
                            exam_ex_id=exam.ex_id,
                            class_cl_id=classId[k],
                            sg_id=exam.strategy_sg_id)
                        information = model.Information_model(
                            **informationArgs)
                        information.insert()

                delete_classId = params['delete_class_cl_id'].encode('utf-8')
                delete_classId = delete_classId.split(',')
                print 'delete_class_cl_id'
                print delete_classId
                for k in range(1, len(delete_classId) - 1):
                    listStuid = stuHasClass.getByArgs(
                        class_cl_id=delete_classId[k])
                    for stuID in listStuid:
                        # informationArgs = dict(student_st_id=stuID.student_st_id, exam_ex_id=exam.ex_id,
                        #                        class_cl_id=delete_classId[k])
                        # information = model.Information_model()
                        # information_id = information.getByArgs(informationArgs)
                        # information.in_id = information_id[0]['in_id']
                        # information.delete()
                        db.delete('information',
                                  where="student_st_id = $student_st_id \
                        and exam_ex_id = $exam_ex_id",
                                  vars={
                                      'student_st_id': stuID.student_st_id,
                                      'exam_ex_id': exam.ex_id
                                  })

                response = util.Response(status=util.Status.__success__)
                return util.objtojson(response)
            else:
                response = util.Response(status=util.Status.__error__)
                return util.objtojson(response)
示例#12
0
 def _get(self):
     try:
         request_id = self.request.arguments['request_id'][0].decode()
         check = int(util.getTranscriptionStatus(request_id))
         #t = util.test()
         print(request_id, check)
         if check < 100:
             return json.dumps(util.Response(
                 status=True,
                 message=
                 "Either transcription not completed or unsuccessful.",
                 data={
                     'progress': check,
                     'transcript': None
                 }).__dict__,
                               cls=util.CustomJSONEncoder)
         if check == 100:
             trans_files = util.getTranscriptFilename(request_id).split(',')
             print(trans_files)
             trans_file = trans_files[0]
             if os.path.isfile(trans_file):
                 with open(trans_file, 'r') as f:
                     transcript = json.load(f)
             transcript2 = None
             if len(trans_files) > 1:
                 trans_file2 = trans_files[1]
                 if os.path.isfile(trans_file2):
                     with open(trans_file2, 'r') as f:
                         transcript2 = json.load(f)
             return json.dumps(util.Response(
                 status=True,
                 message="Transcription successful.",
                 data={
                     'progress': check,
                     'transcript': transcript,
                     'transcript2': transcript2
                 }).__dict__,
                               cls=util.CustomJSONEncoder)
         return json.dumps(util.Response(
             status=False,
             message="Transcribed file is not available.",
             data={
                 'progress': check,
                 'transcript': None
             }).__dict__,
                           cls=util.CustomJSONEncoder)
     except Exception as ex:
         #logging.error(traceback.print_exc())
         logging.error(ex)
         return json.dumps(util.Response(status=False,
                                         message=str(ex),
                                         data={}).__dict__,
                           cls=util.CustomJSONEncoder)
示例#13
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     exam = model.Exam_model(**params)
     exam.delete()
     if exam.getByArgs(**params):
         response = util.Response(status=util.Status.__error__)
         return util.objtojson(response)
     else:
         response = util.Response(status=util.Status.__success__)
         return util.objtojson(response)
示例#14
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     print(params)
     teacher = model.Teacher_model(**params)
     if teacher.insert():
         response = util.Response(status=util.Status.__success__, )
         return 1
     else:
         response = util.Response(status=util.Status.__error__, )
         return 0
示例#15
0
 def POST(self):
     print("删除教师信息")
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     print(params)
     teacher = model.Teacher_model(**params)
     if teacher.delete():
         response = util.Response(status=util.Status.__success__, )
         return util.objtojson(response)
     else:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
示例#16
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     params.setdefault("in_state", '1')
     params.setdefault("in_ip", web.ctx.ip)
     information = model.Information_model(**params)
     if information.update():
         response = util.Response(status=util.Status.__error__)
         return util.objtojson(response)
     else:
         response = util.Response(status=util.Status.__success__)
         return util.objtojson(response)
示例#17
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     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_endtime = datetime.datetime.now()
     information.in_state = '2'
     information.in_temp_ip = None
     exam = model.Exam_model.getByPK(session.ex_id)
     if exam.ex_type == "0":
         util.SaveFillb(information.in_id)
         db.update(
             'exam_question',
             where="information_in_id = %s" % (information.in_id),
             eq_get_score='-2',
         )
         # information.in_score = util.upInformationScore(1000,information.in_id)
         # while 1:
         #     exam_question = model.Exam_question_model.getByArgs(information_in_id=information.in_id)
         #     information.in_score = 0
         #     flag = 0
         #     for question in exam_question:
         #         if question.eq_get_score >= 0:
         #             information.in_score += question.eq_get_score
         #         else:
         #             flag = 1
         #             break
         #     if flag == 0:
         #         break
         #
         information.in_state = '0'
         information.update()
         response = util.Response(status=util.Status.__params_ok__,
                                  message=information.in_score)
         return util.objtojson(response)
     else:
         if exam.ex_auto == "1":
             util.SaveFillb(information.in_id)
             db.update(
                 'exam_question',
                 where="information_in_id = %s" % (information.in_id),
                 eq_get_score='-2',
             )
             thread.start_new(util.GetScore, (1, information.in_id))
         information.update()
         response = util.Response(status=util.Status.__success__, )
         return util.objtojson(response)
示例#18
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     print params
     information=model.Information_model.getByPK(params.in_id)
     try:
         minutes = datetime.timedelta(minutes=int(params.delay_time))
         information.in_endtime += minutes
         information.update()
     except:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__,)
     return util.objtojson(response)
示例#19
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     session = web.ctx.session
     teacher = model.Teacher_model.getByArgs(tc_id=params.tc_id)
     if teacher[0].tc_password != params.password:
         response = util.Response(status=util.Status.__error__,
                                  message="password_error")
         return util.objtojson(response)
     else:
         session.username = params.tc_id
         response = util.Response(status=util.Status.__success__, )
         return util.objtojson(response)
示例#20
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     information=model.Information_model.getByPK(params.in_id)
     try:
         information.in_state ='3'
         information.in_score = 0
         information.update()
         db.update('exam_question', where="information_in_id=%s"%(params.in_id), eq_get_score=0, )
     except:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__,)
     return util.objtojson(response)
示例#21
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     print params
     information=model.Information_model.getByPK(params.in_id)
     try:
         information.in_ip =None
         information.in_temp_ip = None
         information.update()
     except:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__,)
     return util.objtojson(response)
示例#22
0
 def POST(self):
     mydata = web.input()
     qbhq = model.Questions_bank_has_question_model()
     web.header("Access-Control-Allow-Origin", "*")
     must_params = set({'qt_id'})
     if(util.paramsok(must_params,mydata) == 2):
         response = util.Response(status = util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         result = qbhq.getByArgs(question_qt_id = mydata.qt_id)
         for k in result:
             qbhq.qbhq_id = k.qbhq_id
             qbhq.delete()
         response = util.Response(status = util.Status.__success__)
         return util.objtojson(response)
示例#23
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*") 
     mydata = web.input()
     # must_params =set({'currentPage'})
     must_params =set({})
     if(util.paramsok(must_params, mydata) == 2):
         response = util.Response(status=util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         qb = model.Questions_bank_model()
         count = qb.count()
         reasurt = qb.getByPage(int(mydata.currentPage)-1)
         page = util.Page(data = reasurt, totalRow = count, currentPage = int(mydata.currentPage), pageSize = 10, status=util.Status.__success__, message = "未知")
         response = util.Response(status=util.Status.__success__,body=page)
         return util.objtojson(response) 
示例#24
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     count = model.Exam_model.count()
     currentPage = int(params.currentPage) - 1
     lists = model.Exam_model.query(
         'select * from exam order by ex_time_end desc limit %s,%s' %
         (currentPage * 10, 10))
     lists = [model.Exam_model(**item) for item in lists]
     for list in lists:
         start_time = list['ex_time_start'].strftime('%Y-%m-%d %H:%M:%S')
         end_time = list['ex_time_end'].strftime('%Y-%m-%d %H:%M:%S')
         del list['ex_time_start']
         del list['ex_time_end']
         list.setdefault('ex_time_start', start_time)
         list.setdefault('ex_time_end', end_time)
     page = util.Page(data=lists,
                      totalRow=count,
                      currentPage=int(params.currentPage),
                      pageSize=10,
                      status=util.Status.__success__,
                      message="未知")
     response = util.Response(status=util.Status.__success__, body=page)
     return util.objtojson(response)
示例#25
0
 def POST(self):
     mydata = web.input()
     kp = model.Knowledge_model()
     must_params = kp.__notnull__
     web.header("Access-Control-Allow-Origin", "*") 
     if(util.paramsok(must_params, mydata) == 2):
         response = util.Response(status=util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         kp = model.Knowledge_model(**mydata)
         if kp.insert():
             response = util.Response(status=util.Status.__success__)
             return util.objtojson(response)
         else:
             response = util.Response(status=util.Status.__error__)
             return util.objtojson(response)
示例#26
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     information=model.Information_model.getByPK(params.in_id)
     try:
         information.in_state ='0'
         information.in_score = None
         information.in_endtime = None
         information.update()
         db.delete('exam_question', where="information_in_id = $information_in_id",
                   vars={'information_in_id': params.in_id})
     except:
         response = util.Response(status=util.Status.__error__, )
         return util.objtojson(response)
     response = util.Response(status=util.Status.__success__,)
     return util.objtojson(response)
    def POST(self):


        web.header("Access-Control-Allow-Origin", "*")
        params = web.input()


        # class Params: #
        #     def __init__(self):
        #         self.ex_id=34
        #         self.class_cl_id=10
        #
        # params=Params()


        # args = dict[exam_ex_id:params.ex_id,class_cl_id:params.class_cl_id]
        student_info = Information_model.query('select * from information where exam_ex_id = %s\
             and class_cl_id = %s order by student_st_id'%(params.ex_id,params.class_cl_id))
        student_info = [Information_model(**item) for item in student_info]
        for student in student_info:
            result = Student_model.getByPK(student.student_st_id)
            student['student_name'] = result.st_name
            student['in_state']=util.in_state[int(student.in_state)]
        # args = dict( in_state=0,exam_ex_id=params.ex_id,class_cl_id=params.class_cl_id)
        # not_login_num = Information_model.count(**args)
        result = Information_model.query('select count(*) from information where in_state=%s\
                and class_cl_id=%s and exam_ex_id=%s'%(0,params.class_cl_id,params.ex_id))
        # login_num = Information_model.count(in_state=1)
        # print('----------------', util.objtojson(result))
        response = util.Response(Status.__success__, body=student_info,message=result[0]['count(*)'])
        return util.objtojson(response)
示例#28
0
 def POST(self):
     mydata = web.input()
     qb = model.Questions_bank_model()
     must_params = qb.__notnull__
     web.header("Access-Control-Allow-Origin", "*") 
     if(util.paramsok(must_params,mydata) == 2):
         response = util.Response(status = util.Status.__params_not_ok__)
         return util.objtojson(response)
     else:
         qb = model.Questions_bank_model(**mydata)
         if qb.update():
             response = util.Response(status=util.Status.__success__)
             return util.objtojson(response)
         else:
             response = util.Response(status=util.Status.__error__)
             return util.objtojson(response)
示例#29
0
 def POST(self):
     params = web.input()
     web.header("Access-Control-Allow-Origin", "*")
     exam = model.Exam_model.getByPK(params.ex_id)
     exam.ex_state = '1'
     delta = exam.ex_time_end - exam.ex_time_start
     exam.ex_time_start = datetime.datetime.now()
     exam.ex_time_end = exam.ex_time_start + delta
     exam.update()
     information_data = model.Information_model.query(
         'SELECT * FROM information WHERE \
                                 exam_ex_id=%s' % (params.ex_id))
     information_data = [
         model.Information_model(**items) for items in information_data
     ]
     for information in information_data:
         information.in_state = '0'
         information.inscore = -1
         information.in_ip = None
         information.update()
         db.delete('exam_question',
                   where="information_in_id = $information_in_id",
                   vars={
                       'information_in_id': information.in_id,
                   })
     response = util.Response(status=util.Status.__success__, )
     return util.objtojson(response)
示例#30
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     params = web.input()
     exam = model.Exam_model.getByPK(params.ex_id)
     exam.delete()
     response = util.Response(status=util.Status.__success__, )
     return util.objtojson(response)