def rejudgeGeneralSubmission( request, gsid): """ rejudge the very general submission with the specific id """ try: gsid = int( gsid) u = User.getSessionUser( request.session) if not u: raise Err( request, err='not login') try: g_s = GeneralSubmission.getById( gsid) except: raise Err( request, err='no generalsubmission', log_format=( '{0}'.format( gsid), ''), user_format=( u'{0}'.format( gsid), u'别扯了!!'), ) # fake if u.priv == 'student': raise Err( request, err = 'no priv') GeneralSubmission.rejudgeGeneralSubmission( g_s) return redirect( 'Submission:status') except Exception as e: return render( request, Const.NEW_ERROR_PAGE, { 'errmsg': unicode(e), }, )
def rejudgeGeneralSubmission(request, gsid): """ rejudge the very general submission with the specific id """ try: gsid = int(gsid) u = User.getSessionUser(request.session) if not u: raise Err(request, err='not login') try: g_s = GeneralSubmission.getById(gsid) except: raise Err( request, err='no generalsubmission', log_format=('{0}'.format(gsid), ''), user_format=(u'{0}'.format(gsid), u'别扯了!!'), ) # fake if u.priv == 'student': raise Err(request, err='no priv') GeneralSubmission.rejudgeGeneralSubmission(g_s) return redirect('Submission:status') except Exception as e: return render( request, Const.NEW_ERROR_PAGE, { 'errmsg': unicode(e), }, )
def viewCodeAndInfo(request, gsid): """ view used to show the detail of some general submission """ try: gsid = int(gsid) u = User.getSessionUser(request.session) if not u: raise Err(request, err='not login') try: g_s = GeneralSubmission.getById(gsid) except: raise Err( request, err='no generalsubmission', log_format=('{0}'.format(gsid), ''), user_format=(u'{0}'.format(gsid), u'别扯了!!'), ) if not GeneralSubmission.canViewCode(g_s, u): raise Err(request, err='no priv') info = eval(g_s.other_info) info['brush'] = Const.BRUSH[g_s.code_language] 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['lang'] = Const.LANG_REFLECT[g_s.code_language] info['judge_time'] = str(g_s.submission_time) info['judger'] = Const.JUDGER_NAME if 'ce' in info: info['ce'] = info['ce'].replace('/${TOKISAKI_KURUMI}', '') info['score_obtained'] = 0 if 'score_sum' not in info: case_dict = json.loads(g_s.problem.case_info) score_sum = sum(map(int, case_dict.values())) info['score_sum'] = score_sum #g_s.other_info = str( info) #g_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 # info['submit_ip'] = request.META['REMOTE_ADDR'] # if 'score_sum' not in info: # case_dict = json.loads(s.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: # for seq in info['case_result']: # seq['res_cn'] = JUDGE_RES_CN[seq['res']] return render( request, 'newtpl/submission/general/code_and_info.html', { 'submission': g_s, 'info': info, 'code_content': default_storage.open(g_s.code_file).read(), 'tpl': { 'sp': True } }, ) except Exception as e: return render( request, Err.ERROR_PAGE, { 'errmsg': unicode(e), }, )
def viewCodeAndInfo( request, gsid): """ view used to show the detail of some general submission """ try: gsid = int( gsid) u = User.getSessionUser( request.session) if not u: raise Err( request, err = 'not login') try: g_s = GeneralSubmission.getById( gsid) except: raise Err( request, err='no generalsubmission', log_format=( '{0}'.format( gsid), ''), user_format=( u'{0}'.format( gsid), u'别扯了!!'), ) if not GeneralSubmission.canViewCode( g_s, u): raise Err( request, err = 'no priv') info = eval( g_s.other_info) info['brush'] = Const.BRUSH[g_s.code_language] 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['lang'] = Const.LANG_REFLECT[g_s.code_language] info['judge_time'] = str(g_s.submission_time) info['judger'] = Const.JUDGER_NAME if 'ce' in info: info['ce'] = info['ce'].replace('/${TOKISAKI_KURUMI}', '') info['score_obtained'] = 0 if 'score_sum' not in info: case_dict = json.loads(g_s.problem.case_info) score_sum = sum( map( int, case_dict.values())) info['score_sum'] = score_sum #g_s.other_info = str( info) #g_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 # info['submit_ip'] = request.META['REMOTE_ADDR'] # if 'score_sum' not in info: # case_dict = json.loads(s.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: # for seq in info['case_result']: # seq['res_cn'] = JUDGE_RES_CN[seq['res']] return render( request, 'newtpl/submission/general/code_and_info.html', { 'submission': g_s, 'info': info, 'code_content': default_storage.open(g_s.code_file).read(), 'tpl': { 'sp': True } }, ) except Exception as e: return render( request, Err.ERROR_PAGE, { 'errmsg': unicode(e),}, )