在最近的几天,主要是改正在以往contest
的实现中存在的一些问题,主要是:
1 无法从contest
的overview
中进入题目的详细说明页面
2 用户在submit
中提交的代码无法正常在Status
中显示评测状态
3 Contest
的时区设置错误,没有设置为东八区时间
4 实现了Contest
的中的倒计时功能
修改过后的contest_get_problem方法####
def contest_get_problem(req, cid):
if req.is_ajax():
contest = Contest.objects.get(id=cid)
pid = req.GET.get('pid')
t = loader.get_template('contest/contest_problem.html')
problem = Problem.objects.get(proid=pid)
if contest.private:
if req.user.is_superuser==False and req.user.info not in contest.accounts.all() :
problem = []
#content_html = t.render(Context({'problem': problem, 'user' : req.user}))
# return HttpResponse(content_html)
return render(req,'contest/contest_problem.html',{'problem': problem, 'user' : req.user})
修改过后的submit方法####
def contest_submit(req, cid):
contest = Contest.objects.get(id=cid)
#time = datetime.datetime.now(pytz.timezone(pytz.country_timezones('cn')[0]))
# time1=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
time=timezone.now()
# print(contest.start_time + contest.duration_time)
if time > contest.start_time + contest.duration_time:
finish = True
else:
finish = False
if contest.private:
if req.user.is_superuser==False and req.user.info not in contest.accounts.all() :
return HttpResponseRedirect("/contest/" + cid + "/")
if req.method == 'GET':
return ren2res("contest/contest_submit.html", req, {'contest': contest, 'problems': contest.get_problem_list()})
elif req.method == 'POST':
pid = req.POST.get('pid')
#need change start
# sub = Status(pro=Problem.objects.get(proid=pid), user=req.user, lang=req.POST.get('lang'))
sub = Status(user=req.user, pro=Problem.objects.get(proid=pid), lang=req.POST.get('lang'), result='Waiting',
time=time)
if not finish:
sub.cid = contest.id
else:
sub.cid = -1
sub.save()
if req.POST.get('code'):
content_file = ContentFile(req.POST.get('code'))
elif req.FILES:
content_file = ContentFile(req.FILES['file'].read())
else:
return ren2res("contest/contest_submit.html", req,
{'contest': contest, 'problems': contest.get_problem_list(), 'err': 'No Submit!'})
#sub.source_code.save(name=str(sub.runid), content=content_file)
sub.save()
#judger.Judger(sub)
#result=judge_delay.delay(sub)
if not finish:
return HttpResponseRedirect("/contest/" + cid + "/")
else:
return HttpResponseRedirect("/contest/"+cid+"/status?pid=" + pid)
#need change end
overview
从overview进入问题描述界面
修正时区
contest
实现正确的计时:
接下来主要集中在开发contest
的clarification
功能,以及整个virtualJudge
的Rank
功能
网友评论