예제 #1
0
def problem_list(courseId, pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberCourseProblemParameter = MemberCourseProblemParameter(memberId = session[SessionResources().const.MEMBER_ID],
                                                                                                             courseId = courseId)).subquery()
        # Current Submission                                      
        submissions = select_current_submissions(lastSubmission).subquery()
        
        # Get Problem Informations
        problems = join_problems_names(select_problems_of_course(memberCourseProblemParameter = MemberCourseProblemParameter(memberId = None,
                                                                                                                             courseId = courseId)).subquery()).subquery()
        # Get ProblemList Count
        try:
            count = select_count(problems.c.problemId).first().\
                                                       count
        except Exception:
            count = 0
        # Get ProblemListRecords OuterJoin
        try:
            problemListRecords = get_page_record(join_problem_lists_submissions(problems,
                                                                                submissions),
                                                 pageNum = pageNum).all()
        except Exception:
            problemListRecords = []
            
        # Get Course Information
        try:
            courseRecords = dao.query(RegisteredCourses.courseId,
                                      RegisteredCourses.courseName).\
                                filter(RegisteredCourses.courseId == courseId).\
                                first()
        except:
            courseRecords = []
        
        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               SETResources = SETResources,
                               SessionResources = SessionResources,
                               LanguageResources = LanguageResources,
                               courseRecords = courseRecords,
                               problemListRecords = problemListRecords,
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception:
        return unknown_error()
예제 #2
0
def problem_list(pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberIdIndex=session[
            SessionResources().const.MEMBER_ID_INDEX]).subquery()

        # Current Submission
        submissions = select_submissions_result(lastSubmission).subquery()

        # Get Problem Informations
        problems = select_all_problems().subquery()

        # Get ProblemList Count
        # Get ProblemListRecords OuterJoin
        try:
            count = select_count(problems.c.problemIndex).first().\
                                                          count

            problemListRecords = get_page_record(
                join_problem_lists_submissions(problems, submissions),
                pageNum=pageNum).all()

        except Exception:
            count = 0
            problemListRecords = []

        # Get Course Information

        browserInformations = request.user_agent.string
        if browserInformations.find('Trident') == -1:
            if browserInformations.find('MSIE') == -1:
                browserVersion = ENUMResources().const.TRUE
            else:
                browserVersion = ENUMResources().const.FALSE
        elif int(browserInformations[browserInformations.find('Trident') +
                                     8]) < 6:
            browserVersion = ENUMResources().const.FALSE
        else:
            browserVersion = ENUMResources().const.TRUE
        wrongTestCaseText = {}
        for problemListRecord in problemListRecords:
            if problemListRecord.wrongTestCaseNumber != 0:
                try:
                    f = open(
                        make_wrong_test_case_path(
                            str(problemListRecord.problemPath),
                            str(problemListRecord.problemName),
                            str(problemListRecord.solutionCheckType),
                            str(problemListRecord.wrongTestCaseNumber)), "r")
                    temp = {problemListRecord.problemName: f.read()}
                    wrongTestCaseText.update(temp)
                    f.close()
                except:
                    pass

        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               problemListRecords=problemListRecords,
                               wrongTestCaseText=wrongTestCaseText,
                               browserVersion=browserVersion,
                               datetime=datetime.now(),
                               pages=get_page_pointed(pageNum=pageNum,
                                                      count=count))
    except Exception as e:
        return unknown_error(e)
def problem_list(pageNum):
    """ problem submitting page """
    try:
        # Get Last Submitted History
        lastSubmission = select_last_submissions(memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]).subquery()
        
        # Current Submission                                      
        submissions = select_submissions_result(lastSubmission).subquery()

        # Get Problem Informations
        problems = select_all_problems().subquery()
        
        # Get ProblemList Count
        # Get ProblemListRecords OuterJoin
        try:
            count = select_count(problems.c.problemIndex).first().\
                                                          count
                                                      
            problemListRecords = get_page_record(join_problem_lists_submissions(problems,
                                                                                submissions),
                                                 pageNum = pageNum).all()
        
        except Exception:
            count = 0
            problemListRecords = []

        # Get Course Information
        
        browserInformations = request.user_agent.string
        if browserInformations.find('Trident') == -1:
            if browserInformations.find('MSIE') == -1:
                browserVersion = ENUMResources().const.TRUE
            else:
                browserVersion = ENUMResources().const.FALSE        
        elif int(browserInformations[browserInformations.find('Trident') + 8]) < 6:
            browserVersion = ENUMResources().const.FALSE
        else:
            browserVersion = ENUMResources().const.TRUE
        wrongTestCaseText = {}
        for problemListRecord in problemListRecords:
            if problemListRecord.wrongTestCaseNumber != 0:
                try:
                    f = open(make_wrong_test_case_path(str(problemListRecord.problemPath),
                                                   str(problemListRecord.problemName),
                                                   str(problemListRecord.solutionCheckType),
                                                   str(problemListRecord.wrongTestCaseNumber)), "r")
                    temp = {problemListRecord.problemName : f.read()}
                    wrongTestCaseText.update(temp)
                    f.close()
                except:
                    pass

        return render_template(HTMLResources().const.PROBLEM_LIST_HTML,
                               problemListRecords = problemListRecords,
                               wrongTestCaseText = wrongTestCaseText,
                               browserVersion = browserVersion,
                               datetime = datetime.now(),
                               pages = get_page_pointed(pageNum = pageNum,
                                                        count = count))
    except Exception as e:
        return unknown_error(e)