Пример #1
0
def manage_problem(problemLevel, pageNum, error=None):
    try:
        # Upload Problems Files
        if request.method == 'POST':
            if is_authority(session[SessionResources().const.AUTHORITY])[0]:
                error = post_problem(request)
            else:
                error = LanguageResources().const.GetOutHere

        # GET, POST 공통 사항
        problems = select_problems(None if problemLevel == LanguageResources().
                                   const.All[1] else problemLevel)

        try:
            count = select_count(problems.subquery().c.problemIndex).first().\
                                                          count

            problemRecords = get_page_record(problems, pageNum=pageNum).all()

        except Exception:
            count = 0
            problemRecords = []

        return render_template('/manage_problem.html',
                               types=[
                                   ENUMResources().const.SOLUTION,
                                   ENUMResources().const.CHECKER
                               ],
                               levels=[
                                   LanguageResources().const.GoldLevel,
                                   LanguageResources().const.SilverLevel,
                                   LanguageResources().const.BronzeLevel
                               ],
                               problemLevel=problemLevel,
                               problemRecords=problemRecords,
                               pages=get_page_pointed(pageNum, count),
                               error=error)
    except Exception as e:
        return unknown_error(e)
 def get_problems():
     try:
         from GradeServer.utils.utilProblemQuery import select_problems
         return select_problems().all()
     except Exception:
         return []