def rejudgeSubmission( request, sid): logger.info(str(request).replace("\n\r","\t")) """ rejudge the very submission with the specific sid """ try: sid = int( sid) u = User.getSessionUser( request.session) if not u: raise Err( request, err='not login') try: s = Submission.getById( sid) except: raise Err( request, err='no submission', log_format=( '{0}'.format( sid), ''), user_format=( u'{0}'.format( sid), u'不要搞笑!!'), ) if not s.problem_index.contest.course_class.canBeManaged( u): raise Err( request, err = 'no priv') Submission.rejudgeSubmission( s) return redirect( 'Submission:contest_status', contest_id=s.problem_index.contest.cid) except Exception as e: logger.error(str(e).replace("\n\r","\t")) return render( request, Const.NEW_ERROR_PAGE, { 'errmsg': unicode(e), }, )
def viewCodeAndInfo(request, sid): logger.info(str(request).replace("\n\r", "\t")) """ view used to see details of the very submission """ try: sid = int(sid) u = User.getSessionUser(request.session) if not u: raise Err(request, err='not login') try: s = Submission.getById(sid) except: raise Err( request, err='no submission', log_format=('{0}'.format(sid), ''), user_format=(u'{0}'.format(sid), u'不要搞笑!!'), ) if not Submission.canViewCode(s, u): raise Err(request, err='no priv') info = eval(s.other_info) if 'ce' in info: info['ce'] = info['ce'].replace('/${TOKISAKI_KURUMI}', '') info['brush'] = Const.BRUSH[s.code_language] info['lang'] = Const.LANG_REFLECT[s.code_language] info['judger'] = Const.JUDGER_NAME info['user'] = s.user.uid info['judge_time'] = str(s.submission_time) info['status_cn'] = Const.STATUS_CN[info['status']] info['status_color'] = Const.STATUS_COLOR[ info['status']] if info['status'] in Const.STATUS_COLOR else '' # info['submit_ip'] = request.META['REMOTE_ADDR'] if 'score_sum' not in info: case_dict = json.loads(s.problem_index.problem.case_info) # score_sum = 0 # for score in case_dict: # score_sum += int( score) score_sum = sum(map(int, case_dict.values())) info['score_sum'] = score_sum s.other_info = str(info) s.save() if 'case_result' in info: score_obtained = 0 for seq in info['case_result']: seq['res_cn'] = JUDGE_RES_CN[seq['res']] temp_res = 'status-' + seq['res'] seq['res_color'] = temp_res if 'score' in seq: score_obtained += int(seq['score']) info['score_obtained'] = score_obtained # seq['res_color'] = Const.STATUS_COLOR[temp_res] if temp_res in Const.STATUS_COLOR else '' return render( request, 'newtpl/submission/code_and_info.html', { 'submission': s, 'info': info, 'code_content': default_storage.open(s.code_file).read().decode( 'utf-8', 'ignore'), 'tpl': { 'sp': True }, }, ) except Exception as e: logger.error(str(e).replace("\n\r", "\t")) return render( request, Err.ERROR_PAGE, { 'errmsg': unicode(e), }, )
def viewCodeAndInfo( request, sid): logger.info(str(request).replace("\n\r","\t")) """ view used to see details of the very submission """ try: sid = int( sid) u = User.getSessionUser( request.session) if not u: raise Err( request, err='not login') try: s = Submission.getById( sid) except: raise Err( request, err='no submission', log_format=( '{0}'.format( sid), ''), user_format=( u'{0}'.format( sid), u'不要搞笑!!'), ) if not Submission.canViewCode( s, u): raise Err( request, err = 'no priv') info = eval( s.other_info) if 'ce' in info: info['ce'] = info['ce'].replace('/${TOKISAKI_KURUMI}', '') info['brush'] = Const.BRUSH[s.code_language] info['lang'] = Const.LANG_REFLECT[s.code_language] info['judger'] = Const.JUDGER_NAME info['user'] = s.user.uid info['judge_time'] = str(s.submission_time) info['status_cn'] = Const.STATUS_CN[info['status']] info['status_color'] = Const.STATUS_COLOR[info['status']] if info['status'] in Const.STATUS_COLOR else '' # info['submit_ip'] = request.META['REMOTE_ADDR'] if 'score_sum' not in info: case_dict = json.loads(s.problem_index.problem.case_info) # score_sum = 0 # for score in case_dict: # score_sum += int( score) score_sum = sum( map( int, case_dict.values())) info['score_sum'] = score_sum s.other_info = str( info) s.save() if 'case_result' in info: score_obtained = 0 for seq in info['case_result']: seq['res_cn'] = JUDGE_RES_CN[seq['res']] temp_res = 'status-' + seq['res'] seq['res_color'] = temp_res if 'score' in seq: score_obtained += int(seq['score']) info['score_obtained'] = score_obtained # seq['res_color'] = Const.STATUS_COLOR[temp_res] if temp_res in Const.STATUS_COLOR else '' return render( request, 'newtpl/submission/code_and_info.html', { 'submission': s, 'info': info, 'code_content': default_storage.open(s.code_file).read().decode('utf-8','ignore'), 'tpl': { 'sp': True }, }, ) except Exception as e: logger.error(str(e).replace("\n\r","\t")) return render( request, Err.ERROR_PAGE, { 'errmsg': unicode(e), }, )