def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     pageSize = 9999
     strategyTerm = model.Strategy_term_model(**params)
     currentPage = int(params.currentPage) - 1
     result = strategyTerm.query('select * from strategy_term where strategy_sg_id =%s \
         order by sm_id desc limit %s,%s' % (strategyTerm.strategy_sg_id, currentPage * pageSize, pageSize))
     strategyTermList = []
     total_score = 0
     for item in result:
         item['sm_type'] = util.type[item.sm_type]
         Knowledge = model.Knowledge_model()
         if item.sm_knowledge == 0:
             item['kl_name'] = "全部知识点"
         else:
             KnowledgeData = Knowledge.getByPK(item.sm_knowledge)
             item['kl_name'] = KnowledgeData.kl_name
         questionbackData = model.Questions_bank_model.getByPK(item.qb_id)
         item['qb_name'] = questionbackData.qb_name
         total_score += int(item['sm_score']) * int(item['sm_number'])
         strategyTermList.append(item)
     strategy = model.Strategy_model()
     strategy.sg_id = strategyTerm.strategy_sg_id
     strategy.sg_score = total_score
     strategy.update()
     result = strategyTerm.query('select count(*) from strategy_term where \
         strategy_sg_id =%s' % (strategyTerm.strategy_sg_id))
     page = util.Page(data=strategyTermList, totalRow=result[0]['count(*)'], currentPage=int(params.currentPage),
                      pageSize=pageSize, status=util.Status.__success__, message=total_score)
     response = util.Response(status=util.Status.__success__, body=page)
     return util.objtojson(response)
Beispiel #2
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) 
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     session = web.ctx.session
     currentPage = int(params.currentPage) - 1
     count = model.Teacher_model.count()
     if params.tc_name == '' and params.tc_id == '':
         teacher = model.Teacher_model.query(
             'select * from teacher where tc_level\
          = %s order by tc_id limit %s,%s' %
             ("'" + params.tc_level + "'", currentPage * 10,
              currentPage * 10 + 9))
         teacher = [model.Teacher_model(**item) for item in teacher]
         page = util.Page(data=teacher,
                          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)
     elif params.tc_name != '' and params.tc_id == '':
         teacher = model.Teacher_model.query(
             'select * from teacher where tc_name \
          like %s and tc_level = %s order by tc_id limit %s,%s' %
             (params.tc_name, "'" + params.tc_level + "'", currentPage * 10,
              currentPage * 10 + 9))
         teacher = [model.Teacher_model(**item) for item in teacher]
         page = util.Page(data=teacher,
                          totalRow=teacher.__len__(),
                          currentPage=int(params.currentPage),
                          pageSize=10,
                          status=util.Status.__success__,
                          message="未知")
         response = util.Response(status=util.Status.__success__, body=page)
         return util.objtojson(response)
     else:
         teacher = model.Teacher_model.getByPK(params.tc_id)
         page = util.Page(data=teacher,
                          totalRow=1,
                          currentPage=int(params.currentPage),
                          pageSize=10,
                          status=util.Status.__success__,
                          message="未知")
         response = util.Response(status=util.Status.__success__, body=page)
         return util.objtojson(response)
 def POST(self):
     web.header("Access-Control-Allow-Origin","*")
     params = web.input()
     count = model.Class_model.count()
     reasurt = model.Class_model.getByPage(int(params.currentPage) - 1)
     page = util.Page(data=reasurt, 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)
Beispiel #7
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     mydata = web.input()
     Knowledge = model.Knowledge_model()
     result = Knowledge.getByArgs()
     KnowledgeData = Knowledge.getByPage(int(mydata.currentPage)-1)
     page = util.Page(data = KnowledgeData, totalRow = len(result), currentPage = int(mydata.currentPage), pageSize = 10, status=util.Status.__success__, message = "未知")
     response = util.Response(status=util.Status.__success__,body=page)
     return util.objtojson(response)
Beispiel #8
0
def write_category(category, info, directory, number):
    """for each category, we'll make the following:
    - directories:
        - docs/documentation/{CATEGORY}
    - files:
        - docs/documentation/{CATEGORY}/{CATEGORY}.md
        - and for each ELEMENT, a file:
            - docs/documentation/{CATEGORY}/{ELEMENT}.md
    """
    category_dir = os.path.join(directory, category)
    util.clean_dir(category_dir)

    # write index
    if info.get('text'):
        with open(info['text'], 'r') as f:
            index_content = f.read()
    else:
        index_content = None

    index = util.Page(
        title=category,
        has_children=True,
        parent='documentation',
        content=index_content,
        permalink='/documentation/{category}/'.format(category=category),
        nav_order=number,
    )

    index.write(category_dir)

    for i, (element, components) in enumerate(info['elements'].items()):
        page_kwargs = {
            'title': element,
            'parent': category,
            'grand_parent': 'documentation',
            'nav_order': i + 1,
        }

        if components.get('text'):
            with open(components['text'], 'r') as f:
                page_kwargs['content'] = f.read()

        page = util.Page(**page_kwargs)
        page.write(category_dir)
Beispiel #9
0
 def GET(self):
     #must_params = ('name','id')
     params = web.input()  #通过web.input()获取的值为unicode编码,最好转码为utf-8
     requestPage = params['requestPage'].encode('utf-8')
     lists = Strategy_model.getByArgs()
     print "session", session.status
     data = []
     for each in lists:
         each_data = [each['sg_name'], each['sg_score']]
         data.append(each_data)
     return util.objtojson(util.Page(data, len(lists), requestPage))
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     currentPage = int(params.currentPage) - 1
     print(params)
     if params.ex_name == '':
         if params.ex_time_end == '' and params.ex_time_start != '':
             params.ex_time_end = '2200-12-12T12:12'
         if params.ex_time_end != '' and params.ex_time_start == '':
             params.ex_time_start = '2000-12-12T12:12'
         if params.ex_time_end == '' and params.ex_time_start == '':
             params.ex_time_start = '2000-12-12T12:12'
             params.ex_time_end = '2200-12-12T12:12'
         lists = model.Exam_model.query('select * from exam where ex_time_start >= %s \
             and ex_time_end <= %s order by ex_time_start desc limit %s,%s' \
                                        % ("'" + params.ex_time_start + "'", "'" + params.ex_time_end + "'",
                                           currentPage * 10, 10))
         result = model.Exam_model.query('select count(*) from exam where ex_time_start \
           >= %s and ex_time_end <= %s' % ("'" + params.ex_time_start + "'", "'" + params.ex_time_end + "'",))
     elif params.ex_time_start == '':
         lists = model.Exam_model.query('select * from exam where ex_name like \
           \'%%%s%%\' order by ex_time_start desc limit %s,%s' % (params.ex_name, currentPage * 10, 10))
         result = model.Exam_model.query('select count(*) from exam where ex_name like \
           \'%%%s%%\' ' % (params.ex_name))
     else:
         if params.ex_time_end == '':
             params.ex_time_end = '2200-12-12T12:12'
         lists = model.Exam_model.query('select * from exam where ex_name like \
           \'%%%s%%\' and ex_time_start >= %s and ex_time_end <= %s order by \
           ex_time_start desc limit %s,%s' % (
         params.ex_name, "'" + params.ex_time_start + "'", "'" + params.ex_time_end + "'", \
         currentPage * 10, 10))
         result = model.Exam_model.query('select count(*) from exam where ex_name like \
           \'%%%s%%\' and ex_time_start >= %s and ex_time_end <= %s' \
                                         % (params.ex_name, "'" + params.ex_time_start + "'",
                                            "'" + params.ex_time_end + "'",))
     count = result[0]['count(*)']
     lists = [model.Exam_model(**item) for item in lists]
     print(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)
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     # 接收参数
     params = web.input()
     currentPage = params['requestPage'].encode('utf-8')
     print(currentPage)
     del params['requestPage']
     args = dict(strategy_sg_id=params.get('strategy_sg_id'))
     totalCount = model.Strategy_term_model.count(**args)
     lists = model.Strategy_term_model.getByPage(int(currentPage), **args)
     currentPage = int(currentPage) + 1
     page = util.Page(data=lists, totalRow=totalCount, currentPage=currentPage, pageSize=10,
                      status=util.Status.__success__, message="")
     return util.objtojson(page)
Beispiel #12
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) 
Beispiel #13
0
    def POST(self):
        mydata = web.input()
        print mydata
        # 必须有的参数
        must_params = set({'questions_bank_qb_id', 'currentPage'})
        web.header("Access-Control-Allow-Origin", "*")
        currentPage = int(mydata.currentPage) - 1
        if (util.paramsok(must_params, mydata) == 2):
            print 333
            response = util.Response(status=util.Status.__params_not_ok__)
            return util.objtojson(response)
        else:
            question = model.Question_model()
            # result = orm.db.query('select * from question where qt_id in (select question_qt_id from questions_bank_has_question where questions_bank_qb_id = %s ) order by qt_id limit %s,%s'%(int(mydata.questions_bank_qb_id),currentPage*10,currentPage*10+9))
            result = orm.db.query(
                'select * from question where qt_id in \
                (select question_qt_id from questions_bank_has_question where questions_bank_qb_id = %s )\
                order by qt_id limit %s,%s' %
                (mydata.questions_bank_qb_id, currentPage * 10, 10))

            questionlist = []
            result = [model.Question_model(**item) for item in result]
            # print result
            result1 = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                from questions_bank_has_question where questions_bank_qb_id = %s )'
                % (mydata.questions_bank_qb_id))
            # print result1[0]
            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)
Beispiel #14
0
 def POST(self):
     web.header("Access-Control-Allow-Origin", "*")
     mydata = web.input()
     cl = model.Class_model()
     exam = model.Exam_model()
     information = model.Information_model()
     student = model.Student_model()
     information_data = orm.db.query(
         'select * from information where exam_ex_id = %s and class_cl_id = %s'
         % (mydata.ex_id, mydata.cl_id))
     # information_data = orm.db.query('select * from information where exam_ex_id = %s'%(mydata.ex_id))
     information_data = [
         model.Information_model(**item) for item in information_data
     ]
     student_data = []
     examquestion_data = []
     for k in information_data:
         result = student.getByArgs(st_id=k.student_st_id)
         student_data.append(result)
         k['in_state'] = util.in_state[int(k.in_state)]
         if k['in_score'] == -1:
             k['in_score'] = u'未出分'
         result = model.Exam_question_model.getByArgs(
             information_in_id=k.in_id)
         for question in result:
             if question.eq_get_score < 0:
                 question.eq_get_score = u'未出分'
         examquestion_data.append(result)
     data = []
     data.append(information_data)
     data.append(student_data)
     data.append(examquestion_data)
     page = util.Page(data=data,
                      totalRow=len(student_data),
                      currentPage=int(mydata.currentPage),
                      pageSize=10,
                      status=util.Status.__success__,
                      message="未知")
     response = util.Response(status=util.Status.__success__, body=page)
     return util.objtojson(response)
Beispiel #15
0
    def POST(self):
        web.header("Access-Control-Allow-Origin", "*")
        # 接收参数
        params = web.input()
        strategyTerm = model.Strategy_term_model()
        must_params = strategyTerm.__notnull__
        if (util.paramsok(must_params, params) == 2):
            response = util.Response(status=util.Status.__params_not_ok__)
            return util.objtojson(response)
        else:
            strategyTerm = model.Strategy_term_model(**params)
            sm_type = "'" + strategyTerm.sm_type + "'"
            # 判断题库题目数量是否足够,知识点id未0表示所有知识点
            if strategyTerm.sm_knowledge == "0":
                print "000000"
                question_result = strategyTerm.query('select count(*) from question where qt_id in \
                        (select question_qt_id from questions_bank_has_question where \
                        questions_bank_qb_id = %s) and qt_type=%s and \
                        qt_diffculty between %s and %s'                                                        % (strategyTerm.qb_id, sm_type,\
                        strategyTerm.sm_difficulty_low,strategyTerm.sm_difficulty_high))
                count = int(question_result[0]['count(*)'])
            else:
                question_result = strategyTerm.query('select count(*) from question where qt_id in \
                    (select question_qt_id from questions_bank_has_question where \
                    questions_bank_qb_id = %s) and qt_type=%s and knowledge_kl_id =%s \
                    and qt_diffculty between %s and %s'                                                        % (strategyTerm.qb_id, sm_type,\
                    strategyTerm.sm_knowledge, strategyTerm.sm_difficulty_low,\
                     strategyTerm.sm_difficulty_high))
                count = int(question_result[0]['count(*)'])
            if count < int(strategyTerm.sm_number):
                result_message = "question num error "
                # result_message = "题库中没有足够的编程题符合策略项 "
                response = util.Response(status=util.Status.__error__,
                                         body=result_message)
                return util.objtojson(response)
            # 判断是否与策略项有交集
            if strategyTerm.sm_knowledge == "0":
                result = strategyTerm.query('select * from strategy_term where strategy_sg_id =%s and sm_type = %s' \
                            % (strategyTerm.strategy_sg_id, sm_type,))
                result = [model.Strategy_term_model(**item) for item in result]
            else:
                result = strategyTerm.query(
                    'select * from strategy_term where strategy_sg_id =%s and sm_type = %s and \
                            sm_knowledge = %s' %
                    (strategyTerm.strategy_sg_id, sm_type,
                     strategyTerm.sm_knowledge))
                result = [model.Strategy_term_model(**item) for item in result]

            for item in result:
                if int(item.sm_difficulty_low) < int(strategyTerm.sm_difficulty_low) and \
                                int(item.sm_difficulty_high) <= int(strategyTerm.sm_difficulty_low) \
                        or int(strategyTerm.sm_difficulty_low) < int(item.sm_difficulty_low) \
                                and int(strategyTerm.sm_difficulty_high) <= int(item.sm_difficulty_low):
                    print '无交集'
                else:
                    result_message = "diffculty error"
                    response = util.Response(status=util.Status.__error__,
                                             body=result_message)
                    return util.objtojson(response)
            if strategyTerm.insert():
                currentPage = int(params.currentPage) - 1
                result = strategyTerm.query(
                    'select * from strategy_term where strategy_sg_id =%s order by sm_id desc limit %s,%s' % \
                    (strategyTerm.strategy_sg_id, currentPage * 5, 5))
                strategyTermList = []
                total_score = 0
                for item in result:
                    item['sm_type'] = util.type[item.sm_type]
                    Knowledge = model.Knowledge_model()
                    if item.sm_knowledge == 0:
                        item['kl_name'] = "全部知识点"
                    else:
                        KnowledgeData = Knowledge.getByPK(item.sm_knowledge)
                        item['kl_name'] = KnowledgeData.kl_name
                    total_score += float(item['sm_score']) * float(
                        item['sm_number'])
                    strategyTermList.append(item)
                strategy = model.Strategy_model()
                strategy.sg_id = strategyTerm.strategy_sg_id
                strategy.sg_score = total_score
                strategy.update()
                result = strategyTerm.query('select count(*) from strategy_term where strategy_sg_id =%s' % \
                                            (strategyTerm.strategy_sg_id))
                page = util.Page(data=strategyTermList,
                                 totalRow=int(result[0]['count(*)']) * 2,
                                 currentPage=int(params.currentPage),
                                 pageSize=5,
                                 status=util.Status.__success__,
                                 message=total_score)
                print page
                response = util.Response(status=util.Status.__success__,
                                         body=page)
                return util.objtojson(response)
            else:
                response = util.Response(status=util.Status.__error__)
                return util.objtojson(response)
Beispiel #16
0
    def POST(self):
        mydata = web.input()
        print mydata
        print 111111111111111111111
        qbhq = model.Questions_bank_has_question_model()
        web.header("Access-Control-Allow-Origin", "*")
        question = model.Question_model()
        Knowledge = model.Knowledge_model()
        must_params = set({'qb_id','qt_type','qt_diffculty_up','qt_diffculty_down','knowledge_kl_id'})

        if(util.paramsok(must_params,mydata) == 2):
            response = util.Response(status = util.Status.__params_not_ok__)
            return util.objtojson(response)
        else:
            # 通过题库ID获取该题库下所有题目ID,并且不在导入题库里
            question_id = qbhq.getByArgs(questions_bank_qb_id = mydata.qb_id)
            question_id = qbhq.query('select * from questions_bank_has_question where \
                  questions_bank_qb_id = %s and question_qt_id not in (select \
                   question_qt_id from questions_bank_has_question where  \
                   questions_bank_qb_id = %s)'%(mydata.qb_id,mydata.questions_bank_qb_id))
            question_id = [model.Questions_bank_has_question_model(**item) for item in question_id]
            # print question_id
            question_list = []
            count = 0
            for k in question_id:
                if mydata.knowledge_kl_id == 'all' and mydata.qt_type == 'all':
                    result = question.query('select * from question where qt_id = %s and qt_diffculty between %s and %s '%(k.question_qt_id,mydata.qt_diffculty_down,mydata.qt_diffculty_up))
                    result1 = [model.Question_model(**item) for item in result ]
                    if result1:
                        qt=result1[0]
                        qt['qt_type']=util.type[qt.qt_type]
                        KnowledgeData = Knowledge.getByPK(qt.knowledge_kl_id)
                        qt['kl_name'] = KnowledgeData.kl_name
                        question_list.append(qt)
                        count+=1
                elif mydata.qt_type == 'all':
                    result = question.query('select * from question where qt_id = %s and knowledge_kl_id = %s and qt_diffculty between %s and %s '%(k.question_qt_id,mydata.knowledge_kl_id,mydata.qt_diffculty_down,mydata.qt_diffculty_up))
                    result1 = [model.Question_model(**item) for item in result ]
                    if result1:
                        qt=result1[0]
                        qt['qt_type']=util.type[qt.qt_type]
                        KnowledgeData = Knowledge.getByPK(qt.knowledge_kl_id)
                        qt['kl_name'] = KnowledgeData.kl_name
                        question_list.append(qt)
                        count+=1
                    else:
                        print '空'
                elif mydata.knowledge_kl_id == 'all':
                    result = question.query('select * from question where qt_id = %s and qt_type = %s and qt_diffculty between %s and %s '%(k.question_qt_id,mydata.qt_type,mydata.qt_diffculty_down,mydata.qt_diffculty_up))
                    result1 = [model.Question_model(**item) for item in result ]
                    if result1:
                        qt=result1[0]
                        qt['qt_type']=util.type[qt.qt_type]
                        KnowledgeData = Knowledge.getByPK(qt.knowledge_kl_id)
                        qt['kl_name'] = KnowledgeData.kl_name
                        question_list.append(qt)
                        count+=1
                    else:
                        print '空'
                        # KnowledgeData = Knowledge.getByArgs(kl_id = result1[0].knowledge_kl_id)
                else:
                    result = question.query('select * from question where qt_id = %s and qt_type = %s and knowledge_kl_id = %s and qt_diffculty between %s and %s '%(k.question_qt_id,mydata.qt_type,mydata.knowledge_kl_id,mydata.qt_diffculty_down,mydata.qt_diffculty_up))
                    result1 = [model.Question_model(**item) for item in result ]
                    if result1:
                        qt=result1[0]
                        qt['qt_type']=util.type[qt.qt_type]
                        KnowledgeData = Knowledge.getByPK(qt.knowledge_kl_id)
                        qt['kl_name'] = KnowledgeData.kl_name
                        question_list.append(qt)
                        count+=1
                    else:
                        print '空'
            currentPage = int(mydata.currentPage)-1
            print count
            if (currentPage*10+10 < count):
                questiondata=question_list[currentPage*10:currentPage*10+10]
            else:
                questiondata=question_list[currentPage*10:count]
            print 1234567890
            print questiondata
            page = util.Page(data = questiondata, 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)
Beispiel #17
0
def pydocutize(output_dir, parent, nav_order):
    functions_mapping = {
        'Web': {
            'display_name': 'webweb.Web',
            'functions': [
                '__init__',
                'show',
                'save',
            ],
        },
        'Network': {
            'display_name': 'webweb.Network',
            'functions': [
                '__init__',
                'add_layer',
            ],
        }
    }

    util.clean_dir(output_dir)
    import pydoc
    import inspect
    webweb_module = util.get_module('webweb', WEBWEB_CODE)

    container = 'python'

    with open('python_documentation.md', 'r') as f:
        index_content = f.read()

    util.Index(
        title=container,
        writeable_title=container,
        nav_order=2,
        layout='main_page',
        has_children=True,
        parent=parent,
        content=index_content,
    ).write(output_dir)

    counter = 1
    for object_name in functions_mapping.keys():
        _object = getattr(webweb_module, object_name)

        object_display_name = functions_mapping[object_name]['display_name']

        for function_name in functions_mapping[object_name]['functions']:
            function_object = getattr(_object, function_name)
            function_signature = inspect.signature(function_object)

            # we want to exclude `self`
            parameters_list = []
            for parameter, parameter_string in function_signature.parameters.items():
                if parameter != 'self':
                    parameters_list.append(str(parameter_string))

            signature_string = "(" + ", ".join(parameters_list) + ")"

            function_doc = pydoc.getdoc(function_object)
            qualified_function_name = object_display_name
            writeable_function_name = object_display_name
            if function_name == '__init__':
                function_doc = pydoc.getdoc(_object) + "\n\n" + function_doc
            else:
                qualified_function_name += '.' + function_name
                writeable_function_name += '_' + function_name

            content = "```python\n{name}{signature}\n````\n\n{doc}".format(
                name=qualified_function_name,
                signature=signature_string,
                doc=function_doc,
            )

            util.Page(
                title=qualified_function_name,
                writeable_title=writeable_function_name,
                nav_order=counter,
                layout='main_page',
                parent=container,
                grand_parent=parent,
                content=content,
            ).write(output_dir)

            counter += 1
Beispiel #18
0
    def POST(self):
        mydata = web.input()
        print("查看题目:", mydata)
        # 必须有的参数
        must_params = set({'questions_bank_qb_id', 'currentPage'})
        web.header("Access-Control-Allow-Origin", "*")
        currentPage = int(mydata.currentPage) - 1
        if (util.paramsok(must_params, mydata) == 2):
            print(333)
            response = util.Response(status=util.Status.__params_not_ok__)
            return util.objtojson(response)
        else:
            question = model.Question_model()
            # result = orm.db.query('select * from question where qt_id in (select question_qt_id from questions_bank_has_question where questions_bank_qb_id = %s ) order by qt_id limit %s,%s'%(int(mydata.questions_bank_qb_id),currentPage*10,currentPage*10+9))
            result = orm.db.query(
                'select * from question where qt_id in \
                (select question_qt_id from questions_bank_has_question where questions_bank_qb_id = %s )\
                order by qt_id limit %s,%s' %
                (mydata.questions_bank_qb_id, currentPage * 10, 10))

            questionlist = []
            result = [model.Question_model(**item) for item in result]
            # print result
            count = dict()
            total_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                from questions_bank_has_question where questions_bank_qb_id = %s )'
                % (mydata.questions_bank_qb_id))
            # print result1[0]
            choice_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                            from questions_bank_has_question where questions_bank_qb_id = %s ) and qt_type = \'choice\''
                % (mydata.questions_bank_qb_id))
            coding_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                                        from questions_bank_has_question where questions_bank_qb_id = %s ) and qt_type = \'coding\''
                % (mydata.questions_bank_qb_id))
            filla_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                                                    from questions_bank_has_question where questions_bank_qb_id = %s ) \
                                                     and qt_type = \'filla\'' %
                (mydata.questions_bank_qb_id))
            fillb_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                                                                from questions_bank_has_question where questions_bank_qb_id = %s ) \
                                                                 and qt_type = \'fillb\''
                % (mydata.questions_bank_qb_id))
            judge_num = question.query(
                'select count(*) from question where qt_id in (select question_qt_id \
                                                                from questions_bank_has_question where questions_bank_qb_id = %s ) \
                                                                 and qt_type = \'judge\''
                % (mydata.questions_bank_qb_id))
            count['total_num'] = total_num[0]['count(*)']
            count['choice_num'] = choice_num[0]['count(*)']
            count['coding_num'] = coding_num[0]['count(*)']
            count['filla_num'] = filla_num[0]['count(*)']
            count['fillb_num'] = fillb_num[0]['count(*)']
            count['judge_num'] = judge_num[0]['count(*)']
            #util.getFileRotatingLog().debug(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=int(count['total_num']),
                             currentPage=int(mydata.currentPage),
                             pageSize=10,
                             status=util.Status.__success__,
                             message=count)
            response = util.Response(status=util.Status.__success__, body=page)
            print("返回信息: ", util.objtojson(response))
            return util.objtojson(response)
    def POST(self):
        debug = 0
        if debug == 1:

            class Mydata:
                pass

            mydata = Mydata()
            mydata.ex_id = 4
            mydata.cl_id = 2
        else:
            web.header("Access-Control-Allow-Origin", "*")
            mydata = web.input()
        student = model.Student_model()
        information_data = orm.db.query(
            'select * from information where exam_ex_id = %s and class_cl_id = %s'
            % (mydata.ex_id, mydata.cl_id))
        information_data = [
            model.Information_model(**item) for item in information_data
        ]
        data = []
        for single_information in information_data:
            single_student_data = []
            single_student_data.append(
                student.getByPK(single_information.student_st_id))
            single_student_data.append(single_information)
            single_information['in_state'] = util.in_state[int(
                single_information.in_state)]
            if single_information['in_score'] == -1:
                single_information['in_score'] = u'未出分'
            result = model.Exam_question_model.getByArgs(
                information_in_id=single_information.in_id)
            result_mapping = {
                'choice': [],
                'judge': [],
                'filla': [],
                'fillb': [],
                'coding': []
            }
            for question in result:
                if question.eq_qt_type == 'fillb':
                    if len(result_mapping["fillb"]) == 0 or result_mapping[
                            "fillb"][-1].qt_id != question.qt_id:
                        if question.eq_get_score < 0:
                            question.eq_get_score = u'未出分'
                        result_mapping["fillb"].append(question)
                    elif result_mapping["fillb"][-1].qt_id == question.qt_id:
                        if result_mapping["fillb"][
                                -1].eq_get_score == u'未出分' or question.eq_get_score < 0:
                            result_mapping["fillb"][-1].eq_get_score = u'未出分'
                        else:
                            result_mapping["fillb"][
                                -1].eq_get_score += question.eq_get_score
                else:
                    if question.eq_get_score < 0:
                        question.eq_get_score = u'未出分'
                    result_mapping[str(question.eq_qt_type)].append(question)
            examquestion_data = []
            examquestion_data.extend(result_mapping['choice'])
            examquestion_data.extend(result_mapping['judge'])
            examquestion_data.extend(result_mapping['filla'])
            examquestion_data.extend(result_mapping["fillb"])
            examquestion_data.extend(result_mapping['coding'])
            single_student_data.append(examquestion_data)
            print(single_student_data)
            data.append(single_student_data)
        if debug != 1:
            page = util.Page(data=data,
                             totalRow=len(data),
                             currentPage=int(mydata.currentPage),
                             pageSize=10,
                             status=util.Status.__success__,
                             message="未知")
            response = util.Response(status=util.Status.__success__, body=page)
            #return util.objtojson(response)
            ls = list()
            for i in range(len(response.body.data)):
                dic = dict()
                dic['st_id'] = response.body.data[i][0].st_id
                dic['st_name'] = response.body.data[i][0].st_name
                dic['in_state'] = response.body.data[i][1].in_state
                dic['in_ip'] = response.body.data[i][1].in_ip
                dic['in_score'] = response.body.data[i][1].in_score
                ls.append(dic)
            print("返回数据:", util.objtojson(ls))
            return util.objtojson(ls)