def get_problem_name(problemIndex): try: problemName = select_problem(problemIndex = problemIndex).first().\ problemName return problemName except: return unknown_error(get_message('dbError'))
def course_problem_check(isAdministrator, authority, memberIdIndex, problemIndex, thisMemberIdIndex, isCode): # Problem in Course Check if problemIndex: if not select_problem(problemIndex).first(): return False if isCode\ and authority[1]\ and thisMemberIdIndex != memberIdIndex: return False return True
def problem(problemIndex, pageNum): """ use db to get its problem page now, it moves to just default problem page """ try: # are Not Access. conditions is an Administrator and endOfSubmission ago # languages of Course try: languageInfoRecords = select_all_languages() except Exception: languageInfoRecords = [] try: problemInformation = select_problem( problemIndex=problemIndex).first() except Exception: problemInformation = [] problemName = problemInformation.problemName.replace(' ', '') pdfExists = os.path.exists(OtherResources().const.PDF_PATH % (problemName, problemName)) browserName = request.user_agent.browser browserVersion = request.user_agent.version return render_template(HTMLResources().const.PROBLEM_HTML, problemIndex=problemIndex, problemInformation=problemInformation, languageInfoRecords=languageInfoRecords, pdfExists=pdfExists, problemName=problemName, pageNum=pageNum, browserName=browserName, datetime=datetime.now(), browserVersion=browserVersion) except Exception as e: return unknown_error(e)
def problem(problemIndex, pageNum): """ use db to get its problem page now, it moves to just default problem page """ try : # are Not Access. conditions is an Administrator and endOfSubmission ago # languages of Course try: languageInfoRecords = select_all_languages() except Exception: languageInfoRecords = [] try: problemInformation = select_problem(problemIndex = problemIndex).first() except Exception: problemInformation = [] problemName = problemInformation.problemName.replace(' ', '') pdfExists = os.path.exists(OtherResources().const.PDF_PATH %(problemName, problemName)) browserName = request.user_agent.browser browserVersion = request.user_agent.version return render_template(HTMLResources().const.PROBLEM_HTML, problemIndex = problemIndex, problemInformation = problemInformation, languageInfoRecords = languageInfoRecords, pdfExists = pdfExists, problemName = problemName, pageNum = pageNum, browserName = browserName, datetime = datetime.now(), browserVersion = browserVersion) except Exception as e: return unknown_error(e)
def submission_code(memberIdIndex, status, problemIndex, error=None): try: # Get endDateOfSubmission of Problem # are Not Access. conditions is an Administrator and endOfSubmission ago if SETResources().const.ADMINISTRATOR in session[SessionResources().const.AUTHORITY]\ or memberIdIndex == session[SessionResources().const.MEMBER_ID_INDEX]: # Get SubmissionIndex dataOfSubmissionBoard = select_data_of_submission_board( None, memberIdIndex, problemIndex) if dataOfSubmissionBoard.first(): submissionIndex = dataOfSubmissionBoard.first().submissionIndex # 내가 Code에 누른 좋아요 정보 try: isLikeCancelled = select_code_is_like(submissionIndex, memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]).first().\ isLikeCancelled except Exception: # Non-Exist Case isLikeCancelled = None if request.method == 'POST': authorityCheck = is_authority( session[SessionResources().const.AUTHORITY]) for form in request.form: # 댓글 달기 if form == 'writeCodeReply': # 새로운 댓글 정보articleParameter codeReplyContent = get_request_value( form=request.form, name='writeCodeReply') if codeReplyContent: dao.add( insert_replies_on_code( submissionIndex, memberIdIndex=session[SessionResources( ).const.MEMBER_ID_INDEX], articleParameter=ArticleParameter( title=None, content=codeReplyContent, updateIp=socket.gethostbyname( socket.gethostname()), updateDate=datetime.now()))) # remove duplicated read count update_code_view_reply_counting( submissionIndex, VIEW_INCREASE=-1, REPLY_INCREASE=1) break # 댓글 삭제 elif 'deleteCodeReply' in form: # Get Reply Index replyIndex = len('deleteCodeReply') submissionReplyIndex = int(form[replyIndex:]) try: writerIndex = select_replies_on_code( submissionIndex=None, submissionReplyIndex=submissionReplyIndex ).first() except Exception: writerIndex = None if (authorityCheck[0] or authorityCheck[1])\ or writerIndex.codeReplierIdIndex == session['memberIdIndex']: update_replies_on_code_delete( submissionReplyIndex, isDeleted=ENUMResources().const.TRUE) # remove duplicated read count update_code_view_reply_counting( submissionIndex, VIEW_INCREASE=-1, REPLY_INCREASE=-1) else: error = LanguageResources().const.GetOutHere break # Commit Modify elif 'modifyCodeReplyContent' in form: replyIndex = len('modifyCodeReplyContent') submissionReplyIndex = int(form[replyIndex:]) try: writerIndex = select_replies_on_code( submissionIndex=None, submissionReplyIndex=submissionReplyIndex ).first() except Exception: writerIndex = None if writerIndex.codeReplierIdIndex == session[ 'memberIdIndex']: submissionReplyContent = get_request_value( form=request.form, name='modifyCodeReplyContent{0}'.format( form[replyIndex:])) if submissionReplyContent: #update comment update_replies_on_code_modify( submissionReplyIndex, ArticleParameter( title=None, content=submissionReplyContent, updateIp=socket.gethostbyname( socket.gethostname()), updateDate=datetime.now())) # remove duplicated read count update_code_view_reply_counting( submissionIndex, VIEW_INCREASE=-1) else: error = LanguageResources().const.GetOutHere break # end Loop # Commit Exception try: dao.commit() except Exception: dao.rollback() error = LanguageResources().const.DBFailed try: # replies 정보 repliesOnSubmissionRecords = select_replies_on_code( submissionIndex).subquery() repliesOnSubmissionRecords = join_member_id( repliesOnSubmissionRecords, repliesOnSubmissionRecords.c.codeReplierIdIndex) # 내가 게시글 리플에 누른 좋아요 정보 repliesOnSubmissionIsLikeRecords = select_replies_on_code_like( repliesOnSubmissionRecords.subquery(), session[ SessionResources().const.MEMBER_ID_INDEX]).all() repliesOnSubmissionRecords = repliesOnSubmissionRecords.all( ) except Exception: repliesOnSubmissionIsLikeRecords = [] repliesOnSubmissionRecords = [] # 읽은 횟수 카운팅 update_code_view_reply_counting(submissionIndex, VIEW_INCREASE=1) # Commit Exception try: dao.commit() except Exception: dao.rollback() # Problem Information (LimitedTime, LimitedMemory try: problemName = select_problem(problemIndex = problemIndex).first().\ problemName except Exception: problemName = None # Problem Solved Users try: # last Submissions Info lastSubmission = select_last_submissions( memberIdIndex=memberIdIndex, problemIndex=problemIndex).subquery() problemSolvedMemberRecords = select_all_submissions( memberIdIndex=memberIdIndex, problemIndex=problemIndex, lastSubmission=lastSubmission).first() except Exception: problemSolvedMemberRecords = [] # Submitted Files Information import codecs try: submittedFileRecords = select_submitted_files( dataOfSubmissionBoard.subquery()).all() fileData = [] for raw in submittedFileRecords: # Open filePath = '{0}/{1}'.format(raw.filePath, raw.fileName) # EUC_KR type try: with codecs.open(filePath, 'r', encoding='cp949') as f: # Read data = f.read() fileData.append(data) # UTF-8 Type except Exception: with codecs.open(filePath, 'r', encoding='utf8') as f: # Read data = f.read() fileData.append(data) except Exception: submittedFileRecords = [] fileData = [] return render_template(HTMLResources().const.SUBMISSION_CODE_HTML, memberIdIndex = memberIdIndex, submissionIndex = submissionIndex, submittedFileRecords = submittedFileRecords, fileData = fileData, problemName = problemName, problemSolvedMemberRecords = problemSolvedMemberRecords, isLikeCancelled = isLikeCancelled, sumOfLikeCount = dataOfSubmissionBoard.first().\ sumOfLikeCount, repliesOnSubmissionIsLikeRecords = repliesOnSubmissionIsLikeRecords, repliesOnSubmissionRecords = repliesOnSubmissionRecords, browserName = request.user_agent.browser, browserVersion = request.user_agent.version, error = error) #Access Rejection else: return redirect( url_for( RouteResources().const.PROBLEM_RECORD, status=status, problemIndex=problemIndex, sortCondition=LanguageResources().const.SubmissionDate[1])) except Exception as e: return unknown_error(e)
def problem_record(status, problemIndex, sortCondition, error=None): # Not Accept URL Check if sortCondition not in (LanguageResources().const.SubmissionDate[1], LanguageResources().const.Memory[1], LanguageResources().const.FileSize[1], LanguageResources().const.Runtime[1]): return page_not_found() try: memberId = None # Request Post if request.method == 'POST': # Search Event if 'memberId' in request.form: memberId = get_request_value(form=request.form, name='memberId') # Chart View Value Text chartSubmissionDescriptions = [ LanguageResources().const.TriedPeople, LanguageResources().const.SolvedPeople, LanguageResources().const.Count, LanguageResources().const.Solved, LanguageResources().const.WrongAnswer, LanguageResources().const.TimeOver, LanguageResources().const.MemoryOverflow, LanguageResources().const.CompileError, LanguageResources().const.RuntimeError ] # last Submissions of Problem Info lastSubmission = select_last_submissions( problemIndex=problemIndex).subquery() submissions = select_all_submissions( problemIndex=problemIndex, lastSubmission=lastSubmission).subquery() try: # Submitted Members Count sumOfSubmissionPeopleCount = select_submissions_peoples_counts( submissions).subquery() # Solved Members Count sumOfSolvedPeopleCount = select_solved_peoples_counts( submissions).subquery() # Problem Record problemSubmittedRecords = select_submitted_records_of_problem( problemIndex=problemIndex).subquery() # Chart SubmissionRecords chartSubmissionRecords = select_problem_chart_submissions( sumOfSubmissionPeopleCount, sumOfSolvedPeopleCount, problemSubmittedRecords).first() except Exception: chartSubmissionRecords = [] # Problem Information (LimitedTime, LimitedMemory try: problemInformation = select_problem( problemIndex=problemIndex).first() except Exception: problemInformation = [] # Problem Solved Users try: # Problem Solved Member problemSolvedMemberRecords = submissions_sorted( select_solved_submissions(submissions).subquery(), sortCondition=sortCondition).all() except Exception: problemSolvedMemberRecords = [] # Search Failed Problem if status != ENUMResources().const.SOLVED\ and status != ENUMResources().const.JUDGING\ and status != ENUMResources().const.SERVER_ERROR: try: # last Submissions of Problem Info lastSubmission = select_last_submissions( memberIdIndex=session[ SessionResources().const.MEMBER_ID_INDEX], problemIndex=problemIndex).subquery() submissions = select_all_submissions( memberIdIndex=session[ SessionResources().const.MEMBER_ID_INDEX], problemIndex=problemIndex, lastSubmission=lastSubmission).subquery() # Current Failed Problem failedProblem = select_failed_problems(submissions).first() except Exception: failedProblem = [] else: failedProblem = [] return render_template( HTMLResources().const.PROBLEM_RECORD_HTML, memberId=memberId, status=status, problemSolvedMemberRecords=problemSolvedMemberRecords, problemInformation=problemInformation, chartSubmissionDescriptions=chartSubmissionDescriptions, chartSubmissionRecords=chartSubmissionRecords, failedProblem=failedProblem, error=error) except Exception as e: return unknown_error(e)
def post_problem(request, error=None): if 'upload' in request.form: files = request.files.getlist('files') # Get Fle Failed if not list(files)[0].filename: return LanguageResources().const.UploadingFileError # read each uploaded file(zip) for fileData in files: # create temporary path to store new problem before moving into 'Problems' folder tmpPath = '%s/tmp' % projectPath ''' @@ Check and Delete temporary folder If temporary folder 'tmp' is exist, then it means it had an error at past request. So, remove the temporary folder 'tmp' first. ''' if os.path.exists(tmpPath): try: subprocess.call('rm -rf %s' % tmpPath, shell=True) except OSError: return LanguageResources().const.DeleteFolderError # unzip file with zipfile.ZipFile(fileData, 'r') as z: z.extractall(tmpPath) try: rowProblemName = re.split('_|\.', os.listdir(tmpPath)[0])[0].\ replace(' ', '\ ') except OSError: return LangaugeResources().const.ListingFilesError ''' @@ Decode problem name If the problem zip's made on window environment, problem name's broken So it needs to be decoded by cp949 ''' problemName = str(rowProblemName.decode('cp949')) # if decoded name is the same with before decoding, # it means the file is not created on window environment isFromWindow = True if rowProblemName != problemName\ else False if isFromWindow: error = handle_file_came_from_window(rowProblemName, problemName) if error: return error problemInformationPath = ('%s/%s.txt' % (tmpPath, problemName)).replace( '\ ', ' ') try: # 'open' command can handle space character without '\' mark, # Replace '\ ' to just space ' ' problemInfoFile = open(problemInformationPath, 'r') problemInformation = problemInfoFile.read() try: problemInfoFile.close() except IOError: return LanguageResources().const.ClosingFileError except IOError: return LanguageResources().const.ReadingFileError ''' @@ Decode problem meta information Problem meta information(.txt) file needs to be decoded as well as problem folder name ''' if isFromWindow: problemInformation = problemInformation.decode('cp949') # slice and make key, value pairs from csv form problemInformation = problemInformation.replace(' ', '').split(',') if len(problemInformation) != 5: return LanguageResources().const.NotEnoughInfoError # re-slice and make information from 'key=value' for eachInformation in problemInformation: key, value = eachInformation.split('=') if key == 'Name': # 'value' doesn't have a space character because of 'replace(' ', '')' command above # Don't use 'value' for problem name problemName = problemName.replace('\ ', ' ') elif key == 'Difficulty': try: problemDifficulty = int(value) except ValueError: return LanguageResources().const.DifficultyCharError elif key == 'SolutionCheckType': solutionCheckType = ENUMResources().const.SOLUTION if value == 'Solution'\ else ENUMResources().const.CHECKER elif key == 'LimitedTime': limitedTime = int(value) elif key == 'LimitedMemory': limitedMemory = int(value) # Insert new problem problemPath = '%s/%s' % (problemsPath, problemName.replace( ' ', '')) if not select_problem( problemIndex=None, problemName=problemName, isDeleted=ENUMResources().const.TRUE).first(): dao.add( insert_problem(problemName, problemDifficulty, solutionCheckType, limitedTime, limitedMemory, problemPath)) else: # Duplication Case update_problem_deleted(select_problem(problemIndex = None, problemName = problemName, isDeleted = ENUMResources().const.TRUE).first().\ problemIndex, isDeleted = ENUMResources().const.FALSE) newProblemPath='%s/%s_%s' %\ (tmpPath, problemName, solutionCheckType) if change_directory_to(newProblemPath): return try: # current path : ../tmp/problemName_solutionCheckType inOutCases=\ [filename for filename in os.listdir(os.getcwd())] except OSError: return LanguageResources().const.ListingFilesError for filename in inOutCases: rowFileName = filename fileName='%s_%s' %\ (problemName, rowFileName.split('_', 1)[1]) if rename_file(rowFileName, str(fileName)): return ''' @@ Changing directory/file name work flow 1. Remove space on its name from> Hello World to> HelloWorld 2. Attach problem ID ahead of the name from> HelloWorld to> 12345_HelloWorld * 12345 is created problem id ''' currentPath, error = get_current_path() if error: return error # inside of SOLUTION or CHECKER folder error = remove_space_from_names_in(currentPath) if error: return error # move to outside of the folder if change_directory_to(tmpPath): return error currentPath, error = get_current_path() if error: return error # inside of Problem folder error = remove_space_from_names_in(currentPath) if error: return error # create final goal path if not os.path.exists(problemPath): os.makedirs(problemPath) problemName = problemName.replace(' ', '') problemDescriptionPath = '%s/%s' % (problemDescriptionsPath, problemName) if not os.path.exists(problemDescriptionPath): os.makedirs(problemDescriptionPath) error = rename_file('%s/*' % tmpPath, '%s/' % problemPath) if error: return error try: subprocess.call('cp %s/%s.pdf %s/' %\ (problemPath, problemName,\ problemDescriptionPath), shell=True) except: return LanguageResources().const.NotExistPDF error = remove_carriage_return(problemPath + '/' + problemName + '_' + solutionCheckType) if error: return error # Modify or Deleted Case else: if 'problemModify' in request.form: # Seach ProblemIndex updateProblemCount, updateCount = len(request.form) / 5, 0 for form in request.form: if updateProblemCount == updateCount: break elif 'problem' not in form\ and 'limited' not in form: updateCount = updateCount + 1 update_problem( problemIndex=form, problemDifficulty=request.form['problemDifficulty' + form], solutionCheckType=request.form['problemType' + form], limitedTime=request.form['limitedTime' + form], limitedMemory=request.form['limitedMemory' + form]) elif 'problemDeleted' in request.form: # Get ProblemIndex for form in request.form: if 'problem' not in form: update_problem_deleted(problemIndex=form) try: dao.commit() if 'upload' in request.form: # update numberOfTestCase problem = select_problem(problemIndex=None, problemName=problemName).first() testCasePath = '{0}/Problems/{1}/{2}_SOLUTION/'.format( projectPath, problem.problemName, problem.problemName) numberOfTestCase = len( fnmatch.filter(os.listdir(testCasePath), '*.txt')) / 2 update_number_of_test_case(problem.problemIndex, numberOfTestCase) try: dao.add( insert_submitted_records_of_problems(problem.problemIndex)) dao.commit() except Exception: dao.rollback() elif 'problemDeleted' in request.form: # Get ProblemIndex for form in request.form: if 'problem' not in form: # Delete Folder problem = select_problem( int(form), isDeleted=ENUMResources().const.TRUE).first() problemPath = '{0}/Problems/{1}/'.format( projectPath, problem.problemName) if os.path.exists(problemPath): shutil.rmtree(problemPath) except exc.SQLAlchemyError: dao.rollback() error = LanguageResources().const.DBFailed return error
def submission_code(memberIdIndex, status, problemIndex, error = None): try: # Get endDateOfSubmission of Problem # are Not Access. conditions is an Administrator and endOfSubmission ago if SETResources().const.ADMINISTRATOR in session[SessionResources().const.AUTHORITY]\ or memberIdIndex == session[SessionResources().const.MEMBER_ID_INDEX]: # Get SubmissionIndex dataOfSubmissionBoard = select_data_of_submission_board(None, memberIdIndex, problemIndex) if dataOfSubmissionBoard.first(): submissionIndex = dataOfSubmissionBoard.first().submissionIndex # 내가 Code에 누른 좋아요 정보 try: isLikeCancelled = select_code_is_like(submissionIndex, memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]).first().\ isLikeCancelled except Exception: # Non-Exist Case isLikeCancelled = None if request.method == 'POST': authorityCheck = is_authority(session[SessionResources().const.AUTHORITY]) for form in request.form: # 댓글 달기 if form == 'writeCodeReply': # 새로운 댓글 정보articleParameter codeReplyContent = get_request_value(form = request.form, name = 'writeCodeReply') if codeReplyContent: dao.add(insert_replies_on_code(submissionIndex, memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX], articleParameter = ArticleParameter(title = None, content = codeReplyContent, updateIp = socket.gethostbyname(socket.gethostname()), updateDate = datetime.now()))) # remove duplicated read count update_code_view_reply_counting(submissionIndex, VIEW_INCREASE = -1, REPLY_INCREASE = 1) break # 댓글 삭제 elif 'deleteCodeReply' in form: # Get Reply Index replyIndex = len('deleteCodeReply') submissionReplyIndex = int(form[replyIndex:]) try: writerIndex = select_replies_on_code(submissionIndex = None, submissionReplyIndex = submissionReplyIndex).first() except Exception: writerIndex = None if (authorityCheck[0] or authorityCheck[1])\ or writerIndex.codeReplierIdIndex == session['memberIdIndex']: update_replies_on_code_delete(submissionReplyIndex, isDeleted = ENUMResources().const.TRUE) # remove duplicated read count update_code_view_reply_counting(submissionIndex, VIEW_INCREASE = -1, REPLY_INCREASE = -1) else: error = LanguageResources().const.GetOutHere break # Commit Modify elif 'modifyCodeReplyContent' in form: replyIndex = len('modifyCodeReplyContent') submissionReplyIndex = int(form[replyIndex:]) try: writerIndex = select_replies_on_code(submissionIndex = None, submissionReplyIndex = submissionReplyIndex).first() except Exception: writerIndex = None if writerIndex.codeReplierIdIndex == session['memberIdIndex']: submissionReplyContent = get_request_value(form = request.form, name = 'modifyCodeReplyContent{0}'.format(form[replyIndex:])) if submissionReplyContent: #update comment update_replies_on_code_modify(submissionReplyIndex, ArticleParameter(title = None, content = submissionReplyContent, updateIp = socket.gethostbyname(socket.gethostname()), updateDate = datetime.now())) # remove duplicated read count update_code_view_reply_counting(submissionIndex, VIEW_INCREASE = -1) else: error = LanguageResources().const.GetOutHere break # end Loop # Commit Exception try: dao.commit() except Exception: dao.rollback() error = LanguageResources().const.DBFailed try: # replies 정보 repliesOnSubmissionRecords = select_replies_on_code(submissionIndex).subquery() repliesOnSubmissionRecords = join_member_id(repliesOnSubmissionRecords, repliesOnSubmissionRecords.c.codeReplierIdIndex) # 내가 게시글 리플에 누른 좋아요 정보 repliesOnSubmissionIsLikeRecords = select_replies_on_code_like(repliesOnSubmissionRecords.subquery(), session[SessionResources().const.MEMBER_ID_INDEX]).all() repliesOnSubmissionRecords = repliesOnSubmissionRecords.all() except Exception: repliesOnSubmissionIsLikeRecords = [] repliesOnSubmissionRecords = [] # 읽은 횟수 카운팅 update_code_view_reply_counting(submissionIndex, VIEW_INCREASE = 1) # Commit Exception try: dao.commit() except Exception: dao.rollback() # Problem Information (LimitedTime, LimitedMemory try: problemName = select_problem(problemIndex = problemIndex).first().\ problemName except Exception: problemName = None # Problem Solved Users try: # last Submissions Info lastSubmission = select_last_submissions(memberIdIndex = memberIdIndex, problemIndex = problemIndex).subquery() problemSolvedMemberRecords = select_all_submissions(memberIdIndex = memberIdIndex, problemIndex = problemIndex, lastSubmission = lastSubmission).first() except Exception: problemSolvedMemberRecords = [] # Submitted Files Information import codecs try: submittedFileRecords = select_submitted_files(dataOfSubmissionBoard.subquery()).all() fileData = [] for raw in submittedFileRecords: # Open filePath = '{0}/{1}'.format(raw.filePath, raw.fileName) # EUC_KR type try: with codecs.open(filePath, 'r', encoding = 'cp949') as f: # Read data = f.read() fileData.append(data) # UTF-8 Type except Exception: with codecs.open(filePath, 'r', encoding = 'utf8') as f: # Read data = f.read() fileData.append(data) except Exception: submittedFileRecords = [] fileData = [] return render_template(HTMLResources().const.SUBMISSION_CODE_HTML, memberIdIndex = memberIdIndex, submissionIndex = submissionIndex, submittedFileRecords = submittedFileRecords, fileData = fileData, problemName = problemName, problemSolvedMemberRecords = problemSolvedMemberRecords, isLikeCancelled = isLikeCancelled, sumOfLikeCount = dataOfSubmissionBoard.first().\ sumOfLikeCount, repliesOnSubmissionIsLikeRecords = repliesOnSubmissionIsLikeRecords, repliesOnSubmissionRecords = repliesOnSubmissionRecords, browserName = request.user_agent.browser, browserVersion = request.user_agent.version, error = error) #Access Rejection else: return redirect(url_for(RouteResources().const.PROBLEM_RECORD, status = status, problemIndex = problemIndex, sortCondition = LanguageResources().const.SubmissionDate[1])) except Exception as e: return unknown_error(e)
def problem_record(status, problemIndex, sortCondition, error = None): # Not Accept URL Check if sortCondition not in (LanguageResources().const.SubmissionDate[1], LanguageResources().const.Memory[1], LanguageResources().const.FileSize[1], LanguageResources().const.Runtime[1]): return page_not_found() try: memberId = None # Request Post if request.method == 'POST': # Search Event if 'memberId' in request.form: memberId = get_request_value(form = request.form, name = 'memberId') # Chart View Value Text chartSubmissionDescriptions = [LanguageResources().const.TriedPeople, LanguageResources().const.SolvedPeople, LanguageResources().const.Count, LanguageResources().const.Solved, LanguageResources().const.WrongAnswer, LanguageResources().const.TimeOver, LanguageResources().const.MemoryOverflow, LanguageResources().const.CompileError, LanguageResources().const.RuntimeError] # last Submissions of Problem Info lastSubmission = select_last_submissions(problemIndex = problemIndex).subquery() submissions = select_all_submissions(problemIndex = problemIndex, lastSubmission = lastSubmission).subquery() try: # Submitted Members Count sumOfSubmissionPeopleCount = select_submissions_peoples_counts(submissions).subquery() # Solved Members Count sumOfSolvedPeopleCount = select_solved_peoples_counts(submissions).subquery() # Problem Record problemSubmittedRecords = select_submitted_records_of_problem(problemIndex = problemIndex).subquery() # Chart SubmissionRecords chartSubmissionRecords = select_problem_chart_submissions(sumOfSubmissionPeopleCount, sumOfSolvedPeopleCount, problemSubmittedRecords).first() except Exception: chartSubmissionRecords = [] # Problem Information (LimitedTime, LimitedMemory try: problemInformation = select_problem(problemIndex = problemIndex).first() except Exception: problemInformation = [] # Problem Solved Users try: # Problem Solved Member problemSolvedMemberRecords = submissions_sorted(select_solved_submissions(submissions).subquery(), sortCondition = sortCondition).all() except Exception: problemSolvedMemberRecords = [] # Search Failed Problem if status != ENUMResources().const.SOLVED\ and status != ENUMResources().const.JUDGING\ and status != ENUMResources().const.SERVER_ERROR: try: # last Submissions of Problem Info lastSubmission = select_last_submissions(memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX], problemIndex = problemIndex).subquery() submissions = select_all_submissions(memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX], problemIndex = problemIndex, lastSubmission = lastSubmission).subquery() # Current Failed Problem failedProblem = select_failed_problems(submissions).first() except Exception: failedProblem = [] else: failedProblem = [] return render_template(HTMLResources().const.PROBLEM_RECORD_HTML, memberId = memberId, status = status, problemSolvedMemberRecords = problemSolvedMemberRecords, problemInformation = problemInformation, chartSubmissionDescriptions = chartSubmissionDescriptions, chartSubmissionRecords = chartSubmissionRecords, failedProblem = failedProblem, error = error) except Exception as e: return unknown_error(e)